Carlos Ribeiro wrote:
> On Mon, 13 Dec 2004 22:59:52 -0200, Carlos Ribeiro <car...@gm...> wrote:
>
>>I'm trying to trace it down, but that's
>>the first time I'm trying to understand SQLBuilder internals, so I
>>thought that it would be good to report it.
>
>
> I think I'm beginning to understand how do SQLBuilder works, but
> still, I have no idea on how to solve this problem. The SQLExpression
> class has this code:
>
> def __str__(self):
> return self.__sqlrepr__(None)
>
> That's the code that is called, and it passes None as the db, in this
> case. But the StringLikeConverter (that is the converter that it finds
> in the registry for a constant string) expects a valid db name:
>
> def StringLikeConverter(value, db):
> if db in ('mysql', 'postgres'):
> for orig, repl in sqlStringReplace:
> value = value.replace(orig, repl)
> elif db in ('sqlite', 'firebird', 'sybase', 'maxdb'):
> value = value.replace("'", "''")
> else:
> assert 0, "Database %s unknown" % db
> return "'%s'" % value
>
> And that's where the assertion happens. What can I do in this case?
> I'm really lost and looking for ideas :-) I could possibly initialize
> the SQLExpression object with a valid db name (borrowed from the best
> possible candidate it finds while building the expression), but I'm
> not sure about the side effects.
SQLObject can't generate SQL without knowing what database it is
generating SQL for -- in this case, particularly strings. So you could do:
print Catalog.sqlrepr(Catalog.q.item == '001')
This calls sqlrepr(Catalog.q.item == '001', Catalog._connection.dbname)
or something like that.
--
Ian Bicking / ia...@co... / http://blog.ianbicking.org
|