Add AdapterInterface dialect helpers and replace MySQL with Postgres SQL and other SQL like RDBS - #41129
Open
Genaker wants to merge 3 commits into
Open
Add AdapterInterface dialect helpers and replace MySQL with Postgres SQL and other SQL like RDBS#41129Genaker wants to merge 3 commits into
Genaker wants to merge 3 commits into
Conversation
…ll sites. Lets a separate Postgres adapter implement the same helpers without Magento embedding GROUP_CONCAT, FIELD, backticks, or CREATE TABLE LIKE. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Hi @Genaker. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
Adobe 2.4-develop already differs from Mage-OS in several files; keep those Magento-only changes and describe the dialect helpers in Magento terms. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
@magento run all tests |
5 tasks
Contributor
Author
|
Static LiveCodeTest fixes are on @magento run all tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description (*)
Magento core still embeds MySQL-only SQL (
GROUP_CONCAT(),FIELD(),IFNULL()literals, backticks,CREATE TABLE … LIKE,CREATE TEMPORARY TABLE … ENGINE=… IGNORE (SELECT),ON DUPLICATE KEY UPDATEtext,UNIONof mixed types,UPDATE … LIMIT,SHOW VARIABLES LIKE 'version'). That is valid on MySQL and fatal on PostgreSQL.This PR does not add a Postgres adapter. It adds dialect helpers on
AdapterInterface/Pdo\Mysqland switches Magento call sites to those helpers (and to existing ones such asgetIfNullSql()/quoteIdentifier()/insertOnDuplicate()).The Postgres driver lives in a separate module: https://github.com/Genaker/postgento (fork of Kirill Morozov’s
Morozov_PgCompat). That repo implements the sameAdapterInterfacemethods onpdo_pgsql. Magento can review/test/merge this core PR on MySQL alone, and optionally install Postgento on a branch of this PR to run Magento on PostgreSQL. After this PR is in Magento, Postgento does not need the Magento SQL call-site patches.The same change set is open for Mage-OS: mage-os/mageos-magento2#321
New adapter methods (MySQL implementations):
getGroupConcatSql()→GROUP_CONCATgetFieldSql()→FIELD()castToText()/castToNumeric()(no-op /CAST(… AS DECIMAL)on MySQL; other engines can map to::text/::numeric)createTableLike()→CREATE TABLE … LIKEcreateTemporaryTableFromSelect()→ existing MySQLCREATE TEMPORARY TABLE … ENGINE=innodb IGNORE (SELECT)Also:
Selectconstructor type-hint relaxed fromPdo\MysqltoZend_Db_Adapter_Abstractso a non-MySQLAdapterInterfacecan callselect().--db-engineis passed throughDbValidator/Installer::assertDbAccessible()so an optional engine can open the correct driver at install time. Default MySQL behavior is unchanged.Behavior on MySQL is intended to be equivalent.
Related Pull Requests
Fixed Issues (if relevant)
N/A — no Magento issue filed yet.
Manual testing scenarios (*)
On a MySQL Magento Open Source install (this PR must not require Postgres):
bin/magento setup:upgrade— exit 0, no SQLSTATE.bin/magento indexer:reindex— all indexers complete (catalog price, stock, EAV, catalog rule, fulltext).WJ01) returns variants;GROUP_CONCAT/FIELD()call sites used by collection / search appliers.setup:install --db-engine=mysqlstill validates and installs as today.Optional Postgres: check out this PR, Composer-require https://github.com/Genaker/postgento (
genaker/module-postgento),setup:install --db-engine=postgresql, then repeat indexer / GraphQL / storefront / admin / checkout.Questions or comments
Happy to split adapter-interface methods vs call-site SQL into two PRs if that is easier to review. The adapter itself is Postgento — Magento can merge this PR first (MySQL-safe) and take Postgento as a Composer module whenever you want Postgres in the distribution.
Unit tests for the new
Pdo\Mysqlhelpers,TemporaryTableService, andBatchIteratorempty-batchminValueare in this PR.Adobe CLA: signed as required for submissions to https://github.com/magento/magento2.
Contribution checklist (*)