F
Filament10mo ago
Andi

Import update if exists not working with database driver

Hi guys I'm on Filament v3.2.34, so latest release. When using sync queue driver, the record gets updated, but as soon as I use the database driver, there is always a new record created. This is my code:
public function resolveRecord(): ?Sale
{
return Sale::firstOrNew([
'shop_id' => $this->options['shop_id'],
'sales_date' => $this->data['sales_date'],
]);
}
public function resolveRecord(): ?Sale
{
return Sale::firstOrNew([
'shop_id' => $this->options['shop_id'],
'sales_date' => $this->data['sales_date'],
]);
}
Do you guys know a workaround or is it a bug?
Solution:
.... it was the global scope which interefered....
Jump to solution
6 Replies
Andi
AndiOP10mo ago
bump bump
Patrick
Patrick10mo ago
have you tried any of the other similar methods updateOrCreate for example and if those records are created, are they identical ? at least those 2 fields
Andi
AndiOP10mo ago
Yes, the records are identical. I tried firstOrCreate, firstOrNew and now also updateOrCreate. Non of them work. I also noted that when I dump the results of the query, with sync I get 1 item back, the one needed. As soon as I switch to DB driver, the query result is emtpy. So therefore it creates a new record.
Patrick
Patrick10mo ago
sounds like there is a rollback happening in mysql or a transaction started but not commited
Andi
AndiOP10mo ago
well I think the process where the queue runs on can't query the data.
Solution
Andi
Andi10mo ago
.... it was the global scope which interefered.
Want results from more Discord servers?
Add your server