1

Anybody know how to resolve the following when using Craft Commerce?

Running the command craft gc/run throws an error.

Next yii\db\Exception: SQLSTATE[HY000]: General error: 1093 You can't specify target table 'commerce_customers' for update in FROM clause
The SQL being executed was: DELETE FROM `commerce_customers` WHERE `id` IN (SELECT `customers`.`id` AS `id`
FROM `commerce_customers` `customers`
LEFT JOIN `commerce_orders` `orders` ON `customers`.`id` = `orders`.`customerId`
WHERE (`orders`.`customerId` IS NULL) AND (`customers`.`userId` IS NULL)) in /vendor/yiisoft/yii2/db/Schema.php:677
Stack trace:
#0 /vendor/yiisoft/yii2/db/Command.php(1298): yii\db\Schema->convertException(Object(PDOException), 'DELETE FROM `co...')
#1 /vendor/yiisoft/yii2/db/Command.php(1093): yii\db\Command->internalExecute('DELETE FROM `co...')
#2 /vendor/craftcms/commerce/src/services/Customers.php(383): yii\db\Command->execute()
#3 /vendor/craftcms/commerce/src/Plugin.php(670): craft\commerce\services\Customers->purgeOrphanedCustomers()
#4 [internal function]: craft\commerce\Plugin->craft\commerce\{closure}(Object(yii\base\Event))
#5 /vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(yii\base\Event))
#6 /vendor/yiisoft/yii2/base/Component.php(636): yii\base\Event::trigger('craft\\services\\...', 'run', Object(yii\base\Event))
#7 /vendor/craftcms/cms/src/services/Gc.php(74): yii\base\Component->trigger('run')
#8 /vendor/craftcms/cms/src/console/controllers/GcController.php(56): craft\services\Gc->run(true)
#9 [internal function]: craft\console\controllers\GcController->actionRun()
#10 /vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#11 /vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#12 /vendor/yiisoft/yii2/console/Controller.php(179): yii\base\Controller->runAction('run', Array)
#13 /vendor/craftcms/cms/src/console/Controller.php(188): yii\console\Controller->runAction('run', Array)
#14 /vendor/yiisoft/yii2/base/Module.php(528): craft\console\Controller->runAction('run', Array)
#15 /vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('gc/run', Array)
#16 /vendor/craftcms/cms/src/console/Application.php(88): yii\console\Application->runAction('gc/run', Array)
#17 /vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('gc/run', Array)
#18 /vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#19 /craft(23): yii\base\Application->run()
#20 {main}
Additional Information:
Array
(
    [0] => HY000
    [1] => 1093
    [2] => You can't specify target table 'commerce_customers' for update in FROM clause
2
  • This sounds like a bug - I'd suggest filing it on github.com/craftcms/commerce/issues along with that stack trace and the version of Craft and Commerce you're seeing it on. Going to go ahead and vote to close here.
    – Brad Bell
    Dec 24 '20 at 19:36
  • I'm seeing this error too, is it reported yet? Jan 4 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.