sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.51k stars 810 forks source link

sqlc generate:when I change uri localhost to aliyun RDS PG16, some problems appeared #3687

Closed LuoShenKui closed 2 weeks ago

LuoShenKui commented 2 weeks ago

Version

1.27.0

What happened?

The database has two schema.

Relevant log output

1 dto/pg/query/a.sql:13:7: relation "table_a" does not exist
3 dto/pg/query/a.sql:14:1: star expansion failed for query
6 invalid URL escape "%A")

Database schema

CREATE TABLE IF NOT EXISTS blacklist
(
    id bigint NOT NULL DEFAULT nextval('blacklist_id_seq'::regclass),
    created_at timestamp(6) with time zone NOT NULL DEFAULT now(),
    state smallint NOT NULL DEFAULT 0,
    remark character varying(255) COLLATE pg_catalog."default" NOT NULL DEFAULT ''::character varying,
    CONSTRAINT blacklist_pkey PRIMARY KEY (id)
)

TABLESPACE pg_default;

SQL queries

-- name: CreateBlackList :one
INSERT INTO a.table_a(id,type,name) 
VALUES ($1,$2,$3)
returning id;

type CreateBlackListParams struct {
    Column1 pgtype.Int8 `json:"column_1"`
    Column2 pgtype.Int2 `json:"column_2"`
    Column3 pgtype.Text `json:"column_3"`

}

type GetBlackListRow struct {
    CreatedAt     interface{} `json:"created_at"
}

Configuration

version: "2"
sql:
- schema: "dto/pg/schema/"
  queries: "dto/pg/query/"
  engine: "postgresql"
  gen:
    go: 
      package: "db"
      sql_package: "pgx/v5"
      out: "dto/pgtree/sqlc"
      emit_json_tags: true
      emit_interface: true
      emit_empty_slices: true 
  database:
    uri: xxx

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

LuoShenKui commented 2 weeks ago

version: "2" sql: