Skip to content

Support for encoding parametrized lists #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/src/postgresql_impl/type_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,8 @@ class DefaultTypeConverter implements TypeConverter {
return n.toString();
}

String encodeArray(List value) {
//TODO implement postgresql array types
throw _error('Postgresql array types not implemented yet. '
'Pull requests welcome ;)', null);
String encodeArray(List values) {
return values?.map((value) => encodeValueDefault(value))?.join(', ');
}

String encodeDateTime(DateTime datetime, {bool isDateOnly}) {
Expand Down
9 changes: 8 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ version: 0.5.1+1
authors:
- Greg Lowe <greg@vis.net.nz>
- Tom Yeh <tomyeh@rikulo.org>
- Martin Edlman <ac@an.y-co.de>
description: >
A temporary fork of Greg's PostgreSQL driver (xxgreg/postgresql)
using conserved substitution respecting strings and @@ operators.
also optimizing the pool implementation aggressivly.
also optimizing the pool implementation aggressively.
With added support for encoding parametrized lists. E.g.
List<int> ids = [ ... ]; // init list with values or get it from parameters
result1 = db.query("select * from table where id in (@ids)", { "ids": ids });
result2 = db.query("select * from table where id = any (array[@ids]::int[])", { "ids": ids });
When using array[@x] syntax in query it's wise to use array type cast (::int[], ::date[], ...)
to avoid problems with null list.
homepage: https://github.com/tomyeh/postgresql

environment:
Expand Down