Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] "null" constraint prevents aliasing SQLite ROWID #35792

Merged
merged 2 commits into from Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
Expand Up @@ -875,7 +875,7 @@ protected function modifyStoredAs(Blueprint $blueprint, Fluent $column)
protected function modifyNullable(Blueprint $blueprint, Fluent $column)
{
if (is_null($column->virtualAs) && is_null($column->storedAs)) {
return $column->nullable ? ' null' : ' not null';
return $column->nullable ? '' : ' not null';
}

if ($column->nullable === false) {
Expand Down
12 changes: 6 additions & 6 deletions tests/Database/DatabaseSQLiteSchemaGrammarTest.php
Expand Up @@ -361,7 +361,7 @@ public function testAddingString()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table "users" add column "foo" varchar null default \'bar\'', $statements[0]);
$this->assertSame('alter table "users" add column "foo" varchar default \'bar\'', $statements[0]);
}

public function testAddingText()
Expand Down Expand Up @@ -663,8 +663,8 @@ public function testAddingTimestamps()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
$this->assertCount(2, $statements);
$this->assertEquals([
'alter table "users" add column "created_at" datetime null',
'alter table "users" add column "updated_at" datetime null',
'alter table "users" add column "created_at" datetime',
'alter table "users" add column "updated_at" datetime',
], $statements);
}

Expand All @@ -675,8 +675,8 @@ public function testAddingTimestampsTz()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());
$this->assertCount(2, $statements);
$this->assertEquals([
'alter table "users" add column "created_at" datetime null',
'alter table "users" add column "updated_at" datetime null',
'alter table "users" add column "created_at" datetime',
'alter table "users" add column "updated_at" datetime',
], $statements);
}

Expand All @@ -687,7 +687,7 @@ public function testAddingRememberToken()
$statements = $blueprint->toSql($this->getConnection(), $this->getGrammar());

$this->assertCount(1, $statements);
$this->assertSame('alter table "users" add column "remember_token" varchar null', $statements[0]);
$this->assertSame('alter table "users" add column "remember_token" varchar', $statements[0]);
}

public function testAddingBinary()
Expand Down