Skip to content

Commit

Permalink
Specify column type to StateManager.check_constraint, for upcoming sw…
Browse files Browse the repository at this point in the history
…itch to Enum
  • Loading branch information
jace committed Jan 3, 2024
1 parent 8d3a244 commit f811ab8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions funnel/models/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Commentset(UuidMixin, BaseMixin[int, Account], Model):
_state: Mapped[int] = sa_orm.mapped_column(
'state',
sa.SmallInteger,
StateManager.check_constraint('state', COMMENTSET_STATE),
StateManager.check_constraint('state', COMMENTSET_STATE, sa.SmallInteger),
nullable=False,
default=COMMENTSET_STATE.OPEN,
)
Expand Down Expand Up @@ -328,7 +328,7 @@ class Comment(UuidMixin, BaseMixin[int, Account], Model):

_state: Mapped[int] = sa_orm.mapped_column(
'state',
StateManager.check_constraint('state', COMMENT_STATE),
StateManager.check_constraint('state', COMMENT_STATE, sa.Integer),
default=COMMENT_STATE.SUBMITTED,
nullable=False,
)
Expand Down
1 change: 1 addition & 0 deletions funnel/models/email_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class methods, depending on whether the email address is linked to an owner or n
StateManager.check_constraint(
'delivery_state',
EMAIL_DELIVERY_STATE,
sa.Integer,
name='email_address_delivery_state_check',
),
nullable=False,
Expand Down
4 changes: 3 additions & 1 deletion funnel/models/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class CommentModeratorReport(UuidMixin, BaseMixin[UUID, Account], Model):
reported_by: Mapped[Account] = relationship(back_populates='moderator_reports')
report_type: Mapped[int] = sa_orm.mapped_column(
sa.SmallInteger,
StateManager.check_constraint('report_type', MODERATOR_REPORT_TYPE),
StateManager.check_constraint(
'report_type', MODERATOR_REPORT_TYPE, sa.SmallInteger
),
nullable=False,
default=MODERATOR_REPORT_TYPE.SPAM,
)
Expand Down
4 changes: 2 additions & 2 deletions funnel/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Project(UuidMixin, BaseScopedNameMixin[int, Account], Model):

_state: Mapped[int] = sa_orm.mapped_column(
'state',
StateManager.check_constraint('state', PROJECT_STATE),
StateManager.check_constraint('state', PROJECT_STATE, sa.Integer),
default=PROJECT_STATE.DRAFT,
nullable=False,
index=True,
Expand All @@ -165,7 +165,7 @@ class Project(UuidMixin, BaseScopedNameMixin[int, Account], Model):
)
_cfp_state: Mapped[int] = sa_orm.mapped_column(
'cfp_state',
StateManager.check_constraint('cfp_state', CFP_STATE),
StateManager.check_constraint('cfp_state', CFP_STATE, sa.Integer),
default=CFP_STATE.NONE,
nullable=False,
index=True,
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Proposal(UuidMixin, BaseScopedIdNameMixin, VideoMixin, ReorderMixin, Model

_state: Mapped[int] = sa_orm.mapped_column(
'state',
StateManager.check_constraint('state', PROPOSAL_STATE),
StateManager.check_constraint('state', PROPOSAL_STATE, sa.Integer),
default=PROPOSAL_STATE.SUBMITTED,
nullable=False,
)
Expand Down
2 changes: 1 addition & 1 deletion funnel/models/rsvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Rsvp(UuidMixin, NoIdMixin, Model):
_state: Mapped[str] = sa_orm.mapped_column(
'state',
sa.CHAR(1),
StateManager.check_constraint('state', RSVP_STATUS),
StateManager.check_constraint('state', RSVP_STATUS, sa.CHAR(1)),
default=RSVP_STATUS.AWAITING,
nullable=False,
)
Expand Down
6 changes: 4 additions & 2 deletions funnel/models/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Update(UuidMixin, BaseScopedIdNameMixin[int, Account], Model):
_visibility_state: Mapped[int] = sa_orm.mapped_column(
'visibility_state',
sa.SmallInteger,
StateManager.check_constraint('visibility_state', VISIBILITY_STATE),
StateManager.check_constraint(
'visibility_state', VISIBILITY_STATE, sa.SmallInteger
),
default=VISIBILITY_STATE.PUBLIC,
nullable=False,
index=True,
Expand All @@ -63,7 +65,7 @@ class Update(UuidMixin, BaseScopedIdNameMixin[int, Account], Model):
_state: Mapped[int] = sa_orm.mapped_column(
'state',
sa.SmallInteger,
StateManager.check_constraint('state', UPDATE_STATE),
StateManager.check_constraint('state', UPDATE_STATE, sa.SmallInteger),
default=UPDATE_STATE.DRAFT,
nullable=False,
index=True,
Expand Down

0 comments on commit f811ab8

Please sign in to comment.