Skip to content

Commit eec6f77

Browse files
committed
default field configuration fix
1 parent b32e953 commit eec6f77

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Space.php

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public function addProperty(string $name, string $type, array $config = [])
7070
throw new Exception("Duplicate property $name");
7171
}
7272

73+
if (array_key_exists('default', $config) && !is_string($config['default'])) {
74+
$config['default'] = (string) $config['default'];
75+
}
76+
7377
$this->format[] = $config;
7478
$this->mapper->client->call("box.space.$this->name:format", $this->format);
7579

tests/MapperTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function createMapper(
3535
return $mapper;
3636
}
3737

38+
public function testDefaults()
39+
{
40+
$mapper = $this->createMapper();
41+
$tester = $mapper->createSpace('tester');
42+
$tester->addProperty('id', 'unsigned');
43+
$tester->addProperty('number', 'unsigned', ['default' => 0]);
44+
$tester->addProperty('string', 'string', ['default' => '']);
45+
}
46+
3847
public function testCache()
3948
{
4049
$mapper = $this->createMapper(dropUserSpaces: false);

0 commit comments

Comments
 (0)