-
Notifications
You must be signed in to change notification settings - Fork 102
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
Implement struct valued constant validator for loading schemas #467
Conversation
Codecov Report
@@ Coverage Diff @@
## master #467 +/- ##
============================================
+ Coverage 58.79% 58.87% +0.08%
+ Complexity 866 861 -5
============================================
Files 69 69
Lines 6436 6451 +15
Branches 1002 1006 +4
============================================
+ Hits 3784 3798 +14
+ Misses 2362 2360 -2
- Partials 290 293 +3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! A few small nits but this is basically good-to-go.
// this should work for exception type as well. structType has isException field | ||
return STRUCT | ||
} | ||
|
||
throw IllegalStateException("Struct-valued constants are not yet implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need a new message for this exception :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) Yup, fixed the messaging
var keyMatchedField: Field? = null | ||
val keyString = key.value | ||
for (field in fields) { | ||
if (field.name == keyString) { | ||
keyMatchedField = field | ||
break | ||
} | ||
} | ||
if (keyMatchedField == null) { | ||
throw IllegalStateException("${expected.name} struct has no field ${key.value}") | ||
} | ||
Constant.validate(symbolTable, value, keyMatchedField.type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var keyMatchedField: Field? = null | |
val keyString = key.value | |
for (field in fields) { | |
if (field.name == keyString) { | |
keyMatchedField = field | |
break | |
} | |
} | |
if (keyMatchedField == null) { | |
throw IllegalStateException("${expected.name} struct has no field ${key.value}") | |
} | |
Constant.validate(symbolTable, value, keyMatchedField.type) | |
val field = fields.firstOrNull { it.name == key.value } ?: error("${expected.name} struct has no field ${key.value}") | |
Constant.validate(symbolTable, value, field.type) |
|
||
const Region DEFAULT_REGION = { | ||
1 : "US", | ||
"isActive" : true // field name does not exist in Region |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isActive
does in fact exist; should the comment be for the line above this one?
Thanks! Looks good; assuming tests pass, please sign the CLA and we'll be good to merge. |
// this should work for exception type as well. structType has isException field | ||
return STRUCT | ||
} | ||
|
||
throw IllegalStateException("Struct-valued constants are not yet implemented") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the exception message since Struct-valued constants are now supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nevermind... the message was updated in the latest update!
@benjamin-bader thanks for the review and approval. I have now signed the CLA so you can accept and merge the PR. Let me know. |
@benjamin-bader thanks for merging the PR. What is the release cycle? Any possibility of releasing a candidate with this change? |
There's no official schedule; releases happen whenever there's enough to justify a release. I'll see about making an RC soon but am not confident I have my laptop properly configured for it right now - it might take a little while. In the meantime I believe you can use a snapshot build. |
Version 3.1.0-RC01 should be up in Maven Central in the next 10 minutes or so |
This commit resolves #466