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

fix: Support multi-argument version of unnest #3738

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"contexts": [
"base"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- name: CreateMemories :many
INSERT INTO memories (vampire_id, memory, victim)
SELECT
unnest(@vampires::uuid[], @memories::text[], @victims::text[])
RETURNING
*;

-- name: GetMemories :many
SELECT vampires.id::uuid, vampires.memory::text, vampires.victim::text FROM unnest(@vampires::uuid[], @memories::text[], @victims::text[]) AS vampires (id, memory, victim);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE vampires (
id uuid PRIMARY KEY DEFAULT gen_random_uuid ()
);

CREATE TABLE memories (
id uuid PRIMARY KEY DEFAULT gen_random_uuid (),
vampire_id uuid REFERENCES vampires (id) NOT NULL,
memory text NOT NULL,
victim text NOT NULL,
created_at timestamp NOT NULL DEFAULT NOW(),
updated_at timestamp
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "1",
"packages": [
{
"path": "go",
"engine": "postgresql",
"sql_package": "pgx/v4",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql",
"emit_interface": true
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"contexts": [
"base"
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- name: CreateMemories :many
INSERT INTO memories (vampire_id, memory, victim)
SELECT
unnest(@vampires::uuid[], @memories::text[], @victims::text[])
RETURNING
*;

-- name: GetMemories :many
SELECT vampires.id::uuid, vampires.memory::text, vampires.victim::text FROM unnest(@vampires::uuid[], @memories::text[], @victims::text[]) AS vampires(id, memory, victim);
Loading
Loading