Skip to content

Commit

Permalink
about orbisgis#1113 remove pk constraint name
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Sep 15, 2020
1 parent 59ba218 commit c8c3439
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,18 @@ private void readAsc(Connection connection, InputStream inputStream, ProgressVis
PreparedStatement preparedStatement;
if (as3DPoint) {
if (zType == 1) {
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL NOT NULL, THE_GEOM GEOMETRY(POINTZ, " + srid + "), Z integer," + " CONSTRAINT ASC_PK PRIMARY KEY (PK))");
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL PRIMARY KEY, THE_GEOM GEOMETRY(POINTZ, " + srid + "), Z integer)");
} else {
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL NOT NULL, THE_GEOM GEOMETRY(POINTZ, " + srid + "), Z double precision," + " CONSTRAINT ASC_PK PRIMARY KEY (PK))");
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL PRIMARY KEY, THE_GEOM GEOMETRY(POINTZ, " + srid + "), Z double precision)");
}
preparedStatement = connection.prepareStatement("INSERT INTO " + requestedTable.toString(isH2)
+ "(the_geom, Z) VALUES (?, ?)");
} else {
if (zType == 1) {
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL NOT NULL, THE_GEOM GEOMETRY(POLYGONZ, " + srid + "),Z integer, " + " CONSTRAINT ASC_PK PRIMARY KEY (PK))");
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL PRIMARY KEY, THE_GEOM GEOMETRY(POLYGONZ, " + srid + "),Z integer)");

} else {
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL NOT NULL, THE_GEOM GEOMETRY(POLYGONZ, " + srid + "),Z double precision, " + " CONSTRAINT ASC_PK PRIMARY KEY (PK))");
st.execute("CREATE TABLE " + requestedTable.toString(isH2) + "(PK SERIAL PRIMARY KEY, THE_GEOM GEOMETRY(POLYGONZ, " + srid + "),Z double precision)");
}
preparedStatement = connection.prepareStatement("INSERT INTO " + requestedTable.toString(isH2)
+ "(the_geom, Z) VALUES (?, ?)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public void testASCRead() throws IOException, SQLException {
assertEquals((15 / 5) * (20 / 5), rs.getInt("CPT"));
}
}

@Test
public void testASCReadPoints() throws IOException, SQLException {
Statement st = connection.createStatement();
Expand Down Expand Up @@ -325,4 +325,22 @@ public void testReadPrecipEnvelopePOSTGIS(TestInfo testInfo) throws IOException,
}
}
}

@Test
public void testASCReadMultiTables() throws IOException, SQLException {
Statement st = connection.createStatement();
st.execute("DROP TABLE PRECIP30MIN1 IF EXISTS");
st.execute(String.format("CALL ASCREAD('%s', 'PRECIP30MIN1')",AscReaderDriverTest.class.getResource("precip30min.asc").getFile()));
st.execute(String.format("CALL ASCREAD('%s', 'PRECIP30MIN2')",AscReaderDriverTest.class.getResource("precip30min.asc").getFile()));

try (ResultSet rs = st.executeQuery("SELECT COUNT(*) CPT FROM PRECIP30MIN1")) {
assertTrue(rs.next());
assertEquals(299, rs.getInt("CPT"));
}
try (ResultSet rs = st.executeQuery("SELECT COUNT(*) CPT FROM PRECIP30MIN2")) {
assertTrue(rs.next());
assertEquals(299, rs.getInt("CPT"));
}
}

}

0 comments on commit c8c3439

Please sign in to comment.