Running drush mi BeerUser reports:

Imported 0 (3 failed) in 0.4 sec (484/min) - done with 'BeerUser'

Looking at the messages, I see three very similar messages. Here's one:

Incorrect integer value: '' for column 'uid' at row 1 query: INSERT INTO users (name, status, created, mail, pass, uid, access) VALUES ('alice', 1, 1269970265, 'alice@example.com', '7c90f2dc82aa5dd4501132f6d074a53a', '', 1287009962) File /.../drupal/includes/database.mysqli.inc, line 128

Comments

adamdicarlo’s picture

I wasn't able to track down the cause of the problem today, but I'll investigate more tomorrow. Any ideas?

adamdicarlo’s picture

The WineUser migration gives the same error, with each item failing. I'm on dbtng-6.x-1.0-alpha7. I tried alpha6 (no go, it crashes), checking out DRUPAL-6--1 dbtng, same result. I'll assume for now dbtng isn't the problem and I'll step through the migration code.

adamdicarlo’s picture

StatusFileSize
new597 bytes

Seems to be because of what might be considered a bug in user_save(): if isset($array['uid']), then core will add uid to the query as a string (thus '%s' with NULL becomes ''). Ugh. I don't see an issue filed in core for this, though. It's bitten me before, actually, and I thought of it as simply a quirk.

Here's a patch for migrate that mitigates the problem.

adamdicarlo’s picture

Status: Active » Needs review
moshe weitzman’s picture

It is possible that this fix is good for d6 but gives a notice for d7 (if the code comment can be believed)

moshe weitzman’s picture

Assigned: Unassigned » moshe weitzman
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new754 bytes

I was seeing a similar (but not same) problem in my user migration and this patch fixes it. Actually, a reverse apply of your patch fixes it. I am guessing that you just reversed your files when generating the patch. Here is new patch. I will commit this when my tree is more up to date.

moshe weitzman’s picture

StatusFileSize
new754 bytes

I was seeing a similar (but not same) problem in my user migration and this patch fixes it. Actually, a reverse apply of your patch fixes it. I am guessing that you just reversed your files when generating the patch. Here is new patch. I will commit this when my tree is more up to date.

adamdicarlo’s picture

Status: Reviewed & tested by the community » Needs review

My patch is fine (it is as intended; I've used it with drush make already) -- check out the logic in Drupal 6's user_save() to see why $account['uid'] being set (even set to NULL) causes user_save() to generate a broken query....

mikeryan’s picture

Status: Needs review » Postponed (maintainer needs more info)

I cannot reproduce this with the latest D6 core, or with what I had before doing a cvs update (months old). What version of D6 are you using? Do you still get this problem with the latest? Also, what version of MySQL are you using?

Thanks.

adamdicarlo’s picture

OK. I just tried mysql> INSERT INTO users (uid, name, mail) VALUES ('', 'foo', 'bar'); in three different environments.

Apparently, inserting '' for uid works only in some MySQL versions. I'm using MariaDB on my development machine, but I'm not sure if the problem is Maria, or if it's the version of MySQL this Maria is based on. Perhaps a configuration setting that makes warning 1366 an error.

My development machine:

  • Ubuntu 9.10 i686, PHP 5.2.10-2ubuntu6.5 with Suhosin-Patch 0.9.7
  • mysql Ver 14.16 Distrib 5.1.49-MariaDB, for debian-linux-gnu (i486) using readline 5.1
MariaDB [sandbox_ni]> INSERT INTO users (uid, name, mail) VALUES ('', 'foo', 'bar');
ERROR 1366 (HY000): Incorrect integer value: '' for column 'uid' at row 1

Two other environments both succeed with a warning:

  • Ubuntu 8.04 x86_64, mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (x86_64) using readline 5.2
  • Ubuntu 10.04.1 LTS i686, mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1
mysql> \W
Show warnings enabled.
mysql> INSERT INTO users (uid, name, mail) VALUES ('', 'foo', 'bar');
Query OK, 1 row affected, 1 warning (0.05 sec)

Warning (Code 1366): Incorrect integer value: '' for column 'uid' at row 1

So I think the question is: Should trying to insert '' for uid be considered a bug in migrate?

chrisnovak’s picture

I just created my first import using 6.x-2.0-beta1 of users from mediawiki into drupal by following the BeerUser example, and got this error.

I used the migrate.940984-3.patch adamdicarlo posted, and now all of my data is importing.

My development machine:

  • Windows7 Home Premium
  • MySQL 5.1.48-community version

I ran INSERT INTO users (uid, name, mail) VALUES ('', 'foo', 'bar') and got the following error:

Error Code: 1062
Duplicate entry '0' for key 'PRIMARY')
mikeryan’s picture

Assigned: moshe weitzman » mikeryan
Status: Postponed (maintainer needs more info) » Fixed

OK, simpletests (and manual test) pass with this patch, committed. Thanks!

Status: Fixed » Closed (fixed)

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

adamdicarlo’s picture

Title: Migrate Example BeerUser is broken -- tries to insert '' into users.uid » User destination fails -- tries to insert '' into users.uid
Version: 6.x-2.x-dev » 6.x-2.0-rc2
Status: Closed (fixed) » Active
StatusFileSize
new505 bytes

The problem is back in 6.x-2.0-rc2 due to this new code:

    // Avoid a notice
    if (!isset($account->uid)) {
      $account->uid = NULL;
    }

I think that D6's user_save() isn't going to let that notice be avoided *and* generate the proper query. (Maybe there is a way, I don't know, but for now I have to patch migrate.)

I've rerolled and attached a new patch.

adamdicarlo’s picture

StatusFileSize
new505 bytes

Whoops -- I guess hitting "Preview" when attaching a file was a bad idea. Here's the patch.

mikeryan’s picture

Status: Active » Needs review
StatusFileSize
new1020 bytes

OK, I think I've got an answer that addresses the notices as well as your problem, please try the attached patch.

mikeryan’s picture

Status: Needs review » Fixed

I went ahead and committed, I want to get a new release out today. Please try rc3 when it's available and reopen this issue if you still have trouble.

Thanks.

Status: Fixed » Closed (fixed)

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