Skip to content

Commit

Permalink
chore: remove deprecated methods (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama authored Feb 16, 2024
1 parent 09a3115 commit e9a32d3
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 110 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Changed
- `Query\Builder::lock()` no longer throw an error and will be ignored instead (#156)
- `Schema\Builder::getIndexListing()` `Schema\Grammar::compileIndexListing()` converted to `getIndexes()` and `compileIndexes()` to align with standard Laravel methods (#161)
- Missing primary key will no longer be checked and will be checked on the server side instead (#177)
- `Connection::runDdl()` and `Connection::runDdls()` has been removed. Use `Connection::runDdlBatch()` instead. (#178)
- Trait `ManagesStaleReads` has been removed (which contained `cursorWithTimestampBound()` and `selectWithTimestampBound()`. Use `selectWithOptions()` instead). (#178)
- `Blueprint::interleave()` and `IndexDefinition::interleave()` now throw an error instead of a deprecation. (#178)

Fixed
- `Schema\Grammar::compileAdd()` `Schema\Grammar::compileChange()` `Schema\Grammar::compileChange()` now create separate statements (#159)
Expand Down
23 changes: 0 additions & 23 deletions src/Concerns/ManagesDataDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Google\Cloud\Spanner\Database;
use RuntimeException;
use function json_encode;
use function trigger_deprecation;

trait ManagesDataDefinitions
{
Expand All @@ -30,28 +29,6 @@ trait ManagesDataDefinitions
*/
abstract public function getSpannerDatabase(): Database;

/**
* @deprecated use runDdlBatch() instead
* @param string $ddl
* @return LongRunningOperation
*/
public function runDdl(string $ddl): LongRunningOperation
{
trigger_deprecation('colopl/laravel-spanner', '5.2', 'runDdl() is deprecated. Use runDdlBatch() instead.');
return $this->getSpannerDatabase()->updateDdl($ddl);
}

/**
* @deprecated use runDdlBatch() instead
* @param string[] $ddls
* @return LongRunningOperation
*/
public function runDdls(array $ddls): LongRunningOperation
{
trigger_deprecation('colopl/laravel-spanner', '5.2', 'runDdls() is deprecated. Use runDdlBatch() instead.');
return $this->getSpannerDatabase()->updateDdlBatch($ddls);
}

/**
* @param list<string> $statements
* @return mixed
Expand Down
64 changes: 0 additions & 64 deletions src/Concerns/ManagesStaleReads.php

This file was deleted.

1 change: 0 additions & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Connection extends BaseConnection
Concerns\ManagesPartitionedDml,
Concerns\ManagesSessionPool,
Concerns\ManagesTransactions,
Concerns\ManagesStaleReads,
Concerns\MarksAsNotSupported;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Illuminate\Database\Schema\Blueprint as BaseBlueprint;
use Illuminate\Database\Schema\ColumnDefinition;
use Illuminate\Support\Fluent;
use LogicException;

/**
* @method IndexDefinition index(string|string[] $columns, string|null $name = null)
Expand Down Expand Up @@ -219,8 +220,7 @@ public function timestampArray($column)
*/
public function interleave(string $parentTableName)
{
trigger_deprecation('colopl/laravel-spanner', '5.2', 'Blueprint::interleave() is deprecated. Use interleaveInParent() instead. This method will be removed in v7.');
return $this->interleaveInParent($parentTableName);
throw new LogicException('This method is not longer valid. Use interleaveInParent() instead.');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Schema/IndexDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Colopl\Spanner\Schema;

use Illuminate\Support\Fluent;
use LogicException;

/**
* @method $this interleaveIn(string $table)
Expand All @@ -19,7 +20,6 @@ class IndexDefinition extends Fluent
*/
public function interleave(string $table)
{
trigger_deprecation('colopl/laravel-spanner', '5.2', 'Blueprint::interleave() is deprecated. Use interleaveIn() instead. This method will be removed in v7.');
return $this->interleaveIn($table);
throw new LogicException('This method is not longer valid. Use interleaveIn() instead.');
}
}
32 changes: 16 additions & 16 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,32 +480,32 @@ public function test_stale_reads(): void
$this->assertNotEmpty($timestamp);

$timestampBound = new StrongRead();
$row = $conn->selectOneWithTimestampBound("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound);
$this->assertNotEmpty($row);
$this->assertEquals($uuid, $row['userId']);
$this->assertEquals('first', $row['name']);
$rows = $conn->selectWithOptions("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound->transactionOptions());
$this->assertCount(1, $rows);
$this->assertSame($uuid, $rows[0]['userId']);
$this->assertSame('first', $rows[0]['name']);

$oldDatetime = Carbon::instance($timestamp->get())->subSecond();

$timestampBound = new ReadTimestamp($oldDatetime);
$row = $conn->selectOneWithTimestampBound("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound);
$this->assertEmpty($row);
$rows = $conn->selectWithOptions("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound->transactionOptions());
$this->assertEmpty($rows);

$timestampBound = new ExactStaleness(10);
$row = $conn->selectOneWithTimestampBound("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound);
$this->assertEmpty($row);
$rows = $conn->selectWithOptions("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound->transactionOptions());
$this->assertEmpty($rows);

$timestampBound = new MaxStaleness(10);
$row = $conn->selectOneWithTimestampBound("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound);
$this->assertNotEmpty($row);
$this->assertEquals($uuid, $row['userId']);
$this->assertEquals('first', $row['name']);
$rows = $conn->selectWithOptions("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound->transactionOptions());
$this->assertCount(1, $rows);
$this->assertSame($uuid, $rows[0]['userId']);
$this->assertSame('first', $rows[0]['name']);

$timestampBound = new MinReadTimestamp($oldDatetime);
$row = $conn->selectOneWithTimestampBound("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound);
$this->assertNotEmpty($row);
$this->assertEquals($uuid, $row['userId']);
$this->assertEquals('first', $row['name']);
$rows = $conn->selectWithOptions("SELECT * FROM ${tableName} WHERE userID = ?", [$uuid], $timestampBound->transactionOptions());
$this->assertCount(1, $rows);
$this->assertSame($uuid, $rows[0]['userId']);
$this->assertSame('first', $rows[0]['name']);
}

public function testEventListenOrder(): void
Expand Down
2 changes: 0 additions & 2 deletions tests/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,11 @@ public function test_index_with_interleave(): void
$conn = $this->getDefaultConnection();
$blueprint = new Blueprint('UserItem', function (Blueprint $table) {
$table->index(['userId', 'createdAt'])->interleaveIn('User');
$table->index(['userId', 'updatedAt'])->interleave('User');
});

$statements = $blueprint->toSql($conn, new Grammar());
$this->assertSame([
'create index `useritem_userid_createdat_index` on `UserItem` (`userId`, `createdAt`), interleave in `User`',
'create index `useritem_userid_updatedat_index` on `UserItem` (`userId`, `updatedAt`), interleave in `User`',
],
$statements
);
Expand Down

0 comments on commit e9a32d3

Please sign in to comment.