For future reference, it is not actually a great idea to use @compiles to
render with AT TIME ZONE as I did above. When done this way, SQLAlchemy
renders all references to that column using this, *including* any
references in a WHERE clause. eg: when looking for log events later than
some
On Jul 17, 2012, at 2:25 PM, Russ wrote:
For future reference, it is not actually a great idea to use @compiles to
render with AT TIME ZONE as I did above. When done this way, SQLAlchemy
renders all references to that column using this, including any references in
a WHERE clause. eg:
I currently define a custom column type for ensuring that dates stored to
the DB are offset-aware UTC, and convert to to the appropriate timezone on
retrieval, using a class something like this:
import pytz
import sqlalchemy as sa
class UTCEnforcedDateTime(sa.types.TypeDecorator):
DateTime
On Jul 12, 2012, at 2:58 PM, Russ wrote:
I'm trying to figure out how to change this so that, rather than converting
in python, the conversion happens at the database layer using AT TIME ZONE
syntax. I've tried using @compiles as follows:
#THIS CODE DOES NOT WORK...
On Thursday, July 12, 2012 3:12:26 PM UTC-4, Michael Bayer wrote:
There is no functionality right now that allows special SQL to be
automatically associated with a type, as associated with an enclosing
column expression, at query time. There's a ticket to begin making this
kind of thing
On Jul 12, 2012, at 5:15 PM, Russ wrote:
I've got it mostly working using this method, but have hit a few roadblocks.
It was pretty easy to intercept Column definitions that were given the
UTCEnforcedDateTime type and, with this done, then use DTColumn wrapper type
instead with an
However... element.table.name doesn't seem like it can be used directly.
It occasionally comes up with strings like %(79508240 log_event)s, which
clearly is getting substituted in the guts somewhere when I don't do this.
To clarify, I've just determined that this is specifically
On Thursday, July 12, 2012 5:42:12 PM UTC-4, Michael Bayer wrote:
let the compiler do it:
elementName = compiler.process(element, **kw)
That causes an infinite loop since it tries to compile DTColumn itself.
I've tried stuff like super(DTColumn, element).compile(), but that doesn't
help
oh right. yeah call compiler.visit_column(element, **kw).
On Jul 12, 2012, at 5:59 PM, Russ wrote:
On Thursday, July 12, 2012 5:42:12 PM UTC-4, Michael Bayer wrote:
let the compiler do it:
elementName = compiler.process(element, **kw)
That causes an infinite loop since it tries to
oh right. yeah call compiler.visit_column(element, **kw).
Perfect... that did the trick, thanks!!!
Since the end result isn't much more than this example:
http://docs.sqlalchemy.org/en/rel_0_7/core/compiler.html#synopsis
it may be worth updating it to replace 'element.name' with
10 matches
Mail list logo