Skip to content

Commit

Permalink
Regression Test for PostgreSQL reserved word column names w/ guarded …
Browse files Browse the repository at this point in the history
…attributes broken in native column attributes implementation

Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Nov 1, 2023
1 parent 87b9e79 commit a03295e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/Integration/Database/EloquentCreateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Illuminate\Tests\Integration\Database;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class EloquentCreateTest extends DatabaseTestCase
{
public function testInsertRecordWithReservedWordFieldName()
{
Schema::create('actions', function (Blueprint $table) {
$table->id();
$table->string('label');
$table->timestamp('start');
$table->timestamp('end');
$table->boolean('analyze');
});

$model = new class extends Model
{
protected $table = 'actions';
protected $guarded = ['id'];
public $timestamps = false;
};

$result = $model->newInstance()->create([
'label' => 'test',
'start' => '2023-01-01 00:00:00',
'end' => '2024-01-01 00:00:00',
'analyze' => true,
]);

$this->assertDatabaseHas('actions', [
'label' => 'test',
'start' => '2023-01-01 00:00:00',
'end' => '2024-01-01 00:00:00',
'analyze' => true,
]);
}
}

0 comments on commit a03295e

Please sign in to comment.