Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Limit/Offset use int32 instead of int64 with schema file vs managed db #4142

Open
@pgr0ss

Description

Version

1.30.0

What happened?

I noticed a difference when generating queries with limit/offset between using a schema file vs a managed database connection. If the table uses an int64 primary key, then the limit and offset params should be int64. This works correctly with a managed database, but when using only a schema.sql, it generates as int32 instead.

In the config below, you can see the difference in behavior by uncommenting the managed db lines.

For simplicity, I ran sqlc for this as:

go run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.30.0 generate

And then I looked at the generated params:

type ListItemsParams struct {
	Limit int32
	Offset int32
}

Relevant log output

Database schema

CREATE TABLE items (
 id BIGSERIAL PRIMARY KEY
);

SQL queries

-- name: ListItems :many
SELECT *
FROM items
LIMIT $1 OFFSET $2;

Configuration

version: "2"
# servers:
# - engine: postgresql
# uri: "postgres://user:pass@localhost:5432/db?sslmode=prefer"
sql:
 - engine: "postgresql"
 queries: "queries.sql"
 schema: "schema.sql"
 # database:
 # managed: true
 gen:
 go:
 package: "dbsqlc"
 out: "dbsqlc"
 emit_pointers_for_null_types: true
 sql_package: "pgx/v5"

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

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

        AltStyle によって変換されたページ (->オリジナル) /