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

Error when using int8 (bigInteger) as query parameter type #22

Open
ryanaston opened this issue Dec 26, 2021 · 2 comments
Open

Error when using int8 (bigInteger) as query parameter type #22

ryanaston opened this issue Dec 26, 2021 · 2 comments

Comments

@ryanaston
Copy link

Dart ints are 64-bit, so I assumed this would work:

await connection.query("SELECT TO_TIMESTAMP(@ts / 1000)", substitutionValues: {'ts': 1640556171599});

However, I get the following error when running the query above:

PostgreSQLSeverity.error 22003: value "1640556171599" is out of range for type integer
package:postgres/src/connection.dart 453:18 _PostgreSQLExecutionContextMixin._query
package:postgres/src/connection.dart 427:7 _PostgreSQLExecutionContextMixin.query

I attempted to remedy by specifying the data type in the query, like so:

await connection.query("SELECT TO_TIMESTAMP(@ts:int8 / 1000)", substitutionValues: {'ts': 1640556171599});

This causes a different error:

PostgreSQLSeverity.error : Specified parameter types do not match column parameter types in query SELECT TO_TIMESTAMP(@ts:int8 / 1000)
package:postgres/src/connection.dart 453:18 _PostgreSQLExecutionContextMixin._query
package:postgres/src/connection.dart 427:7 _PostgreSQLExecutionContextMixin.query

Is this a bug or am I mistaken on how to safely use 64-bit ints as query parameters?

@isoos
Copy link
Owner

isoos commented Dec 27, 2021

In theory we should have full int8 support both in Dart and in package:postgres. We should have a test or two that uses it as input and output for a query, but I don't recall the details right away. If you have some time, please debug it a bit more, I'm happy to accept PRs...

@isoos
Copy link
Owner

isoos commented Nov 28, 2023

Note: #264 suggests we have already fixed the :int8 part, not sure if/how the untyped part should work.

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