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

[BUG]: using skipAttributes method causes column map load incorrectly in inherited entity #16544

Open
markofo opened this issue Mar 12, 2024 · 1 comment
Labels
bug A bug report status: unverified Unverified

Comments

@markofo
Copy link
Sponsor

markofo commented Mar 12, 2024

We have problem with skipAttributes method, which behaves differently than expected.

We have an entity that has a database view as its source, lets call it ViewProduct, and it inherits from another Product entity that has a database table as its source. The database view entity ViewProduct contains more attributes like a reference to the Company entity and the column map definition is joined from both tables.

If we go through the ViewProduct entity and load the related Company entity via ORM, everything works as it should.

However, if the skipAttributes method is called in the Product entity in the initialize method, then by calling parent::initialize in the ViewProduct entity, this call is triggered even when I load the ViewProduct entity from database and this is where the problem occurs, because the related entity Company is always null.

If the skipAttributes method is not called, then Company entity is fetched as it should. This problem occurs in Phalcon version 5. In Phalcon 3 this works without any problems.

Steps to reproduce the behavior:
Here is a github link to an example application: https://github.com/slechtic/phalcon5_skip_attributes/tree/main

Details

  • Phalcon version: 5.6.1
  • PHP Version: 8.2.15
  • Operating System: Debian 12
  • Installation type: Compiling from source
  • Zephir version (if any): 0.18.0
  • Server: Apache
  • Other related info: PostgreSQL 14
@markofo markofo added bug A bug report status: unverified Unverified labels Mar 12, 2024
@s-ohnishi
Copy link

skipAttributes() has such strange behavior.
I find it unpleasant that the relationship between skipAttributes() and getChangedFields() is different depending on whether the instance is a new instance or not.
(See abandoned posts)
It may be that skipAttributes() is not reflected correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
None yet
Development

No branches or pull requests

2 participants