Is there a way to prevent this from being valid......
# exposed
a
Is there a way to prevent this from being valid... 🤦 I had a type where
someColumn
was not defined I was using something like
some
instead and it essentially basically deleted all my rows.
Copy code
Mytable.deleteWhere {
    Mytable.someColumn eq someColumn
}
Copy code
DELETE FROM mytable where mytable.some_column = mytable.some_column
d
The implicit receiver of of the lambda parameter is the Table instance, which is why
someColumn
resolved. There isn't a way to make this a compiler error, if that's what you're asking. You'll just need to make sure you have unit-tests that cover these use-cases.
✅ 1
a
Yea I was hoping there was a way to make the compiler error out 😕
d
Nope, since it is a valid block.
g
Maybe it's possible to throw runtime exception here: in
eq
function (and probably other comparison functions) if receiver
===
parameter, then probably something unexpected is happening (I can't imagine any use-case where you would like to compare expression with itself) and exception can be thrown
d
In complex outer joins it might be useful to compare the same column with itself, but I'm not sure.