Skip to content

Commit b563047

Browse files
dimitri-yatsenkokushalbakshiclaude
committed
fix: use fetchone() instead of rowcount and quote job metadata columns
Three additional backend-agnostic fixes: - table.py: is_declared uses fetchone() instead of rowcount — DBAPI2 does not guarantee rowcount for non-DML statements, breaking on some PostgreSQL drivers. - schemas.py: Schema.exists uses fetchone() instead of rowcount — same DBAPI2 portability issue. - autopopulate.py: _update_job_metadata uses adapter.quote_identifier() for _job_start_time, _job_duration, _job_version columns — these were hardcoded with MySQL backticks, broken on PostgreSQL. Co-Authored-By: Kushal Bakshi <kushal.bakshi@datajoint.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4a9bc3d commit b563047

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/datajoint/autopopulate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,10 @@ 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
779780
self.connection.query(
780781
f"UPDATE {self.full_table_name} SET "
781-
"`_job_start_time`=%s, `_job_duration`=%s, `_job_version`=%s "
782+
f"{q('_job_start_time')}=%s, {q('_job_duration')}=%s, {q('_job_version')}=%s "
782783
f"WHERE {pk_condition}",
783784
args=(start_time, duration, version[:64] if version else ""),
784785
)

src/datajoint/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def exists(self) -> bool:
427427
"""
428428
if self.database is None:
429429
raise DataJointError("Schema must be activated first.")
430-
return bool(self.connection.query(self.connection.adapter.schema_exists_sql(self.database)).rowcount)
430+
return self.connection.query(self.connection.adapter.schema_exists_sql(self.database)).fetchone() is not None
431431

432432
@property
433433
def lineage_table_exists(self) -> bool:

src/datajoint/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def is_declared(self):
457457
True if the table is declared in the schema.
458458
"""
459459
query = self.connection.adapter.get_table_info_sql(self.database, self.table_name)
460-
return self.connection.query(query).rowcount > 0
460+
return self.connection.query(query).fetchone() is not None
461461

462462
@property
463463
def full_table_name(self):

0 commit comments

Comments
 (0)