databasepostgresqluuidnumeric

Postgresql 15 - Trailing junk after numeric literal error


After the Postgresql update v15, I realised that even I have a column that accepts UUID data type, it will throw me similar error like this whenever I try to Insert UUID data into the table.

Script:

INSERT INTO public.testing(uuid, rating) VALUES (${uuid}, ${rating});

Error:

error running query error: trailing junk after numeric literal at or near "45c"

Postgresql 15 release note:

Prevent numeric literals from having non-numeric trailing characters (Peter Eisentraut)

Is there any solution for this issue? Or there an alternative data type that allows storing UUID into my table?


Solution

  • It seems that you forgot the single quotes around the UUID, so that the PostgreSQL parser took the value for a subtraction and complained that there were letters mixed in with the digits. This may throw a different error on older PostgreSQL versions, but it won't do the right thing either.

    Be careful about SQL injection when you quote the values.