Skip to content

Commit 675aa8d

Browse files
authored
feat: do primary key check on server side (#177)
* feat: do primary key check on server side * update changelog * redelete
1 parent 09f3489 commit 675aa8d

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# v6.2.0 (Not Released Yet)
1+
# v7.0.0 (Not Released Yet)
22

33
Added
44
- `json` `mediumText` `longText` `char` support for `Schema\Builder` (#155) (#158)
@@ -10,6 +10,7 @@ Added
1010
Changed
1111
- `Query\Builder::lock()` no longer throw an error and will be ignored instead (#156)
1212
- `Schema\Builder::getIndexListing()` `Schema\Grammar::compileIndexListing()` converted to `getIndexes()` and `compileIndexes()` to align with standard Laravel methods (#161)
13+
- Missing primary key will no longer be checked and will be checked on the server side instead (#177)
1314

1415
Fixed
1516
- `Schema\Grammar::compileAdd()` `Schema\Grammar::compileChange()` `Schema\Grammar::compileChange()` now create separate statements (#159)

src/Schema/Grammar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ protected function addPrimaryKeys(Blueprint $blueprint)
399399
if (! is_null($primary = $this->getCommandByName($blueprint, 'primary'))) {
400400
return "primary key ({$this->columnize($primary->columns)})";
401401
}
402-
throw new LogicException('Cloud Spanner require a primary key!');
402+
return '';
403403
}
404404

405405
/**

tests/Schema/BlueprintTest.php

-13
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,6 @@ public function test_dropForeign(): void
210210
], $statements);
211211
}
212212

213-
public function test_no_primaryKey(): void
214-
{
215-
$this->expectException(LogicException::class);
216-
$this->expectExceptionMessage('Cloud Spanner require a primary key!');
217-
218-
$tableName = $this->generateTableName();
219-
$blueprint = new Blueprint($tableName, function (Blueprint $table) {
220-
$table->create();
221-
$table->uuid('id');
222-
});
223-
$blueprint->toSql($this->getDefaultConnection(), new Grammar());
224-
}
225-
226213
public function test_composite_primary_key(): void
227214
{
228215
$conn = $this->getDefaultConnection();

0 commit comments

Comments
 (0)