-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add check for all missing arguments to schema. #124
base: main
Are you sure you want to change the base?
Conversation
IMO there shouldn't be any warning if I do |
As an addendum to @ericphanson's statement, I think But I wonder if this is best solved in a method signature. Are there cases where it makes sense to have an identical method signature that differs only between |
Not sure I follow @iamed2:
Are you saying that downstream consumers should be able to handle both I think the issue is that you can get an error when using |
I think @iamed2 is suggesting method authors should take care to avoid this problem by type annotations in their methods signatures. I agree that would be good too, but I think suitably restricted this could be a reasonable fallback. FWIW a culprit of bad method signatures in this department is a particular closed source database client. |
Okay, thanks for clarifying. Sounds like I need to adjust this PR by:
|
As a reminder to myself: still todo is to make a method for |
Hm, is it feasible to add a second constructor with no arguments and make that one warn? That might be simpler, but I suppose it’s only valid if every field is nullable |
It's funny because I wrote a reply saying that yes, we could simplify this the way you suggest, and then I remembered why we can't when I tried to implement it. The method |
A common mistake in using Legolas is to call
MySchemaV1()
instead ofMySchemaV1SchemaVersion()
. Since callingMySchemaV1()
is rarely intentional, this PR flags a warning when that method is called. The warning can be silenced by callingMySchemaV1(Legolas.AllMissing())
to signal that, yes, you really do want a record with all missing fields.