On Mon, 13 Dec 2004 19:47:09 -0600, Ian Bicking <ia...@co...> wrote:
> SQLObject can't generate SQL without knowing what database it is
> generating SQL for -- in this case, particularly strings. So you could do:
I'm curious now. This is an example quoted in the SQLBuilder doc:
>>> person.first_name == 'John'
person.first_name = 'John'
In this case, how does it know how to quote the string? (or, in other
words, does this example still work?)
> print Catalog.sqlrepr(Catalog.q.item == '001')
>
> This calls sqlrepr(Catalog.q.item == '001', Catalog._connection.dbname)
> or something like that.
If the expression on the left side is attached to a db, I think that
it could use this information to format the term on the right side.
For example:
def __eq__(self, other):
if other is None:
return ISNULL(self)
else:
return SQLOp("=", self, other)
On the call to SQLOp("=", self, other), a wrapper could be provided
for the "other" term that would fill the db information. Something
like this:
def __eq__(self, other):
if other is None:
return ISNULL(self)
else:
return SQLOp("=", self, default_db_wrapper(other, self.db))
Anyway, it's now to late to even start looking at it today. I've
solved my problem partially by writing the queries manually, but I
would like to be able to use SQLBuilder too keep the code cleaner &
more db independent.
--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: car...@gm...
mail: car...@ya...
|