-
-
Notifications
You must be signed in to change notification settings - Fork 714
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
Unchanged columns logged when selecting a subset of columns #1095
Comments
In your model you can define it like bellow:
This worked for me even when we updating fields which are not in the select statement. |
Hi @KKSzymanowski, When you call |
@n41tik not true: DB::listen(function($q) {
dump($q->sql);
});
Faq::query()->get(['id', 'order']);
|
Hello everyone, I am presenting the same situation that @KKSzymanowski indicates, is there any way to resolve it? I tried @vishalw89 idea but it didn't work for me. Greetings, |
Hello everyone again, Considering this part
I have done the following in the method that returns the options
Do you think this could affect the general functioning of the project? |
Describe the bug
I have a table which has an
order
column. When I reorder the elements I update each model with the new order.Because the table has some large JSON columns I select only
id
andorder
columns for efficiency. I set the new order and save the model.The diffs created in the
activity_log
table look like this:From what I see laravel-activitylog fetches the model with all columns from the database before creating a log entry which kind of defeats the purpose of my "select list optimization" and produces an incorrect diff.
Generally I want these large JSON columns to be logged in case a user changes them but in this case I only change the
order
column so I would like to see only theorder
column in the diff.I have tried running these updates straight off the Eloquent builder:
but in this case nothing is logged.
I have the following activitylog configuration for my models:
To Reproduce
Select a subset of columns from the database, change these columns, save the model and see that other (not initially selected) columns are present in the diff.
Expected behavior
Only columns that've actually been changed should be present in the diff.
Versions
The text was updated successfully, but these errors were encountered: