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

pgx go generate execresult and execlastid not working #3699

Open
optimuspaul opened this issue Nov 9, 2024 · 1 comment
Open

pgx go generate execresult and execlastid not working #3699

optimuspaul opened this issue Nov 9, 2024 · 1 comment

Comments

@optimuspaul
Copy link

Version

1.27.0

What happened?

created some tables and queries to insert values into the tables. the generated code doesn't generate sensible or expected results.

  • :execresult produces pgconn.CommandTag
  • :execlastid doesn't even generate the function at all

Relevant log output

No response

Database schema

CREATE TABLE users (
    id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
    email text NOT NULL UNIQUE,
    password text,
    enabled boolean NOT NULL DEFAULT TRUE
);

CREATE TABLE lusers (
    id serial PRIMARY KEY,
    email text NOT NULL UNIQUE,
    password text,
    enabled boolean NOT NULL DEFAULT TRUE
);

SQL queries

-- name: CreateUserA :execresult
insert into users (email, password, enabled) values ($1, $2, $3) returning *;

-- name: CreateUserB :execlastid
insert into users (email, password, enabled) values ($1, $2, $3) returning *;


-- name: CreateUserC :execrows
insert into users (email, password, enabled) values ($1, $2, $3) returning *;


-- name: CreateUserD :exec
insert into users (email, password, enabled) values ($1, $2, $3) returning *;

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "postgresql",
    "gen": {
      "go": {
        "out": "db",
        "sql_package": "pgx/v5" 
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/1f7b12addc3f2d40a3e92ab77d5ea4e6e988e3c1cb1a521801a4023e2dc5b4dc

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@weeco
Copy link

weeco commented Nov 19, 2024

You have to use :one or :many rather than :execresult

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants