uc_store_schema contains the following declaration:

  $schema['uc_countries'] = array(
    'fields' => array(
      'country_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      ...
  );

The 'serial' type specifically refers to auto_increment fields. I guess that at some point in the past this was an arbitrary ID, but since then it has been repurposed to reference ISO-3166 numeric IDs.

This distinction doesn't make much difference at the moment, since the official Ubercart policy on country def files is still to INSERT the data directly using a db_query() call, but if the country system is ever to be updated to use the drupal_write_record() function it's a change that will have to be made.

TBH the whole country system should be updated so it's less of a manual insert process and more of a "declare values to be imported" thing - not unlike a hook_schema implementation - but that's a matter for another time.

CommentFileSizeAuthor
#3 610664_serial_country_id.patch1.05 KBIsland Usurper

Comments

kingandy’s picture

For "it's a change that will have to be made" read "this should be changed to an 'int' type field". I could have sworn I'd actually mentioned that earlier in the issue. Memory's the first thing to go, evidently.

(With a 'serial' field, any call to drupal_write_record() actively ignores any value in the field in favour of the internal auto_incremented sequence. I learned this to my cost when I was trying to manually add some arbitrary countries...)

rszrama’s picture

Yeah, this should be fixed before the 2.0 release.

Island Usurper’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB

I hate having to switch on $GLOBALS['db_type'] anymore, but there's not much I can do about it in this case. I really hope they've made this task easier in Drupal 7.

rszrama’s picture

Status: Needs review » Fixed

Update patch worked fine for me. Committing.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.