Fixed ArrowType to store and retrieve time consistently.
Fixed ArrowType to store and retrieve time consistently.

SQLAlchemy's handling of time is stupid.  If you hand it a datetime with an explicit time zone set, and attempt to put it in a "timestamp without time zone" field, it will convert it to your local time first.  This is probably not what you want!  Especially in ArrowType case, because when you retrieve the value and pass it to arrow.get, arrow assumes the time is in UTC, when it's really in local time.  This leads to nonsense like this:

myrecord.time = time
db.session.commit()
myrecord.time != time # wtf!  It changed!

In this commit, I make the assumption that you always want to put UTC timestamps into your database, so I convert the incoming time to UTC and then discard the time zone so SQLAlchemy wont mess with it.

A future version of this type might allow you to specify what time zone you want to assume this database column actually represents, so you can convert to and from that time zone when saving and retrieving.
tonyseek/sqlalchemy-utils,marrybird/sqlalchemy-utils,rmoorman/sqlalchemy-utils,konstantinoskostis/sqlalchemy-utils,joshfriend/sqlalchemy-utils,cheungpat/sqlalchemy-utils,JackWink/sqlalchemy-utils,joshfriend/sqlalchemy-utils,spoqa/sqlalchemy-utils,tonyseek/sqlalchemy-utils