$_isDotted
$_isDotted : boolean
Stores the use of dots in fields names when selecting
Extends the core Query class to provide support for parsing valid queries containing JSON fields properties.
jsonFieldsNameinString(string $expression) : string
Apply jsonFieldName to every property name detected in a string, mainly used to parse SQL fragments
The regexp is a bit tricky to avoid collision with mail parameter value that will be enclosed by quotes
string | $expression | SQL fragment to be reworked |
Parsed string that contains modified SQL fragment
rawSqlConverter(string $expression) : \Cake\Database\Expression\QueryExpression
Returns a new QueryExpression built upon the parsing of the expression to update datfield names
string | $expression | Raw expression to transform |
QueryExpression
comparisonConverter(\Cake\Database\Expression\Comparison $expression) : \Cake\Database\Expression\Comparison|\Cake\Database\Expression\QueryExpression
Update or replace the Comparison expression to perform comparisons on datFields. In some cases, PDO limitations implies to replace the expression with a raw SQL fragment. It can be a bit dangerous when using raw user input to perform global matching in `array` mode.
Regular fields expressions are left as is.
\Cake\Database\Expression\Comparison | $expression | Comparison expression |
Updated expression
unaryExpressionConverter(\Cake\Database\Expression\UnaryExpression $expression) : \Cake\Database\Expression\UnaryExpression
Parses the unary expression to apply conversions on childrens and returns an updated UnaryExpression
Note : This a VERY hacky way because the UnaryExpression class doesn't expose
getter/setter for protected _value
property.
In this implementation, it causes an infinite loop when used directly with a SQL fragment :
['NOT' => 'sub.prop@datfield like "%buggy%"]
That's why, an exception is thrown as soon as $value is extracted
\Cake\Database\Expression\UnaryExpression | $expression | Expression |
New expression
queryExpressionConverter(\Cake\Database\Expression\QueryExpression $expression) : \Cake\Database\Expression\QueryExpression
Iterates over a QueryExpression and replace Comparison expressions to handle JSON comparison in datfields.
\Cake\Database\Expression\QueryExpression | $expression | QueryExpression |
Updated QueryExpression
expressionConverter(string|\Cake\Database\ExpressionInterface $expression) : \Cake\Database\ExpressionInterface
Returns the appropriate ExpressionInterface regarding the incoming one
string|\Cake\Database\ExpressionInterface | $expression | Incoming expression |
Updated expression
jsonWhere(string|array|callable $conditions) : \Lqdt\OrmJson\ORM\JsonQuery
Add conditions to the query that can be matched against datfield value
jsonWhere accepts exactly the same parameters than the regular Query::where method
The conditions are first parsed in a regular QueryExpression. The result is then converted to replace Comparison expressions in a suitable way to query JSON fields in database.
The conditions that are matching regular fields are kept intact, thus allowing to mix regular/datfields comparisons in a single call to jsonWhere.
string|array|callable | $conditions | Conditions for WHERE clause |
Self for chaining
jsonSelect(string|array $fields, string|boolean $separator = '_', boolean $lowercasedKey = false) : \Lqdt\OrmJson\ORM\JsonQuery
Adds support to fetch selected properties within a JSON field
Aliases fields are now supported as well as the use of a dot as separator or in alias for the resulting field name
string|array | $fields | Field name in datfield notation |
string|boolean | $separator | Separator string for field aliases name (dot is not allowed). Set it to false to return Resultset as associative array |
boolean | $lowercasedKey | Force key alias to be lowercased (useful when using models name in datfield that must be capitalized) |
Self for chaining
clause(string $name) : array
Intercepts calls to clause('select') to enable or disable autofields
When sorting, we must select custom fields to sort and thus disable autofields even if no selection have been made. This wrapper prevents this behavior
string | $name | Clause name |
Array of clause
jsonOrder(string|array $conditions) : \Lqdt\OrmJson\ORM\JsonQuery
Sets up the sorting based on JSON fields value
string|array | $conditions | Sorting conditions |
self for chaining
all() : \Cake\Datasource\ResultSetInterface
Wrapper for the genuine `\Cake\ORM\Query::all` method to allow dot in field names and sorting
When extracting data, it unescapes dotted field names and clean json fields used for sorting and not requested
Result set to iterate on