Live data from Hacker News

How about trailing commas in SQL?

peter.eisentraut.org

91–100 of 272 posts

Re: How about trailing commas in SQL?

#91
post #71

Earlier quoted context omitted.

That's as bad as using regular expressions: now you have TWO problems. Why do you seem to think you've cleverly solved the problem, when you've just moved the problem somewhere else just as bad, by blithely messing with the standard formatting conventions universally used by most human written languages and programming languages in the world? Programming languages borrow commas from human written languages, and no hu…

> I would fire and forget any developer who tried to pull that stunt. A tad bit harsh there? it is a trade off. clarity and ease during design time versus slightly uglier but still consistent code as a work around. miniscule energy overhead

Firing and forgetting was your suggestion!

>tezza 4 hours ago | root | parent | next [–]

>as mentioned elsewhere, i personally introduce a pad element to get fire and forget consistency

Adding an extra pad entry is a cure much worse than the disease, and I'd expect it should be objectively obvious to anyone that you're introducing more complexity and noise than you're removing, so it's not just a matter of "style" when you're pointlessly increasing the amount of work, memory, and network traffic per row. But sadly some people are just blind to or careless about that kind of complexity and waste.

You might at least have the courtesy of writing a comment explaining "Ignore this extra unused pad argument because I'm just adding it to make the following commas line up." But that would make it even more painfully obvious that your solution was much worse than the problem you're trying to solve. You seem to have forgotten that other people have to read your code. Maybe just don't leave dumpster fires burning in your code that you want to forget in the first place.

As Guido so wisely puts it: "the complexity introduced by a solution to a design problem must be somehow proportional to the problem's importance".

Re: How about trailing commas in SQL?

#92

IIRC BigQuery started allowing trailing commas in queries around 2019. It all came as a very big surprise, out of thin air.

That's correct, and I absolutely love it. If I move to a new role where BigQuery is not the data warehouse of choice, I think this will be the thing I'll miss most.

Re: How about trailing commas in SQL?

#95
post #34
post #16

Earlier quoted context omitted.

That’s why I use leading commas. Unless I change the first column, no problem.

When you start working with sql you despise leading commas. When you stop working with any other code than SQL you look back on your younger self and think ‘I was soooo young’ when typing those lovely leading commas.

I mainly work with SQL and like them.

Re: How about trailing commas in SQL?

#96
post #88

Prql has trailing commas https://prql-lang.org/ if you're ok with running that transformation.

Unfortunately it’s written in Rust, so it can only be used with Rust projects.

If Rust can only be used with Rust, then it's strange that the project lists a number of other languages in the docs: https://prql-lang.org/book/project/bindings/index.html

Re: How about trailing commas in SQL?

#97
post #23

Earlier quoted context omitted.

That’s why I use leading commas.

You’re clearly missing the entire point. The mismatched number of commas in either orientation requires you to alter unrelated fields when making modifications.

I rarely change the beginning of the query more likely the end.

Re: How about trailing commas in SQL?

#99
post #43
post #16

Earlier quoted context omitted.

That’s why I use leading commas. Unless I change the first column, no problem.

Yea, and if you do trailing commas, "unless I change the last column, no problem". This is exactly the problem. Supporting leading or trailing redundant comma are both good options. Not supporting either isn't.

I rarely change the first column in a query but often the end especially while debugging. So a leading comma isn't the same problem to me.

Re: How about trailing commas in SQL?

#100
post #88

Earlier quoted context omitted.

Unfortunately it’s written in Rust, so it can only be used with Rust projects.

If Rust can only be used with Rust, then it's strange that the project lists a number of other languages in the docs: https://prql-lang.org/book/project/bindings/index.html

Alright, it supports four languages, but that’s still not much.
Post reply on HN