Hi there,
I'd really like to use the NATURAL <x> JOIN facility in postgresql as outlined in http://www.postgresql.org/docs/8.3/interactive/queries-table-expressions.htm..., so my first instinct was to patch s-sql (-:
This patch also fixes the syntax emitted for :cross-join (it really doesn't require an :ON) and adds a :USING keyword to specify the same-named columns to use for joining.
The result can be used like so:
(:select 'x 'y :from 'foo :cross-join 'bar) (:select 'x 'y :from 'foo :natural-left-join 'bar :where (:= 'a 2)) (:select 'x 'y :from 'foo :natural-inner-join 'bar :where (:= 'a 1))
(:select 'x 'y :from 'foo :outer-join 'bar :using ('a 'b 'c)) ;;; which is mostly equivalent to: (:select 'x 'y :from 'foo :inner-join 'bar :on (:and (:= 'foo.a 'bar.a) (:= 'foo.b 'bar.b) (:= 'foo.c 'bar.c)))
I hope you find the attached patch useful, and will consider committing it.
Cheers,
Hey Andreas,
I like the idea, but can't really live with the code you submitted. I've implemented something similar, except without the funky hacks, and with :natural occurring as a separate keyword, so you'd get...
(:select 'x 'y :from 'foo :natural :left-join 'bar :where (:= 'a 2))
It's in the repository. Could you see if it works for you?
Cheers, Marijn
2009/4/9 Marijn Haverbeke marijnh@gmail.com:
Hey Andreas,
Hi Marijn,
I like the idea, but can't really live with the code you submitted. I've implemented something similar, except without the funky hacks, and with :natural occurring as a separate keyword, so you'd get...
(:select 'x 'y :from 'foo :natural :left-join 'bar :where (:= 'a 2))
It's in the repository. Could you see if it works for you?
Works like a charm. Looking at it again, what I submitted is pretty awful code; what you committed is way better.
Thanks a lot,
postmodern-devel@common-lisp.net