classParenthesizedQuery
final class ParenthesizedQuery
implements Statement, Query
uses Snapshot
@visibility public.A query written in parentheses where the parentheses group it.
The parentheses keep a query in its place: an operand of a set operation with its own ordering, a query with a WITH clause, or a parenthesized statement. The parentheses that a subquery, a derived table or a common table expression requires belong to that construct and are not a parenthesized query; only further parentheses are.
Rule: MYSQL-PARENTHESIZED-QUERY-001. The rows are those of the inner query. Source: https://dev.mysql.com/doc/refman/8.4/en/union.html. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('(SELECT a FROM t ORDER BY a LIMIT 1) UNION SELECT b FROM u');
$query->statement->left->query->limit !== null // => trueProperties§
public Query $queryMethods§
public function __construct(public Query $query)Parameters
$query | Query | The query inside the parentheses |
public function deriveStatement(Derivation $derivation): voidDerives the query as a statement root and records its rows as the output.
Parameters
$derivation | Derivation |
Calls 3
- method-call Derivation::output() line 49
- method-call Derivation::query() line 49
- method-call Derivation::environment() line 49
public function deriveQuery(Derivation $derivation, Environment $outer): QueryFactAnswers the rows of the inner query.
Parameters
$derivation | Derivation | |
$outer | Environment |
Returns
Calls 1
- method-call Derivation::query() line 57
public function render(Output $out): voidTest cases 18§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 16
ChainTest::testEnclosedKeepsTheClausesAfterTheFirstParenthesizedOperandcallsChainTest::testEnclosedRejectsAnOrderingAfterAParenthesizedOperandThatLimitsItselfcallsChainTest::testEnclosedRejectsClausesAfterALaterParenthesizedOperandcallsFactorRuleTest::testContentAnswersTheBlockOfADerivedTablecallsUnionRuleTest::testViewQueryLowersTheQueryOfAViewcallsExpressionRuleTest::testIntoLowersTheIntoAfterTheQuerycallsQueryRulesTest::testLegacyParenthesizedQueryKeepsTheParenthesesAndTheUnioncallsTrailerTest::testWrapPutsTheOrderingAndTheLockingAroundAQuerycallsTrailerTest::testWrapRejectsProcedureAnalysecallsCommonTablesTest::testOperandsAnswersTheChainInWrittenOrdercallsQueryTailsTest::testExpressionWritesTheOrderingAndTheLimitOnlycallsQueryExpressionTest::testAnIntegerOrderingItemIsRejectedcallsQueryExpressionTest::testAWrapperWithoutClausesIsRejectedcallsQueryStatementTest::testAnIntoAfterTheSelectListIsRejectedcallsSetOperationTest::testAQueryExpressionOnTheRightIsRejectedcallsSetOperationTest::testAQueryStatementAsAnOperandIsRejectedcalls
Relations§
Instantiated in 8
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\FactorRule::content() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/FactorRule.php:166
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\SubqueryRule::paren() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/SubqueryRule.php:128
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::operand() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:80
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::paren() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:99
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::viewQuery() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:177
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:95
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::parenthesized() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:181
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::legacyParenthesizedQuery() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:120
Type checks 8
- instanceof SqlSemantics\Platform\MySql\Lowering\Query\Legacy\Chain::enclosed() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/Chain.php:137
- instanceof SqlSemantics\Platform\MySql\Rules\Dml\GeneratedWrites::valueRows() packages/sql-semantics-mysql/src/Rules/Dml/GeneratedWrites.php:122
- instanceof SqlSemantics\Platform\MySql\Rules\Query\CommonTables::operands() packages/sql-semantics-mysql/src/Rules/Query/CommonTables.php:154
- instanceof SqlSemantics\Platform\MySql\Rules\Query\CommonTables::operands() packages/sql-semantics-mysql/src/Rules/Query/CommonTables.php:155
- instanceof SqlSemantics\Platform\MySql\Rules\Routine\ProgramRestrictions::into() packages/sql-semantics-mysql/src/Rules/Routine/ProgramRestrictions.php:153
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\EnclosedQuery::accepts() packages/sql-semantics-mysql/src/Rules/TableDefinition/EnclosedQuery.php:43
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\EnclosedQuery::write() packages/sql-semantics-mysql/src/Rules/TableDefinition/EnclosedQuery.php:61
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\ViewColumns::block() packages/sql-semantics-mysql/src/Rules/TableDefinition/ViewColumns.php:133