Skip to content

Commit 96588bd

Browse files
test for issue 390 (#392)
Merging with skip parameter
1 parent c8e59cb commit 96588bd

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/v3_test.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff 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

475508
final _isPostgresException = isA<PgException>();

0 commit comments

Comments
 (0)