Skip to content

pgx go generate execresult and execlastid not working #3699

Open
@optimuspaul

Description

@optimuspaul

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions