On 6/30/15 7:21 PM, Jonathon Nelson wrote:


On Tue, Jun 30, 2015 at 6:18 PM, Mike Bayer <mike...@zzzcomputing.com <mailto:mike...@zzzcomputing.com>> wrote:

    how are you getting this Compiler object?  the .string element is
    created within the constructor.


It was actually as a result of trying to figure out how to use the code you gave me for the psycopg2 percentile escaping thing:

Well Compiler likes to return the SQL from __str__(), so if the SQL isn't there, i suppose it could return some generic thing, but then again __repr__() might be better to call in any case.





from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import TextClause

@compiles(TextClause, "postgresql")
def _reverse_escaping(element, compiler, **kw):
    # I PUT THE stringification of 'compiler' here
text = compiler.process_text(element, **kw) # should be .post_process_text?
    text = text.replace("%%", "%")
    return text






    On 6/30/15 6:32 PM, Jonathon Nelson wrote:
    When trying to debug something, I tried to acquire the string
    representation of a 'compiler' object.
    I got this error:

      File
    "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/compiler.py",
    line 218, in __str__
        return self.string or ''
    AttributeError: 'PGCompiler_psycopg2' object has no attribute
    'string'


    It would appear that trying to acquire the string representation
    of the object (before instantiation) fails.
    :-(


-- You received this message because you are subscribed to the
    Google Groups "sqlalchemy" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to sqlalchemy+unsubscr...@googlegroups.com
    <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
    To post to this group, send email to sqlalchemy@googlegroups.com
    <mailto:sqlalchemy@googlegroups.com>.
    Visit this group at http://groups.google.com/group/sqlalchemy.
    For more options, visit https://groups.google.com/d/optout.

-- You received this message because you are subscribed to a topic in
    the Google Groups "sqlalchemy" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/sqlalchemy/xXYGOZoCg40/unsubscribe.
    To unsubscribe from this group and all its topics, send an email
    to sqlalchemy+unsubscr...@googlegroups.com
    <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
    To post to this group, send email to sqlalchemy@googlegroups.com
    <mailto:sqlalchemy@googlegroups.com>.
    Visit this group at http://groups.google.com/group/sqlalchemy.
    For more options, visit https://groups.google.com/d/optout.




--
Jon Nelson
Dyn / Senior Software Engineer
p. +1 (603) 263-8029
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to