Skip to content

Commit fda5119

Browse files
revert: keep rowcount for existence checks (works on pymysql+psycopg2)
Both pymysql and psycopg2 correctly implement cursor.rowcount for SELECT statements. The fetchone() change was defensive for hypothetical future drivers but triggers an unnecessary row fetch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 19f3e8b commit fda5119

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/datajoint/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def exists(self) -> bool:
422422
"""
423423
if self.database is None:
424424
raise DataJointError("Schema must be activated first.")
425-
return self.connection.query(self.connection.adapter.schema_exists_sql(self.database)).fetchone() is not None
425+
return bool(self.connection.query(self.connection.adapter.schema_exists_sql(self.database)).rowcount)
426426

427427
@property
428428
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).fetchone() is not None
460+
return self.connection.query(query).rowcount > 0
461461

462462
@property
463463
def full_table_name(self):

0 commit comments

Comments
 (0)