diff --git a/actual/database.py b/actual/database.py index 1957e39..72a34f1 100644 --- a/actual/database.py +++ b/actual/database.py @@ -97,7 +97,9 @@ def before_flush(sess, flush_context, instances): @event.listens_for(session, "after_commit") @event.listens_for(session, "after_soft_rollback") - def after_commit_or_rollback(sess): + def after_commit_or_rollback( + sess, previous_transaction=None # noqa: previous_transaction needed for soft rollback + ): if sess.info.get("messages"): del sess.info["messages"] @@ -384,6 +386,7 @@ class Payees(BaseModel, table=True): transfer_acct: Optional[str] = Field( default=None, sa_column=Column("transfer_acct", Text, ForeignKey("accounts.id")) ) + favorite: Optional[int] = Field(default=None, sa_column=Column("favorite", Integer, server_default=text("0"))) account: Optional["Accounts"] = Relationship(back_populates="payee", sa_relationship_kwargs={"uselist": False}) transactions: List["Transactions"] = Relationship( @@ -413,6 +416,7 @@ class ReflectBudgets(SQLModel, table=True): amount: Optional[int] = Field(default=None, sa_column=Column("amount", Integer, server_default=text("0"))) carryover: Optional[int] = Field(default=None, sa_column=Column("carryover", Integer, server_default=text("0"))) goal: Optional[int] = Field(default=None, sa_column=Column("goal", Integer, server_default=text("null"))) + long_goal: Optional[int] = Field(default=None, sa_column=Column("long_goal", Integer, server_default=text("null"))) class Rules(BaseModel, table=True): @@ -571,6 +575,7 @@ class ZeroBudgets(SQLModel, table=True): amount: Optional[int] = Field(default=None, sa_column=Column("amount", Integer, server_default=text("0"))) carryover: Optional[int] = Field(default=None, sa_column=Column("carryover", Integer, server_default=text("0"))) goal: Optional[int] = Field(default=None, sa_column=Column("goal", Integer, server_default=text("null"))) + long_goal: Optional[int] = Field(default=None, sa_column=Column("long_goal", Integer, server_default=text("null"))) class PendingTransactions(SQLModel, table=True): diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index c71e6da..e14f204 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,7 +2,7 @@ services: actual: container_name: actual - image: docker.io/actualbudget/actual-server:24.7.0 + image: docker.io/actualbudget/actual-server:24.8.0 ports: - '5006:5006' volumes: diff --git a/tests/conftest.py b/tests/conftest.py index 81d627c..3e932d3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,7 +6,7 @@ import pytest from sqlmodel import Session, create_engine -from actual.database import SQLModel +from actual.database import SQLModel, strong_reference_session class RequestsMock: @@ -33,4 +33,4 @@ def session(): engine = create_engine(sqlite_url, connect_args={"check_same_thread": False}) SQLModel.metadata.create_all(engine) with Session(engine) as session: - yield session + yield strong_reference_session(session) diff --git a/tests/test_database.py b/tests/test_database.py index 41a8c40..794bdba 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -172,3 +172,12 @@ def test_normalize_payee(): assert normalize_payee(" mY paYeE ") == "My Payee" assert normalize_payee(" ", raw_payee_name=True) == "" assert normalize_payee(" My PayeE ", raw_payee_name=True) == "My PayeE" + + +def test_rollback(session): + create_account(session, "Bank", 5000) + session.flush() + assert "messages" in session.info + assert len(session.info["messages"]) + session.rollback() + assert "messages" not in session.info diff --git a/tests/test_integration.py b/tests/test_integration.py index 340ae5c..6c6ff7b 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -23,7 +23,7 @@ ) -@pytest.fixture(params=["24.3.0", "24.4.0", "24.5.0", "24.6.0", "24.7.0"]) +@pytest.fixture(params=["24.8.0"]) # todo: support multiple versions at once def actual_server(request): # we test integration with the 5 latest versions of actual server with DockerContainer(f"actualbudget/actual-server:{request.param}").with_exposed_ports(5006) as container: