-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add support for ANY/SOME and ALL operators #151
Comments
I think it is also worth updating this issue with the fact that surrounding an Valid: SELECT * FROM table WHERE id = ANY(ARRAY[1, 2, 3]); Not valid: SELECT * FROM table WHERE id = (ANY(ARRAY[1, 2, 3])); |
After going over the codebase, I think it would be best to treat Another approach is to treat binary operators as things that can be modified with export interface ExprBinary extends PGNode {
type: 'binary';
left: Expr;
right: Expr;
op: BinaryOperator;
arrayOp?: 'any' | 'all' | 'some';
opSchema?: string;
}
const myOperator: ExprBinary = {
type: 'binary',
left: Ref.id,
right: Ref.param1,
op: '@>',
arrayOp: 'any',
}
|
Currently this library does not support array operations.
It parses them fine, and will even render them (albeit incorrectly). I think an example is the best way to show this.
output is:
and if we declutter it a bit:
If you notice the issue, it is that
ANY
is quoted, since the library thinks it is a keyword. Running this query nets you this error in postgres:[42883] ERROR: function any(jsonb[]) does not exist
.As an AST, the
any
is represented as acall
node, and eventuallyident
gets called on it:kwSet
includesany
, so it gets quoted. The same issue would happen withSOME
(an alias ofANY
) andALL
.The text was updated successfully, but these errors were encountered: