Skip to content

Commit 6cbf00b

Browse files
authored
chore: exclude last_update from the THEN RETURN clause (#799)
Columns that are assigned a `PENDING_COMMIT_TIMESTAMP()` value cannot be included in `THEN RETURN` clauses. Fixes this build error: https://github.com/googleapis/python-spanner-sqlalchemy/actions/runs/19180600096/job/54948361746?pr=798 A recent fix in the Emulator caused the samples for SQLAlchemy to start fail. That is not due to a bug in the Emulator, but due to a bug __fix__ in the Emulator. Previously, the Emulator would allow something that would fail on Spanner. That difference has now been fixed.
1 parent 4e7cb97 commit 6cbf00b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

samples/model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,16 @@ class TicketSale(Base):
199199
String(36), ForeignKey("singers.id", spanner_not_enforced=True)
200200
)
201201
# Create a commit timestamp column and set a client-side default of
202-
# PENDING_COMMIT_TIMESTAMP() An event handler below is responsible for
202+
# PENDING_COMMIT_TIMESTAMP(). An event handler below is responsible for
203203
# setting PENDING_COMMIT_TIMESTAMP() on updates. If using SQLAlchemy
204204
# core rather than the ORM, callers will need to supply their own
205205
# PENDING_COMMIT_TIMESTAMP() values in their inserts & updates.
206+
#
207+
# Columns that use PENDING_COMMIT_TIMESTAMP() cannot be included in a
208+
# THEN RETURN clause.
206209
last_update_time: Mapped[datetime.datetime] = mapped_column(
207210
spanner_allow_commit_timestamp=True,
211+
spanner_exclude_from_returning=True,
208212
default=text("PENDING_COMMIT_TIMESTAMP()"),
209213
)
210214

0 commit comments

Comments
 (0)