stablekernel / postgresql-dart

Dart PostgreSQL driver: supports extended query format, binary protocol and statement reuse.
https://www.dartdocs.org/documentation/postgres/latest
BSD 3-Clause "New" or "Revised" License
129 stars 32 forks source link

help for connection.mappedResultsQuery with numeric field #108

Closed cardosodario closed 3 years ago

cardosodario commented 4 years ago

hi in my table i have two field codigo numeric(11) and nome varchar(35)

select codigo, nome from vendedor where nome like 'A%' limit 2; codigo | nome --------+-------------- 49 | ANGELA 55 | ANA CAROLINA

i am use

List<Map<String, Map<String, dynamic>>> results = await connection.mappedResultsQuery( "select codigo, nome from vendedor where nome like 'A%' order by nome limit 2"); for (final row in results) { print(row["vendedor"]["codigo"]); print(row["vendedor"]["nome"]); }

i receive return

I/flutter (11230): I/flutter (11230): ADELICIA I/flutter (11230): I/flutter (11230): ALDIRA

the field codigo not show because this is numeric

how i resolv this?

thanks

dario

jcowgar commented 4 years ago

I'm running into the same problem as well with numeric fields. I found if I cast them to float in the SQL select, that causes it to work, but that's not correct at all.

jcowgar commented 4 years ago

Actually see #50

pdqsoftware commented 4 years ago

I'm running into the same problem as well with numeric fields. I found if I cast them to float in the SQL select, that causes it to work, but that's not correct at all.

Thanks @jcowgar. Casting to Float is not an ideal solution but it will do me for now. Paul

andriwsluna commented 3 years ago

cast($fieldName as DOUBLE PRECISION) works for me, until solves that issue.