Live data from Hacker News

How about trailing commas in SQL?

peter.eisentraut.org

141–150 of 272 posts

Re: How about trailing commas in SQL?

#141

Why even have commas at all? This is a non-issue for the likes of Tcl and Lisp and your average shell-scripting language and what have you; whitespace is already a good enough delimiter.

Because in SQL whitespace is already used for all manner of special syntax.

That said, generating SQL from s-expressions can be a very pleasant experience.

Re: How about trailing commas in SQL?

#142

Earlier quoted context omitted.

in 20 years of writing SQL, preceding commas is so much better IMO. Its so easy to miss a comma at the end of a long expression. preceding commas means you can never forget them. Then if I can have an extra leading comma, I can reorder, comment out or remove, or add a column at any point in the list without having to think about the rest of the projection. Also diffs are cleaner, it only highlights the rows that have…

It's only easy to miss a comma at the end of a long expression because you need to calculate whether it should be there in the first place. If commas were always required unconditionally, it wouldn't be a problem.

its still a problem if you forget to write it, and with a trailing comma its often that you forget it because theyre hard to see

Re: How about trailing commas in SQL?

#143
post #110

Earlier quoted context omitted.

The limitation is clearly not Rust. Any language that can bind to C libraries can bind to the functions PRQL exposes... the authors just haven't chosen to implement convenient SDKs for many languages. They also list 8 languages, not 4, just that they've had time to polish the libraries for 4 languages, apparently. PRQL appears to be a rather small project... not some major corporate effort.

I wouldn’t mind writing the C bindings myself, but the docs say that not even C is officially supported.

Hi, PRQL contributor here.

C bindings would be great! Do you want to open an issue in the repo?

Re: How about trailing commas in SQL?

#144
post #6

I feel the problem. When coding (not only in SQL) you often have to add something to the end of a list, and it is annoying that the end of the list is always special. You can't just copy some line and move it there. Also when moving things around you always have to take extra care at the end. So, my solution for this was always SELECT a , b , c FROM ... instead of: SELECT a, b, c, -- people want to allow trailing com…

Mode Analytics published some data years ago showing that SQL programmers who preferred leading commas had a lower rate of errors than programmers who used trailing commas. [0] 0 - https://mode.com/blog/should-sql-queries-use-trailing-or-lea...

I do this but I'm skeptical of the causation. I think it might be a symptom of people who are generally more careful with syntax because the formatting means more to them, so they spend time reading the query and moving bits around, which is how they find little typo bugs.

Re: How about trailing commas in SQL?

#145
post #143
post #110

Earlier quoted context omitted.

I wouldn’t mind writing the C bindings myself, but the docs say that not even C is officially supported.

Hi, PRQL contributor here. C bindings would be great! Do you want to open an issue in the repo?

Sorry, by my comment I meant that if PRQL exposed a C API (as the parent commenter claims it does), I’d write bindings for the languages I use that can consume C libraries. Unfortunately I’m not proficient enough with Rust to create the C API myself.

Re: How about trailing commas in SQL?

#146
post #100

Earlier quoted context omitted.

Alright, it supports four languages, but that’s still not much.

The limitation is clearly not Rust. Any language that can bind to C libraries can bind to the functions PRQL exposes... the authors just haven't chosen to implement convenient SDKs for many languages. They also list 8 languages, not 4, just that they've had time to polish the libraries for 4 languages, apparently. PRQL appears to be a rather small project... not some major corporate effort.

Yes, that's precisely it. PRQL is a completely volunteer driven project by folks who had enough of the thousands of paper cuts from SQL and felt that we deserved something better after 50 years. Throw away the SQL syntax and keep what people usually like about SQL - declarative, relational operators - plus add functions and composition.

The main limitation is developer time. There is so much that could be done with PRQL! Without corporate sponsor, parent company, or more contributors, velocity is unfortunately limited. If you'd like to see that change, please reach out!

Re: How about trailing commas in SQL?

#149
post #145
post #143

Earlier quoted context omitted.

Hi, PRQL contributor here. C bindings would be great! Do you want to open an issue in the repo?

Sorry, by my comment I meant that if PRQL exposed a C API (as the parent commenter claims it does), I’d write bindings for the languages I use that can consume C libraries. Unfortunately I’m not proficient enough with Rust to create the C API myself.

Right, that's not my forte as well. Seems like quite a key enabler though so let me see where we are on that.

There was also a helpful comment on a HN thread a few weeks back about how to make the API better to develop against. I've been meaning to get back to that but been constrained myself.

Re: How about trailing commas in SQL?

#150

Why even have commas at all? This is a non-issue for the likes of Tcl and Lisp and your average shell-scripting language and what have you; whitespace is already a good enough delimiter.

Because there's existing implementations that would interpret that as aliasing column names. ``` SELECT Field AS Renamed, OtherField AS AlsoRenamed ``` and ``` SELECT Field Renamed, OtherField AlsoRenamed ``` are semantically equivalent.

Making AS mandatory for naming columns would be an improvement in and of itself.
Post reply on HN