Skip to content

Conversation

cmizzi
Copy link
Contributor

@cmizzi cmizzi commented Jul 16, 2020

As you may know, since PHP 7.4, it is now possible to use special operators (known mainly under PostgreSQL as ?, ?|, ?&...) by doubling the question mark (??, ??|, ??&...). The formatter didn't support this feature, it's done now.

In addition, the formatter replaces the question mark escape so that it can be easily copied and pasted to debug a query. I also implemented a test on this feature.

SELECT ('[1, 2, 3]'::jsonb ?? ?) as a, ('[4, 5, 6]'::jsonb ??| ?) as b, 'hello world ? example ??' as c

Bindings : [3, '{4}']
-SELECT ('[1, 2, 3]'::jsonb 3'{4}' ?) as a, ('[4, 5, 6]'::jsonb ??| ?) as b, 'hello world ? example ??' as c
+SELECT ('[1, 2, 3]'::jsonb ? 3) as a, ('[4, 5, 6]'::jsonb ?| '{4}') as b, 'hello world ? example ??' as c

@barryvdh
Copy link
Owner

How does this work? Is that postgre specific?

@cmizzi
Copy link
Contributor Author

cmizzi commented Jul 17, 2020

@barryvdh

At the moment, it seems that only PostgreSQL defines operators containing ? (not enough skill on other RDMSs to confirm). However, the RFC has been directly implemented in SQL Parser PDO.

@barryvdh barryvdh merged commit b942837 into barryvdh:master Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants