Skip to content

TEXT [] support #121

@kevin-sakemaer

Description

@kevin-sakemaer

I didn't succeed to INSERT a value corresponding to TEXT [] is that supported by the package ?
and if yes how to do it ?

here is some dart code:

  await conn.connection.execute('DROP TABLE conversations;');
  await conn.connection.execute(
      'CREATE TABLE IF NOT EXISTS conversations (id TEXT NOT NULL, subject TEXT, avatar TEXT, admins TEXT [] NOT NULL, users TEXT [] NOT NULL);');

  await conn.connection
      .query('DELETE FROM conversations WHERE id = @id;', substitutionValues: {
    'id': 'conv1',
  });

  await conn.connection.query(
    'INSERT INTO conversations (id, admins, users) VALUES (@id, @admins, @users);',
    substitutionValues: {
      'id': 'conv1',
      'admins': ['1000'],
      'users': ['1000', '1001'],
    },
  );

  final conversations =
      await conn.connection.query('SELECT * FROM conversations;');
  print('conversations: $conversations');

and here is the crash message:

Unhandled exception:
PostgreSQLSeverity.error : Could not infer type of value '[1000]'. 
#0      PostgresTextEncoder.convert (package:postgres/src/text_codec.dart:40:5)
#1      new ParameterValue.text (package:postgres/src/query.dart:213:47)
#2      new ParameterValue (package:postgres/src/query.dart:194:29)
#3      Query.sendExtended.<anonymous closure> (package:postgres/src/query.dart:80:22)
#4      MappedListIterable.elementAt (dart:_internal/iterable.dart:417:29)
#5      ListIterable.toList (dart:_internal/iterable.dart:221:19)
#6      Query.sendExtended (package:postgres/src/query.dart:81:10)
#7      _PostgreSQLConnectionStateIdle.processQuery (package:postgres/src/connection_fsm.dart:19
7:9)
#8      _PostgreSQLConnectionStateIdle.awake (package:postgres/src/connection_fsm.dart:183:14)
#9      _PostgreSQLExecutionContextMixin._enqueue (package:postgres/src/connection.dart:482:67)
#10     _PostgreSQLExecutionContextMixin._query (package:postgres/src/connection.dart:431:24)
#11     _PostgreSQLExecutionContextMixin.query (package:postgres/src/connection.dart:402:7)
#12     main (file:///Users/kleak/Work/github.com/Kleak/talk.dart/backend/bin/main.dart:58:25)
<asynchronous suspension>
#13     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
#14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12

i'm on dart version Dart VM version: 2.7.2 (Mon Mar 23 22:11:27 2020 +0100) on "macos_x64"
postgres version 12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions