Skip to content

Add DatabaseDialect and implement identifiers truncation#54

Merged
cre-os merged 7 commits intocre-dev:mainfrom
martinv13:feature/add_db_dialects
May 6, 2026
Merged

Add DatabaseDialect and implement identifiers truncation#54
cre-os merged 7 commits intocre-dev:mainfrom
martinv13:feature/add_db_dialects

Conversation

@martinv13
Copy link
Copy Markdown
Collaborator

Two related problems motivated this refactor:

  • Backend-specific logic was scattered across 6 files as if db_type == "..." conditionals, making it hard to maintain.
  • PostgreSQL limits identifiers to 63 characters, which caused errors with longer XSD element names.

Changes:

  • Added a DatabaseDialect class hierarchy (base, postgresql, mssql, mysql, duckdb), one subclass per backend.
  • Migrated all db_type conditionals into the appropriate dialect class.
  • db_identifier() in the base class now truncates names exceeding MAX_IDENTIFIER_LENGTH using a stable MD5 hash suffix. Each dialect sets its own limit.
  • SQLAlchemy's key/name duality on Column is used to keep logical names stable in Python while sending truncated physical names to the database.

@cre-os cre-os merged commit ce120c5 into cre-dev:main May 6, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants