Comments (4)
Awesome! This has been merged in and deployed through 6.2.3
from donald.
Hey Daniel! Thanks for bringing this to my attention, admittedly it's not a field type I use or encounter very often. So it's no suprise that I didn't catch this myself (since I use this package everyday at work with SQL Server) and if you look carefully at the "type reader test" the mapper is missing the datetimeoffset
🤦.
So let's solve the two problems in front of us. First and most importantly, getting your code working. Here's a solution for right now.
open System.Data.SqlClient
// quick & dirty
let mapRow (rd : IDataReader) : DateTimeOffset =
let sqlRd = rd :?> SqlDataReader
sqlRd.GetDateTimeOffset(sqlRd.GetOrdinal("dto"))
conn
|> Db.newCommand "SELECT SYSDATETIMEOFFSET() AS dto"
|> Db.query mapRow
Now as far as the package goes, I think I have a couple ideas. Regardless of how we proceed on that, first thing should be to mark the current ReadDateTimeOffset
as obsolete, release as a patch and remove it in the next major version release.
In my view the cleanest solution is to apply generics. If we change the signature of the map param to the following, you can pass in any function which receives any implementation of the interface.
let query (map : 'reader -> 'a when 'reader :> IDataReader) (cmd : IDbCommand) : DbResult<'a list> = // ...
// now this works
let mapRow (rd : SqlDataReader) : DateTimeOffset =
rd.GetDateTimeOffset(sqlRd.GetOrdinal("dto"))
conn
|> Db.newCommand "SELECT SYSDATETIMEOFFSET() AS dto"
|> Db.query mapRow
At first glance, I think this idea is our best approach. It's regression-proof and immediately, without any work allows people to plugin vendor specific consumption.
Thoughts?
from donald.
Hey, thanks for quick fix and all the detail!
Yeah I think that looks like a great path forward. Switching query to use generics provides easy accesses to the
more specific IDataReader type and looks like it's backwards compatible too!
from donald.
Ref: commit 41a7b6c
from donald.
Related Issues (20)
- GetDateTimeOffset Signature is string -> DateTime HOT 1
- Unable to execute query without a transaction HOT 6
- Add a wrapper around ExecuteScalar HOT 6
- TransactionBuilder HOT 9
- CommandBehavior.SequentialAccess causes error with SqlHydra readers HOT 5
- [Help] How to parse results with sequential access? HOT 2
- Db.Async.execMany throws "A command is already in progress" with NPGSQL HOT 5
- v.7.0.0 HOT 9
- FsDto lib review HOT 2
- Who is @dysme on the landing page? HOT 3
- CancellationToken support
- Support of transaction in newCommand in Fluent syntax HOT 3
- Getting error while using Db.Async.query method HOT 6
- Require help on query HOT 7
- Support or Transition to Microsoft.Data.SqlClient HOT 3
- SQLite: What SQL Type should I choose for a JSON column? HOT 2
- Possible issue with Db.Async.exec throwing instead of returning a Result HOT 1
- How to deal with DB enums in Donald? HOT 1
- Doc comment error for newSproc HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from donald.