Support JSON column->path for quoteName
Just want to check if there is any plan to support MySQL JSON column->path for quoteName function.
https://dev.mysql.com/doc/refman/5.7/en/json-search-functions.html#operator_json-column-path
Something like:
$db->quoteName('params->"$.field"', 'as_field');
It should only quote the "params" part.
This would be possible only, if either PostgreSQL supports that, too, or we can (want to) mimic that for PostgreSQL. I'm not very much into that subject, so I leave this open for a day or so to allow posting hints.
Looks like they do.
https://www.postgresqltutorial.com/postgresql-json/
Doesn't sound like a good idea, quoting functions shouldn't be to complex. It would be better to have an own constructor for such queries that can build a proper field statement.
Maybe looking at other database layers how this is handled.
Out of the blue have something like
function quoteJsonAsJson($field, $elements =[], $as='') {
return $this->quoteName($field).' -> '. implode('->', $this->quote($elements)) . ' AS ' . $as;
}
function quoteJsonAsText($field, $elements =[], $as='') {
$last = array_pop($elements);
return $this->quoteJsonAsJson($field, $elements) .' ->>' . $last . ' AS ' . $as;
}
function quoteJsonAsType($type, $field, $elements =[], $as='') {
$last = array_pop($elements);
switch($type) {
case ParameterType::INTERGER:
$type = 'INTEGER';
....
}
return 'CAST(' . $this->quoteJsonAsText($field, $elements) . ') AS ' . $as;
}
That's just a short idea, nothing detail maybe others solved this in a much better or more generic/specific way.