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

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

Closed
marmiha opened this issue Sep 15, 2023 · 2 comments
Closed

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

marmiha opened this issue Sep 15, 2023 · 2 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@marmiha
Copy link

marmiha commented Sep 15, 2023

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.0

package repository

import (
	"context"
	"time"
)

type Querier interface {
	CreateTemporaryDoorLink(ctx context.Context, arg CreateTemporaryDoorLinkParams) (*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

CREATE TABLE IF NOT EXISTS temporary_door_links (
    id SERIAL PRIMARY KEY,
    token VARCHAR(256) NOT NULL,
    expires_at TIMESTAMP NOT NULL DEFAULT 'now'::timestamp + '14 day'::interval, 
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
);

SQL queries

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

Configuration

version: "2"
sql:
  - schema: ../../db/migrations
    queries: sqlc.queries.sql
    engine: postgresql
    database:
      uri: postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/{DB_NAME}
    gen:
      go:
        package: repository
        out: .
        emit_db_tags: true
        emit_interface: true
        emit_json_tags: true
        emit_result_struct_pointers: true
        rename:
          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

@marmiha marmiha added bug Something isn't working triage New issues that hasn't been reviewed labels Sep 15, 2023
@orisano
Copy link
Contributor

orisano commented Sep 16, 2023

This issue has already been resolved by #2709 (Not yet released)

@marmiha
Copy link
Author

marmiha commented Sep 16, 2023

Great, thanks, didn't seem to find the linked issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

3 participants