Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlHydra.Cli missing SQL Server timestamp data type mapping #103

Closed
tommi1hirvonen opened this issue Oct 19, 2024 · 3 comments
Closed

SqlHydra.Cli missing SQL Server timestamp data type mapping #103

tommi1hirvonen opened this issue Oct 19, 2024 · 3 comments

Comments

@tommi1hirvonen
Copy link

SQL Server includes the timestamp data type, which is essentially a synonym for rowversion. Mapping for this data type is missing from SqlServerDataTypes.fs, which means columns with data type timestamp are currently excluded from generated SqlHydra types and readers. rowversion is included in the data type mappings, and thus I believe timestamp should be implemented too.

@JordanMarr
Copy link
Owner

JordanMarr commented Oct 19, 2024

Which data type does it map to?
DateTime? DateTimeOffset?

@tommi1hirvonen
Copy link
Author

tommi1hirvonen commented Oct 19, 2024

I think it should actually map to byte[], since it's the same as rowversion. I manually added the missing timestamp column to my generated SqlHydra type and reader as byte[], and that seemed to work correctly. Also, according to Microsoft's documentation the correct ClrType for timestamp is Byte[].

This could potentially be as simple as just copying the rowversion mapping like this:

SqlServerdatatypes.ds

let supportedTypeMappings =
    [
        // ...
        "ROWVERSION", "byte[]", DbType.Binary, Some (nameof SqlDbType.Binary), nameof r.GetFieldValue
        // Added timestamp data type mapping
        "TIMESTAMP", "byte[]", DbType.Binary, Some (nameof SqlDbType.Binary), nameof r.GetFieldValue
        // ...
    ]

And yes, timestamp in SQL Server is notorious for being confusing and badly named. 😄

@JordanMarr
Copy link
Owner

Added to v2.5.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants