Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
42180823
Commit
42180823
authored
Sep 02, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DQL BNF overhaul. Streamlining with JPQL spec.
parent
305d3b35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
161 additions
and
34 deletions
+161
-34
query-language.txt
query-language.txt
+161
-34
No files found.
query-language.txt
View file @
42180823
...
@@ -14,16 +14,63 @@
...
@@ -14,16 +14,63 @@
* Initially Select and Sub-select DQL will not support LIMIT and OFFSET (due to limit-subquery algorithm)
* Initially Select and Sub-select DQL will not support LIMIT and OFFSET (due to limit-subquery algorithm)
*/
*/
/*
* IDENTIFIERS
*/
IdentificationVariable ::= identifier
/* identifier that must be a class name */
AbstractSchemaName ::= identifier
/* identifier that must be a field */
FieldIdentificationVariable ::= identifier
/* identifier that must be a collection-valued association field (to-many) */
CollectionValuedAssociationField ::= FieldIdentificationVariable
/* identifier that must be a single-valued association field (to-one) */
SingleValuedAssociationField ::= FieldIdentificationVariable
/* identifier that must be an embedded class state field (for the future) */
EmbeddedClassStateField ::= FieldIdentificationVariable
/* identifier that must be a simple state field (name, email, ...) */
SimpleStateField ::= FieldIdentificationVariable
/*
* PATH EXPRESSIONS
*/
JoinAssociationPathExpression ::= JoinCollectionValuedPathExpression | JoinSingleValuedAssociationPathExpression
JoinCollectionValuedPathExpression ::= IdentificationVariable "." CollectionValuedAssociationField
JoinSingleValuedAssociationPathExpression ::= IdentificationVariable "." SingleValuedAssociationField
AssociationPathExpression ::= CollectionValuedPathExpression | SingleValuedAssociationPathExpression
SingleValuedPathExpression ::= StateFieldPathExpression | SingleValuedAssociationPathExpression
StateFieldPathExpression ::= {IdentificationVariable | SingleValuedAssociationPathExpression} "." StateField
SingleValuedAssociationPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}* SingleValuedAssociationField
CollectionValuedPathExpression ::= IdentificationVariable "." {SingleValuedAssociationField "."}*CollectionValuedAssociationField
StateField ::= {EmbeddedClassStateField "."}*SimpleStateField
/*
* QUERY LANGUAGE (START)
*/
QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement
QueryLanguage ::= SelectStatement | UpdateStatement | DeleteStatement
/*
* STATEMENTS
*/
SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
SelectStatement ::= SelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
UpdateStatement ::= UpdateClause [WhereClause]
UpdateStatement ::= UpdateClause [WhereClause]
DeleteStatement ::= DeleteClause [WhereClause]
DeleteStatement ::= DeleteClause [WhereClause]
Subselect ::= SimpleSelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
/*
* CLAUSES
*/
SelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression {"," SelectExpression}*
SelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression {"," SelectExpression}*
SimpleSelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression
SimpleSelectClause ::= "SELECT" ["ALL" | "DISTINCT"] SelectExpression
DeleteClause ::= "DELETE" ["FROM"]
VariableDeclaration
DeleteClause ::= "DELETE" ["FROM"]
AbstractSchemaName [["AS"] IdentificationVariable]
WhereClause ::= "WHERE" ConditionalExpression
WhereClause ::= "WHERE" ConditionalExpression
FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}*
FromClause ::= "FROM" IdentificationVariableDeclaration {"," IdentificationVariableDeclaration}*
HavingClause ::= "HAVING" ConditionalExpression
HavingClause ::= "HAVING" ConditionalExpression
...
@@ -31,52 +78,132 @@ GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}*
...
@@ -31,52 +78,132 @@ GroupByClause ::= "GROUP" "BY" GroupByItem {"," GroupByItem}*
OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
OrderByClause ::= "ORDER" "BY" OrderByItem {"," OrderByItem}*
LimitClause ::= "LIMIT" integer
LimitClause ::= "LIMIT" integer
OffsetClause ::= "OFFSET" integer
OffsetClause ::= "OFFSET" integer
UpdateClause ::= "UPDATE" VariableDeclaration "SET" UpdateItem {"," UpdateItem}*
UpdateClause ::= "UPDATE" AbstractSchemaName [["AS"] IdentificationVariable] "SET" UpdateItem {"," UpdateItem}*
/* TODO: subselect needs to be changed maybe. See JPQL spec. */
Subselect ::= SimpleSelectClause FromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
OrderByItem ::= Expression ["ASC" | "DESC"]
/*
GroupByItem ::= PathExpression
* ITEMS
UpdateItem ::= PathExpression "=" (Expression | "NULL")
*/
OrderByItem ::= StateFieldPathExpression ["ASC" | "DESC"]
GroupByItem ::= SingleValuedPathExpression
UpdateItem ::= [IdentificationVariable"."]{StateField | SingleValuedAssociationField} "=" NewValue
NewValue ::= SimpleArithmeticExpression | StringPrimary | DatetimePrimary | BooleanPrimary |
EnumPrimary | SimpleEntityExpression | "NULL"
/*
* FROM/JOIN/INDEX BY
*/
IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
IdentificationVariableDeclaration ::= RangeVariableDeclaration [IndexBy] {JoinVariableDeclaration}*
JoinVariableDeclaration ::= Join [IndexBy]
JoinVariableDeclaration ::= Join [IndexBy]
RangeVariableDeclaration ::=
identifier {"." identifier}* [["AS"] IdentificationVariable]
RangeVariableDeclaration ::=
AbstractSchemaName [AS] IdentificationVariable
VariableDeclaration ::= identifier [["AS"] IdentificationVariable
]
Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression [AS] IdentificationVariable [("ON" | "WITH") ConditionalExpression
]
I
dentificationVariable ::= identifier
I
ndexBy ::= "INDEX" "BY" StateFieldPathExpression
Join ::= ["LEFT" | "INNER"] "JOIN" RangeVariableDeclaration [("ON" | "WITH") ConditionalExpression]
/*
IndexBy ::= "INDEX" "BY" identifier
* SELECT EXPRESSION
*/
SelectExpression ::= IdentificationVariable ["." "*"] |
(StateFieldPathExpression | AggregateExpression |
"(" Subselect ")" ) [["AS"] FieldIdentificationVariable]
ConditionalExpression ::= ConditionalTerm {"OR" ConditionalTerm}*
/*
ConditionalTerm ::= ConditionalFactor {"AND" ConditionalFactor}*
* CONDITIONAL EXPRESSIONS
*/
ConditionalExpression ::= ConditionalTerm | ConditionalExpression "OR" ConditionalTerm
ConditionalTerm ::= ConditionalFactor | ConditionalTerm "AND" ConditionalFactor
ConditionalFactor ::= ["NOT"] ConditionalPrimary
ConditionalFactor ::= ["NOT"] ConditionalPrimary
ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
ConditionalPrimary ::= SimpleConditionalExpression | "(" ConditionalExpression ")"
SimpleConditionalExpression
/* EmptyCollectionComparisonExpression and CollectionMemberExpression are for the future */
::= Expression (ComparisonExpression | BetweenExpression | LikeExpression
SimpleConditionalExpression ::= ComparisonExpression | BetweenExpression | LikeExpression |
| InExpression | NullComparisonExpression) | ExistsExpression
InExpression | NullComparisonExpression | ExistsExpression |
EmptyCollectionComparisonExpression | CollectionMemberExpression
/*
* COLLECTION EXPRESSIONS (FOR THE FUTURE)
*/
EmptyCollectionComparisonExpression ::= CollectionValuedPathExpression "IS" ["NOT"] "EMPTY"
CollectionMemberExpression ::= EntityExpression ["NOT"] "MEMBER" ["OF"] CollectionValuedPathExpression
Atom ::= string | integer | float | boolean | input_parameter
Atom ::= string | integer | float | boolean | input_parameter
Expression ::= Term {("+" | "-") Term}*
/*
Term ::= Factor {("*" | "/") Factor}*
* ARITHMETIC EXPRESSIONS
Factor ::= [("+" | "-")] Primary
*/
Primary ::= PathExpression | Atom | "(" Expression ")" | Function | AggregateExpression
ArithmeticExpression ::= SimpleArithmeticExpression | "(" Subselect ")"
SimpleArithmeticExpression ::= ArithmeticTerm | SimpleArithmeticExpression ("+"|"-") ArithmeticTerm
ArithmeticTerm ::= ArithmeticFactor | ArithmeticTerm ("*" |"/") ArithmeticFactor
ArithmeticFactor ::= [("+" | "-")] ArithmeticPrimary
ArithmeticPrimary ::= StateFieldPathExpression | Atom | "(" SimpleArithmeticExpression ")" | Function | AggregateExpression
SelectExpression ::= (PathExpressionEndingWithAsterisk | Expression | "(" Subselect ")" ) [["AS"] FieldIdentificationVariable]
PathExpression ::= identifier {"." identifier}*
PathExpressionEndingWithAsterisk ::= {identifier "."}* "*"
FieldIdentificationVariable ::= identifier
AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] Expression ")"
/*
| "COUNT" "(" ["DISTINCT"] (Expression | "*") ")"
* STRING/BOOLEAN/DATE/ENTITY/ENUM EXPRESSIONS
*/
StringExpression ::= StringPrimary | "(" Subselect ")"
StringPrimary ::= StateFieldPathExpression | string_literal | input_parameter | FunctionsReturningStrings | AggregateExpression
BooleanExpression ::= BooleanPrimary | "(" Subselect ")"
BooleanPrimary ::= StateFieldPathExpression | boolean_literal | input_parameter
EnumExpression ::= EnumPrimary | "(" Subselect ")"
EnumPrimary ::= StateFieldPathExpression | enum_literal | input_parameter
EntityExpression ::= SingleValuedAssociationPathExpression | SimpleEntityExpression
SimpleEntityExpression ::= IdentificationVariable | input_parameter
DatetimeExpression ::= DatetimePrimary | "(" Subselect ")"
DatetimePrimary ::= StateFieldPathExpression | input_parameter | FunctionsReturningDatetime | AggregateExpression
QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
/*
BetweenExpression ::= ["NOT"] "BETWEEN" Expression "AND" Expression
* AGGREGATE EXPRESSION
ComparisonExpression ::= ComparisonOperator ( QuantifiedExpression | Expression | "(" Subselect ")" )
*/
InExpression ::= ["NOT"] "IN" "(" (Atom {"," Atom}* | Subselect) ")"
AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM") "(" ["DISTINCT"] StateFieldPathExpression ")" |
LikeExpression ::= ["NOT"] "LIKE" Expression ["ESCAPE" string]
"COUNT" "(" ["DISTINCT"] IdentificationVariable | SingleValuedAssociationPathExpression | StateFieldPathExpression ")"
NullComparisonExpression ::= "IS" ["NOT"] "NULL"
ExistsExpression ::= "EXISTS" "(" Subselect ")"
/*
* QUANTIFIED/BETWEEN/COMPARISON/LIKE/NULL/EXISTS EXPRESSIONS
*/
QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
BetweenExpression ::= ArithmeticExpression ["NOT"] "BETWEEN" ArithmeticExpression "AND" ArithmeticExpression
ComparisonExpression ::= ArithmeticExpression ComparisonOperator ( QuantifiedExpression | ArithmeticExpression ) |
StringExpression ComparisonOperator (StringExpression | QuantifiedExpression) |
BooleanExpression ("=" | "<>") (BooleanExpression | QuantifiedExpression) |
EnumExpression ("=" | "<>") (EnumExpression | QuantifiedExpression) |
DatetimeExpression ComparisonOperator (DatetimeExpression | QuantifiedExpression) |
EntityExpression ("=" | "<>") (EntityExpression | QuantifiedExpression)
InExpression ::= StateFieldPathExpression ["NOT"] "IN" "(" (Atom {"," Atom}* | Subselect) ")"
LikeExpression ::= ["NOT"] "LIKE" pattern_value ["ESCAPE" escape_character]
NullComparisonExpression ::= (SingleValuedPathExpression | input_parameter) "IS" ["NOT"] "NULL"
ExistsExpression ::= ["NOT"] "EXISTS" "(" Subselect ")"
ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
ComparisonOperator ::= "=" | "<" | "<=" | "<>" | ">" | ">=" | "!="
Function ::= identifier "(" [Expression {"," Expression}*] ")"
/*
* FUNCTIONS
*/
FunctionsReturningStrings ::= PortableFunctionsReturningStrings | OtherFunctionsReturningStrings
FunctionsReturningNumerics ::= PortableFunctionsReturningNumerics | OtherFunctionsReturningNumerics
FunctionsReturningDateTime ::= PortableFunctionsReturningDateTime | OtherFunctionsReturningDateTime
/*
* OTHER FUNCTIONS: List of all allowed (but not portable) functions here.
*/
OtherFunctionsReturningStrings ::= ...
OtherFunctionsReturningNumerics ::= ...
OtherFunctionsReturningDateTime ::= ...
/*
* PORTABLE FUNCTIONS: List all portable functions here
* @TODO add all supported portable functions here
*/
PortableFunctionsReturningNumerics ::=
"LENGTH" "(" StringPrimary ")" |
"LOCATE" "(" StringPrimary "," StringPrimary ["," SimpleArithmeticExpression]")" |
"ABS" "(" SimpleArithmeticExpression ")" | "SQRT" "(" SimpleArithmeticExpression ")" |
"MOD" "(" SimpleArithmeticExpression "," SimpleArithmeticExpression ")" |
"SIZE" "(" CollectionValuedPathExpression ")"
PortableFunctionsReturningDateTime ::= "CURRENT_DATE" | "CURRENT_TIME" | "CURRENT_TIMESTAMP"
PortableFunctionsReturningStrings ::=
"CONCAT" "(" StringPrimary "," StringPrimary ")" |
"SUBSTRING" "(" StringPrimary "," SimpleArithmeticExpression "," SimpleArithmeticExpression ")" |
"TRIM" "(" [["LEADING" | "TRAILING" | "BOTH"] [trim_character] "FROM"] StringPrimary ")" |
"LOWER" "(" StringPrimary ")" |
"UPPER" "(" StringPrimary ")"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment