Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_class_by_table should provide list of found classes when #680

Open
lachaib opened this issue Feb 9, 2023 · 0 comments
Open

get_class_by_table should provide list of found classes when #680

lachaib opened this issue Feb 9, 2023 · 0 comments

Comments

@lachaib
Copy link

lachaib commented Feb 9, 2023

Hello,

I'm using get_class_by_table method to find the declarative base associated to a table object, without any data associated (trying to export a list of tables associated to the files they are defined in).
In case of polymorphic tables, this method raises a ValueError that multiple classes are found for the table. Although I totally understand this error, I think it would be valuable for at least the exception to be decorated with the multiple results, so that client code may do a follow-up process accordingly with all matching classes.

Something such as

class PolymorphicIndeterminationError(ValueError):
    def __init__(self, message,  polymorphic_classes):
           super().__init__(message)
           self.polymorphic_classes = polymorphic_classes

and then raise PolymorphicIndeterminationError instead of ValueError.

An alternative that may be enough in my case would be to add a parameter only_polymorphic_base to the method, and return only the class that has base in its direct __bases__

I don't know which option would be preferred, but I think this could be a great improvement.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant