Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Module - Database Field Problem with Null

 
Reply
   X-Cart forums > X-Cart 5 > Third Party Add-Ons for X-Cart 5
 
Thread Tools Search this Thread
  #1  
Old 01-06-2017, 07:45 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Module - Database Field Problem with Null

I have had a module for a while that I wrote that creates a "Products Per Case" ppcField field in xcProducts .. For some reason everytime I update the site (or disable a module) it attempts to reset this field to Not Null (this field can be null and default is set to Null). How do I prevent Xcart redeploy (step 5 I believe) to stop trying to set this field to Not Null?

Here is the error in the php_error log

Code:
[06-Jan-2017 15:33:21] Error (code: 0): An exception occurred while executing 'ALTER TABLE xc_products CHANGE PPCField PPCField VARCHAR(32) NOT NULL': SQLSTATE[22004]: Null value not allowed: 1138 Invalid use of NULL value Server API: fpm-fcgi; Request method: GET; URI: /admin.php?target=addons_list_installed&__cache_key__=82b5339fc4a155b03641a06c2c6b47ad&cpid=34d5b4bb4d90caf09248f04d54627d4c; Backtrace: #0 /home/numus/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php(116): Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\DBAL\Driver\PDOException)) #1 /home/numus/public_html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(836): Doctrine\DBAL\DBALException::driverExceptionDuringQuery(Object(XLite\Core\PDOMySqlDriver), Object(Doctrine\DBAL\Driver\PDOException), 'ALTER TABLE xc_...', Array) #2 /home/numus/public_html/var/run.82b5339fc4a155b03641a06c2c6b47ad/classes/XLite/Core/Connection.php(51): Doctrine\DBAL\Connection->executeQuery('ALTER TABLE xc_...', Array, Array, NULL) #3 /home/numus/public_html/var/run.82b5339fc4a155b03641a06c2c6b47ad/classes/XLite/Core/DatabaseAbstract.php(657): XLite\Core\Connection->executeQuery('ALTER TABLE xc_...') #4 /home/numus/public_html/Includes/Decorator/Plugin/Doctrine/Plugin/UpdateSchema/Main.php(28): XLite\Core\DatabaseAbstract->executeQueries(Array) #5 /home/numus/public_html/Includes/Decorator/Utils/PluginManager.php(62): Includes\Decorator\Plugin\Doctrine\Plugin\UpdateSchema\Main->executeHookHandler() #6 /home/numus/public_html/Includes/Decorator/Utils/CacheManager.php(981): Includes\Decorator\Utils\PluginManager::invokeHook('step_fifth') #7 [internal function]: Includes\Decorator\Utils\CacheManager::executeStepHandler5() #8 /home/numus/public_html/Includes/Utils/Operator.php(213): call_user_func_array(Array, Array) #9 /home/numus/public_html/Includes/Decorator/Utils/CacheManager.php(826): Includes\Utils\Operator::executeWithCustomMaxExecTime('600', Array) #10 /home/numus/public_html/Includes/Decorator/Utils/CacheManager.php(845): Includes\Decorator\Utils\CacheManager::runStep(5) #11 /home/numus/public_html/Includes/Decorator/Utils/CacheManager.php(1188): Includes\Decorator\Utils\CacheManager::runStepConditionally(5) #12 /home/numus/public_html/top.inc.PHP53.php(90): Includes\Decorator\Utils\CacheManager::rebuildCache() #13 /home/numus/public_html/top.inc.php(26): require_once('/home/numus/pub...') #14 /home/numus/public_html/admin.php(16): require_once('/home/numus/pub...') #15 {main}
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #2  
Old 01-08-2017, 10:31 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Module - Database Field Problem with Null

How does your Model class (the one that adds the field) look like?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #3  
Old 01-09-2017, 06:32 AM
  GlasPak's Avatar 
GlasPak GlasPak is offline
 

eXpert
  
Join Date: May 2015
Posts: 241
 

Default Re: Module - Database Field Problem with Null

Quote:
Originally Posted by qualiteam
How does your Model class (the one that adds the field) look like?

Code:
<?php // vim: set ts=4 sw=4 sts=4 et: namespace XLite\Module\EBLIEB\GlasPak\Model; class Product extends \XLite\Model\Product implements \XLite\Base\IDecorator { /** * @Column (type="string", length=32) */ protected $PPCField; /** * Updates "Pieces per case" field. * * @param string $value New value * * @return void */ public function setPPCField($value) { $this->PPCField = $value; } /** * Returns the value of "Pieces per case" field. * * @return string */ public function getPPCField() { return $this->PPCField; } }

http://devs.x-cart.com/en/basics/understanding_models.html - This doesn't seem to reference Not Null vs Null...

Edit:

Does Xlite follow the doctrine? http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/annotations-reference.html

Would this work to my PPCField set to null?

Code:
{ /** * @Column (type="string", length=32, nullable=true) */ protected $PPCField;
__________________
Business License
https://glaspak.com
GoDaddy VPS - Apache with WHM
2GB ECC DDR3 1600MHz
2x Intel E5-2630L v2 Hex Core 2.4/2.8ghz
15 MB proc cache
60 GB 10k RPM hdd
PHP 7.0.15
MariaDB 10.1.21 with InnoDB engine
Reply With Quote
  #4  
Old 01-10-2017, 11:57 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Module - Database Field Problem with Null

Quote:
Would this work to my PPCField set to null?
Code:
@Column (type="string", length=32, nullable=true)

Yes, this should work.

Also, if you need the opposite, you can it like this:
Code:
@Column (type="integer", options={ "unsigned": true, "default": 0 })
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Third Party Add-Ons for X-Cart 5


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:18 PM.

   

 
X-Cart forums © 2001-2020