diff --git a/src/Jenssegers/Mongodb/Query/Builder.php b/src/Jenssegers/Mongodb/Query/Builder.php index a340976e3..8180c7c83 100644 --- a/src/Jenssegers/Mongodb/Query/Builder.php +++ b/src/Jenssegers/Mongodb/Query/Builder.php @@ -1133,6 +1133,23 @@ protected function compileWhereRaw(array $where) return $where['sql']; } + /** + * @inheritdoc + */ + protected function addUpdatedAtColumn(array $values) + { + if (! $this->model->usesTimestamps()) { + return $values; + } + + $column = $this->qualifyColumn($this->model->getUpdatedAtColumn()); + + return array_merge( + [$column => $this->model->freshTimestampString()], + $values + ); + } + /** * Set custom options for the query. * diff --git a/tests/AuthTest.php b/tests/AuthTest.php index 2b671fdd5..dad34e7a4 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -5,7 +5,7 @@ class AuthTest extends TestCase { - public function tearDown() + public function tearDown(): void { User::truncate(); DB::collection('password_reminders')->truncate(); diff --git a/tests/EmbeddedRelationsTest.php b/tests/EmbeddedRelationsTest.php index 5caae5b28..18e01557b 100644 --- a/tests/EmbeddedRelationsTest.php +++ b/tests/EmbeddedRelationsTest.php @@ -2,7 +2,7 @@ class EmbeddedRelationsTest extends TestCase { - public function tearDown() + public function tearDown(): void { Mockery::close(); diff --git a/tests/GeospatialTest.php b/tests/GeospatialTest.php index 2d646b337..b13ed46af 100644 --- a/tests/GeospatialTest.php +++ b/tests/GeospatialTest.php @@ -2,7 +2,7 @@ class GeospatialTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); @@ -43,7 +43,7 @@ public function setUp() ]); } - public function tearDown() + public function tearDown(): void { Schema::drop('locations'); } diff --git a/tests/HybridRelationsTest.php b/tests/HybridRelationsTest.php index 2223950ec..ade509067 100644 --- a/tests/HybridRelationsTest.php +++ b/tests/HybridRelationsTest.php @@ -2,7 +2,7 @@ class HybridRelationsTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); @@ -11,7 +11,7 @@ public function setUp() MysqlRole::executeSchema(); } - public function tearDown() + public function tearDown(): void { MysqlUser::truncate(); MysqlBook::truncate(); diff --git a/tests/ModelTest.php b/tests/ModelTest.php index 4387d1231..906a39e68 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -8,7 +8,7 @@ class ModelTest extends TestCase { - public function tearDown() + public function tearDown(): void { User::truncate(); Soft::truncate(); @@ -548,4 +548,13 @@ public function testChunkById() $this->assertEquals(3, $count); } + + public function testUpdateWithUpdatedAt() + { + $item = Item::create(['name' => 'sword']); + $item->update($item->toArray()); + + $this->assertNull($item->items); + $this->assertNull(optional($item->items)->updated_at); + } } diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index ac1479d26..0807b4ece 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -5,7 +5,7 @@ class QueryBuilderTest extends TestCase { - public function tearDown() + public function tearDown(): void { DB::collection('users')->truncate(); DB::collection('items')->truncate(); diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 2011305c2..de8589ebd 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -4,7 +4,7 @@ class QueryTest extends TestCase { protected static $started = false; - public function setUp() + public function setUp(): void { parent::setUp(); User::create(['name' => 'John Doe', 'age' => 35, 'title' => 'admin']); @@ -18,7 +18,7 @@ public function setUp() User::create(['name' => 'Error', 'age' => null, 'title' => null]); } - public function tearDown() + public function tearDown(): void { User::truncate(); parent::tearDown(); diff --git a/tests/QueueTest.php b/tests/QueueTest.php index 35be33f9a..f3ebc94f6 100644 --- a/tests/QueueTest.php +++ b/tests/QueueTest.php @@ -2,7 +2,7 @@ class QueueTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/RelationsTest.php b/tests/RelationsTest.php index 1e2aaa491..de3e0f222 100644 --- a/tests/RelationsTest.php +++ b/tests/RelationsTest.php @@ -2,7 +2,7 @@ class RelationsTest extends TestCase { - public function tearDown() + public function tearDown(): void { Mockery::close(); diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index a04715d9d..5d63e28eb 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -2,7 +2,7 @@ class SchemaTest extends TestCase { - public function tearDown() + public function tearDown(): void { Schema::drop('newcollection'); } diff --git a/tests/SeederTest.php b/tests/SeederTest.php index 9581df3d3..61143e330 100644 --- a/tests/SeederTest.php +++ b/tests/SeederTest.php @@ -2,7 +2,7 @@ class SeederTest extends TestCase { - public function tearDown() + public function tearDown(): void { User::truncate(); } diff --git a/tests/ValidationTest.php b/tests/ValidationTest.php index 16e31f4cf..267996420 100644 --- a/tests/ValidationTest.php +++ b/tests/ValidationTest.php @@ -2,7 +2,7 @@ class ValidationTest extends TestCase { - public function tearDown() + public function tearDown(): void { User::truncate(); }