On Thu, Jan 24, 2019 at 9:07 PM Zsolt Ero <
zsol...@gmail.com> wrote:
>
> Do I understand it right that there is no approach which could print a
> query without the need to modify it, if it contains datetimes?
>
> If so, how can I turn a where statement into something which is
> printable using SDateTime?
>
> .where(trips.c.end_time >= datetime.datetime.now())
where you define your Table and its column called end_time, don't use
DateTime, use your custom version of that type.
if you are relying upon reflection, use a column_reflect event
(
https://docs.sqlalchemy.org/en/latest/core/events.html?highlight=column_reflect#sqlalchemy.events.DDLEvents.column_reflect)
to replace occurrences of DateTime with the custom DateTime object.
SQLAlchemy can of course eventually support rendering datetimes as
literal strings but this becomes a slippery slope where it has to
support literal rendering for every possible type, and we're then in a
place where we are reimplementing what the DBAPI already does and I
don't like to be doing that. We likely could benefit from a hook
that works like @compiles here but that's not available at this
moment.