[Kepler-Project] Simple SQL parametrization

Andre Carregal carregal at fabricadigital.com.br
Tue Nov 20 19:44:28 GMT+3 2007

On Nov 17, 2007 3:26 PM, Serge <mindrats at list.ru> wrote:
> Hello.
> If anyone interested here goes simple SQL parametrization:
> I myself found it pretty handy :).
> table sql_formats controls formatting, makes it easy to switch between
> databases and types representation.

Interesting, thanks.

Since you are looking at parameterization, you may want to check
Yuri's Cosmo library (to be include with Kepler soon). It woud allow a
very similar construct, but using $name instead of {name} as place

Another variant would be using the SQL types directly as function
calls, instead of arguments, so you could have something like

cosmo.fill("SELECT FROM T WHERE N = $param_Name AND x = $test",
   {param_Name = sql_formats.string("string with 'single quotes' in it"),
    test = sql_formats.money(123)

And since you are it, you could make sql_formats be part of your DB
object, so the formatting rules would change as the DB object changes
(currently you have a coupling on the name "sql_formats" in PSql).

Using Cosmo would give you also conditionals, a powerful mechanism
that could really help those long WHERE clauses. :o)


More information about the Kepler-Project mailing list