-
Notifications
You must be signed in to change notification settings - Fork 122
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
Unexpected behavior with DateTimeOffset ? #260
Comments
Hey. So... the value is not stored as a string in the database, but with the following setup: For
This is in the TDS standard, and comparison is done in the byte level, not by string. The database can render the value how it wants, but under the surface the storage is as written here. E.g. not a bug, unless you can find a test that clearly shows we do something wrong! |
Yes, I understand how dates are stored and displayed in a database. The issue I observed is that the way tiberius stores the values does not seem to be compatible with other languages. For example, if I insert the same date However, if I insert that value using tiberius, it is displayed in the database as The expected behavior should be that inserting and retrieving a date should yield the same value regardless of which language does the inserting and retrieving. However, this is not the case here. |
Hmm, I'd love to see a test and PR to fix this, if you find what we do differently! |
While inserting and retrieving DateTimeOffset values from a SQL Server database, I noticed a surprising behavior where the inserted value is stored differently in the database than what was inserted and retrieved.
Setup
main.rs
Cargo.toml
docker-compose.yml
Execution
Result
As shown, the inserted and retrieved DateTimeOffset values are the same while using tiberius.
However, when looking at the actual value stored in the database using something like sqlcmd there is a different value.
The inserted value was
2022-05-20T11:30:11.642+02:00
, but the database shows the value to be2022-05-20 13:30:11.6420000 +02:00
.This means that if you interact with the database using something other than tiberius you would get the wrong value.
Is this the intended outcome, or a bug?
The text was updated successfully, but these errors were encountered: