Skip to content

Commit

Permalink
Issue #7: Upgrade HSQLDB dependency to org.hsqldb:hsqldb:jar:2.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Jul 12, 2024
1 parent de169c6 commit 625be03
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<dep.jackcess.version>5.0.0-SNAPSHOT</dep.jackcess.version>
<dep.jackcess-encrypt.version>4.0.2</dep.jackcess-encrypt.version>

<dep.hsqldb.version>2.7.1</dep.hsqldb.version>
<dep.hsqldb.version>2.7.3</dep.hsqldb.version>
<dep.hsqldb.classifier/>

<dep.slf4j.version>2.0.13</dep.slf4j.version>
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/net/ucanaccess/converters/Persist2Jet.java
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,20 @@ public void createPrimaryKey(String tableName) throws IOException, SQLException
String ntn = escape4Hsqldb(tableName);
String tn = escape4Access(tableName);
Table t = db.getTable(tn);
ResultSet pkrs = conn.getHSQLDBConnection().getMetaData().getPrimaryKeys(null, null, ntn.toUpperCase());
Metadata md = new Metadata(conn);

List<String> cols = new ArrayList<>();
IndexBuilder ib = new IndexBuilder(IndexBuilder.PRIMARY_KEY_NAME).withPrimaryKey();
while (pkrs.next()) {
String colName = pkrs.getString(COLUMN_NAME);
Metadata mt = new Metadata(conn);
colName = mt.getColumnName(ntn, colName);
cols.add(colName);
try (Statement st = conn.getHSQLDBConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs = st.executeQuery("SELECT * FROM INFORMATION_SCHEMA.SYSTEM_PRIMARYKEYS "
+ "WHERE TABLE_NAME = '" + ntn.toUpperCase() + "' ORDER BY KEY_SEQ")) {
while (rs.next()) {
cols.add(md.getColumnName(ntn, rs.getString(COLUMN_NAME)));
}
}
ib.withColumns(cols).addToTable(t);
new IndexBuilder(IndexBuilder.PRIMARY_KEY_NAME)
.withPrimaryKey()
.withColumns(cols)
.addToTable(t);
}

public void createForeignKey(String tableName, String referencedTable) throws IOException, SQLException {
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/net/ucanaccess/jdbc/AlterTableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ void testCreatePk(AccessVersion _accessVersion) throws SQLException, IOException
init(_accessVersion);

try (UcanaccessStatement st = ucanaccess.createStatement()) {
String tbl = "AAA n";
st.execute("ALTER TABLE [" + tbl + "] ADD PRIMARY KEY (baaaa, a)");
st.execute("ALTER TABLE [AAA n] ADD PRIMARY KEY (baaaa, a)");
Database db = ucanaccess.getDbIO();
assertThat(db.getTable(tbl).getPrimaryKeyIndex().getColumns().stream().map(Column::getName))
Table tbl = db.getTable("AAA n");
assertThat(tbl.getPrimaryKeyIndex().getColumns().stream().map(Column::getName))
.containsExactly("baaaa", "A");

st.execute("ALTER TABLE Sample ADD PRIMARY KEY (RegionId)");
Expand Down

0 comments on commit 625be03

Please sign in to comment.