File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,19 @@ public function addProperty($name, $type)
35
35
$ this ->parseFormat ();
36
36
}
37
37
38
+ public function removeProperty ($ name )
39
+ {
40
+ $ format = $ this ->getFormat ();
41
+ $ last = array_pop ($ format );
42
+ if ($ last ['name ' ] != $ name ) {
43
+ throw new Exception ("Remove only last property " );
44
+ }
45
+ $ this ->mapper ->getClient ()->evaluate ("box.space[ $ this ->id ]:format(...) " , [$ format ]);
46
+ $ this ->format = $ format ;
47
+
48
+ $ this ->parseFormat ();
49
+ }
50
+
38
51
public function removeIndex ($ name )
39
52
{
40
53
$ this ->mapper ->getClient ()->evaluate ("box.space[ $ this ->id ].index. $ name:drop() " );
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use Exception ;
4
3
use Tarantool \Mapper \Mapper ;
5
4
use Tarantool \Mapper \Space ;
6
5
7
6
class SchemaTest extends TestCase
8
7
{
8
+ public function testRemoveProperty ()
9
+ {
10
+ $ mapper = $ this ->createMapper ();
11
+ $ this ->clean ($ mapper );
12
+
13
+ $ space = $ mapper ->getSchema ()->createSpace ('tester ' );
14
+ $ space ->addProperty ('first ' , 'unsigned ' );
15
+ $ space ->addProperty ('second ' , 'unsigned ' );
16
+ $ space ->addProperty ('third ' , 'unsigned ' );
17
+
18
+ $ this ->assertCount (3 , $ space ->getFormat ());
19
+
20
+ $ space ->removeProperty ('third ' );
21
+ $ this ->assertCount (2 , $ space ->getFormat ());
22
+
23
+ $ this ->expectException (Exception::class);
24
+ $ space ->removeIndex ('first ' );
25
+ }
26
+
9
27
public function testRemoveIndex ()
10
28
{
11
29
$ mapper = $ this ->createMapper ();
You can’t perform that action at this time.
0 commit comments