Skip to content

Commit

Permalink
test for issue 390 (#392)
Browse files Browse the repository at this point in the history
Merging with skip parameter
  • Loading branch information
davidmartos96 authored Nov 20, 2024
1 parent c8e59cb commit 96588bd
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/v3_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,39 @@ void main() {
expect(isClosed, isTrue);
});
});

withPostgresServer('issue 390', (server) {
test(
'issue 390 - Cannot ALTER TABLE because it is being used by active queries in this session',
() async {
final conn = await server.newConnection();
const tableToAlter = 'table_to_alter';
const otherTable = 'other_table';

await conn.execute('''
CREATE TABLE $tableToAlter (
a_id INTEGER PRIMARY KEY NOT NULL,
a_other_id INTEGER NOT NULL
);''');

await conn.execute(
'CREATE TABLE $otherTable (other_id INTEGER PRIMARY KEY NOT NULL);');

await conn.runTx((tx) async {
// Select from the table that will be altered
await tx.execute('SELECT * FROM $tableToAlter;');

// Add a foreign key constraint
await tx.execute('''
ALTER TABLE $tableToAlter
ADD CONSTRAINT fk_other
FOREIGN KEY (a_other_id)
REFERENCES $otherTable(other_id);''');
});

// Should not throw
}, skip: 'investigation needed');
});
}

final _isPostgresException = isA<PgException>();
Expand Down

0 comments on commit 96588bd

Please sign in to comment.