joaopamaral opened a new pull request, #37582: URL: https://github.com/apache/superset/pull/37582
<!--- Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/ Example: fix(dashboard): load charts correctly --> ### SUMMARY <!--- Describe the change below, including rationale and design decisions --> This pull request introduces a fix for a MariaDB-specific DDL syntax issue in Superset by patching SQLAlchemy's sequence creation logic. The main change ensures that when creating sequences for MariaDB, the generated SQL uses `NOCYCLE` instead of the incorrect `NO CYCLE` syntax. The fix is applied early in the import chain to guarantee it takes effect throughout the application. Unit tests have also been added to verify the patch works as intended. > This issue breaks table creation during `superset db upgrade` when using MariaDB database. **MariaDB DDL syntax fix:** * Added `apply_mariadb_ddl_fix()` to `superset/utils/database.py`, which patches SQLAlchemy's `DDLCompiler.visit_create_sequence` method to replace `NO CYCLE` with `NOCYCLE` for MariaDB dialects. This prevents SQL errors when creating sequences in MariaDB. * Called `apply_mariadb_ddl_fix()` early in the `superset/extensions/__init__.py` import chain to ensure the fix is active before any database operations occur. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF <!--- Skip this if not applicable --> N/A ### TESTING INSTRUCTIONS <!--- Required! What steps can be taken to manually verify the changes? --> * Added new unit tests in `tests/unit_tests/utils/test_database.py` to verify that the patch correctly modifies the generated SQL for MariaDB and does not affect other dialects like PostgreSQL. ``` pytest tests/unit_tests/utils/test_database.py -v tests/unit_tests/utils/test_database.py::test_mariadb_nocycle_fix_applied PASSED [ 50%] tests/unit_tests/utils/test_database.py::test_nocycle_fix_not_applied_for_postgresql PASSED ``` ### ADDITIONAL INFORMATION <!--- Check any relevant boxes with "x" --> <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue --> - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
