-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: jsonb comparator operators are not implemented #49144
Comments
Hello, I am Blathers. I am here to help you get the issue triaged. Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here. I have CC'd a few people who may be able to assist you:
If we have not gotten back to your issue within a few business days, you can try the following:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
This would be fixed by moving toward a Postgres-style implicit cast model. We could also add a quick fix for it. @timgraham do you think this is a really useful thing, or is it one of those things that comes up just in tests? |
I don't think this case deserves special priority over similar issues (cockroachdb/django-cockroachdb#19, cockroachdb/django-cockroachdb#20, etc) that may be fixed by the more general solution you described. |
EDIT: nvm, misread this one! |
ah this is slightly more than i expected: we don't support jsonb comparison!
Prisma relies on this too, but I am skipping those tests. |
I'm evaluating cockroachDB as a new DB for darklang. We use jsonb to store all user data, and then compile users' queries -- written in darklang -- to SQL. (Blog post on that here: https://blog.darklang.com/compiling-dark-to-sql/, and the implementation is here https://github.com/darklang/dark/blob/3e6fd9959e0ec9e87bce1f6033386e9c44d81c53/fsharp-backend/src/LibBackend/SqlCompiler.fs). To be able to switch over, we would need to support |
@pbiggar I would expect you are extracting a specific field and comparing that--to perform a "numerical comparison"--not comparing the JSON object values themselves, and so you should not need this feature? |
We need to make the sort of query listed in this issues description:
We also allow this sort of query:
We do not support (or intend to support) this sort of query:
|
@pbiggar But you said you wanted to do a "numerical comparison". The reason those queries don't work is because, from a type perspective, But, if you want to just extract fields whose type you know, this works fine (though it would be preferable, to me at least, to be able to directly cast a jsonb to a decimal instead of having to first get its value as a string, but that's a different issue from being unable to compare jsonb values):
|
@saurik Ah, I see! Yes, that's exactly what I need. Sounds like it's already supported. I always know the types and the sql I generate already has appropriate type-casts. Thanks! |
The case in the issue description works in CockroachDB 23.2 nightly. (Not sure if it was fixed in a duplicate issue or as a side effect of another change, possibly 5cdb625.) |
Describe the problem
A clause like
("jsontest"."value" -> 'c') > '2'
crashes (but works on PostgreSQL).To Reproduce
Expected behavior
Expected result (for both select queries):
Actual results:
Environment:
Django 3.1 (to be released in August 2020) adds support for JSONField and this issue came up in a failing test.
Jira issue: CRDB-4253
The text was updated successfully, but these errors were encountered: