Skip to content

Error with constraint to other schema enum? #3

@agronholm

Description

@agronholm

Originally reported by: YKdvd NA (Bitbucket: YKdvd, GitHub: YKdvd)


I was trying to run sqlacodegen on a MySQL database which does FK constraints to a different schema. So the Parent schema has a Users table, which includes a userGroup field which is an ENUM. The Child schema has a Something table which does something like:

CONSTRAINT fk_S_U FOREIGN KEY (user_id) REFERENCES Parent.Users (id) ON UPDATE CASCADE

If I dump the Parent schema with sqlacodegen, there's no problem, and Users dumps fine. I can also dump tables from the Child schema that do FK constraints to other tables (not Users) in the Parent schema. But a Child table that refers to Parent.Users crashes with:

File ".../sqlacodegen/codegen.py", line 469, in init
if isinstance(table.c[colname].type, String):
File "../sqlalchemy/util/_collections.py", line 154, in getitem
return self._data[key]
KeyError: u'users.`userGroup'

I'm not sure why it doesn't like that Parent.Users.userGroup field cross-schema, perhaps something to do with it being an enum? This is sqlacodegen 1.1.1 and SQLAlchemy 0.8.2, against MySQL 5.5/5.1. I'll see if I can dig into the code, or create a minimal example reduction someday when I have free time.


Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions