Skip to content

Queue SerializesAndRestoresModelIdentifiers id column name doesnt exist #42978

Closed
@HthSolid

Description

@HthSolid
  • Laravel Version: 9.17.0
  • PHP Version: 8.1.7
  • Database Driver & Version: mysql , MariaDB 10.1.48-MariaDB-0+deb9u2

Description:

When you call a get() in eloquent DB with a wherein outside of a queue, then use the results inside of a queue with a custom id column name like "sotb_id" that is not "id" and doesnt have a column named "id", the SerializesAndRestoresModelIdentifiers.php from vendor\laravel\framework\src\Illuminate\Queue
will translate it inside of the queue to call the id column which in this table doesnt exist and therefore will cause an error.

Steps To Reproduce:

Outside function:
$myList = SomeTable::whereIn('sotb_id', $myListofIDs)->where('is_something', 0)->where('is_else', 0)->select('sotb_id', 'some_info')->get();
myQueue::dispatch($myList)

Inside Queue: App/Jobs/VerifyJob.php

foreach($this->myList as $key => $value) {
//something
}

Detailed Error:

[2022-06-27 15:35:38] production.CRITICAL: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sometable.id' in 'where clause' (SQL: select * from sometable where sometable.id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?))
[2022-06-27 15:35:38] production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sometable.id' in 'where clause' (SQL: select * from sometable where sometable.id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) {"exception":"[object] (Illuminate\Database\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sometable.id' in 'where clause' (SQL: select * from sometable where sometable.id in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) at /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php:742)
[stacktrace]
#0 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php(702): Illuminate\Database\Connection->runQueryCallback()
#1 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Connection.php(404): Illuminate\Database\Connection->run()
#2 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2630): Illuminate\Database\Connection->select()
#3 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2618): Illuminate\Database\Query\Builder->runSelect()
#4 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3154): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#5 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2619): Illuminate\Database\Query\Builder->onceWithColumns()
#6 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(698): Illuminate\Database\Query\Builder->get()
#7 /httpdocs/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(682): Illuminate\Database\Eloquent\Builder->getModels()
#8 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(74): Illuminate\Database\Eloquent\Builder->get()
#9 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php(56): App\Jobs\VerifyEmailJob->restoreCollection()
#10 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php(126): App\Jobs\VerifyEmailJob->getRestoredPropertyValue()
#11 [internal function]: App\Jobs\VerifyJob->__unserialize()
#12 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(96): unserialize()
#13 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(59): Illuminate\Queue\CallQueuedHandler->getCommand()
#14 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\Queue\CallQueuedHandler->call()
#15 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(428): Illuminate\Queue\Jobs\Job->fire()
#16 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(378): Illuminate\Queue\Worker->process()
#17 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(172): Illuminate\Queue\Worker->runJob()
#18 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(130): Illuminate\Queue\Worker->daemon()
#19 /httpdocs/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(114): Illuminate\Queue\Console\WorkCommand->runWorker()
#20 /httpdocs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#21 /httpdocs/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#22 /httpdocs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
#23 /httpdocs/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
#24 /httpdocs/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\Container\BoundMethod::call()
#25 /httpdocs/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call()
#26 /httpdocs/vendor/symfony/console/Command/Command.php(308): Illuminate\Console\Command->execute()
#27 /httpdocs/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()
#28 /httpdocs/vendor/symfony/console/Application.php(998): Illuminate\Console\Command->run()
#29 /httpdocs/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()
#30 /httpdocs/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#31 /httpdocs/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\Component\Console\Application->run()
#32 /httpdocs/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run()
#33 /httpdocs/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
#34 {main}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions