View Issue Details

IDProjectCategoryView StatusLast Update
0001989OXID eShop (all versions)1. ----- eShop frontend -----public2012-12-10 14:38
Reporterdominik_ziegler 
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionno change required 
Product Version4.4.0 revision 28699 
Target VersionFixed in Version 
Summary0001989: oxBase::_getUpdateFieldValue() does not respect database default value
DescriptionThe method _getUpdateFieldValue in oxBase class sets the value for a database field if it is not set via the object for example $oArticle->oxarticle__oxactive->value.

If the field value is not set, the value gets a) "null" if the column is not configured with NOT NULL or b) 0 due to quoting an empty variable.

At this point OXID have to check if the requested column has a default value and return its value instead of returning 0. If you create an article in an backend module and don't set oxarticles.OXACTIVE to 1 the save() operation of the article object results in saving the article with oxarticles.OXACTIVE = 0 even the database default value is 1.

Please provide a fallback to the default value. With the default ADODB database table definition data this information is still provided and simply must be read out (has_default and default_value) in this method.
Steps To Reproduce$oArticle = oxNew('oxArticle');
$oArticle->setId();
$oArticle->oxarticles__oxtitle = new oxField('Test article');
$oArticle->save();

Saving this in admin environment (isAdmin() must be true) results in saving the article with oxarticles.OXACTIVE = 0 even its column default value is 1.
TagsNo tags attached.
Theme
BrowserAll
PHP Versionany
Database Versionany

Relationships

related to 0002434 resolvedLinas Kukulskis oxbase::_insert ignores database-default-values 

Activities

dainius.bigelis

2010-09-01 11:35

reporter   ~0003460

This fix needs important DB changes, so can be implemented only in some Upgrades (i.e. 5th version eShop). Until then this entry is suspended.

dominik_ziegler

2010-09-03 17:16

reporter   ~0003478

I thought this is a minor change in the described method in oxBase.

tomas_liubinas

2010-09-06 16:21

reporter   ~0003480

Last edited: 2010-09-06 16:21

View 2 revisions

It's a nice idea, there are a few ways to solve this problem.
1. Init empty object and use only set fields when saving.
2. Load default DB values on oxbase object init.

dainius.bigelis

2010-09-10 17:22

reporter   ~0003505

(sorry, note about DB change was my mistake).
It's very good idea and would be good to have it implemented in the eShop. But as we talked inside the team - to have this working properly - need some wider changes in the core functionality of eShop (i.e. improve lazy loading in entire eShop). So such changes can be implemented only in some major eShop version, like 5th.
For now it's is moved to the list of improvements for implementing in future version. Here the entry is closed.
Thank you for suggestion.