Skip to content

Commit

Permalink
mapper: fixed processing DATE type as simple datetime value (without …
Browse files Browse the repository at this point in the history
…timezone processing)
  • Loading branch information
hrach committed Jan 12, 2019
1 parent df0cf9b commit 6fc2d78
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Mapper/Dbal/StorageReflection/StorageReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ protected function getDefaultModifiers(): array

switch ($this->platform->getName()) {
case 'pgsql':
$types = ['TIMESTAMP' => true];
$types = [
'TIMESTAMP' => true,
'DATE' => true,
];
break;

case 'mysql':
Expand All @@ -301,7 +304,10 @@ protected function getDefaultModifiers(): array
break;

case 'mssql':
$types = ['TIMESTAMP' => true];
$types = [
'TIMESTAMP' => true,
'DATE' => true,
];
break;

default:
Expand Down
39 changes: 39 additions & 0 deletions tests/cases/integration/Mapper/mapper.datetimesimple.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php declare(strict_types = 1);

/**
* @testCase
* @dataProvider ../../../sections.ini
*/

namespace NextrasTests\Orm\Integration\Mapper;

use NextrasTests\Orm\Author;
use NextrasTests\Orm\DataTestCase;
use Tester\Assert;


$dic = require_once __DIR__ . '/../../../bootstrap.php';


class MapperDateTimeSimpleTest extends DataTestCase
{
public function testToCollection()
{
$author = $this->e(
Author::class,
[
'born' => new \DateTimeImmutable('2018-01-09 00:00:00')
]
);
$this->orm->persistAndFlush($author);
$id = $author->id;

$this->orm->clear();
$author2 = $this->orm->authors->getById($id);
Assert::equal('2018-01-09', $author2->born->format('Y-m-d'));
}
}


$test = new MapperDateTimeSimpleTest($dic);
$test->run();

0 comments on commit 6fc2d78

Please sign in to comment.