Skip to content

Commit

Permalink
Merge pull request #181 from conveyal/fix-missing-double
Browse files Browse the repository at this point in the history
Fix missing double in EntityPopulator
  • Loading branch information
Landon Reed authored Jan 7, 2019
2 parents 658d9fe + 7b197fb commit 07025e3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main/java/com/conveyal/gtfs/loader/EntityPopulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,12 @@ static URL getUrlIfPresent (ResultSet resultSet, String columnName,
static double getDoubleIfPresent (ResultSet resultSet, String columnName,
TObjectIntMap<String> columnForName) throws SQLException {
int columnIndex = columnForName.get(columnName);
// FIXME: if SQL value is null, resultSet.getInt will return 0. Should return value equal 0 if column is missing?
if (columnIndex == 0) return Entity.DOUBLE_MISSING;
else return resultSet.getDouble(columnIndex);
double doubleValue = resultSet.getDouble(columnIndex);
// If SQL value for column was null, resultSet.getDouble will return 0.0. If this is the case, override value with
// DOUBLE_MISSING.
if (resultSet.wasNull()) return Entity.DOUBLE_MISSING;
else return doubleValue;
}

static int getIntIfPresent (ResultSet resultSet, String columnName,
Expand Down

0 comments on commit 07025e3

Please sign in to comment.