Skip to content

Commit

Permalink
Add typecast to string in the ORM schema (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
laxity7 authored Nov 8, 2024
1 parent 32cff8f commit 5345eb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Generator/GenerateTypecast.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ private function typecast(AbstractColumn $column)
return 'datetime';
}

if ($column->getType() === AbstractColumn::STRING) {
return 'string';
}

return null;
}
}
1 change: 1 addition & 0 deletions tests/Schema/Generator/TypecastGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function testCompiledUser(): void
$this->assertSame('int', $schema['user'][Schema::TYPECAST]['p_id']);
$this->assertSame('float', $schema['user'][Schema::TYPECAST]['p_balance']);
$this->assertSame('datetime', $schema['user'][Schema::TYPECAST]['p_created_at']);
$this->assertSame('string', $schema['user'][Schema::TYPECAST]['p_name']);

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

0 comments on commit 5345eb4

Please sign in to comment.