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

Unable to use a string array as a parameter in WhereRaw #729

Open
wr-cdargis opened this issue Oct 2, 2024 · 0 comments
Open

Unable to use a string array as a parameter in WhereRaw #729

wr-cdargis opened this issue Oct 2, 2024 · 0 comments

Comments

@wr-cdargis
Copy link

wr-cdargis commented Oct 2, 2024

FYI I have seen issue #162

This is similar but I am trying to use .WhereRaw() with a string array.

This is the raw SQL I am trying to accomplish:

SELECT * FROM "v0"."Users" WHERE "Roles" && ('{"Member", "Admin"}');

My attempt at using SQL Kata looks like this

string str = String.Join(",", request.Roles.Select(r => $"\"{r.ToString()}\""));
str = $"'{{{str}}}'";
string raw = "\"Users\".\"Roles\" && (?)";
query = query.WhereRaw(raw, str);

The postgres server is telling me:

ERROR: operator does not exist: text[] && text;

The column I am querying is of type text[].

I have also tried just going totally RAW SQL without a parm, but that still isn't working:

string str = String.Join(",", request.Roles.Select(r => $"\"{r.ToString()}\""));
str = $"'{{{str}}}'";
string raw = $"\"Users\".\"Roles\" && ({str})";
query = query.WhereRaw(raw);

But my SQL ends up looking like this:

AND "Users"."Roles" && ('""Support","Admin""')

Looks like the {} chars are getting replaced with quotes?

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