by eyelidlessness · 10y ago · 0 comments
In this case. It would be better to ensure all SQL is properly escaped, but because that isn't a trivial task, instead you end up adding another layer of complexity.
http://stackoverflow.com/questions/4456438/how-to-pass-null-...
function normalise(s) {
return (s + "").toLowerCase();
}
function isEqual(a, b) {
return normalise(a) == normalise(b);
}
And then someone else uses it in some form validation logic: if (isEqual(surname, null)) {
return error;
}The problem with data destruction is that only one thing in the entire data pipeline has to spuriously map two distinct values to the same output value, and the data is destroyed and can not be recovered. Very few programmers think carefully about whether a serialization or data transfer format maps every single possible input to a different output. It may only take one oversight to ruin your year.
Edit: IIRC there was a directive that would prevent the behavior though?
null is coerced to "null" when it's needed as a string. This behaviour is similar to printf in C. It's not the case that "null" === null like True == 1 in Python. (This would be my interpretation of "x is represented by y".)
Side note: please refrain from "sounds like someone doesn't understand". It is extremely condescending, dissuades discussion by most people whether they actually know the topic or not, and can be especially deflating to people who are less educated but currently learning.
If there is something that you feel I misunderstood about the way popular languages treat the string `"null"`, feel free to explain it (there are many other response comments I've gotten that are good examples). But if the purpose of your comment is to make me or anyone else feel ignorant, please just keep it to yourself.
Edit: whoops, forgot the one time I wrote a one-off Mac app in Swift.