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

sql: allow UUID[] literals to be written as '{uuid-..., uuid-...}' #54672

Closed
rafiss opened this issue Sep 22, 2020 · 8 comments · Fixed by #54709
Closed

sql: allow UUID[] literals to be written as '{uuid-..., uuid-...}' #54672

rafiss opened this issue Sep 22, 2020 · 8 comments · Fixed by #54709
Assignees
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-typing SQLtype inference, typing rules, type compatibility. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@rafiss
Copy link
Collaborator

rafiss commented Sep 22, 2020

Postgres emits UUIDs in this format when using pg_dump, and allows users to enter this format in the SQL shell. We should support it too.

Currently, this errors in CockroachDB

root@:26257/defaultdb> create table t (a int primary key, b uuid[]);
CREATE TABLE

root@:26257/defaultdb> insert into t values (1, '{18e7b17e-4ead-4e27-bfd5-bb6d11261bb6, 18e7b17e-4ead-4e27-bfd5-bb6d11261bb7}');
ERROR: value type string doesn't match type uuid[] of column "b"
SQLSTATE: 42804
HINT: you will need to rewrite or cast the expression
@rafiss rafiss added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-typing SQLtype inference, typing rules, type compatibility. labels Sep 22, 2020
@rafiss rafiss self-assigned this Sep 22, 2020
@rafiss
Copy link
Collaborator Author

rafiss commented Sep 23, 2020

Removing the good first issue label since I'll be pairing up on this issue with a new hire

@z0mb1ek
Copy link

z0mb1ek commented Dec 10, 2020

HI. When will it be released?

@rafiss
Copy link
Collaborator Author

rafiss commented Dec 10, 2020

This is released in v20.2.0 already

@z0mb1ek
Copy link

z0mb1ek commented Dec 10, 2020

I use 20.2.2 and it not working

row 8279: parse "sub_categories_ids" as UUID[]: at or near "{": syntax error
DETAIL:  source SQL:
SET ROW ({ccd765d4-818b-4767-825c-aa97ef3712ba,14e91dce-6c36-4529-a726-316dc83a220f,610f6862-17ba-4915-8c33-dfcaf69b3efb,c75b5cb7-222a-445f-97b3-82eda0d469a0,d30d1365-cd6a-4290-a18b-79aff9b7d0f4,936d0955-ddee-4c7a-be47-61f363779766,386b320b-255e-4c4f-81f6-859e89ea59eb,670b93d8-f617-48db-a2f5-53cc5777ac8a,7d2d7758-371d-4033-820b-13c33c27abba,26bd53cc-ab0b-4717-9fc9-36a34b71a359,11cf9fee-94c2-437d-af48-9de1d537e657,11a126f5-7a87-45c6-b44d-c90915b2dcf2,2d9cf427-dada-458a-8761-af261ce236f6,38c96b69-3b6e-448b-bf47-5a6092369125,3b3e3b64-f933-4bcc-87ac-744e155cece0,a6fb1dc5-d798-45c9-b1fc-9d11007649fd,5fff743b-de25-4e77-9425-496cc9a026c6,b6327039-b546-4aef-b1e6-7f49638e91d4,c008a4ba-e3eb-4151-a401-a3bc6b29fab9,ecb31291-0df2-432c-9bd6-428651ae993f})

I use IMPORT PGDUMP

@rafiss
Copy link
Collaborator Author

rafiss commented Dec 10, 2020

Thanks for the details. This issue only addressed INSERT/UPDATE functionality. For IMPORT PGDUMP, there remains more work to be done: #29043 and #56593

@z0mb1ek
Copy link

z0mb1ek commented Dec 10, 2020

it strange but i see

ERROR:  at or near "{": syntax error
DETAIL:  source SQL:
INSERT INTO "public"."video_meta" ("video_id", "associated_ids") VALUES ('000c7502-b2f1-428e-98f3-45c9afded2e1', {a9b61bcd-86c9-423c-89fe-a0a38344129f})

@rafiss
Copy link
Collaborator Author

rafiss commented Dec 10, 2020

If you are writing an INSERT statement, the array must be in single-quotes. See the initial PR description. (This is the same in PostgreSQL too)

@z0mb1ek
Copy link

z0mb1ek commented Dec 10, 2020

thx!!! it is TablePlus bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-typing SQLtype inference, typing rules, type compatibility. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants