postgresql-dart icon indicating copy to clipboard operation
postgresql-dart copied to clipboard

[Postgres v3 experimental] support aliases for type in parameters

Open xvrh opened this issue 2 years ago • 3 comments

I'm experimenting with the postgres_v3_experimental.dart

I notice this throws an exception:

PgSql.map('select email from "AspNetUsers" where id=@userId:int')

FormatException: Error at offset 42 (@userId:int): Unknown type: int

According to this table: https://www.postgresql.org/docs/16/datatype.html#:~:text=Table%C2%A08.1.%C2%A0Data%20Types integer, int and int4 are aliases.

Screenshot 2023-11-15 at 13 34 51

It would be convenient to support them too.

xvrh avatar Nov 15 '23 12:11 xvrh

Right now only int4 is implemented. Note: 3.0.0 is out since yesterday evening, I'd suggest to use that instead of the older one you seem to be using.

isoos avatar Nov 15 '23 12:11 isoos

@simolus3: I think we should have multiple values in nameForSubstitution (I'm glad that it is hidden right now), or rather have a way to also add types ad-hoc in TypeRegistry.

isoos avatar Nov 15 '23 12:11 isoos

I agree, nameForSubstitution should allow a way to include aliases.

Do you remember why serial and bigSerial map to int4 and int8 respectively when apparently serial4 and serial8 are type names supported by Postgres as well? Maybe we can use the opportunity to resolve that as well.

simolus3 avatar Nov 16 '23 19:11 simolus3

I believe this has been fixed.

isoos avatar Sep 06 '24 20:09 isoos