We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Internally, Prisma truncates DateTime values to 3 decimal places, e.g.
DateTime
2021-11-17 17:04:56.936198 -> 2021-11-17 17:04:56.936000
2021-11-17 17:04:56.936198
2021-11-17 17:04:56.936000
This can lead to a bug where records cannot be filtered by a DateTime equals value.
This bug was not caught until now as it does not appear on SQLite but does on PostgreSQL.
import asyncio from datetime import datetime from prisma import Client async def main() -> None: db = Client() await db.connect() date = datetime.utcnow() print(date) post = await db.post.create( data={ 'title': 'My first post', 'created_at': date, }, ) print(post.created_at) found = await db.post.find_first( where={ 'created_at': date, }, ) print(f'Post found? {found is not None}') await db.disconnect() if __name__ == '__main__': asyncio.get_event_loop().run_until_complete(main())
SQLite output:
2021-11-17 17:13:21.288983 2021-11-17 17:13:21.288000+00:00 Post found? True
PostgreSQL output:
2021-11-17 17:14:15.055458 2021-11-17 17:14:15.055000+00:00 Post found? False
2021-11-17 17:14:15.055458 2021-11-17 17:14:15.055000+00:00 Post found? True
datasource client { // provider = "sqlite" // url = "file:dev.db" provider = "postgres" url = env("DATABASE_URL") } generator client { provider = "prisma-client-py" interface = "asyncio" } model Post { id String @id @default(cuid()) created_at DateTime @default(now()) updated_at DateTime @updatedAt title String published Boolean @default(false) desc String? }
prisma : 3.4.0 prisma client python : 0.3.0 platform : darwin engines : 1c9fdaa9e2319b814822d6dbfd0a69e1fcc13a85 install path : .venv/lib/python3.9/site-packages/prisma installed extras : []
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Bug description
Internally, Prisma truncates
DateTime
values to 3 decimal places, e.g.2021-11-17 17:04:56.936198
->2021-11-17 17:04:56.936000
This can lead to a bug where records cannot be filtered by a
DateTime
equals value.This bug was not caught until now as it does not appear on SQLite but does on PostgreSQL.
How to reproduce
SQLite output:
PostgreSQL output:
Expected behavior
PostgreSQL output:
Prisma information
Environment & setup
The text was updated successfully, but these errors were encountered: