[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] postgresql: support for query parameters
From: |
Graham Fawcett |
Subject: |
Re: [Chicken-users] postgresql: support for query parameters |
Date: |
Wed, 27 Feb 2008 10:44:40 -0500 |
On Wed, Feb 27, 2008 at 12:24 AM, Matthew Welland <address@hidden> wrote:
> On Tuesday 26 February 2008 07:47:27 pm Graham Fawcett wrote:
> > ;; new interface
> > (pg:query-tuples
> > (list "select foo, bar from baz where foo > $1 and baz < $2"
> > foo-low baz-high)
> > the-conn)
>
> I don't know if it is a standard of sorts but all the db api's (perl, ruby,
> sqlite3 egg) I have used use a ? for the placeholder.
[snip]
> It would be nice to be consistent IMHO, perhaps even going to the extent of
> a DBI like approach.
The dollar-sign syntax is the native Postgres parameter syntax. Oracle
uses (:1, :2, ...) and as you've noted, many others use a question
mark. If we ever have a common db-api, this conversion should probably
be addressed at that level, but I think the Postgres egg should be
true to its roots.
On the other hand, if you're really interested in that feature, I
think the right way to implement it would be as a module-level
parameter, e.g. (pg:use-?-for-parameters #t). We could rewrite the
queries to replace the question marks with dollar-numbers when the
parameter is true. A good compromise?
Thanks for offering to test it!
Graham