pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
304 stars 444 forks source link

Consider to change the return value when Eloquent model is updated #10487

Open Vitaliy-1 opened 2 weeks ago

Vitaliy-1 commented 2 weeks ago

Describe the bug Originally, when eloquent model is updated, the method returns the number of updated rows from the primary table. E.g.,

Announcement::where('type_id', '=', '1')->update([
  'title' => 'Announcement Title'
  'type_id' => '2'
])

After refactoring, Models that are utilising settings table, will return the number of updated rows from the primary table and settings table.

  1. Explore if this has any drawbacks.
  2. Consider alternative option, return associative array with the number of updated rows from primary and settings table (https://github.com/pkp/pkp-lib/pull/10382#discussion_r1771402157)

What application are you using? OJS main branch

touhidurabir commented 1 week ago

I think we should try to preserve the default behaviours of Eloquent and Builders as much as possible and if need to changed, should be changed for all cases . Having the update return 2 different types of value structure (int and array) only given that when there is settings table associated will make it harder to track how to use the return values .