Skip to content

Commit

Permalink
Merge pull request #258 from finiteinfinity/fix-date-casts
Browse files Browse the repository at this point in the history
Replace 'date' casts with 'datetime' casts
  • Loading branch information
finiteinfinity authored Apr 4, 2023
2 parents 5e23e16 + c445d0b commit b283b30
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Coders/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function phpTypeHint($castType, $nullable)
case 'collection':
$type = '\Illuminate\Support\Collection';
break;
case 'date':
case 'datetime':
$type = '\Carbon\Carbon';
break;
case 'binary':
Expand Down Expand Up @@ -994,7 +994,7 @@ public function getDates()
{
return array_diff(
array_filter($this->casts, function (string $cast) {
return $cast === 'date';
return $cast === 'datetime';
}),
[$this->CREATED_AT, $this->UPDATED_AT]
);
Expand Down
2 changes: 1 addition & 1 deletion src/Meta/MySql/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Column implements \Reliese\Meta\Column
*/
public static $mappings = [
'string' => ['varchar', 'text', 'string', 'char', 'enum', 'set', 'tinytext', 'mediumtext', 'longtext', 'longblob', 'mediumblob', 'tinyblob', 'blob'],
'date' => ['datetime', 'year', 'date', 'time', 'timestamp'],
'datetime' => ['datetime', 'year', 'date', 'time', 'timestamp'],
'int' => ['bigint', 'int', 'integer', 'tinyint', 'smallint', 'mediumint'],
'float' => ['float', 'decimal', 'numeric', 'dec', 'fixed', 'double', 'real', 'double precision'],
'boolean' => ['bit']
Expand Down
2 changes: 1 addition & 1 deletion src/Meta/Postgres/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Column implements \Reliese\Meta\Column
*/
public static $mappings = [
'string' => ['character varying', 'varchar', 'text', 'string', 'char', 'character','enum', 'tinytext', 'mediumtext', 'longtext', 'json'],
'date' => ['timestamp with time zone', 'timestamp without time zone', 'timestamptz', 'datetime', 'year', 'date', 'time', 'timestamp'],
'datetime' => ['timestamp with time zone', 'timestamp without time zone', 'timestamptz', 'datetime', 'year', 'date', 'time', 'timestamp'],
'int' => ['int', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint', 'bigserial', 'serial', 'smallserial', 'tinyserial', 'serial4', 'serial8'],
'float' => ['float', 'decimal', 'numeric', 'dec', 'fixed', 'double', 'real', 'double precision'],
'boolean' => ['boolean', 'bool', 'bit'],
Expand Down
2 changes: 1 addition & 1 deletion src/Meta/Sqlite/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Column implements \Reliese\Meta\Column
*/
public static $mappings = [
'string' => ['varchar', 'text', 'string', 'char', 'enum', 'tinytext', 'mediumtext', 'longtext'],
'date' => ['datetime', 'year', 'date', 'time', 'timestamp'],
'datetime' => ['datetime', 'year', 'date', 'time', 'timestamp'],
'int' => ['bigint', 'int', 'integer', 'tinyint', 'smallint', 'mediumint'],
'float' => ['float', 'decimal', 'numeric', 'dec', 'fixed', 'double', 'real', 'double precision'],
'boolean' => ['longblob', 'blob', 'bit'],
Expand Down

0 comments on commit b283b30

Please sign in to comment.