Skip to content
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

Support postgres Array constructor as function #683

Open
prakol16 opened this issue Aug 23, 2023 · 0 comments
Open

Support postgres Array constructor as function #683

prakol16 opened this issue Aug 23, 2023 · 0 comments

Comments

@prakol16
Copy link

Motivation

I want to be able to construct a postgres array using the Array constructor:

SELECT ARRAY[3, 4, 5 + 6];

Notice that the elements are expressions rather than simply values.

Proposed Solutions

Allow functions to use either square brackets ([ and ]) or ordinary parentheses (( and )) as their invocation method. The default should be parentheses, with only a few operators or functions requiring square brackets.

Additional Information

Unfortunately, the while the current Value type supports arrays, it does not support embedding expressions in the array constructor.

This wouldn't be such a big limitation if we could work around this using custom expressions, but even this isn't possible:

let array_expr = sea_query::Expr::cust_with_exprs(
    "ARRAY [ $, $, $, $ ]",
    [
        "a".into(), "b".into(), "c".into(), "d".into()
    ]
);

doesn't produce the expected outcome when building because the square brackets are apparently interpreted as string delimiters when tokenizing.

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

No branches or pull requests

1 participant