Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Allow null values for foreign ref fields or required fields where permitted #133

Merged
merged 11 commits into from
Nov 8, 2018

Conversation

landonreed
Copy link
Contributor

@landonreed landonreed commented Aug 23, 2018

This fixes a couple of editor bugs:

It also adds a basic CRUD test for fares.

…mpty

This fixes a bug where create/update requests with foreign refs (such as route_id in fare_rules)
could not be null even if the table definition permits the null value.

fixes catalogueglobal/datatools-ui#224
@codecov-io
Copy link

codecov-io commented Aug 23, 2018

Codecov Report

Merging #133 into dev will increase coverage by 1.46%.
The diff coverage is 41.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##               dev     #133      +/-   ##
===========================================
+ Coverage     53.7%   55.17%   +1.46%     
- Complexity     697      731      +34     
===========================================
  Files          143      143              
  Lines         7170     7176       +6     
  Branches       828      830       +2     
===========================================
+ Hits          3851     3959     +108     
+ Misses        2996     2880     -116     
- Partials       323      337      +14
Impacted Files Coverage Δ Complexity Δ
...java/com/conveyal/gtfs/loader/JdbcTableWriter.java 35.76% <28.57%> (+19.77%) 57 <0> (+30) ⬆️
.../com/conveyal/gtfs/loader/JdbcGtfsSnapshotter.java 83.33% <60%> (-1.93%) 26 <11> (+1)
...va/com/conveyal/gtfs/storage/StorageException.java 0% <0%> (-55.56%) 0% <0%> (-1%)
...java/com/conveyal/gtfs/loader/JDBCTableReader.java 62.5% <0%> (-4.55%) 7% <0%> (ø)
...in/java/com/conveyal/gtfs/loader/BatchTracker.java 70.83% <0%> (-4.17%) 5% <0%> (-1%)
src/main/java/com/conveyal/gtfs/loader/Table.java 83.68% <0%> (+0.69%) 72% <0%> (+2%) ⬆️
...ain/java/com/conveyal/gtfs/loader/DoubleField.java 72% <0%> (+12%) 8% <0%> (+1%) ⬆️
...main/java/com/conveyal/gtfs/loader/ShortField.java 68.75% <0%> (+18.75%) 5% <0%> (+1%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 54aff02...d10aff3. Read the comment docs.

Copy link
Contributor

@evansiroky evansiroky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll approve this, but we should get into the habit of adding tests to JDBCTableWriterTest while we make fixes like these.

@evansiroky
Copy link
Contributor

I'll assign this back to you, Landon, and let you decide if this is a good time to start adding tests.

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Oct 15, 2018
@landonreed landonreed changed the title Allow null values for foreign ref fields allowed to be empty by definition Editor: Allow null values for foreign ref fields or required fields where permitted Oct 16, 2018
@landonreed landonreed assigned evansiroky and unassigned landonreed Oct 16, 2018
@landonreed
Copy link
Contributor Author

OK, @evansiroky. I added one other bug fix to this PR in addition to a new CRUD test for fares.

true
);
LOG.info("delete {} output:", fareTable.name);
LOG.info(updateOutput);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be deleteOutput.

);
LOG.info(fareRulesSql);
ResultSet fareRulesResultSet = testDataSource.getConnection().prepareStatement(fareRulesSql).executeQuery();
assertThat(fareRulesResultSet.getFetchSize(), equalTo(0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I look at these tests, it seems like they could really use a sql check to make sure that the data was created and updated. Also, these 2 lines could be made into a reusable method assertThatSqlQueryYieldsZeroRows or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

Copy link
Contributor Author

@landonreed landonreed Nov 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, actually I think the checking for created/updated data gets a little muddied because we would then need to ensure that we're using the same connection to see the data we expect. I think the first part of your comment is out of scope, but I will add a TODO.

@evansiroky
Copy link
Contributor

Excellent! I gave an idea of how to improve the CRUD tests, but if that seems out of scope for this PR, let's create an issue for that and do that later.

@evansiroky evansiroky assigned landonreed and unassigned evansiroky Oct 16, 2018
@landonreed landonreed merged commit 1a3de7d into dev Nov 8, 2018
@landonreed
Copy link
Contributor Author

🎉 This PR is included in version 4.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants