Skip to content

bug: imports time in querier.go when inserting TIMESTAMP column#2739

@marmiha

Description

@marmiha

Version

1.21.0

What happened?

Generating code with the given database schema the corresponding querier is generated as such:

// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.21.0package repository import ( "context""time" ) typeQuerierinterface{CreateTemporaryDoorLink(ctx context.Context, argCreateTemporaryDoorLinkParams) (*TemporaryDoorLink, error) } var_Querier= (*Queries)(nil)

where the import time is not used, resulting in unrunable code. I also use golang-migrate.

Relevant log output

No response

Database schema

CREATETABLEIF NOT EXISTS temporary_door_links ( id SERIALPRIMARY KEY, token VARCHAR(256) NOT NULL, expires_at TIMESTAMPNOT NULL DEFAULT 'now'::timestamp+'14 day'::interval, created_at TIMESTAMPNOT NULL DEFAULT CURRENT_TIMESTAMP, );

SQL queries

-- name: CreateTemporaryDoorLink :oneINSERT INTO temporary_door_links ( token, max_uses, expires_at ) VALUES ( $1, $2, $3 ) RETURNING *;

Configuration

version: "2"sql: - schema: ../../db/migrationsqueries: sqlc.queries.sqlengine: postgresqldatabase: uri: postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/{DB_NAME}gen: go: package: repositoryout: .emit_db_tags: trueemit_interface: trueemit_json_tags: trueemit_result_struct_pointers: truerename: id: "Id"account_id: "AccountId"

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions