-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
Silent invalid behavior of withFieldConst
when field name starts with "set"
#461
Comments
Setter names are NOT prohibited - we are explicitly testing that if all bean-like names are provided manually then there is no need to use a flag to enable automatic matching of bean names. The lack of errors here is a feature, that for the last 5+ years (we're testing for this since Nov 2018). Sure it, might brings some corner cases like this were:
where the difference shows when there is a case where only human can say what is expected behavior from the context. There might be several possible approaches like:
so, any solution would require some discussion rather just stating fix it the way I like. Besides, the #499 is NOT ignored - it was if it was closed with wontfix label. Instead, I wrote there that I do not have a capacity for such fixes, but I would happily discuss how they can be fixed and review+accept PRs. I have very little time for any OSS work these days (and I spend way too much time the last year to get this library to where is it now) so current if anyone is bothered by such bug, then, I as said, this is OSS, we can discuss what would be an acceptable change of the behavior, someone can make a PR, I could merge it and release it. |
Hey @MateuszKubuszok - maybe I didn't spell it clear enough, but the problem is that |
It seems to be an interaction between legitimate features @Tvaroh - support for java beans is interfering with your naming convention. |
Yes, I do. The issue stems from the fact that:
Therefore before throwing any sort of simple compile time error - which would introduce a regression to a lot of users who DO NOT EXPECT NOR WANTS IT - it would make more sense to:
and I can imagine more than one way to fix it. Like the ones I already mentioned. Simply throwing an error if there are 2 similar cases can break cases like e.g. // Scala 2.13
// what you see:
case class Foo(@BeanProperty a: Int)
class Bar {
@BeanProperty
var a: Int = 0
}
// what compiler sees:
class Foo(@val a: Int) {
def getA(): Int = a
// ...
}
object Foo { /* ... */ }
class Bar {
var a: Int = 0
def getA(): Int = a
def setA(a: Int): Unit = this.a = a
}
// oh no! Foo has a and getA, and Bar has a, getA and setA! which is pretty damn legit case. Here generated with I am pretty damn sure, that if I used some "simple and naive" approach like throwing compiler error always, in 2 weeks I'll get another bug, this time from a frustrated legacy-integration developers who used Chimney effortlessly with Java Beans before and now they cannot. The solution usually looks simple if you have a statistical pool of 1, but after putting here 500+ tests of various parts of the library I can assure you that sometimes a good solution is pretty fucking far from obvious, and "just failing compilation" doesn't always make a cut. |
It is, I checked how much effort would take to fix #449 for instance (by fix I mean "make the test case for it pass without failing other test cases"), and I can confidently say - more than 1 evening. |
withFieldConst
when field name starts with "set"withFieldConst
when field name starts with "set"
Fixed in |
Reproducing example:
Result:
If renamed to e.g.
settUuid
:Result:
Notice if I rename the other
uuid
field to something else then it works correctly. Chimney0.8.5
.I saw the ignored #449 bug too. Just worth mentioning that in our domain
setUuid
wasn't considered a setter, but rather a uuid of a set of entities. Anyway, it shouldn't allow to compile it silently, if using "setter"-like names is prohibited.The text was updated successfully, but these errors were encountered: