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

JSON boolean is string? #7528

Closed
kennethklee opened this issue Feb 22, 2024 · 3 comments · Fixed by dolthub/go-mysql-server#2343
Closed

JSON boolean is string? #7528

kennethklee opened this issue Feb 22, 2024 · 3 comments · Fixed by dolthub/go-mysql-server#2343
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue

Comments

@kennethklee
Copy link

Boolean values in json objects seem to be converted to string.

root@1dcd620894a2:/var/lib/dolt# dolt sql
# Welcome to the DoltSQL shell.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
> set @a = '{"one": true}';
> select @a->'$.one' = true, @a->'$.one' = 'true', true = true, true = 'true';
+--------------------+----------------------+-------------+---------------+
| @a->'$.one' = true | @a->'$.one' = 'true' | true = true | true = 'true' |
+--------------------+----------------------+-------------+---------------+
| 0                  | 1                    | 1           | 0             |
+--------------------+----------------------+-------------+---------------+
1 row in set (0.01 sec)

Expected @a->'$.one' = true to be evaluated to 1.

Just in case, here's the equivalent in mysql:

mysql> create table test (a json);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into test values ('{"one": true}');
Query OK, 1 row affected (0.00 sec)

mysql> select * from test;
+---------------+
| a             |
+---------------+
| {"one": true} |
+---------------+
1 row in set (0.00 sec)

mysql> select a, a->'$.one' = true, a->'$.one' = 'true' from test;
+---------------+-------------------+---------------------+
| a             | a->'$.one' = true | a->'$.one' = 'true' |
+---------------+-------------------+---------------------+
| {"one": true} |                 1 |                   0 |
+---------------+-------------------+---------------------+
1 row in set (0.00 sec)

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.36    |
+-----------+
1 row in set (0.00 sec)
@timsehn timsehn added bug Something isn't working correctness We don't return the same result as MySQL labels Feb 22, 2024
@timsehn
Copy link
Contributor

timsehn commented Feb 22, 2024

@jycor will fix this tomorrow.

@jycor
Copy link
Contributor

jycor commented Feb 23, 2024

Hey @kennethklee, thanks for reporting this issue!
JSON booleans were a little tricky, but the fix is merged to dolt main.

We can cut a release for you tomorrow morning.

@bpf120
Copy link

bpf120 commented Feb 23, 2024

@kennethklee , thanks again for filing and using Dolt. Hope we can learn about your use case soon. Swing by our Discord or shoot me an email when you want to share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants