Hi There,

So I have a bit of an (admittedly unusual) question:

I understand that the Interval type is designed to operate using
datetime.timedelta on those SQL engines that natively support the
Interval data type (eg PostgreSQL).

I also understand that when operating on SQL engines that do *not*
natively support the Interval data type, SQLAlchemy coerces
datetime.timedelta values to datetime.datetime values relative to the
epoch date.

Is my understanding so far correct?

If so, here is the crux of the situation: given an ORM model class
with an Interval attribute, when introspecting either that model class
(i.e. the class of the model itself) OR when introspecting an instance
of that model class (presumably navigating across
InstrumentedAttributes and related Comparators) how can one
differentiate between:
A) an attribute that is still a native Interval type,
B) a “converted” Interval (now represented as a DATETIME type), and
C) a native DATETIME type that does not have any relationship to intervals

I’m almost certain there’s a mechanism to do this differentiation by
navigating the internals, but I'm having trouble putting my finger on
how best to accomplish this. My overall objective is to use this
differentiation to do appropriate datetime / timedelta arithmetic and
conversion based on whether the timedelta is to be persisted to the DB
as a native Interval type, or as a datetime relative to the epoch
time.

Any help or guidance would be much appreciated!

All the best,
Chris

Sent from my iPhone

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CACng_W8AwxAZp1ODeBBTsh%2B1v0hRcet%2Bw6cvdOmsfxwp8WRSLw%40mail.gmail.com.

Reply via email to