Add database adapter dialect helpers for PostgreSQL support - #41163
Open
mmustafasenoglu wants to merge 2 commits into
Open
Add database adapter dialect helpers for PostgreSQL support#41163mmustafasenoglu wants to merge 2 commits into
mmustafasenoglu wants to merge 2 commits into
Conversation
This adds the following new methods to AdapterInterface and implements them in the MySQL adapter: - getGroupConcatSql() - GROUP_CONCAT equivalent - getFieldSql() - FIELD() / CASE equivalent for ORDER BY a fixed list - castToText() - Cast expression to text for UNION type alignment - castToNumeric() - Cast expression to numeric type for arithmetic - createTableLike() - CREATE TABLE new LIKE origin - createTemporaryTableFromSelect() - CREATE TEMPORARY TABLE from a SELECT Also updates: - Select constructor to accept Zend_Db_Adapter_Abstract instead of Pdo\Mysql - TemporaryTableService to use the new adapter method - BatchIterator to handle empty batch (null max) correctly - AbstractDb to use quoteIdentifier() instead of literal backticks for reserved words - Setup validators (DbValidator, Installer, ConfigOptionsList) to support --db-engine option Part of magento#41148
|
Hi @mmustafasenoglu. 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. |
- MysqlTest: testDialectHelpers, testCreateTableLikeAndTemporaryFromSelect - TemporaryTableServiceTest: updated to mock createTemporaryTableFromSelect - BatchIteratorTest: testEmptyBatchDoesNotBindNullMinValue
Contributor
|
@magento create issue |
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.
What this PR does
Adds database adapter dialect helpers to enable PostgreSQL support via a separate module (Postgento). This is the core Magento changes needed - the actual PostgreSQL driver lives in a separate module: https://github.com/Genaker/postgento
Changes
AdapterInterface (lib/internal/Magento/Framework/DB/Adapter/AdapterInterface.php)
Added new methods:
getGroupConcatSql()- GROUP_CONCAT / string_agg equivalentgetFieldSql()- FIELD() / CASE equivalent for ORDER BY a fixed listcastToText()- Cast expression to text for UNION type alignmentcastToNumeric()- Cast expression to numeric type for arithmeticcreateTableLike()- CREATE TABLE new LIKE origincreateTemporaryTableFromSelect()- CREATE TEMPORARY TABLE from a SELECTMySQL Implementation (lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php)
Implemented all new methods with MySQL-specific SQL.
Select (lib/internal/Magento/Framework/DB/Select.php)
Relaxed constructor type-hint from
Pdo\MysqltoZend_Db_Adapter_Abstractso any AdapterInterface implementation can callselect().TemporaryTableService (lib/internal/Magento/Framework/DB/TemporaryTableService.php)
Updated to use the new adapter method
createTemporaryTableFromSelect().BatchIterator (lib/internal/Magento/Framework/DB/Query/BatchIterator.php)
Fixed empty batch handling - keeps previous minValue when MAX() returns NULL to avoid binding null/empty string.
AbstractDb (lib/internal/Magento/Framework/Data/Collection/AbstractDb.php)
Replaced literal backticks with
quoteIdentifier()for reserved words.Setup Validators (setup/src/Magento/Setup/Validator/DbValidator.php, Installer.php, ConfigOptionsList.php)
Added
--db-engineoption support to pass through DbValidator/Installer.Testing
Related
Resolved issues: