F
Filament4mo 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
Andi4mo ago
bump bump
Patrick1989
Patrick19894mo 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
Andi4mo 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.
Patrick1989
Patrick19894mo ago
sounds like there is a rollback happening in mysql or a transaction started but not commited
Andi
Andi4mo ago
well I think the process where the queue runs on can't query the data.
Solution
Andi
Andi4mo ago
.... it was the global scope which interefered.
Want results from more Discord servers?
Add your server
More Posts
Custom Action in the Resource Edit PageI’m new to Filament but so impressed with what it can do. Working on an Application resource & need Is it possible to add a default emptyStateHeading for all the tables?Hello I know how to edit emptyStateHeading explained here https://filamentphp.com/docs/3.x/tables/emHow to align TextInput to the right side?Adding `->extraAttributes(['class' => 'text-right'])` didn't work.Specify 'id' col for editpageI have a resource, which defines a join as part of its `getEloquentQuery`. Viewing records works jusVery slow server performance when rendering large number of rows and columns - slow blade renderingI have a client where one of the requirements is to regularly have views containing 100, 200 or somerich editor not displaying input field while embedded in Livewire componentI simply cut/paste from filament docs and inserted into an existing Livewire component. Everything wHow to set the value of the relationship form based on the parent form?I'm trying to pre-fill a relationship form based on the parent form. Tried with the following, but tSame field entered in varying formatsIs it possible for me to enter a field as a string or as a date, depending upon another field. I haRendering custom livewire page on a modal viewHi! I've created a custom livewire page displaying a map with route calculation using Google API. I can't see avatar after updateHello, I have a custom page for the profile. After save the form data the view throw an error **fila