lelit/pglast

Decimal('4294967310') gets rendered as 4294967310.0

df7cb opened this issue · 5 comments

df7cb commented

Integer literals > 2^31 get parsed as Decimal which gets incorrectly .0 appended when rendered back:

>>> RawStream()(pglast.parse_sql('select 4294967310'))
'SELECT 4294967310.0'

That is a problem if the query is actually expecting a bigint.

  • PG15 regression testsuite: SELECT lo_put(33349, 4294967310, 'foo');
  • Query when piped though pglast/pgpp: SELECT lo_put(33349, 4294967310.0, 'foo')
  • ERROR: function lo_put(integer, numeric, unknown) does not exist
lelit commented

Thanks for the report!

lelit commented

Should be fixed as well!

lelit commented

Released in v3.9.

df7cb commented

Thanks for the fixes and the new release!

Fwiw I've build pglast packages for apt.postgresql.org, called python3-pglast there.

They are not in Debian/main yet as that has already moved to PostgreSQL 14 and the required PG13 server headers aren't available anymore, but I'll fix that as soon there is a libpg-query + pglast supporting that.

Cheers,
Christoph

lelit commented

Thank you!