File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -731,7 +731,7 @@ protected function shouldUpdate($row): bool
731731 {
732732 $ id = $ this ->getIdValue ($ row );
733733
734- return ! ($ id === null || $ id === []);
734+ return ! ($ id === null || $ id === [] || $ id === '' );
735735 }
736736
737737 /**
Original file line number Diff line number Diff line change @@ -42,6 +42,24 @@ public function testSaveNewRecordObject(): void
4242 $ this ->seeInDatabase ('job ' , ['name ' => 'Magician ' ]);
4343 }
4444
45+ /**
46+ * @see https://github.com/codeigniter4/CodeIgniter4/issues/8613
47+ */
48+ public function testSaveNewRecordArrayWithEmptyStringId (): void
49+ {
50+ $ this ->createModel (JobModel::class);
51+
52+ $ data = [
53+ 'id ' => '' ,
54+ 'name ' => 'Magician ' ,
55+ 'description ' => 'Makes peoples things dissappear. ' ,
56+ ];
57+
58+ $ this ->model ->save ($ data );
59+
60+ $ this ->seeInDatabase ('job ' , ['name ' => 'Magician ' ]);
61+ }
62+
4563 public function testSaveNewRecordArray (): void
4664 {
4765 $ this ->createModel (JobModel::class);
You can’t perform that action at this time.
0 commit comments