-
Notifications
You must be signed in to change notification settings - Fork 87
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
Foreign key references as string #30
Conversation
…'t working if using a lazy reference
The Table metaclass wasn't being called on columns, so the ForeignKeyMeta wasn't being setup correctly on ForeignKey columns.
I am still seeing circular import issues even when using lazy references. I have a project with structure like this: users accounts users.tables.User is a subclass of BaseUser, and accounts.tables.UserAccount has the following reference:
The users.tables module does not reference the accounts package at all, and there are no explicit imports of users into accounts, just the lazy reference. Now, the problem occurs in users.views where there are explicit imports of both User, and UserAccount in order to make use of both of these in my user profile views. When that import is attempted, I get an error like:
I realize there is not a lot to go on here without building out a demonstrating isolated version of the problem, but any ideas that come to mind as to how I might work through this would be appreciated. I have tried re-ordering the User and User account imports in the view, but to no avail. I suppose if I really have to, I can consolidate these classes into a single module, but organizationally I see these as distinct concepts that I'd like to keep separate if at all possible. fwiw I was on piccolo 0.73.0, have updated to 0.82.0, and am still seeing this problem. |
For the time being, I have moved my UserAccount import into the view function that uses it. That will have to do for now. |
The
ForeignKey
references
argument can now be specified using a string, or aLazyTableReference
instance, rather than just aTable
subclass. This allows aTable
to be specified which is in a Piccolo app, or Python module. TheTable
is only loaded after imports have completed, which prevents circular import issues.Other issues fixed:
await Band.select(Band.manager.name).run()
).