zlacker

[parent] [thread] 1 comments
1. mrjin+(OP)[view] [source] 2024-08-24 23:41:48
Starting with SELECT was a mistake in SQL as you need to know where before what to select from. What we really need is something like

FROM r JOIN s on r.Id = s.Id ORDER BY r.Id SELECT *

But the thing is, such changes will break pretty much all existing code, so the author added |> to distinguish, but why not use | instead? Don't make people typing one more character please.

replies(1): >>svat+o51
2. svat+o51[view] [source] 2024-08-25 13:14:39
>>mrjin+(OP)
Yes, being able to start with FROM is what makes this so intuitive to use (and autocomplete work better); your hypothetical

    FROM r JOIN s on r.Id = s.Id ORDER BY r.Id SELECT *
would indeed be pretty much that (linebreaks optional):

    FROM r JOIN s on r.Id = s.Id 
    |> ORDER BY r.Id 
    |> SELECT *
The question about “typing one more character” is answered in the paper's section 4.1.5 “Why use ‘|>’ for the pipe character?” (page 6): “The most natural and obvious choice would be to use ‘|’. Unfortunately…” — they don't want to break existing queries that use | for bitwise OR.

(I wonder if one day, if the majority of users are using pipe syntax and don't mind updating their old queries or adding a special directive to enable single pipe…)

[go to top]