You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everyone I know there are quite a few issues documented regarding the assertion error that occurs as a result of the same enum being utilized in two different SQL alchemy mappings with the same column name. I've read through #208, as well as this PR: #210 which in theory should resolve the issue I'm seeing. The other approaches around changing the naming with connections fields seem unnecessary in 2.3 based on the PR and other documentation that such cases are accounted for, but please let me know if I missed a potential solution.
The resulting error is:
AssertionError: Found different types with the same name in the schema: JobStatusEnum, JobStatusEnum.
For context here's my enum, mappings, and graphene setup:
Mapping (left out extra columns and CinexBase is just a declarative_base(metadata=MetaData("schema_name")) ):
from sqlalchemy import Enum # and some other things
class SavedJobs(CinexBase):
__tablename__ = 'saved_jobs'
job_status = Column('job_status', Enum(JobStatusEnum))
class MatchedJobs(CinexBase):
__tablename__ = 'matched_jobs'
job_status = Column('job_status', Enum(JobStatusEnum))
The graphene setup:
class SavedJobsType(SQLAlchemyObjectType):
class Meta:
model = SavedJobs
interfaces = (graphene.relay.Node,)
class MatchedJobsType(SQLAlchemyObjectType):
class Meta:
model = MatchedJobs
interfaces = (graphene.relay.Node,)
Query Class (I have a custom object that adds authentication logic and filtering as a result on top of the graphene-sqlalchemy-filter library though this library simply extends the usage of core graphene-sqlalchemy objects by adding filters. Let me know if y'all think this may be the culprit (https://github.com/art1415926535/graphene-sqlalchemy-filter):
class Query(graphene.ObjectType):
matched_jobs = AuthModifiedFilterableConnectionField(MatchedJobsType.connection, filters=MatchedJobsFilter())
saved_jobs = AuthModifiedFilterableConnectionField(SavedJobsType.connection, filters=SavedJobsFilter())
Would appreciate any help. The way I've gotten around this is creating an extra enum class with a slightly different name as such:
class SavedJobs(CinexBase):
__tablename__ = 'saved_jobs'
job_status = Column('job_status', Enum(JobStatusEnum))
class MatchedJobs(CinexBase):
__tablename__ = 'matched_jobs'
job_status = Column('job_status', Enum(JobStatusEnum2))
Though this solution seems impractical as I would be expected to create multiple copies of the same enum for potentially 5+ tables and attempt to maintain a universal set of options. Defeats the purpose of the enum IMO.
Thanks in advance would love any direction here!
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.
Hi everyone I know there are quite a few issues documented regarding the assertion error that occurs as a result of the same enum being utilized in two different SQL alchemy mappings with the same column name. I've read through #208, as well as this PR: #210 which in theory should resolve the issue I'm seeing. The other approaches around changing the naming with connections fields seem unnecessary in 2.3 based on the PR and other documentation that such cases are accounted for, but please let me know if I missed a potential solution.
The resulting error is:
For context here's my enum, mappings, and graphene setup:
Enum:
Mapping (left out extra columns and CinexBase is just a
declarative_base(metadata=MetaData("schema_name"))
):The graphene setup:
Query Class (I have a custom object that adds authentication logic and filtering as a result on top of the graphene-sqlalchemy-filter library though this library simply extends the usage of core graphene-sqlalchemy objects by adding filters. Let me know if y'all think this may be the culprit (https://github.com/art1415926535/graphene-sqlalchemy-filter):
Would appreciate any help. The way I've gotten around this is creating an extra enum class with a slightly different name as such:
Though this solution seems impractical as I would be expected to create multiple copies of the same enum for potentially 5+ tables and attempt to maintain a universal set of options. Defeats the purpose of the enum IMO.
Thanks in advance would love any direction here!
The text was updated successfully, but these errors were encountered: