Skip to content

Commit

Permalink
Merge pull request #262 from conveyal/dev
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
landonreed authored Oct 7, 2019
2 parents 1dbcbfc + faa73db commit 334daae
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public class GraphQLGtfsSchema {
public static final GraphQLObjectType feedInfoType = newObject().name("feed_info")
.description("A GTFS feed_info object")
.field(MapFetcher.field("id", GraphQLInt))
.field(MapFetcher.field("feed_id"))
.field(MapFetcher.field("feed_publisher_name"))
.field(MapFetcher.field("feed_publisher_url"))
.field(MapFetcher.field("feed_lang"))
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/conveyal/gtfs/loader/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,12 @@ public Table (String name, Class<? extends Entity> entityClass, Requirement requ
).addPrimaryKey();

// FIXME: Should we add some constraint on number of rows that this table has? Perhaps this is a GTFS editor specific
// feature.
// feature.
public static final Table FEED_INFO = new Table("feed_info", FeedInfo.class, OPTIONAL,
new StringField("feed_publisher_name", REQUIRED),
// feed_id is not the first field because that would label it as the key field, which we do not want because the
// key field cannot be optional.
new StringField("feed_id", OPTIONAL),
new URLField("feed_publisher_url", REQUIRED),
new LanguageField("feed_lang", REQUIRED),
new DateField("feed_start_date", OPTIONAL),
Expand Down Expand Up @@ -256,7 +259,7 @@ public Table (String name, Class<? extends Entity> entityClass, Requirement requ
// FIXME: Do we need an index on from_ and to_stop_id
new StringField("from_stop_id", REQUIRED).isReferenceTo(STOPS),
new StringField("to_stop_id", REQUIRED).isReferenceTo(STOPS),
new StringField("transfer_type", REQUIRED),
new ShortField("transfer_type", REQUIRED, 3),
new StringField("min_transfer_time", OPTIONAL))
.addPrimaryKey()
.keyFieldIsNotUnique()
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/conveyal/gtfs/model/FeedInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void setStatementParameters(PreparedStatement statement, boolean setDefau
DateField feedEndDateField = (DateField) Table.FEED_INFO.getFieldForName("feed_end_date");
String feedPublisherUrl = feed_publisher_url != null ? feed_publisher_url.toString() : null;
statement.setString(oneBasedIndex++, feed_publisher_name);
statement.setString(oneBasedIndex++, feed_id);
statement.setString(oneBasedIndex++, feedPublisherUrl);
statement.setString(oneBasedIndex++, feed_lang);
feedStartDateField.setParameter(statement, oneBasedIndex++, feed_start_date);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/conveyal/gtfs/GTFSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,8 @@ private void assertThatPersistenceExpectationRecordWasFound(
new PersistenceExpectation(
"feed_info",
new RecordExpectation[]{
new RecordExpectation("feed_publisher_name", "Conveyal"
),
new RecordExpectation("feed_id", "fake_transit"),
new RecordExpectation("feed_publisher_name", "Conveyal"),
new RecordExpectation(
"feed_publisher_url", "http://www.conveyal.com"
),
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/conveyal/gtfs/dto/FeedInfoDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class FeedInfoDTO {
public int id;
public String feed_id;
public String feed_publisher_name;
public String feed_publisher_url;
public String feed_lang;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void canCreateUpdateAndDeleteFeedInfoEntities() throws IOException, SQLEx
// create new object to be saved
FeedInfoDTO feedInfoInput = new FeedInfoDTO();
String publisherName = "test-publisher";
feedInfoInput.feed_id = null;
feedInfoInput.feed_publisher_name = publisherName;
feedInfoInput.feed_publisher_url = "example.com";
feedInfoInput.feed_lang = "en";
Expand Down Expand Up @@ -175,6 +176,7 @@ public void canPreventSQLInjection() throws IOException, SQLException, InvalidNa
// create new object to be saved
FeedInfoDTO feedInfoInput = new FeedInfoDTO();
String publisherName = "' OR 1 = 1; SELECT '1";
feedInfoInput.feed_id = "fake_id";
feedInfoInput.feed_publisher_name = publisherName;
feedInfoInput.feed_publisher_url = "example.com";
feedInfoInput.feed_lang = "en";
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/fake-agency/feed_info.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
feed_publisher_name,feed_publisher_url,feed_lang,feed_version
Conveyal,http://www.conveyal.com,en,1.0
feed_id,feed_publisher_name,feed_publisher_url,feed_lang,feed_version
fake_transit,Conveyal,http://www.conveyal.com,en,1.0

0 comments on commit 334daae

Please sign in to comment.