Skip to content

Commit

Permalink
Merge pull request #245 from conveyal/fix-gtfs+-ref-tracking
Browse files Browse the repository at this point in the history
Properly track primary keys in proprietary files
  • Loading branch information
landonreed authored Aug 5, 2019
2 parents b348b3a + 3e9101f commit 0db2209
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/com/conveyal/gtfs/loader/ReferenceTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ public Set<NewGTFSError> checkReferencesAndUniqueness(String keyValue, int lineN
listOfUniqueIds = this.transitIdsWithSequence;
uniqueId = String.join(":", field.name, keyValue, value);
}
// Add ID and check duplicate reference in entity-scoped IDs (e.g., stop_id:12345)
if (table.required.equals(Requirement.PROPRIETARY)) {
// Some proprietary tables in the GTFS+ spec do not conform to the general principle in GTFS where a key
// field (e.g., stop_id) only acts as the primary key field in the entity's table. For example, stop_id
// acts as a primary key on stop_attributes.txt, so we prepend the table name to the unique ID for these
// tables when checking for duplicate entries.
uniqueId = String.join(":", table.name, field.name, value);
}
// Add ID and check duplicate reference in entity-scoped IDs (e.g., stop_id:12345)
boolean valueAlreadyExists = !listOfUniqueIds.add(uniqueId);
if (valueAlreadyExists) {
// If the value is a duplicate, add an error.
Expand Down

0 comments on commit 0db2209

Please sign in to comment.