Closed edlman closed 3 years ago
Infinity date time: could you put a link in the comment pointing PG's doc about the definitions of these values?
encodeArray: Sorry, I don't accept it. As mentioned in other pull requests, it is error prone (e.g., the list is empty). Also, I prefer to leave it for supporting PG's array type.
pgMin/MaxDateTime
to dartMin/MaxDateTime
. These values are specified in Dart DateTime doc https://api.dart.dev/stable/2.10.2/dart-core/DateTime-class.htmlselect * from table where id in (@arr)
) as well in pgsql array (e.g. select * from table where id = any(array[@arr]::type[])
.
You're right that in case of empty list the query select * from table where id in ()
will fail with ERROR 42601 syntax error at or near ")"
but I propose to let the user (developer) to test and prevent such call. It's just like another SQL syntax error. The user can always use id = any(array[@arr]::type[])
instead of id in (@arr)
which is little bit longer but it's error proof.Sorry, I still don't like the implementation of array. Also, it doesn't support the update/insert statement well. In theory, it shall be as simple as
insert into Foo value(@name, @array)
In this case, the value has to be encoded with curly braces. As I mentioned, array shall be PostgreSQL's array type. We can assume it is always used in a select statement.
If it is really what you want, you can override the type converter in your environment, which is actually what I did -- we have some custom way for handling data.
I enhanced TypeConverter to support the array type.
To convert infinity to a DateTime object, please override DefaultTypeConverter.decodeDateTime
instead.
This PR add support for array of parameters and for ±infinity date. '-infinity' is represented in Dart as minimum possible DateTime
DateTime.utc(-271821,04,20)
, 'infinity' is represented as maximum possible DateTimeDateTime.utc(275760,09,13)