CloverHealth / temporal-sqlalchemy

SQLAlchemy + Temporal
http://temporal-sqlalchemy.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
43 stars 3 forks source link

New style temporal #17

Closed multigl closed 7 years ago

multigl commented 7 years ago

3

Declarative temporal:


class NewStyleModelWithRelationship(Base, temporal_sqlalchemy.TemporalModel):
    __tablename__ = 'new_style_temporal_model_with_relationship'
    __table_args__ = {'schema': SCHEMA}

    id = auto_uuid()
    description = sa.Column(sa.TEXT)

    int_prop = sa.Column(sa.Integer)
    bool_prop = sa.Column(sa.Boolean)
    datetime_prop = sa.Column(sa.DateTime(True))
    rel_id = sa.Column(sa.ForeignKey(RelatedTable.id))
    rel = orm.relationship(RelatedTable)

    class Temporal:
        activity_class = Activity
        track = (
            'description',
            'int_prop',
            'bool_prop',
            'datetime_prop',
            'rel_id',
            'rel',
        )
        schema = TEMPORAL_SCHEMA
multigl commented 7 years ago

Adds support for tracking entities that:

  1. Don't have a UUID primary key
  2. Have a composite primary key
polotek commented 7 years ago

Does this still support the decorator style? If so, are the 2 styles compatible or is it an either or kind of thing?

multigl commented 7 years ago

both are still supported, and both use the same underlying data models & session hooks

polotek commented 7 years ago

Sounds great. I don't have any feedback about the code because I don't have enough context. I'll leave that to others.

multigl commented 7 years ago

tagging some people @aclowes @bjjclover @stroud109 @NicoleZuckerman

multigl commented 7 years ago

Resolves #3