Skip to content

Commit 5345eb4

Browse files
authored
Add typecast to string in the ORM schema (#77)
1 parent 32cff8f commit 5345eb4

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Generator/GenerateTypecast.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ private function typecast(AbstractColumn $column)
7373
return 'datetime';
7474
}
7575

76+
if ($column->getType() === AbstractColumn::STRING) {
77+
return 'string';
78+
}
79+
7680
return null;
7781
}
7882
}

tests/Schema/Generator/TypecastGeneratorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function testCompiledUser(): void
2828
$this->assertSame('int', $schema['user'][Schema::TYPECAST]['p_id']);
2929
$this->assertSame('float', $schema['user'][Schema::TYPECAST]['p_balance']);
3030
$this->assertSame('datetime', $schema['user'][Schema::TYPECAST]['p_created_at']);
31+
$this->assertSame('string', $schema['user'][Schema::TYPECAST]['p_name']);
3132

3233
$this->assertTrue(in_array($schema['user'][Schema::TYPECAST]['p_id'], ['int', 'bool']));
3334
}

0 commit comments

Comments
 (0)