Skip to content

Enum values for "" are not proper Go identifiers, cannot emit constants #1082

@bryanmcgrane

Description

@bryanmcgrane

If you're having a generation problem please answer these questions before submitting your issue. Thanks!

What version of SQLBoiler are you using (sqlboiler --version)?

SQLBoiler v4.8.6

What is your database and version (eg. Postgresql 10)

Postgres 12

If this happened at generation time what was the full SQLBoiler command you used to generate your models? (if not applicable leave blank)

sqlboiler psql

where my .toml file looks like

output   = "internal/database/schema/db"
pkgname = "db"
wipe     = true
no-tests = true
struct-tag-casing = "camel"
add-enum-types = true

[psql]
  dbname = "user"
  host   = "localhost"
  port   = 5432
  user   = "user"
  pass   = "mypass"
  schema = "public"
  sslmode = "disable"

If this happened at runtime what code produced the issue? (if not applicable leave blank)

At generation

What is the output of the command above with the -d flag added to it? (Provided you are comfortable sharing this, it contains a blueprint of your schema)

Can't share all of it, but here is one table with a enum that is not generating correctly.

{
         "name":"Key",
         "schema_name":"",
         "columns":[
            {
               "name":"id",
               "type":"string",
               "db_type":"uuid",
               "default":"",
               "comment":"",
               "nullable":false,
               "unique":true,
               "validated":false,
               "auto_generated":false,
               "arr_type":null,
               "udt_name":"uuid",
               "domain_name":null,
               "full_db_type":"uuid"
            },
            {
               "name":"createdAt",
               "type":"time.Time",
               "db_type":"timestamp without time zone",
               "default":"CURRENT_TIMESTAMP",
               "comment":"",
               "nullable":false,
               "unique":false,
               "validated":false,
               "auto_generated":false,
               "arr_type":null,
               "udt_name":"timestamp",
               "domain_name":null,
               "full_db_type":"timestamp"
            },
            {
               "name":"name",
               "type":"null.String",
               "db_type":"character varying",
               "default":"NULL",
               "comment":"",
               "nullable":true,
               "unique":false,
               "validated":false,
               "auto_generated":false,
               "arr_type":null,
               "udt_name":"varchar",
               "domain_name":null,
               "full_db_type":"character varying(127)"
            },
            {
               "name":"keyType",
               "type":"string",
               "db_type":"enum.KeyType('PUBLIC_KEY','PUBLIC_KEY_ED25519','SHARED_SECRET')",
               "default":"",
               "comment":"",
               "nullable":false,
               "unique":false,
               "validated":false,
               "auto_generated":false,
               "arr_type":null,
               "udt_name":"KeyType",
               "domain_name":null,
               "full_db_type":"KeyType"
            },
            {
               "name":"value",
               "type":"[]byte",
               "db_type":"bytea",
               "default":"",
               "comment":"",
               "nullable":false,
               "unique":false,
               "validated":false,
               "auto_generated":false,
               "arr_type":null,
               "udt_name":"bytea",
               "domain_name":null,
               "full_db_type":"bytea"
            },
            {
               "name":"expires",
               "type":"null.Time",
               "db_type":"timestamp without time zone",
               "default":"NULL",
               "comment":"",
               "nullable":true,
               "unique":false,
               "validated":false,
               "auto_generated":false,
               "arr_type":null,
               "udt_name":"timestamp",
               "domain_name":null,
               "full_db_type":"timestamp"
            },
         ],
         "p_key":{
            "name":"Key_pkey",
            "columns":[
               "id"
            ]
         },
         "f_keys":[],
         "is_join_table":false,
         "to_one_relationships":null,
         "to_many_relationships":[
            {
               "name":"Client_keyId_fkey",
               "table":"Key",
               "column":"id",
               "nullable":false,
               "unique":true,
               "foreign_table":"Client",
               "foreign_column":"keyId",
               "foreign_column_nullable":true,
               "foreign_column_unique":false,
               "to_join_table":false,
               "join_table":"",
               "join_local_fkey_name":"",
               "join_local_column":"",
               "join_local_column_nullable":false,
               "join_local_column_unique":false,
               "join_foreign_fkey_name":"",
               "join_foreign_column":"",
               "join_foreign_column_nullable":false,
               "join_foreign_column_unique":false
            }
         ],
         "is_view":false,
         "view_capabilities":{
            "can_insert":false,
            "can_upsert":false
         }
      }

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

SQL To generate

CREATE TYPE "KeyType" AS ENUM ('PUBLIC_KEY', 'PUBLIC_KEY_ED25519', 'SHARED_SECRET');

CREATE TABLE "Key" (
    "id" UUID NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "name" VARCHAR(127),
    "keyType" "KeyType" NOT NULL,
    "value" BYTEA NOT NULL,
    "expires" TIMESTAMP(3),

    PRIMARY KEY ("id")
);

Further information. What did you do, what did you expect?

My boil_types.go has this error message printed for each enum. It looks like the enum name isn't populated in the error message.

// Enum values for  are not proper Go identifiers, cannot emit constants
// Enum values for  are not proper Go identifiers, cannot emit constants
// Enum values for  are not proper Go identifiers, cannot emit constants
// Enum values for  are not proper Go identifiers, cannot emit constants
// Enum values for  are not proper Go identifiers, cannot emit constants
// Enum values for  are not proper Go identifiers, cannot emit constants
// Enum values for  are not proper Go identifiers, cannot emit constants

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions