-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat(quaint): upgrade tiberius to 0.12.3 #5037
Conversation
CodSpeed Performance ReportMerging #5037 will not alter performanceComparing Summary
|
WASM Query Engine file Size
|
The way Strings in raw queries bypass both this conversion and the bug in Tiberius because they are carried along as strings all the way to the database and aren't serialized as datetimes with offsets in binary form in TDS wire protocol. Datetime values with UTC offsets were not affected by the bug in Tiberius because applying an offset of 0 twice still yields the same result. This means that Prisma was never affected by that bug when writing data, only when reading data that was written using raw queries or using something else than Prisma. Moreover, in the case when Prisma is reading back a value stored using a raw query, it would actually read a different, wrong value, and not what user wrote in the raw query. Unlike the scenario described in the Tiberius issue, where the values are stored in the wrong format, but what the library reads back is consistent with what it wrote, here Prisma is being inconsistent with itself. Again, the reason for that is that the buggy code path is only used for reading and not for writing. In other words, while this fix was a breaking change for other users of Reproduction: schema.prisma generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlserver"
url = env("TEST_MSSQL_JDBC_URI")
}
model A {
id Int @id @default(autoincrement())
dt DateTime @db.DateTimeOffset
} index.ts console.log(
await prisma.a.create({
data: {
dt: "2024-11-07T14:35:30.998+02:00"
}
})
);
console.log(
await prisma.$queryRaw`
insert into a (dt)
output inserted.id, inserted.dt
values ('2024-11-07T14:35:30.998+02:00')
`
);
console.log(await prisma.a.findMany()); shell $ tsx index.ts
{ id: 1, dt: 2024-11-07T12:35:30.998Z }
[ { id: 2, dt: 2024-11-07T10:35:30.998Z } ]
[
{ id: 1, dt: 2024-11-07T12:35:30.998Z },
{ id: 2, dt: 2024-11-07T10:35:30.998Z }
]
$ sqlcmd -d master -P Pr1sm4_Pr1sm4 -S localhost,1433 -U SA -Q 'select * from a'
id dt
----------- ---------------------------------------------
1 2024-11-07 12:35:30.9980000 +00:00
2 2024-11-07 14:35:30.9980000 +02:00
(2 rows affected) Explanation of the output: We try to create the same datetime value with the time component equal to 14:35 (UTC+2): once using a create query and once using a raw query, and then fetch both of them again using findMany. In the sqlcmd output we can see that both values were stored correctly and correspond to the same point in time, the first one was just converted to UTC (as expected in Prisma). However, in the output of the script we can see that the value stored using the raw query is being read back incorrectly, with the timezone offset subtracted twice. |
This PR contributes to ORM-314.
The current version of tiberius in
prisma-engines
is 0.11.8.The most recent version available is 0.12.3.
Upgrading causes a breaking change due to prisma/tiberius#260, which affects how
DATETIMEOFFSET
values are inserted in SQL Server.