Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDOException when dispatching job with DynamoDbModel model as argument #132

Closed
adrian7 opened this issue Feb 22, 2018 · 5 comments
Closed

Comments

@adrian7
Copy link
Contributor

adrian7 commented Feb 22, 2018

The exception is thrown from App\Jobs\Job->__wakeup (implemented in Illuminate\Queue\SerializesModels)

SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "dynamoTable" does not exist
LINE 1: select * from "dynamoTable" where "dynamoTable"."pkey" = $1

File:
vendor/illuminate/database/Connection.php in execute at line 330

@baopham
Copy link
Owner

baopham commented Feb 23, 2018

Can you show the code that leads to this error?

@adrian7
Copy link
Contributor Author

adrian7 commented Feb 23, 2018

Basically I was sending a model as an argument to job constructor and then, assigning it to a local var.

use App\Models\Dynamo\Feed;
use Illuminate\Contracts\Queue\ShouldQueue;

class UpdateFeedJob extends Job implements ShouldQueue
{

    protected $feed = NULL;

    public function __construct(Feed $feed) {
        $this->feed  = $feed;
    }

    public function handle(){
        //handle job
    }

}

@baopham
Copy link
Owner

baopham commented Feb 23, 2018

Ah ok.

For now, you can do this:

class UpdateFeedJob extends Job implements ShouldQueue
{
	use SerializesModels;

    protected $feed = NULL;

    public function __construct(Feed $feed) {
        $this->feed  = $feed;
    }

    public function handle(){
        //handle job
    }

	/**
	 * @override
	 */
    public function restoreModel($value)
    {
        return Feed::find($value->id);
    }
}

@baopham
Copy link
Owner

baopham commented Mar 1, 2018

Does it help? can this be closed?

@baopham
Copy link
Owner

baopham commented Mar 16, 2018

Looks like there's no issue now... Closing for now.

@baopham baopham closed this as completed Mar 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants