-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
table_exists should not return SQL views #303
Comments
Well, right now it's used for detecting an object in the DB and act accordingly (meaning for example that a module is installed), so as is, it's correct. If you want such specific use, then an extra argument for restricting the search or a new function should be implemented, but this can't be changed, as that would mean to break existing scripts relying on this behavior. |
I understand that changing current behavior would break existing scripts but shouldn't that be addressed? In my case migration failed because a model based on a view had a reference field and Open upgrade tried to rename the referenced model. Anyway, shouldn't we at some point define functions to make explicit checks for objects Odoo uses and deprecate the current function? Should you agree, I'll be happy to help with a PR. |
I have already stated that an extra method or argument may be acceptable. |
hi @diggy128. Did you planned to do a PR for that extra feature ? |
@diggy128 I would be open to changing the behaviour slightly to fit the name more properly, but I'm curious to learn more about the problem you encountered. What do you mean with "a model based on a view had a reference field and Open upgrade tried to rename the referenced model", and how did the current behaviour of |
@StefanRijnhart That is what I was thinking. We have a method named table_exists but essentially looks for many other database objects. Now in my case:
And two others that inherit it. One of them is:
The inherited models instantiate a separate SQL view passing parameters to a base query from the abstract class. Let's assume here that there is a row with a calculated ref value of account.invoice,123456 This worked great but when trying to run OpenUpgrade, table_exists returns True even though this is a view and not a table. Since the table is non updatable an error occurs. So the problem occurs when migrating the reference field but stems from the fact that table_exists returns True when it should return False. This is around L901 in openupgrade.py Ideally as I mentioned above we should define separate functions to make explicit checks for objects Odoo uses and fix the current function (to reflect the function name). |
table_exists returns all database objects that match the name provided.
This includes:
as per relkind in documentation
This fails to run when upgrading a module that has a model defined with view (_auto=False).
Query should limit the object type to table (aka relkind = v)
The text was updated successfully, but these errors were encountered: