Jaguar-dart / jaguar_orm

Source-generated ORM with relations (one-to-one, one-to-many, many-to-many), preloading, cascading, polymorphic relations, etc
https://jaguar-dart.github.io
BSD 3-Clause "New" or "Revised" License
217 stars 54 forks source link

PostgreSQL DateTime field "insert" crash #195

Open unipenlabs opened 3 years ago

unipenlabs commented 3 years ago

The bug is inside:

postgresql/lib/src/compose/insert.dart

When try to insert a DateTime in a timestamp field:

ModelAccount(13bfc209-ae58-4aa5-a340-aa444cfac1a4, 2020-09-06 22:39:15.556270, 2020-09-06 22:39:15.556271, account@test.com) Unhandled exception: PostgreSQLSeverity.error 42601: syntax error at or near "22"

So it's trying to use 2020-09-06 22:39:15.556270 as integer and crashes because of that.

 } else if (val is DateTime) {
    return "$val"; //TODO
  } else if (val is bool) {

there is even // TODO the correct code is:

  } else if (val is DateTime) {
    return "'$val'";
  } else if (val is bool) {