magerine
magerine

Reputation: 53

Temporal Postgres Database with sys_period

I am building a test database for unit testing.

I have a model like this

class MyObject(Base):
    __tablename__ = "my_object"

    id = Column(UUID, primary_key=True)
    sys_period = Column(TSTZRANGE, nullable=False, index=True)

In the the fixture I have the following code

object = schema.MyObject(
            id=str(uuid.uuid4()),
            ... other fields
            sys_period="[2018-10-01 09:00:00Z,)",)

After persisting the information, the sys_period fields returns a current timestamp instead of the values that I have sat above. Here is how I persist the object in the fixture

con_obj.db.add(object)
con_obj.db.commit()
``

What would be the cause for this? 

If I load the object from the database, the sys_period value is current timestamp instead of "2018-10-01 09:00:00Z"

Upvotes: 0

Views: 44

Answers (0)

Related Questions