VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: melix on December 23, 2024, 14:38:45 PM

Title: 1048 Column 'ordering' cannot be null
Post by: melix on December 23, 2024, 14:38:45 PM
Joomla 4x and Virtuemart 4x
I found this... 1048 Column 'ordering' cannot be null
When i tried this :

Reset booleans storing if main table needs to load an xref table. It also recreates the new category optimisations by rebuilding from category_categories table

In the database, the 'ordering' column is set to NOT NULL, the problem come from :

administrator/components/com_virtuemart/models/updatesmigration.php

At this block code :
$q = 'UPDATE #__virtuemart_categories SET `has_children`=NULL,`has_medias`=NULL, `category_parent_id`=NULL, `ordering`=NULL';
$db->setQuery($q);
$db->execute();

I replaced with :
$q = 'UPDATE #__virtuemart_categories SET `has_children`=NULL,`has_medias`=NULL, `category_parent_id`=NULL';
$db->setQuery($q);
$db->execute();

Is it safe this way ?
Title: Re: 1048 Column 'ordering' cannot be null
Post by: hazael on December 23, 2024, 19:02:14 PM
$q = 'UPDATE #__virtuemart_categories
      SET `has_children`=NULL,
          `has_medias`=NULL,
          `category_parent_id`=NULL,
          `ordering`=0';
$db->setQuery($q);
$db->execute();

The modified query sets ordering=0 instead of NULL to avoid potential issues with the database schema if the column ordering is defined as NOT NULL.
Title: Re: 1048 Column 'ordering' cannot be null
Post by: melix on December 24, 2024, 10:34:54 AM
Thanks mate !
But, the old 'ordering' settings (hand made) will be lost or not ?
Title: Re: 1048 Column 'ordering' cannot be null
Post by: hazael on December 25, 2024, 14:28:48 PM
this is just the numbering of the order of added categories. Nothing will happen even if your values are duplicated. This is only useful in the admin panel. "0" is the default value for the first created item and from there each subsequent one has 1, 2 and so on.