Skip to content

Commit 67cfc6b

Browse files
authored
Added support for useCurrentOnUpdate modifier (#493)
1 parent f9df5de commit 67cfc6b

File tree

7 files changed

+10
-2
lines changed

7 files changed

+10
-2
lines changed

src/Lexers/ModelLexer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class ModelLexer implements Lexer
9090
'nullable' => 'nullable',
9191
'unsigned' => 'unsigned',
9292
'usecurrent' => 'useCurrent',
93+
'usecurrentonupdate' => 'useCurrentOnUpdate',
9394
'always' => 'always',
9495
'unique' => 'unique',
9596
'index' => 'index',

tests/Feature/Lexers/ModelLexerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ public function it_accepts_lowercase_keywords()
226226
'sequence' => 'unsignedbiginteger autoincrement',
227227
'content' => 'longtext',
228228
'saved_at' => 'timestamptz usecurrent',
229+
'updated_at' => 'timestamptz usecurrent usecurrentOnUpdate',
229230
],
230231
],
231232
];
@@ -241,7 +242,7 @@ public function it_accepts_lowercase_keywords()
241242
$this->assertFalse($model->usesSoftDeletes());
242243

243244
$columns = $model->columns();
244-
$this->assertCount(4, $columns);
245+
$this->assertCount(5, $columns);
245246
$this->assertEquals('id', $columns['id']->name());
246247
$this->assertEquals('id', $columns['id']->dataType());
247248
$this->assertEquals([], $columns['id']->attributes());
@@ -258,6 +259,7 @@ public function it_accepts_lowercase_keywords()
258259
$this->assertEquals('timestampTz', $columns['saved_at']->dataType());
259260
$this->assertEquals([], $columns['saved_at']->attributes());
260261
$this->assertEquals(['useCurrent'], $columns['saved_at']->modifiers());
262+
$this->assertEquals(['useCurrent', 'useCurrentOnUpdate'], $columns['updated_at']->modifiers());
261263
}
262264

263265
/**

tests/fixtures/drafts/post.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ models:
44
author_id: id
55
author_bio: longtext
66
content: bigtext nullable
7-
published_at: timestamp nullable
7+
published_at: timestamp nullable useCurrent
8+
updated_at: timestamp nullable useCurrent useCurrentOnUpdate
89
word_count: integer unsigned

tests/fixtures/factories/post-configured-laravel8.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function definition()
2929
'author_bio' => $this->faker->text,
3030
'content' => $this->faker->paragraphs(3, true),
3131
'published_at' => $this->faker->dateTime(),
32+
'updated_at' => $this->faker->dateTime(),
3233
'word_count' => $this->faker->randomNumber(),
3334
];
3435
}

tests/fixtures/factories/post-configured.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'author_bio' => $faker->text,
1313
'content' => $faker->paragraphs(3, true),
1414
'published_at' => $faker->dateTime(),
15+
'updated_at' => $faker->dateTime(),
1516
'word_count' => $faker->randomNumber(),
1617
];
1718
});

tests/fixtures/factories/post-laravel8.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function definition()
2929
'author_bio' => $this->faker->text,
3030
'content' => $this->faker->paragraphs(3, true),
3131
'published_at' => $this->faker->dateTime(),
32+
'updated_at' => $this->faker->dateTime(),
3233
'word_count' => $this->faker->randomNumber(),
3334
];
3435
}

tests/fixtures/factories/post.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'author_bio' => $faker->text,
1313
'content' => $faker->paragraphs(3, true),
1414
'published_at' => $faker->dateTime(),
15+
'updated_at' => $faker->dateTime(),
1516
'word_count' => $faker->randomNumber(),
1617
];
1718
});

0 commit comments

Comments
 (0)