File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -263,10 +263,22 @@ public function save($instance)
263263 {
264264 $ tuple = [];
265265
266+ $ format = $ this ->space ->getFormat ();
267+
268+ // complete indexes fields
269+ foreach ($ this ->space ->getIndexes () as $ index ) {
270+ foreach ($ index ->parts as $ part ) {
271+ $ name = $ format [$ part [0 ]]['name ' ];
272+ if (!property_exists ($ instance , $ name )) {
273+ $ instance ->{$ name } = null ;
274+ }
275+ }
276+ }
277+
266278 $ size = count (get_object_vars ($ instance ));
267279 $ skipped = 0 ;
268280
269- foreach ($ this -> space -> getFormat () as $ index => $ info ) {
281+ foreach ($ format as $ index => $ info ) {
270282 if (!property_exists ($ instance , $ info ['name ' ])) {
271283 $ skipped ++;
272284 $ instance ->{$ info ['name ' ]} = null ;
Original file line number Diff line number Diff line change 77
88class MapperTest extends TestCase
99{
10+ public function testNullIndexedValuesFilling ()
11+ {
12+ $ mapper = $ this ->createMapper ();
13+ $ this ->clean ($ mapper );
14+
15+ $ mapper ->getSchema ()
16+ ->createSpace ('rules ' , [
17+ 'id ' => 'unsigned ' ,
18+ 'module ' => 'unsigned ' ,
19+ 'rule ' => 'unsigned ' ,
20+ ])
21+ ->addIndex ('id ' )
22+ ->addIndex ('module ' )
23+ ->addIndex ('rule ' );
24+
25+ $ rule = $ mapper ->create ('rules ' , [
26+ 'id ' => 1 ,
27+ 'module ' => 1
28+ ]);
29+ $ this ->assertSame ($ rule ->rule , 0 );
30+ }
31+
1032 public function testTypesCasting ()
1133 {
1234 $ mapper = $ this ->createMapper ();
You can’t perform that action at this time.
0 commit comments