Closed kevinelliott closed 1 year ago
2022-09-24 22:05:11.473 UTC [3571191] STATEMENT: WITH messages as (INSERT INTO messages (timestamp, source_type, source, link_direction, from_hex, to_hex, frequency, level, error, mode, label, block_id, ack, tail, flight, message_number, text, departing_airport, destination_airport, block_end, station_id, airframe_id, flight_id, latitude, longitude, altitude) VALUES ($1, $2, $3, $4, $5, $6, CAST ($7 as double precision), $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, CAST ($24 as double precision), CAST ($25 as double precision), $26) RETURNING messages.id, messages.created_at, messages.updated_at, messages.timestamp, messages.station_id, messages.airframe_id, messages.flight_id, messages.source, messages.source_type, messages.link_direction, messages.from_hex, messages.to_hex, messages.channel, messages.frequency, messages.level, messages.error, messages.mode, messages.label, messages.block_id, messages.ack, messages.tail, messages.flight, messages.message_number, messages.data, messages.text, messages.departing_airport, messages.destination_airport, messages.latitude, messages.longitude, messages.altitude, messages.block_end) SELECT id, created_at, updated_at, timestamp, station_id, airframe_id, flight_id, source, source_type, link_direction, from_hex, to_hex, channel, CAST (frequency AS char), level, error, mode, label, block_id, ack, tail, flight, message_number, data, text, departing_airport, destination_airport, CAST (latitude AS char), CAST (longitude AS char), altitude, block_end FROM messages
This appears to be the source of the issue... https://github.com/dukefirehawk/angel/blob/master/packages/orm/angel_orm_generator/lib/src/orm_generator.dart#L114
There are other areas in the generated files where it's doing a double
--> string
--> double
unnecessarily. And then of course the conversion to string and back causes it to be null for some reason, and then Postgres complains about it.
If I remove the conversions between double and string throughout the generated, things work! double --> database direct, rather than the intermediary conversions.
Can you please adjust to not do the intermediary for double?
Looks like the existing test cases do not cover this. Will resolve this issue as high priority and add a test case for it.
double --> string --> double
casting has been removed in angel_orm_generator
7.0.1. All the numeric fields now goes directly to the database. Thanks for reporting this bug as the casting
is in the code since version 4. This changes should improve the performance. Let me know if it works for you.
This seems to have been resolved, thank you @dukefirehawk
Recently updated to latest, and now doubles are not correctly going into Postgres.
These are showing correctly as
double
objects in dart, but then when the query executes:They are all native doubles, and in the database it is
double precision
.In the generated file, I see:
Which tells me the doubles are being cast during execution. They should be cast to
double precision
. Or likely, not cast at all.