Skip to content

Conversation

@ElIsaac
Copy link

@ElIsaac ElIsaac commented Jul 1, 2025

🐛 Problem

In Firebird 3 (tested with the fdb driver), the original _render_string_type method expected a type_ object with attributes like .length, .charset, and .collation. However, it was being called with plain arguments instead, leading to incorrect SQL type rendering and runtime errors such as:
File "~\Desktop\nexus\venv\Lib\site-packages\sqlalchemy_firebird\base.py", line 436, in _render_string_type
text = text + (length and "(%d)" % length or "")

✅ Solution

  • Modified _render_string_type to accept direct parameters: name, length, and collation.
  • Removed the dependency on extracting attributes from type_.
  • Ensures proper SQL type rendering in environments using Firebird 3.

🔍 Notes

  • The fix mirrors the behavior of sqlalchemy.sql.compiler._render_string_type.
  • Tested with:
    • sqlalchemy-firebird==2.1
    • fdb driver
  • Prevents errors related to incorrect SQL generation for string-based fields.

@fdcastel
Copy link
Contributor

fdcastel commented Jul 2, 2025

Thank you for your contribution, @ElIsaac.

The issue appears to stem from this commit in SQLAlchemy, which modified the signature of _render_string_type.

In hindsight, it seems this API is less stable than I had initially assumed. To improve code robustness, we should add dedicated functions for each CHAR type instead of relying directly on _render_string_type.

I'm looking into this, now.

@fdcastel
Copy link
Contributor

fdcastel commented Jul 4, 2025

Superseded by #79. Let's close this one.

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