Skip to content

SAWarning "Could not parse type name 'USER-DEFINED'" when reflecting CockroachDB enum #303

@NotJustPizza

Description

@NotJustPizza

Description

Reflecting a CockroachDB user-defined enum column triggers a noisy SAWarning and prevents Alembic autogenerate from determining the DB type for the column.

Reproduction

models.py

from enum import Enum as PyEnum
from sqlmodel import SQLModel, Field
from sqlalchemy import Column, Enum as SAEnum

class MyEnum(PyEnum):
    VALUE_A = "value_a"
    VALUE_B = "value_b"

class MyModel(SQLModel, table=True):
    __tablename__ = "my_model"

    id: str = Field(primary_key=True)
    my_enum: MyEnum = Field(sa_column=Column(SAEnum(MyEnum), nullable=False))

Run commands:
alembic revision -m init --autogenerate
alembic upgrade head
alembic check

Expected

  • Reflection returns usable SQLAlchemy type metadata for my_model.my_enum (Enum or equivalent) with no SAWarning.
  • Alembic autogenerate does not log "Couldn't determine database type..." for that column.

Actual

.venv\Lib\site-packages\sqlalchemy_cockroachdb\base.py:232: SAWarning: Could not parse type name 'USER-DEFINED'
  warn("Could not parse type name '%s'" % type_str)
INFO Couldn't determine database type for column 'my_model.my_enum'
  • Autogenerate emits no meaningful change for the column and is noisy.

Versions

  • sqlalchemy-cockroachdb == 2.0.4
  • SQLAlchemy == 2.0.49
  • sqlmodel == 0.0.38
  • asyncpg == 0.31.0
  • Python == 3.14.4
  • Alembic == 1.17.2 (also observed on 1.18.3)

Relevant code path

  • sqlalchemy_cockroachdb/base.py — parser that attempts to map Cockroach-reported type strings and calls warn("Could not parse type name '%s'").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions