Skip to content

Commit 7f1b902

Browse files
fix: address review — drop unnecessary quoting and transaction guards
- autopopulate.py: remove quote_identifier() for _job_start_time, _job_duration, _job_version — these are plain identifiers that don't need quoting on any backend. - connection.py: revert transaction SQL guards — both MySQL and PostgreSQL always return non-empty SQL. The guards were premature abstraction for hypothetical backends. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c7f353f commit 7f1b902

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/datajoint/autopopulate.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,9 @@ def _update_job_metadata(self, key, start_time, duration, version):
776776
from .condition import make_condition
777777

778778
pk_condition = make_condition(self, key, set())
779-
q = self.connection.adapter.quote_identifier
780779
self.connection.query(
781780
f"UPDATE {self.full_table_name} SET "
782-
f"{q('_job_start_time')}=%s, {q('_job_duration')}=%s, {q('_job_version')}=%s "
781+
"_job_start_time=%s, _job_duration=%s, _job_version=%s "
783782
f"WHERE {pk_condition}",
784783
args=(start_time, duration, version[:64] if version else ""),
785784
)

src/datajoint/connection.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -486,25 +486,19 @@ def start_transaction(self) -> None:
486486
"""
487487
if self.in_transaction:
488488
raise errors.DataJointError("Nested connections are not supported.")
489-
sql = self.adapter.start_transaction_sql()
490-
if sql:
491-
self.query(sql)
489+
self.query(self.adapter.start_transaction_sql())
492490
self._in_transaction = True
493491
logger.debug("Transaction started")
494492

495493
def cancel_transaction(self) -> None:
496494
"""Cancel the current transaction and roll back all changes."""
497-
sql = self.adapter.rollback_sql()
498-
if sql:
499-
self.query(sql)
495+
self.query(self.adapter.rollback_sql())
500496
self._in_transaction = False
501497
logger.debug("Transaction cancelled. Rolling back ...")
502498

503499
def commit_transaction(self) -> None:
504500
"""Commit all changes and close the transaction."""
505-
sql = self.adapter.commit_sql()
506-
if sql:
507-
self.query(sql)
501+
self.query(self.adapter.commit_sql())
508502
self._in_transaction = False
509503
logger.debug("Transaction committed and closed.")
510504

0 commit comments

Comments
 (0)