Repository navigation
Render the MySQL dialect at render time - #90
Draft
simon-mundy wants to merge 3 commits into
Draft
simon-mundy wants to merge 3 commits into
simon-mundy wants to merge 3 commits into
Conversation
Follows the phpdb change that applies the dialect when a statement is rendered. The MySQL Select, CreateTable and AlterTable subclasses and the statement factory are replaced by a Dialect that names what MySQL renders differently from standard SQL. LimitRenderer supplies the maximum limit for a select that has an offset and no limit. It now applies to any Select the platform renders, so a subselect built with new Select() no longer renders an OFFSET without a LIMIT. ColumnOptionRenderer adds the MySQL column options to each column definition and places an added column with AFTER, using the existing ColumnOptionTrait. The DDL and select tests render the standard statements through the MySQL platform.
…a limit The dialect lists the limit clause only for a select that has an offset and no limit, and gives it as a FixedClause, so every other select is rendered without building a render context. LimitRenderer had nothing left to decide and is removed. ColumnOptionRenderer returns the standard definition for a column with no options, and builds the AFTER resolver once.
The dialect built the maximum-limit clause and the column option renderer in its constructor, and the renderer built its AFTER resolver in its own, whether or not a statement that needs them was ever rendered. Each is now created the first time it is asked for and reused after.
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.
Renders the MySQL dialect through the render-time dialect in php-db/phpdb#261, replacing the statement subclasses.
Depends on php-db/phpdb#258 and php-db/phpdb#259, and on #88 and #89 here. This branch is stacked on #89.
What changes
AdapterPlatform::getStatementFactory()becomesgetDialect(), which returns oneSql\Dialectinstance.Sql\Dialectnames what MySQL renders differently from standard SQL:LIMIT 18446744073709551615. Any other select is rendered as standard SQL.Sql\Ddl\ColumnOptionRenderer, which adds the MySQL column options and places an added column withAFTER. It uses the existingColumnOptionTraitunchanged.Sql\Platform,Sql\Select,Sql\Ddl\CreateTableandSql\Ddl\AlterTable.Why
The MySQL limit rule now applies to any
Selectthe platform renders, so a subselect built withnew Select()no longer renders anOFFSETwithout aLIMIT. The core pull request has the example.Checked
AdapterPlatform::quoteValue(), which is also reported on Refuse to quote a value the driver cannot quote #89 as it stands.SelectRenderingTestcovers the subselect case as a string and as a prepared statement.Not done
composer.jsonstill requiresdev-rfc/256-statement-factory, so CI here installs a core without the dialect interfaces and will fail until the core branch is available to require. The tests above were run with the core branch linked in locally.