Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
zegl committed Nov 2, 2023
1 parent 823a402 commit 7bee0d3
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 11 deletions.
8 changes: 5 additions & 3 deletions server/polar/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class Status(str, Enum):

email: Mapped[str | None] = mapped_column(String(254), nullable=True, default=None)

country: Mapped[str | None] = mapped_column(String(2))
currency: Mapped[str | None] = mapped_column(String(3))
country: Mapped[str] = mapped_column(String(2))
currency: Mapped[str] = mapped_column(String(3))

is_details_submitted: Mapped[bool] = mapped_column(Boolean, nullable=False)
is_charges_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False)
Expand All @@ -65,7 +65,9 @@ class Status(str, Enum):
StringEnum(Status), nullable=False, default=Status.CREATED
)

data: Mapped[dict[str, Any]] = mapped_column(JSONB, nullable=False, default=dict)
data: Mapped[dict[str, Any]] = mapped_column(
JSONB, nullable=False, default=None, insert_default=dict
)

@declared_attr
def organization(cls) -> Mapped[Organization | None]:
Expand Down
2 changes: 1 addition & 1 deletion server/polar/models/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ class Notification(RecordModel, MappedAsDataclass, kw_only=True):
PostgresUUID, ForeignKey("pull_requests.id"), nullable=True, default=None
)

payload: Mapped[JSONDict | None] = mapped_column(JSONB, nullable=True, default=dict)
payload: Mapped[JSONDict | None] = mapped_column(JSONB, nullable=True, default=None)
4 changes: 2 additions & 2 deletions server/polar/models/pull_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class PullRequest(IssueFields, RecordModel, MappedAsDataclass, kw_only=True):
changed_files: Mapped[int | None] = mapped_column(Integer, nullable=True)

requested_reviewers: Mapped[JSONList | None] = mapped_column(
JSONB, nullable=True, default=list
JSONB, nullable=True, default=None, insert_default=list
)
requested_teams: Mapped[JSONList | None] = mapped_column(
JSONB, nullable=True, default=list
JSONB, nullable=True, default=None, insert_default=list
)

# Part of Full Pull Request object, must be nullable
Expand Down
2 changes: 1 addition & 1 deletion server/polar/models/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def organization(cls) -> Mapped[Organization]:

main_branch: Mapped[str | None] = mapped_column(String, nullable=True)
topics: Mapped[list[str] | None] = mapped_column(
JSONB, nullable=False, default=list
JSONB, nullable=False, default=None, insert_default=list
)

license: Mapped[str | None] = mapped_column(String, nullable=True)
Expand Down
6 changes: 3 additions & 3 deletions server/polar/models/subscription_benefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SubscriptionBenefit(RecordModel, MappedAsDataclass, kw_only=True):
)

properties: Mapped[SubscriptionBenefitProperties] = mapped_column(
"properties", JSONB, nullable=False, default=dict
"properties", JSONB, nullable=False, default=None, insert_default=dict
)

organization_id: Mapped[UUID | None] = mapped_column(
Expand Down Expand Up @@ -98,7 +98,7 @@ def repository(cls) -> Mapped["Repository | None"]:

class SubscriptionBenefitCustom(SubscriptionBenefit):
properties: Mapped[SubscriptionBenefitCustomProperties] = mapped_column(
use_existing_column=True, default=dict
use_existing_column=True, default=None, insert_default=dict
)

__mapper_args__ = {
Expand All @@ -109,7 +109,7 @@ class SubscriptionBenefitCustom(SubscriptionBenefit):

class SubscriptionBenefitBuiltin(SubscriptionBenefit):
properties: Mapped[SubscriptionBenefitCustomProperties] = mapped_column(
use_existing_column=True, default=dict
use_existing_column=True, default=None, insert_default=dict
)

__mapper_args__ = {
Expand Down
4 changes: 3 additions & 1 deletion server/tests/fixtures/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class TestModel(Model):

__tablename__ = "test_model"
id: Mapped[int] = mapped_column(Integer, primary_key=True, default=None)
uuid: Mapped[UUID] = mapped_column(PostgresUUID, default=generate_uuid)
uuid: Mapped[UUID] = mapped_column(
PostgresUUID, default=None, insert_default=generate_uuid
)
int_column: Mapped[int | None] = mapped_column(Integer, default=None, nullable=True)
str_column: Mapped[str | None] = mapped_column(String, default=None, nullable=True)

Expand Down
1 change: 1 addition & 0 deletions server/tests/issue/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ async def issue_with_milestone(number: int) -> Issue:
)

ms = github.rest.Milestone(
id=123,
url="http://example.com/",
html_url="http://example.com/",
labels_url="http://example.com/",
Expand Down

0 comments on commit 7bee0d3

Please sign in to comment.