-
-
Notifications
You must be signed in to change notification settings - Fork 23
Added support for JSON datatype #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| * @phpstan-ignore-next-line | ||
| */ | ||
| if (!isset($columnMeta['native_type'])) { | ||
| $columnMeta['native_type'] = \PDO::PARAM_INT === $columnMeta['pdo_type'] ? 'INT' : 'STRING'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to pdo_mysql src, native_type can be missing from the return value:
https://github.com/php/php-src/blob/14319c203cb13a7cc0644fb4276d6e62338fda5e/ext/pdo_mysql/mysql_statement.c#L806-L808
and in that case, we may fallback to the pdo_type, problem is, according to my understanding of the sources, this can be either INT or STR... https://github.com/php/php-src/blob/14319c203cb13a7cc0644fb4276d6e62338fda5e/ext/pdo_mysql/mysql_statement.c#L811-L827.
|
|
||
| /* | ||
| * Native type may not bo set, for example in case of JSON column. | ||
| * @phpstan-ignore-next-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not updated the ColumnMeta to represent the actual state of PDO.getColumnMeta return value as just ignoring this line was so much easier... 🤡
|
This looks great, thank you. Can the same bug be reproduced with PGSQL? Additionally it would be cool if you could add a new testcase for the DbaInferenceTest which contains sql queries using the JSON column, to make sure it also works in non trivial |
Kind of. PdoPgQueryReflector does not crash in case of json, because the extension fallbacks to selecting This still possibly may not return
Yes, I could, but do you have something specific in mind? As |
cool
makes sense, perfect.
I am thinking about very simple json sql select queries which involve the json columns with e.g. WHERE conditions working on the json column with e.g. json functions. a few real world statements so we can be sure phpstan-dba does not detect syntax errors etc please put them into a new file under https://github.com/staabm/phpstan-dba/tree/main/tests/default/data |
|
as this is really useful as is, I will merge for now. would be great you could add the JSON tests we talked about in a separate PR. Thank you. |
Sure, I should be able to deliver over the weekend 🙃 |
Expect this to fail (in more places than intended).The significant failing job is: PHPUnit (8.0, mysql:8.0, pdo, recording), the rest is failing because of cache mismatch (I believe?).
Closes: #357