Skip to content

fix(sessions): support MySQL and MariaDB schema creation - #4741

Open
linhongyu510 wants to merge 1 commit into
openai:mainfrom
linhongyu510:fix/mysql-sqlalchemy-session-schema
Open

fix(sessions): support MySQL and MariaDB schema creation#4741
linhongyu510 wants to merge 1 commit into
openai:mainfrom
linhongyu510:fix/mysql-sqlalchemy-session-schema

Conversation

@linhongyu510

Copy link
Copy Markdown

This pull request fixes automatic SQLAlchemy session table creation on MySQL and MariaDB. Both dialects reject an unbounded String when compiling indexed VARCHAR columns, so SQLAlchemySession(create_tables=True) currently fails before issuing any DDL.

Summary

  • Use a dialect-specific VARCHAR(190) for both session_id columns on MySQL and MariaDB.
  • Preserve the existing unbounded VARCHAR type on PostgreSQL and SQLite.
  • Keep the parent primary-key and child foreign-key column types identical.
  • Use 190 characters so the (session_id, created_at) index remains within the traditional 767-byte InnoDB key limit under utf8mb4.
  • Add offline MetaData.create_all() regression tests for MySQL and MariaDB covering both tables, ON DELETE CASCADE, and the full composite index.

Test plan

  • uv run --extra sqlalchemy pytest -q tests/extensions/memory/test_sqlalchemy_session.py (46 passed)
  • .agents/skills/code-change-verification/scripts/run.sh
    • format: passed
    • lint: passed
    • typecheck: passed
    • tests: passed

Issue number

Closes #4740

Checks

  • I've added new tests, if relevant
  • I've run .agents/skills/code-change-verification/scripts/run.sh
  • I've confirmed all verification steps pass
  • If using Codex, I've run /review before submitting this PR

Signed-off-by: linhongyu510 <linhongyu510@users.noreply.github.com>
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.

SQLAlchemySession(create_tables=True) cannot create tables on MySQL due to unbounded String columns

1 participant