News for hackers. Stuff that matters.
Re:Sqlfluff the SQL Linter for Humans by ThePadawan on Wednesday October 06, 2021 @08:27AM (#28772289)
This is a linter which complains about spaces and newlines, but lets "WHERE col = NULL" pass (which can never be meaningful) just fine?

Obviously this depends on the rules configuration, but just judging that first smell test, it seems very ill thought out.

Re:Sqlfluff the SQL Linter for Humans by Genmutant on Wednesday October 06, 2021 @11:01AM (#28773972)
In MS SQL Server, with ANSI_NULLS set to OFF, it will select all rows having a NULL value for col. AFAIK not used that often.
Re:Sqlfluff the SQL Linter for Humans by marcosdumay on Wednesday October 06, 2021 @02:20PM (#28776379)
That is a serious gotcha of SQL Server. It (and Oracle) has some serious problems with unique constraints because of that kind of stuff.
Re:Sqlfluff the SQL Linter for Humans by tunetheweb on Wednesday October 06, 2021 @06:58PM (#28779538)
Seems like a good thing to check for! So we added a rule for this: https://github.com/sqlfluff/sqlfluff/pull/1527

Including autofixing if wanted.

Will be in the next release.

Re:Sqlfluff the SQL Linter for Humans by justusw on Wednesday October 06, 2021 @08:38AM (#28772403)
I guess it depends on what you want out of a linter e.g. if you want it to check just syntax or semantics as well. Is “= NULL” syntactically correct?
Re:Sqlfluff the SQL Linter for Humans by ThePadawan on Wednesday October 06, 2021 @08:43AM (#28772443)
A linter is supposed to tell you "you are probably making a mistake."

"= NULL" is as syntactically correct in SQL as "if (x = null)" in C.

If it wasn't, code highlighting or compiling would break, both of which are much much more obvious.

Re:Sqlfluff the SQL Linter for Humans by danachow on Wednesday October 06, 2021 @10:16AM (#28773465)
The compiler checks syntax - if that’s all a linter did it wouldn’t be very useful.
Re:Sqlfluff the SQL Linter for Humans by munk-a on Wednesday October 06, 2021 @01:05PM (#28775507)
`= NULL` is perfectly legal syntax - but it isn't doing what you think it is.
Re:Sqlfluff the SQL Linter for Humans by ThePadawan on Wednesday October 06, 2021 @01:22PM (#28775730)
That's what parent is saying. He is contrasting a compiler (which this isn't) to a linter (which this arguably also isn't).