sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Type overrides not working with nullable varchar in mysql

Open bokunodev opened this issue 3 years ago • 0 comments

Version

1.14.0

What happened?

Type overrides not working with nullable varchar in mysql i have three varchar(255) fields with DEFAULT NULL. but for some reason types override does not work on those fields.

Relevant log output

No response

Database schema

this is the table, exported from adminer.

CREATE TABLE `murid` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nama` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nis` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `rfid` varchar(255) NOT NULL,
  `role` tinyint(4) NOT NULL DEFAULT 3,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `kelas` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sekolah_id` int(11) NOT NULL,
  `hp_siswa` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hp_orangtua` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hp_pengurus` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `nis` (`nis`),
  UNIQUE KEY `rfid` (`rfid`),
  KEY `sekolah_id` (`sekolah_id`),
  CONSTRAINT `murid_ibfk_1` FOREIGN KEY (`sekolah_id`) REFERENCES `sekolah` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

SQL queries

No response

Configuration

version: "2"
sql:
- schema: "schema.sql"
  queries: "query.sql"
  engine: "mysql"
  gen:
    go:
      package: "model"
      out: "."
      emit_db_tags: true
      emit_json_tags: true
      emit_methods_with_db_argument: true
      overrides:
        - db_type: "text"
          go_type: "smkti.pc/absensiNext/pkg/types.NullString"
          nullable: true

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

bokunodev avatar Jun 26 '22 21:06 bokunodev