Skip to content

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

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'").

Activity

  1. gordthompson commented on May 3, 2026

    @gordthompson
    Collaborator

    Hi @NotJustPizza . Thanks for reporting.

    Can you please try your repro after doing

    pip install git+https://github.com/gordthompson/sqlalchemy-cockroachdb@issue_297
    
  2. NotJustPizza commented on May 5, 2026

    @NotJustPizza
    Author

    Hi @gordthompson, sorry for late response! It works with your branch.

    Thanks for quick fix! I'm looking forward to next release then :)

  3. gordthompson commented on May 5, 2026

    @gordthompson
    Collaborator

    Will be fixed by #298

  4. added a commit that references this issue on Sep 24, 2026
    82b44b0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions