Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions piccolo/columns/column_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def get_querystring(
raise ValueError(
"Adding values across joins isn't currently supported."
)
column_name = column._meta.db_column_name
return QueryString(f"{column_name} {operator} {column_name}")
other_column_name = value._meta.db_column_name
return QueryString(f"{column_name} {operator} {other_column_name}")
elif isinstance(value, (int, float)):
if reverse:
return QueryString(f"{{}} {operator} {column_name}", value)
Expand Down
15 changes: 15 additions & 0 deletions tests/table/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def test_update_returning_alias(self):

class MyTable(Table):
integer = Integer(null=True)
other_integer = Integer(null=True, default=5)
Copy link
Contributor Author

@ryanvarley ryanvarley Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no way i can see of setting initial values on two columns in this test suite so defining here as a demonstration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine.

timestamp = Timestamp(null=True)
timestamptz = Timestamptz(null=True)
date = Date(null=True)
Expand Down Expand Up @@ -295,6 +296,20 @@ class OperatorTestCase:
querystring=2000 - MyTable.integer,
expected=1000,
),
OperatorTestCase(
description="Subtract Integer Columns",
column=MyTable.integer,
initial=1000,
querystring=MyTable.integer - MyTable.other_integer,
expected=995,
),
OperatorTestCase(
description="Add Integer Columns",
column=MyTable.integer,
initial=1000,
querystring=MyTable.integer + MyTable.other_integer,
expected=1005,
),
OperatorTestCase(
description="Multiply Integer",
column=MyTable.integer,
Expand Down