Skip to content

Commit be7d079

Browse files
style: Fix linting issues
- Break long line in get_columns_sql for col_description - Remove unused variable 'quote' in dependencies.py Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e54e4a7 commit be7d079

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/datajoint/adapters/postgres.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def core_type_to_sql(self, core_type: str) -> str:
309309
# Generate a deterministic type name based on values
310310
# Use a hash to keep name reasonable length
311311
import hashlib
312+
312313
value_hash = hashlib.md5("_".join(sorted(values)).encode()).hexdigest()[:8]
313314
type_name = f"enum_{value_hash}"
314315
# Track this enum type for CREATE TYPE DDL
@@ -703,13 +704,16 @@ def get_columns_sql(self, schema_name: str, table_name: str) -> str:
703704
"""Query to get column definitions including comments."""
704705
# Use col_description() to retrieve column comments stored via COMMENT ON COLUMN
705706
# The regclass cast allows using schema.table notation to get the OID
707+
schema_str = self.quote_string(schema_name)
708+
table_str = self.quote_string(table_name)
709+
regclass_expr = f"({schema_str} || '.' || {table_str})::regclass"
706710
return (
707711
f"SELECT c.column_name, c.data_type, c.is_nullable, c.column_default, "
708712
f"c.character_maximum_length, c.numeric_precision, c.numeric_scale, "
709-
f"col_description(({self.quote_string(schema_name)} || '.' || {self.quote_string(table_name)})::regclass, c.ordinal_position) as column_comment "
713+
f"col_description({regclass_expr}, c.ordinal_position) as column_comment "
710714
f"FROM information_schema.columns c "
711-
f"WHERE c.table_schema = {self.quote_string(schema_name)} "
712-
f"AND c.table_name = {self.quote_string(table_name)} "
715+
f"WHERE c.table_schema = {schema_str} "
716+
f"AND c.table_name = {table_str} "
713717
f"ORDER BY c.ordinal_position"
714718
)
715719

src/datajoint/dependencies.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ def load(self, force: bool = True) -> None:
153153

154154
# Get adapter for backend-specific SQL generation
155155
adapter = self._conn.adapter
156-
quote = adapter.quote_identifier
157156

158157
# Build schema list for IN clause
159158
schemas_list = ", ".join(adapter.quote_string(s) for s in self._conn.schemas)

0 commit comments

Comments
 (0)