-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
fix "model does not have column" error #850
fix "model does not have column" error #850
Conversation
d1d1fc7
to
ef809d7
Compare
Hi, thank you for this PR. I wanted to inform you that there is a flaw in the way you're checking if a field has already been visited. Storing the index of the field in |
ef809d7
to
4fd3638
Compare
Thanks for your input @TonDar0n, I've integrated your test case and fixed the code accordingly. |
This fixes the case of two belongs-to fields with different names but with the same type.
4fd3638
to
cda3343
Compare
I've just force-pushed a new version, adding an new test case for circular relations. The Now, the seen map is cloned so that all the paths of what has been visited is saved, and we're able to stop the recursion more precisely: only when a path starts looping. @vmihailenco this is ready for review, thanks! |
Merging since this is an improvement to the current behavior, but this does not look like a complete fix for the recursion case. We just give up at some later point then before. #849 looks more promising since it adds dynamic resolving, but it requires more work... |
This reverts commit 16367aa.
The following type has two belongs-to fields with different names (BillingAddress and ShippingAddress) but with the same type (Address):
It causes this error when making a
SELECT
(see test case):I've attached a test case to demonstrate the problem.
This commit is an attempt to fix the bug. I've narrowed it down to the Table.inlineFields method.
There is a
seen
map that saves which fields have already been visited to avoid an infinite loop in case of circular relations. In the case with two fields with different names but the same type (BillingAddress and ShippingAddress), theseen
map prevents theinlineFields
method to visit one of the two fields, which causes the error.This is just one attempt to fix the bug, I'm happy to make changes if you think it should be fixes in another way.
(Another attempt by another contributor to fix this bug has been made in #849, original bug #847. This other PR doesn't have a test case, but fixes the problem elsewhere in the code, it might be interesting to compare the two different fixes.)