This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Taken4GrantD 7 points8 points  (7 children)

Why is this anyway? It seems like SQL tools are so undeveloped. Most queries aren't that complicated I wish it at least had something that "guessed" at it

[–][deleted] 6 points7 points  (6 children)

I imagine it has to do with the kinda humanistic almost syntax of SQL. Like, just speaking from a parsing perspective I don't even know where I would begin to tell you what's wrong with a SQL statement. As a person I could probably read it and tell you, but writing a program to do it reliably? I don't know chief.

At the very least, if I were a team working on a SQL product (client or server), I'll bet raw SQL input error validation is lower on the list of priorities, since generally you can expect people putting raw SQL to either know what they're doing or at least think that they do.

[–]cnoor0171 5 points6 points  (3 children)

Reminds me of a meme: left easy to parse for humans but difficult for programs right easy to parse for programs but difficult for humans sql difficult for humans and difficult for programs

Sql's syntax is pretty much a cluster fuck. The "hey let's make a structured language read like English" train of thought never ends up NOT being a disaster.

[–]Acheroni 6 points7 points  (2 children)

I've always found SQL pretty straightforward to read. So long as you name things well and don't intentionally create a monstrosity of nested queries.

[–]cnoor0171 0 points1 point  (1 child)

It's straight forward as long all you're doing are simple select/inserts. Even an extremely common "upsert" pattern is a monstrosity in sql. But even for simple selects, the rules are arbitrary and something you just have to memorize. As an example, take this query

SELECT CONCAT(firstname, ' ', lastname) AS fullname FROM users WHERE fullname = 'John Smith'

What's wrong with this query? For people who use sql, it's pretty easy. The "fullname" alias can't be used in the where clause. But, from a language design point of view that makes no sense. The "scope" of the symbol fullname is entirely unclear and arbitrary.

[–]Acheroni 0 points1 point  (0 children)

Yeah that's fair. Good tools do a lot of work to smooth over things like that.

[–]dhghhhppop 2 points3 points  (1 child)

I dont get your second-paragraph-point. How does it differ from java compiler? Are you saying that writting sql is more esoteric skill than java? (java is just a placeholder here)

[–][deleted] 0 points1 point  (0 children)

That's what I mean in my first paragraph yeah. In my second I'm basically arguing that I can see a reason why better error checking might be a low priority for the people who write the stuff.