Skip to content

Commit

Permalink
Merge pull request #41 from clementbirkle/main
Browse files Browse the repository at this point in the history
Fix phpType Handling for Big Integer Columns
  • Loading branch information
freekmurze authored Jun 21, 2024
2 parents 64b0906 + 813961b commit 0cbdd83
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .phpunit.cache/test-results
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"pest_2.34.8","defects":[],"times":{"P\\Tests\\RelationTest::__pest_evaluable_it_will_find_no_relations_on_a_model_that_has_none":0,"P\\Tests\\RelationTest::__pest_evaluable_it_can_get_the_model_info_of_the_related_model":0.001,"P\\Tests\\RelationTest::__pest_evaluable_it_can_find_the_relations_on_a_model":0.001,"P\\Tests\\ModelFinderTest::__pest_evaluable_it_can_discover_all_models_in_a_directory":0.001,"P\\Tests\\AttributeTest::__pest_evaluable_it_can_get_extended_column_types_for_a_model":0.002,"P\\Tests\\AttributeTest::__pest_evaluable_it_can_get_the_attributes_of_a_model":0.002,"P\\Tests\\AttributeTest::__pest_evaluable_it_can_get_the_accessor_attributes_of_a_model":0.001,"P\\Tests\\AttributeTest::__pest_evaluable_it_can_get_the_mutator_attributes_of_a_model":0.001,"P\\Tests\\AttributeTest::__pest_evaluable_it_can_handle_virtual_attributes_of_a_model":0.001,"P\\Tests\\AttributeTest::__pest_evaluable_it_can_handle_accessor_mutator_combinations":0.002,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_can_get_meta_information_about_all_models":0.037,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_can_get_traits_from_a_model":0.001,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_it_will_return_null_when_getting_a_non_existing_attribute":0.001,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_can_get_a_specific_relation":0.002,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_can_get_extra_info_from_a_model":0.001,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_can_get_a_specific_attribute":0.001,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_it_will_return_null_when_getting_a_non_existing_relation":0.001,"P\\Tests\\ModelInfoTest::__pest_evaluable_it_can_get_meta_information_about_a_model":0.013}}
3 changes: 1 addition & 2 deletions src/Attributes/AttributeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function getPhpType(array $column): string
};

$type ??= match ($column['type_name']) {
'tinyint', 'integer', 'int', 'int4', 'smallint', 'int2', 'mediumint' => 'int',
'tinyint', 'integer', 'int', 'int4', 'smallint', 'int2', 'mediumint', 'bigint', 'int8' => 'int',
'float', 'real', 'float4', 'double', 'float8' => 'float',
'binary', 'varbinary', 'bytea', 'image', 'blob', 'tinyblob', 'mediumblob', 'longblob' => 'resource',
'boolean', 'bool' => 'bool',
Expand All @@ -77,7 +77,6 @@ protected function getPhpType(array $column): string
// 'char', 'bpchar', 'nchar',
// 'varchar', 'nvarchar',
// 'text', 'tinytext', 'longtext', 'mediumtext', 'ntext',
// 'bigint', 'int8',
// 'decimal', 'numeric',
// 'money', 'smallmoney',
// 'uuid', 'uniqueidentifier',
Expand Down
2 changes: 1 addition & 1 deletion tests/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
it('can get the attributes of a model', function () {
$attributes = AttributeFinder::forModel(new TestModel());

expect($attributes)->toHaveCount(11);
expect($attributes)->toHaveCount(12);

matchesAttributesSnapshot($attributes);
});
Expand Down
1 change: 1 addition & 0 deletions tests/TestSupport/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function getEnvironmentSetUp($app)
$table->id();
$table->string('name');
$table->string('password');
$table->bigInteger('bigInteger');
$table->timestamps();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@
cast: null
virtual: false
hidden: true
-
name: bigInteger
phpType: int
type: integer
increments: false
nullable: false
default: null
primary: false
unique: false
fillable: false
appended: null
cast: null
virtual: false
hidden: false
-
name: created_at
phpType: DateTime
Expand Down

0 comments on commit 0cbdd83

Please sign in to comment.