Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 1807877

Browse files
committed
fix: exclude commit_timestamp col from THEN RETURN
1 parent afd84fa commit 1807877

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,14 @@ def returning_clause(self, stmt, returning_cols, **kw):
425425
self._label_select_column(
426426
None, c, True, False, {"spanner_is_returning": True}
427427
)
428-
for c in expression._select_iterables(returning_cols)
428+
for c in expression._select_iterables(
429+
filter(
430+
lambda col: not col.dialect_options.get("spanner", {}).get(
431+
"exclude_from_returning", False
432+
),
433+
returning_cols,
434+
)
435+
)
429436
]
430437

431438
return "THEN RETURN " + ", ".join(columns)

test/system/test_basics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ class TimestampUser(Base):
316316
updated_at: Mapped[datetime.datetime] = mapped_column(
317317
spanner_allow_commit_timestamp=True,
318318
default=text("PENDING_COMMIT_TIMESTAMP()"),
319+
# Make sure that this column is never part of a THEN RETURN clause.
320+
spanner_exclude_from_returning=True,
319321
)
320322

321323
@event.listens_for(TimestampUser, "before_update")

0 commit comments

Comments
 (0)