Skip to content

Commit

Permalink
#2217 Use an explicit table reference when calling `generate_insert_s…
Browse files Browse the repository at this point in the history
…tatement`
  • Loading branch information
homedirectory committed Mar 25, 2024
1 parent 9b85101 commit 10d3703
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ public List<String> genInsertStmt(final Collection<PersistedEntityMetadata<?>> e
// and:
// SELECT * FROM 'TABLE_NAME';
// The source for this stored procedure can be found in tgpsa-dao/src/main/resources/sql/create_insert_statement.sql
try (final PreparedStatement ps = conn.prepareStatement(format("select create_insert_statement(tableoid, %s) from %s", table, table))) {

// Must pass mytable.* to create_insert_statement: if table "mytable" has column named "mytable",
// then "mytable" will refer to the column, not the table.
try (final PreparedStatement ps = conn.prepareStatement(
format("select create_insert_statement(tableoid, %1$s.*) from %1$s", table))) {
try (final ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
inserts.add(rs.getString(1));
Expand All @@ -97,4 +101,4 @@ public DbVersion dbVersion() {
return DbVersion.POSTGRESQL;
}

}
}

0 comments on commit 10d3703

Please sign in to comment.