--
Jon
> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To post to this group, send email to sqlal...@googlegroups.com.
> To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
>
So does psycopg2 send '%' or '%%' ? It seems to me that if the
strings are held as atoms (individual arguments rather than a single,
concatenated string) then '%%' is unnecessary.
On Feb 25, 2011, at 10:20 AM, Jon Nelson wrote:
> On Fri, Feb 25, 2011 at 9:15 AM, Michael Bayer <mik...@zzzcomputing.com> wrote:
>> % is significant in DBAPIs like postgresql and mysqldb where pyformat and format: %(foo)s and %s, are allowed, so % must be doubled.
>
> So does psycopg2 send '%' or '%%' ?
psycopg2 is the DBAPI here, % is significant so the client of DBAPI must escape % that is not part of a string format.
> It seems to me that if the
> strings are held as atoms (individual arguments rather than a single,
sorry, I don't know what you mean by "individual arguments", do you mean bind params, i.e. :p1 + :p2 + :p3 ?
> concatenated string) then '%%' is unnecessary.
The compiler most certainly needs to escape literal-rendered % signs across the board on those DBAPIs where the symbol has other meanings, since a user might use literal_column() with a '%' sign in it, and would like this symbol to behave the same way on all backends.
>
>> On Feb 25, 2011, at 8:53 AM, Jon Nelson wrote:
>>
>>> I've been wondering something about sqlalchemy - let's say I have a
>>> text column "foo". Being able to do foo.startswith(some_value),
>>> foo.endswith, foo.like and so on is really nice. However, I've noticed
>>> that the SQL that is emitted contains two percent signs. However, I
>>> thought only one was necessary. Why is sqlalchemy emitting two?
>
>
> --
> Jon
>
On Feb 25, 2011, at 10:20 AM, Jon Nelson wrote:> On Fri, Feb 25, 2011 at 9:15 AM, Michael Bayer <mik...@zzzcomputing.com> wrote:
>> % is significant in DBAPIs like postgresql and mysqldb where pyformat and format: %(foo)s and %s, are allowed, so % must be doubled.
>
> So does psycopg2 send '%' or '%%' ?psycopg2 is the DBAPI here, % is significant so the client of DBAPI must escape % that is not part of a string format.
> It seems to me that if the
> strings are held as atoms (individual arguments rather than a single,sorry, I don't know what you mean by "individual arguments", do you mean bind params, i.e. :p1 + :p2 + :p3 ?
> concatenated string) then '%%' is unnecessary.
The compiler most certainly needs to escape literal-rendered % signs across the board on those DBAPIs where the symbol has other meanings, since a user might use literal_column() with a '%' sign in it, and would like this symbol to behave the same way on all backends.