anlutro / laravel-settings

Persistent settings in Laravel
MIT License
940 stars 112 forks source link

Passing all digits in key causes error while updating settings later #140

Closed KailasRazorpay closed 4 years ago

KailasRazorpay commented 4 years ago

Reproducing the problem which I am been facing :

  1. Set key value pair with key having all digits (eg:- '123') and save.
  2. Set key value pair with key having at least one alphabet (eg:- 'abc') and save.
  3. Set key value pair again with any generic value (eg:- 'efg') and save.

On the third insertion, getting the error, "SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: 'abc' (SQL: update `settings` set `value` = , `updated_at` = 1589182653 where `entity_type` = {entity_type} and `entity_id` = {entity_id} and `module` = {module_type} and `key` = 123)"

This is due to implicit conversion of string into integer inside for loop for updating in write function().

This can be solved by explicit conversion of $key to string in write() function in DatabaseSettingsStore.php.

bweston92 commented 4 years ago

Fix is in v0.11.1