sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Failed to generate when schema datetime is not null

Open afikrim opened this issue 4 months ago • 1 comments

Version

1.27.0

What happened?

I want to generate sql query using copyfrom annotations and got an error

Relevant log output

# package bankstatement
error generating code: values with a timezone are not yet supported

Database schema

CREATE TABLE `bank_statements` (
  `id` int NOT NULL AUTO_INCREMENT,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=17136 DEFAULT CHARSET=latin1

SQL queries

-- name: CreateBankStatements :copyfrom
INSERT INTO bank_statements (created_at, updated_at)
  VALUES (
    sqlc.arg(created_at),
    sqlc.arg(updated_at)
  );

Configuration

version: "2"
overrides:
  go:
    overrides:
      - db_type: int
        go_type: int64
      - db_type: int
        nullable: true
        go_type:
          import: github.com/guregu/null/v5
          type: Int64
      - db_type: tinyint
        go_type: int64
      - db_type: tinyint
        nullable: true
        go_type:
          import: github.com/guregu/null/v5
          type: Int64
      - db_type: varchar
        nullable: true
        go_type:
          import: github.com/guregu/null/v5
          type: String
      - db_type: datetime
        nullable: true
        go_type:
          import: github.com/guregu/null/v5
          type: Time
      - db_type: decimal
        nullable: true
        go_type:
          import: github.com/guregu/null/v5
          type: String
      - db_type: date
        nullable: true
        go_type:
          import: github.com/guregu/null/v5
          type: String
sql:
  - name: bank_statement_sql_gen
    engine: mysql
    queries:
      - ./db/query/create_bank_statements.sql
    schema:
      - ./db/schema/bank_statements.sql
    gen:
      go:
        package: bankstatement
        sql_package: database/sql
        sql_driver: github.com/go-sql-driver/mysql
        out: pkg/repository/gen/bank_statement
        emit_db_tags: true
        emit_result_struct_pointers: true
        emit_params_struct_pointers: true
        emit_methods_with_db_argument: true
        emit_interface: true
        omit_unused_structs: true

Playground URL

https://play.sqlc.dev/p/7efe51f305a19f7d9c847f5a4bcb6f9004d64ea5f3383b51fe081a4ade0fd72f

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

afikrim avatar Oct 08 '24 11:10 afikrim