Bug regarding propel and entitymapping
Hi, i think i found an interesting bug regarding propel and entitymapping wich can cause that data is not saved. Has someone time so i can explain this issue, so that it can be addressed?
Best Answer
Answers
-
Hello @USX5CJLS1,
Could you please open a support ticket with us and we will get back to you
http://support.spryker.com/0 -
If it is related to the
sync:data
command there is a fix in the next major release for propel entity mapping.0 -
No something else, i will write it here:
0 -
i also created a supportticket for this, but fyi : i am not sure if this is fixed in the latest versions, i checked the latest implementations in the affected classes and i do not think so.
- In propel xml-schema xml-files you can use "defaultValue"-attribute for column-tags
- this results for persistence-baseclasses (the ones implementing \Propel\Runtime\ActiveRecord\ActiveRecordInterface) that the constructor calls applyDefaultValues()-Method with the defined defaultvalues
- for example we have a table with one integer column called "columnA" with a xml-definition like this: ""
- if you built a a EnityManager-class for the table with this column extending \Spryker\Zed\Kernel\Persistence\AbstractEntityManager and use save-Method, this calls \Spryker\Zed\Kernel\Persistence\EntityManager\TransferToEntityMapper::mapEntityCollection and this calls \Spryker\Zed\Kernel\Persistence\EntityManager\TransferToEntityMapper::mapEntityΒ
- \Spryker\Zed\Kernel\Persistence\EntityManager\TransferToEntityMapper::mapEntity uses fromArray() to map the data into EntityTransfer-Object, if there is a defaultValue defined and you want to save this default-value the column is not marked as "modifiedProperty" and therefore it is NOT added into the database INPUT-Statmenent , so if you want to save values, defined as dafaultValue this values are not saved
Actual Behaviour: For Example:
- Table with a column defined as Β
- i persist value "2" into this database column
- i persist value "0" int this database column, this does not work, the value remains 2
Expected Behaviour: For Example:
- Table with a column defined as Β
- i persist value "2" into this database column
- i persist value "0" int this database column, this works, the value 0 i saved to the databasecolumn
To Reproduce: For Example:
- Table with a column defined as Β
- i persist value "2" into this database column
- i persist value "0" int this database column, this does not work, the value remains 2
0 -
thx - received that one
0 -
any news on this? i didnt get an issue number
0 -
Not yet unfortunately. Clarifying with our development as I can't reproduce the problem. But I'm not a developer unfortunately, so I'm waiting for their feedback.
0 -
Iβve noticed this issue yesterday and was just about to create a bug ticket before noticing it reported here. @USX5CJLS1 your example might not be completely correct. The issue occurs when attempting to update an existing entity that has fields with a default value. Inserting a new entity works.
0 -
The fix is almost or is ready to be released.
0 -
-
Thank you, we will add it into our project :-)
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 69 Spryker News
- 899 Developer Corner
- 760 Spryker Development
- 83 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 24 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random