Skip to content

Commit 5010b85

Browse files
refactor: Remove boolean_true_literal, use TRUE for both backends
MySQL accepts TRUE as a boolean literal (alias for 1), so we can use TRUE universally instead of having backend-specific literals. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 215bc9c commit 5010b85

File tree

3 files changed

+1
-31
lines changed

3 files changed

+1
-31
lines changed

src/datajoint/adapters/base.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -563,21 +563,6 @@ def supports_inline_indexes(self) -> bool:
563563
"""
564564
return True # Default for MySQL, override in PostgreSQL
565565

566-
@property
567-
def boolean_true_literal(self) -> str:
568-
"""
569-
Return the SQL literal for boolean TRUE.
570-
571-
MySQL uses 1 (since bool maps to tinyint).
572-
PostgreSQL uses TRUE (native boolean type).
573-
574-
Returns
575-
-------
576-
str
577-
SQL literal for boolean true value.
578-
"""
579-
return "1" # Default for MySQL, override in PostgreSQL
580-
581566
def create_index_ddl(
582567
self,
583568
full_table_name: str,

src/datajoint/adapters/postgres.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -710,20 +710,6 @@ def supports_inline_indexes(self) -> bool:
710710
"""
711711
return False
712712

713-
@property
714-
def boolean_true_literal(self) -> str:
715-
"""
716-
Return the SQL literal for boolean TRUE.
717-
718-
PostgreSQL uses native boolean type with TRUE literal.
719-
720-
Returns
721-
-------
722-
str
723-
SQL literal for boolean true value.
724-
"""
725-
return "TRUE"
726-
727713
# =========================================================================
728714
# Introspection
729715
# =========================================================================

src/datajoint/declare.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,11 @@ def declare(
477477
primary_key = ["_singleton"]
478478
singleton_comment = ":bool:singleton primary key"
479479
sql_type = adapter.core_type_to_sql("bool")
480-
bool_literal = adapter.boolean_true_literal
481480
singleton_sql = adapter.format_column_definition(
482481
name="_singleton",
483482
sql_type=sql_type,
484483
nullable=False,
485-
default=f"NOT NULL DEFAULT {bool_literal}",
484+
default="NOT NULL DEFAULT TRUE",
486485
comment=singleton_comment,
487486
)
488487
attribute_sql.insert(0, singleton_sql)

0 commit comments

Comments
 (0)