Skip to content

Support composite TRADITIONAL SQL mode - #509

Open
JanJakes wants to merge 1 commit into
trunkfrom
traditional-sql-mode
Open

JanJakes wants to merge 1 commit into
trunkfrom
traditional-sql-mode

Conversation

@JanJakes

@JanJakes JanJakes commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Make TRADITIONAL enable its component SQL modes. Previously, SET sql_mode = 'TRADITIONAL' stored only the composite flag, leaving the driver's existing strict and zero-date checks disabled. It now expands the mode for both named and numeric assignments and retains TRADITIONAL in @@sql_mode.

The expansion follows the emulated MySQL version, including NO_AUTO_CREATE_USER before its removal in MySQL 8.0.11. Regression coverage checks version differences, canonical mode ordering, combination with ANSI, reassignment, clearing modes, and rejection of invalid dates and missing required values.

This PR does not implement the deprecated MySQL 5.7 composite modes, such as ORACLE, MSSQL, and POSTGRESQL.

Why

Applications should get the same existing checks whether they select TRADITIONAL or list its component modes individually. This change uses the driver's current implementations of those modes; their existing emulation limits still apply.

MySQL documents TRADITIONAL as a combination mode.

Summary by CodeRabbit

  • Bug Fixes
    • The TRADITIONAL SQL mode now applies its expected strict validation rules, including rejecting invalid or zero dates and missing or NULL values in NOT NULL columns.
    • TRADITIONAL mode assignments now expand consistently across supported assignment formats, including combined mode lists and numeric bitmaps.
    • Mode expansion respects MySQL version differences, including whether NO_AUTO_CREATE_USER is available.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 7520eb41-2986-4b4b-b779-f03d9cd47dfe

📥 Commits

Reviewing files that changed from the base of the PR and between a8468b5 and 0af7e9d.

📒 Files selected for processing (2)
  • packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php
  • packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

set_sql_modes() now expands TRADITIONAL into its component SQL modes. The expansion includes NO_AUTO_CREATE_USER when that mode has not been removed for the emulated MySQL version. Tests cover mode assignments, serialization, and SQL constraint behavior.

Changes

TRADITIONAL SQL mode

Layer / File(s) Summary
Mode expansion and behavior coverage
packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php, packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php
set_sql_modes() expands TRADITIONAL into its component modes, with version-dependent handling of NO_AUTO_CREATE_USER. Tests cover assignment forms, serialized modes, invalid date rejection, and NOT NULL constraints.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: chubes4

Merge Risk: ⚪ Minimal · up to 0af7e

Assigning TRADITIONAL now enables its component SQL modes, with NO_AUTO_CREATE_USER included only for MySQL versions before 8.0.11. The change is small and comes with coverage for version boundaries and enforcement. No merge-blocking risk is evident.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 0af7e

The change activates existing validation within the same database connection without expanding SQL access or privileges. No material security risk introduced or worsened by this change was identified; existing emulation limitations remain.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The direct changed control scope is the owning driver instance and subsequent statements executed through it. Broader application effects depend on how applications share connections; tenant and deployment mappings were not supplied.

Trust Boundaries and Controls

  • observed — Caller-controlled SQL still reaches mode assignment through the existing query parser and SET dispatcher. Session assignments remain connection-local, while GLOBAL, PERSIST, and PERSIST_ONLY assignments are rejected. The expansion does not introduce an identity transition or grant additional SQL authority.

Resilience and Maintainability Implications

  • observed — Multi-definition SET processing publishes definitions sequentially, and query failure handling does not restore active_sql_modes. Thus a successful earlier mode assignment can survive a later failure. This behavior predates the expansion; the change neither adds that recovery behavior nor provides a new way to disable validation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: support for the composite TRADITIONAL SQL mode.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Retain TRADITIONAL while enabling its strict, zero-date, division-by-zero,
and engine-substitution flags for named and numeric assignments. Include
NO_AUTO_CREATE_USER only for MySQL versions before its removal in 8.0.11.

Cover version differences, canonical serialization, mixed composite modes,
round trips, clearing modes, and existing strict and date validation.

https://dev.mysql.com/doc/refman/8.4/en/sql-mode.html#sql-mode-combo
https://github.com/mysql/mysql-server/blob/5.7/sql/sys_vars.cc
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-11.html
@JanJakes
JanJakes force-pushed the traditional-sql-mode branch from b15ab9d to 0af7e9d Compare September 30, 2026 15:08
@JanJakes
JanJakes marked this pull request as ready for review September 30, 2026 15:39
@JanJakes
JanJakes requested a review from zaerl September 30, 2026 15:39
@JanJakes JanJakes changed the title Support composite TRADITIONAL SQL mode Support composite TRADITIONAL SQL mode Sep 30, 2026

This branch has not been deployed

No deployments
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.

1 participant