Unknown column 'first_name'...

Scott M. Sanders - May 13, 2009 - 15:38
Project:Ubercart Addresses
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

Hi. Adding or entering addresses gives the error in the issue title and fails terminally with Ubercart 2.0 RC3.

Looking at the Drupal database, it seems that all the address fields have newly been suffixed with "delivery_", such that the correct column should now be "delivery_first_name?"

#1

Scott M. Sanders - May 13, 2009 - 17:00

Okay, having now taken a more detailed look at the code of this module, it looks like uc_addresses is actually supposed to have columns/fields like "first_name," etc. due to different address types like delivery and billing.

So how my Drupal database's uc_addresses ended up with "delivery_" suffixes I dunno, though I did do a straight upgrade from d5uc1 to d6uc2 which seemed to work 99% okay.

So I edited the structure of uc_addresses in my Drupal database (with phpMyAdmin) accordingly to mirror that of my old d5 database (field name and type particularly), and everything now seems to be working okay.

I think this issue should remain open to see if anyone else would have the same issue. I updated my Drupal database twice from d5 to d6 with same results.

#2

plasticlax - November 24, 2009 - 23:29

same problem. i had to remove the "delivery_" prefix in the uc_addresses table. not sure if that was the right thing to do but it works without errors now.

#3

kanani - November 29, 2009 - 19:16

Looks like the field names were changed as part of the First Drupal 6 Update uc_address.install line 176

/**
* First Drupal 6 update: standardize database definitions as per uc_orders
*/
function uc_addresses_update_6000() {
  db_drop_primary_key($ret, 'uc_addresses');
  db_drop_index($ret, 'uc_addresses', 'aid_uid_idx');
  db_change_field($ret, 'uc_addresses', 'aid', 'aid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('aid')));
  db_change_field($ret, 'uc_addresses', 'uid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
  db_change_field($ret, 'uc_addresses', 'first_name', 'delivery_first_name', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'last_name', 'delivery_last_name', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'phone', 'delivery_phone', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'company', 'delivery_company', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'street1', 'delivery_street1', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'street2', 'delivery_street2', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'city', 'delivery_city', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'zone', 'delivery_zone', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'medium', 'not null' => TRUE, 'default' => 0));
  db_change_field($ret, 'uc_addresses', 'postal_code', 'delivery_postal_code', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
  db_change_field($ret, 'uc_addresses', 'country', 'delivery_country', array('type' => 'int', 'unsigned' => TRUE, 'size' => 'medium', 'not null' => TRUE, 'default' => 0));
  db_add_index($ret, 'uc_addresses', 'aid_uid_idx', array('aid', 'uid'));

  db_drop_primary_key($ret, 'uc_addresses_defaults');
  db_change_field($ret, 'uc_addresses_defaults', 'aid', 'aid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE));
  db_change_field($ret, 'uc_addresses_defaults', 'uid', 'uid', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0));
  db_add_primary_key($ret, 'uc_addresses_defaults', array('aid', 'uid'));

  return $ret;
}

The comment says this was done to standardize with uc_orders, so looks like the module source code should be updated to reflect the naming change as well.

#4

kanani - November 29, 2009 - 22:16

untested patch attached. Basically it changes the instances that interact with the database from first_name -> delivery_first_name, last_name -> delivery_last_name, etc.

Will try and run simpletest against the patch when I have time.

AttachmentSize
uc_addressdelivery.patch 3 KB
 
 

Drupal is a registered trademark of Dries Buytaert.