You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When querying a table with a jsonb column that contains a json list, the result is parsed correctly.
When trying to insert or update with the same list (the exact object that i received as result) I get this error:
PostgreSQLSeverity.error : Could not infer array type of value '[{key1: 123, key2: 456}]'.
I think the cause of this error is that the PostgresTextEncoder does not recognize the list as a JSON value:
if (value is Map) {
return _encodeJSON(value, escapeStrings);
}
if (value is PgPoint) {
return _encodePoint(value);
}
if (value is List) {
return _encodeList(value);
}
(from text_codec.dart line 31 and following)
Also, there could be a bug in the _encodeList method here:
final type = value.fold(value.first.runtimeType, (type, item) {
if (type == item.runtimeType) {
return type;
} else if ((type == int || type == double) && item is num) {
return double;
} else {
return Map;
}
});
(text_codec.dart line 176)
AFAIK comparing runtimeType is not advisable because (like in this scenario) it would result in type being _InternalLinkedHashMap<String, dynamic>. This would then clash with line 197 where type is compared to Map
but _InternalLinkedHashMap<String, dynamic> != Map. But since the syntax of the resulting sql would not fit for use with jsonb anyway, i think the first code part above is the root of my problem.
If you can give me some opinion about how this should be handled, i would be happy to contribute a PR for this.
Best regards
The text was updated successfully, but these errors were encountered:
When querying a table with a jsonb column that contains a json list, the result is parsed correctly.
When trying to insert or update with the same list (the exact object that i received as result) I get this error:
PostgreSQLSeverity.error : Could not infer array type of value '[{key1: 123, key2: 456}]'.
I think the cause of this error is that the
PostgresTextEncoder
does not recognize the list as a JSON value:(from text_codec.dart line 31 and following)
Also, there could be a bug in the
_encodeList
method here:(text_codec.dart line 176)
AFAIK comparing runtimeType is not advisable because (like in this scenario) it would result in
type
being_InternalLinkedHashMap<String, dynamic>
. This would then clash with line 197 wheretype
is compared toMap
but
_InternalLinkedHashMap<String, dynamic> != Map
. But since the syntax of the resulting sql would not fit for use with jsonb anyway, i think the first code part above is the root of my problem.If you can give me some opinion about how this should be handled, i would be happy to contribute a PR for this.
Best regards
The text was updated successfully, but these errors were encountered: