Skip to content

Commit 0b48db6

Browse files
authored
Merge branch 'master' into fix/get-columns-data
2 parents 3429db7 + bd0adbe commit 0b48db6

File tree

18 files changed

+261
-342
lines changed

18 files changed

+261
-342
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
"php": "^8.2",
1212
"ext-grpc": "*",
1313
"ext-json": "*",
14-
"laravel/framework": "^11.31.0",
14+
"laravel/framework": "^12.0",
1515
"google/cloud-spanner": "^1.58.4",
1616
"grpc/grpc": "^1.42",
1717
"symfony/cache": "~7",
1818
"symfony/lock": "~7"
1919
},
2020
"require-dev": {
21-
"orchestra/testbench": "~9",
21+
"orchestra/testbench": "~10",
2222
"phpunit/phpunit": "~11.0",
2323
"phpstan/phpstan": "^2"
2424
},

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ parameters:
22
level: 9
33
paths:
44
- src
5+
ignoreErrors:
6+
- message: "#^Call to an undefined method Illuminate\\\\Database\\\\ConnectionInterface\\:\\:recordsHaveBeenModified\\(\\)\\.$#"
7+
count: 1
8+
path: src/Query/Processor.php

src/Concerns/ManagesMutations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use InvalidArgumentException;
3030

3131
/**
32-
* @phpstan-type TDataSet list<array<string, array<array-key, mixed>>>|array<string, array<array-key, mixed>>
32+
* @phpstan-type TDataSet list<array<string, mixed>>|array<string, mixed>
3333
*/
3434
trait ManagesMutations
3535
{
@@ -129,7 +129,7 @@ protected function prepareForMutation(array $dataSet): array
129129
return [];
130130
}
131131

132-
if (Arr::isAssoc($dataSet)) {
132+
if (!array_is_list($dataSet)) {
133133
$dataSet = [$dataSet];
134134
}
135135

src/Connection.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ public function disconnect()
202202
*/
203203
protected function getDefaultQueryGrammar(): QueryGrammar
204204
{
205-
$grammar = new QueryGrammar();
206-
$grammar->setConnection($this);
207-
$this->withTablePrefix($grammar);
208-
return $grammar;
205+
return new QueryGrammar($this);
209206
}
210207

211208
/**
@@ -214,10 +211,7 @@ protected function getDefaultQueryGrammar(): QueryGrammar
214211
*/
215212
protected function getDefaultSchemaGrammar(): SchemaGrammar
216213
{
217-
$grammar = new SchemaGrammar();
218-
$grammar->setConnection($this);
219-
$this->withTablePrefix($grammar);
220-
return $grammar;
214+
return new SchemaGrammar($this);
221215
}
222216

223217
/**
@@ -427,16 +421,6 @@ public function getReadPdo()
427421
$this->markAsNotSupported('PDO access');
428422
}
429423

430-
/**
431-
* TODO: Remove in v9
432-
* @deprecated Parent method no longer exists. This will be removed in v9.
433-
* @return never
434-
*/
435-
public function getDoctrineConnection()
436-
{
437-
$this->markAsNotSupported('Doctrine');
438-
}
439-
440424
/**
441425
* {@inheritDoc}
442426
* @param array<array-key, mixed> $bindings

src/Eloquent/Concerns/DoesNotAutoIncrement.php

Lines changed: 0 additions & 58 deletions
This file was deleted.

src/Eloquent/Model.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
*/
2929
class Model extends BaseModel
3030
{
31-
use Concerns\InterleaveKeySupport,
32-
Concerns\DoesNotAutoIncrement;
31+
use Concerns\InterleaveKeySupport;
3332

3433
/**
3534
* @var list<string>

src/Query/Grammar.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ public function compileUpsert(Builder $query, array $values, array $uniqueBy, ar
5353
/**
5454
* {@inheritDoc}
5555
* @param array<array-key, mixed> $values
56+
* @param string|null $sequence
5657
*/
5758
public function compileInsertGetId(Builder $query, $values, $sequence)
5859
{
59-
$this->markAsNotSupported('insertGetId');
60+
return $this->compileInsert($query, $values) . ' then return ' . $this->wrap($sequence ?? 'id');
6061
}
6162

6263
/**

src/Query/Processor.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,41 @@
2323
use Illuminate\Database\Query\Builder;
2424
use Illuminate\Database\Query\Processors\Processor as BaseProcessor;
2525
use Illuminate\Support\Carbon;
26+
use LogicException;
2627

2728
class Processor extends BaseProcessor
2829
{
2930
/**
3031
* {@inheritDoc}
32+
* @param array<array-key, mixed> $values
33+
*/
34+
public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
35+
{
36+
$connection = $query->getConnection();
37+
38+
$connection->recordsHaveBeenModified();
39+
40+
$queryCall = static fn() => $connection->selectOne($sql, $values);
41+
42+
$result = $connection->transactionLevel() > 0
43+
? $queryCall()
44+
: $connection->transaction($queryCall);
45+
46+
$sequence ??= 'id';
47+
48+
$id = match(true) {
49+
is_object($result) => $result->{$sequence},
50+
is_array($result) => $result[$sequence],
51+
default => throw new LogicException('Unknown result type : ' . gettype($result)),
52+
};
53+
54+
assert(is_int($id));
55+
56+
return $id;
57+
}
58+
59+
/**
60+
* @inheritDoc
3161
* @param array<array-key, array<array-key, mixed>> $results
3262
* @return array<array-key, array<array-key, mixed>>
3363
*/

src/Schema/Blueprint.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,6 @@ public function tokenList(string $column, TokenizerFunction $function, string $t
262262
])->invisible()->nullable();
263263
}
264264

265-
/**
266-
* @deprecated use interleaveInParent instead.
267-
* @param string $parentTableName
268-
* @return InterleaveDefinition
269-
*/
270-
public function interleave(string $parentTableName)
271-
{
272-
throw new LogicException('This method is not longer valid. Use interleaveInParent() instead.');
273-
}
274-
275265
/**
276266
* @param string $table
277267
* @return InterleaveDefinition

src/Schema/Builder.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ class Builder extends BaseBuilder
4141
public static $defaultMorphKeyType = 'uuid';
4242

4343
/**
44+
* @param null $schema
4445
* @inheritDoc Adds a parent key, for tracking interleaving
4546
*
4647
* @return list<array{ name: string, type: string, parent: string }>
4748
*/
48-
public function getTables()
49+
public function getTables($schema = null)
4950
{
5051
/** @var list<array{ name: string, type: string, parent: string }> */
5152
return $this->connection->select(
52-
$this->grammar->compileTables(),
53+
$this->grammar->compileTables(null),
5354
);
5455
}
5556

@@ -87,7 +88,7 @@ protected function createBlueprint($table, ?Closure $callback = null)
8788
/** @phpstan-ignore isset.property */
8889
return isset($this->resolver)
8990
? ($this->resolver)($table, $callback)
90-
: new Blueprint($table, $callback);
91+
: new Blueprint($this->connection, $table, $callback);
9192
}
9293

9394
/**
@@ -135,7 +136,7 @@ public function dropAllTables()
135136
foreach ($foreigns as $foreign) {
136137
$blueprint->dropForeign($foreign);
137138
}
138-
array_push($queries, ...$blueprint->toSql($connection, $this->grammar));
139+
array_push($queries, ...$blueprint->toSql());
139140
}
140141
/** @var Connection $connection */
141142
$connection->runDdlBatch($queries);
@@ -153,7 +154,7 @@ public function dropAllTables()
153154
$blueprint->dropIndex($index);
154155
}
155156
$blueprint->drop();
156-
array_push($queries, ...$blueprint->toSql($connection, $this->grammar));
157+
array_push($queries, ...$blueprint->toSql());
157158
}
158159
$connection->runDdlBatch($queries);
159160
}

0 commit comments

Comments
 (0)