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

Cannot sum bigint columns with negative values on SQLite #1099

Open
danconnell opened this issue Sep 12, 2024 · 3 comments
Open

Cannot sum bigint columns with negative values on SQLite #1099

danconnell opened this issue Sep 12, 2024 · 3 comments

Comments

@danconnell
Copy link

Because of the way bigint columns are encoded in SQLite here https://github.com/ponder-sh/ponder/blob/main/packages/core/src/utils/encoding.ts
trying to sum over that column is a meaningless operation if it contains negative values as the EVM_MIN_INT decoding is not accounted for.

Everything works fine with using sum on a bigint column with negative values on PostgreSQL.

I am largely just noting this for anyone else who experiences the same issue.

However, it would be helpful to note constraints like this with specific drivers on https://ponder.sh/docs/schema#column-types

@0xOlias
Copy link
Collaborator

0xOlias commented Sep 12, 2024

Thanks for opening, definitely a limitation of the encoding format. In what query context did you run into this? Direct SQL queries against the SQLite file, or in an API function?

Will give this more thought re: including the limitation in the docs. As an aside, we're considering a migration from SQLite to PGlite (#1084) as the dev database. Curious for your take.

@danconnell
Copy link
Author

It was in an API function.

I haven't had a chance to try PGlite yet, but doing some quick reading it seems to me like it would be an improvement over SQLite.

I have no preference for SQLite (I actually very strongly dislike it), it's just something we use in local dev to save the trouble of having to run a local PostgreSQL server when a dev has no other need for one. In our deployed environments we use PostgreSQL and everything is fine.

@ind-igo
Copy link

ind-igo commented Sep 25, 2024

+1 just ran into this issue, was wondering wtf was going on.

I ran into this issue when reading off of the result of a create call, and using that for a batch job (aggregating swap events into candlestick chart data)

Fully support moving to pglite if it will help alleviate this small issues with encoding mismatches (along with im sure a ton of other issues). Some note in the docs in the meantime would help a lot.

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

3 participants