1
0
mirror of synced 2024-12-13 22:56:04 +03:00
doctrine2/query-language.txt

83 lines
4.1 KiB
Plaintext
Raw Normal View History

2008-05-25 00:36:12 +04:00
/* Context-free grammar for Doctrine Query Language
*
* Document syntax:
* - non-terminals begin with an upper case character
* - terminals begin with a lower case character
* - parentheses (...) are used for grouping
* - square brackets [...] are used for defining an optional part, eg. zero or
* one time
2008-05-25 00:36:12 +04:00
* - curly brackets {...} are used for repetion, eg. zero or more times
* - double quotation marks "..." define a terminal string
* - a vertical bar | represents an alternative
*
* At a first glance we'll support SQL-99 based queries
* Initially Select and Sub-select DQL will not support LIMIT and OFFSET (due to limit-subquery algorithm)
*/
QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement
2008-05-25 00:36:12 +04:00
SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
UpdateStatement ::= UpdateClause [WhereClause]
DeleteStatement ::= DeleteClause [WhereClause]
2008-05-25 00:36:12 +04:00
Subselect ::= SimpleSelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
SelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression {"," SelectExpression}*
SimpleSelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression
DeleteClause ::= "DELETE" ["FROM"] VariableDeclaration
WhereClause ::= "WHERE" ConditionalExpression
FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}*
HavingClause ::= "HAVING" ConditionalExpression
GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}*
OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
LimitClause ::= "LIMIT" integer
OffsetClause ::= "OFFSET" integer
UpdateClause ::= "UPDATE" VariableDeclaration "SET" UpdateItem {"," UpdateItem}*
2008-05-25 00:36:12 +04:00
OrderByItem ::= Expression ["ASC" | "DESC"]
GroupByItem ::= PathExpression
UpdateItem ::= PathExpression "=" (Expression | "NULL")
2008-05-25 00:36:12 +04:00
IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
JoinVariableDeclaration ::= Join [IndexBy]
RangeVariableDeclaration ::= identifier {"." identifier}* [["AS"] IdentificationVariable]
VariableDeclaration ::= identifier [["AS"] IdentificationVariable]
IdentificationVariable ::= identifier
2008-05-25 00:36:12 +04:00
Join ::= ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression]
IndexBy ::= "INDEX" "BY" identifier
2008-05-25 00:36:12 +04:00
ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*
ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*
ConditionalFactor ::= ["NOT"] ConditionalPrimary
ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
2008-05-25 00:36:12 +04:00
SimpleConditionalExpression
::= Expression (ComparisonExpression | BetweenExpression | LikeExpression
2008-05-25 00:36:12 +04:00
| InExpression | NullComparisonExpression) | ExistsExpression
Atom ::= string | integer | float | boolean | input_parameter
2008-05-25 00:36:12 +04:00
Expression ::= Term {("+" | "-") Term}*
Term ::= Factor {("*" | "/") Factor}*
Factor ::= [("+" | "-")] Primary
Primary ::= PathExpression | Atom | "(" Expression ")" | Function | AggregateExpression
2008-05-25 00:36:12 +04:00
SelectExpression ::= (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] FieldIdentificationVariable]
PathExpression ::= identifier {"." identifier}*
PathExpressionEndingWithAsterisk ::= {identifier "."}* "*"
FieldIdentificationVariable ::= identifier
2008-05-25 00:36:12 +04:00
AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] Expression ")"
2008-05-25 00:36:12 +04:00
| "COUNT" "(" ["DISTINCT"] (Expression | "*") ")"
QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
BetweenExpression ::= ["NOT"] "BETWEEN" Expression "AND" Expression
ComparisonExpression ::= ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" )
InExpression ::= ["NOT"] "IN" "(" (Atom {"," Atom}* | Subselect) ")"
LikeExpression ::= ["NOT"] "LIKE" Expression ["ESCAPE" string]
NullComparisonExpression ::= "IS" ["NOT"] "NULL"
ExistsExpression ::= "EXISTS" "(" Subselect ")"
2008-05-25 00:36:12 +04:00
ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
2008-05-25 00:36:12 +04:00
Function ::= identifier "(" [Expression {"," Expression}*] ")"