File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -470,6 +470,39 @@ void main() {
470470 expect (isClosed, isTrue);
471471 });
472472 });
473+
474+ withPostgresServer ('issue 390' , (server) {
475+ test (
476+ 'issue 390 - Cannot ALTER TABLE because it is being used by active queries in this session' ,
477+ () async {
478+ final conn = await server.newConnection ();
479+ const tableToAlter = 'table_to_alter' ;
480+ const otherTable = 'other_table' ;
481+
482+ await conn.execute ('''
483+ CREATE TABLE $tableToAlter (
484+ a_id INTEGER PRIMARY KEY NOT NULL,
485+ a_other_id INTEGER NOT NULL
486+ );''' );
487+
488+ await conn.execute (
489+ 'CREATE TABLE $otherTable (other_id INTEGER PRIMARY KEY NOT NULL);' );
490+
491+ await conn.runTx ((tx) async {
492+ // Select from the table that will be altered
493+ await tx.execute ('SELECT * FROM $tableToAlter ;' );
494+
495+ // Add a foreign key constraint
496+ await tx.execute ('''
497+ ALTER TABLE $tableToAlter
498+ ADD CONSTRAINT fk_other
499+ FOREIGN KEY (a_other_id)
500+ REFERENCES $otherTable (other_id);''' );
501+ });
502+
503+ // Should not throw
504+ }, skip: 'investigation needed' );
505+ });
473506}
474507
475508final _isPostgresException = isA <PgException >();
You can’t perform that action at this time.
0 commit comments