[postmodern-devel] s-sql: Better join keyword recognition

Andreas Fuchs asf at boinkor.net
Thu Apr 9 12:07:22 UTC 2009


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.html,
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,
-- 
Andreas Fuchs, (http://|im:asf@|mailto:asf@)boinkor.net, antifuchs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s-sql-join-keyword-improvements.patch
Type: application/octet-stream
Size: 5109 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/postmodern-devel/attachments/20090409/901edc5f/attachment.obj>


More information about the postmodern-devel mailing list