Purpose
- Support for json and jsonb in PHQL for PostgreSQL dialect, I've explained it here:
https://github.com/phalcon/cphalcon/issues/13115
I want to add support only for WHERE conditions, I do not need it for SELECT ... FROM section.
If I succeed, I will pull request in Phalcon incubator.
Current plan / my thought process:
- Extend current PostgreSQL dialect, like:
<?php
namespace inopx\db;
class InopxPgDialect extends \Phalcon\Db\Dialect\Postgresql {
....
inopx is my private namespace of choice.
-
Introduce new expression type json, and detect it, for example:
\k3\product\K3ProductEntity.title::jsonb <@ '{"name":"Thor"}'
Where do I start? I mean is there some common funcion where all SQL statements go regardless of using find(), findFirst(), exectute() on Query or Connection Object?
-
Extend getSqlExpression method, and support for new json expression type
Pass oryginal json expression without modyfying or scanning/validating it to the final SQL Expression.
Except for modifications of Class properties into valid SQL column name, for example \k3\product\K3ProductEntity.title -> "product"."title"
But im not sure right now if it will be needed.
- Is it proper way to add json support for PostgreSQL?
What's more need to / should be done regarding new expression type?