From a7bcafce3e48cf141a89129758a63d95509e63bf Mon Sep 17 00:00:00 2001 From: "philip.cline" Date: Tue, 26 Sep 2023 12:19:37 -0400 Subject: [PATCH] refactor(JdbcTableWriter): allow nulls --- src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java b/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java index d0e88a5f5..8a239ffb5 100644 --- a/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java +++ b/src/main/java/com/conveyal/gtfs/loader/JdbcTableWriter.java @@ -1483,6 +1483,10 @@ private String[] parseExceptionListField(int id, String namespace, Table table, return parsedString.replaceAll("[{}]", "").split("[,]", 0); } + private String getResultSetString(int column, ResultSet resultSet) throws java.sql.SQLException { + return resultSet.getString(column) == null ? "" : resultSet.getString(resultSet.getString(1) == null ? "" : resultSet.getString(1)); + } + /** * Delete all entries in calendar dates associated with a schedule exception. */ @@ -1599,7 +1603,7 @@ private void updateReferencingTables( ResultSet resultSet = patternStopSelectStatement.getResultSet(); while (resultSet.next()) { patternAndRouteIds.add( - "{" + resultSet.getString(1) + "-" + resultSet.getString(2) + "-" + resultSet.getString(3) + "-" + resultSet.getString(3) + "}" + "{" + getResultSetString(1, resultSet) + "-" + getResultSetString(2, resultSet) + "-" + getResultSetString(3, resultSet)+ "-" + getResultSetString(4, resultSet) + "}" ); } }