-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: Support snapshot queries #215
Conversation
@coderabbitai review |
Actions performedReview triggered.
|
Caution Review failedThe pull request is closed. WalkthroughThe changes introduce enhanced querying capabilities with the addition of snapshot queries, allowing users to retrieve data as it existed at a specific point in time. The Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- src/Connection.php (1 hunks)
- src/Query/Builder.php (2 hunks)
- src/Query/Concerns/UsesSnapshot.php (1 hunks)
Additional context used
PHPStan
src/Query/Builder.php
null-null: Ignored error pattern #^Strict comparison using === between Illuminate\Database\Query\IndexHint and null will always evaluate to false.$# in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Query/Builder.php was not matched in reported errors. (ignore.unmatched)
26-26: Class Colopl\Spanner\Query\Builder extends unknown class Illuminate\Database\Query\Builder. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
43-43: Method Colopl\Spanner\Query\Builder::insert() has no return type specified. (missingType.return)
45-45: Colopl\Spanner\Query\Builder::insert() calls parent::insert() but Colopl\Spanner\Query\Builder does not extend any class. (class.noParent)
51-51: Method Colopl\Spanner\Query\Builder::update() has no return type specified. (missingType.return)
59-59: Colopl\Spanner\Query\Builder::update() calls parent::update() but Colopl\Spanner\Query\Builder does not extend any class. (class.noParent)
65-65: Method Colopl\Spanner\Query\Builder::updateOrInsert() has no return type specified. (missingType.return)
67-67: Call to an undefined method Colopl\Spanner\Query\Builder::where(). (method.notFound)
71-71: Call to an undefined method Colopl\Spanner\Query\Builder::take(). (method.notFound)
71-71: Call to static method except() on an unknown class Illuminate\Support\Arr. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
77-77: Method Colopl\Spanner\Query\Builder::upsert() has no return type specified. (missingType.return)
77-77: Method Colopl\Spanner\Query\Builder::upsert() has parameter $uniqueBy with no type specified. (missingType.parameter)
77-77: Method Colopl\Spanner\Query\Builder::upsert() has parameter $update with no type specified. (missingType.parameter)
93-93: Call to an undefined method Colopl\Spanner\Query\Builder::applyBeforeQueryCallbacks(). (method.notFound)
96-96: Access to an undefined property Colopl\Spanner\Query\Builder::$grammar. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
97-97: Call to an undefined method Colopl\Spanner\Query\Builder::cleanBindings(). (method.notFound)
97-97: Call to static method flatten() on an unknown class Illuminate\Support\Arr. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
104-104: Method Colopl\Spanner\Query\Builder::truncate() has no return type specified. (missingType.return)
106-106: Call to an undefined method Colopl\Spanner\Query\Builder::applyBeforeQueryCallbacks(). (method.notFound)
108-108: Access to an undefined property Colopl\Spanner\Query\Builder::$grammar. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
131-131: Access to an undefined property Colopl\Spanner\Query\Builder::$wheres. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
133-133: Call to an undefined method Colopl\Spanner\Query\Builder::addBinding(). (method.notFound)
144-144: Parameter $values of method Colopl\Spanner\Query\Builder::whereInUnnest() has invalid type Illuminate\Contracts\Support\Arrayable. (class.notFound)
151-151: Access to an undefined property Colopl\Spanner\Query\Builder::$wheres. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
153-153: Call to an undefined method Colopl\Spanner\Query\Builder::addBinding(). (method.notFound)
168-168: Call to static method isAssoc() on an unknown class Illuminate\Support\Arr. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
178-178: Method Colopl\Spanner\Query\Builder::runSelect() has no return type specified. (missingType.return)
180-180: Call to an undefined method Colopl\Spanner\Query\Builder::toSql(). (method.notFound)
181-181: Call to an undefined method Colopl\Spanner\Query\Builder::getBindings(). (method.notFound)
210-210: Access to an undefined property Colopl\Spanner\Query\Builder::$indexHint. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
210-210: Class Colopl\Spanner\Query\IndexHint does not have a constructor and must be instantiated without any parameters. (new.noConstructor)
220-220: Access to an undefined property Colopl\Spanner\Query\Builder::$indexHint. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-propertysrc/Connection.php
null-null: Ignored error pattern #^Cannot access offset 'requestTag' on mixed.$# in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Connection.php was not matched in reported errors. (ignore.unmatched)
null-null: Ignored error pattern #^Expression on left side of ?? is not nullable.$# in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Connection.php was not matched in reported errors. (ignore.unmatched)
null-null: Ignored error pattern #^Generator expects value type array, mixed given.$# in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Connection.php was not matched in reported errors. (ignore.unmatched)
null-null: Ignored error pattern #^Method Colopl\Spanner\Connection::selectWithOptions() should return array<int, array> but returns mixed.$# in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Connection.php was not matched in reported errors. (ignore.unmatched)
null-null: Ignored error pattern #^Parameter #1
$pdo of method Illuminate\Database\Connection::__construct() expects Closure|PDO, null given.$ # in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Connection.php was not matched in reported errors. (ignore.unmatched)
null-null: Ignored error pattern #^Parameter #1
$start of method Illuminate\Database\Connection::getElapsedTime() expects int, float given.$ # in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Connection.php was not matched in reported errors. (ignore.unmatched)
null-null: Ignored error pattern #^Parameter #1
$table of method Illuminate\Database\Query\Builder::from() expects Closure|Illuminate\Database\Eloquent\Builder|Illuminate\Database\Query\Builder|string, Closure|Illuminate\Contracts\Database\Query\Expression|Illuminate\Database\Query\Builder|string given.$ # in path /cache/1a5483e6-0399-4ade-9400-837a7d9808e5/home/jailuser/git/src/Connection.php was not matched in reported errors. (ignore.unmatched)
49-49: Class Colopl\Spanner\Connection extends unknown class Illuminate\Database\Connection. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
67-67: Property Colopl\Spanner\Connection::$spannerClient has unknown class Google\Cloud\Spanner\SpannerClient as its type. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
72-72: Property Colopl\Spanner\Connection::$spannerDatabase has unknown class Google\Cloud\Spanner\Database as its type. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
82-82: Property Colopl\Spanner\Connection::$authCache has unknown class Psr\Cache\CacheItemPoolInterface as its type. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
87-87: Property Colopl\Spanner\Connection::$sessionPool has unknown class Google\Cloud\Spanner\Session\SessionPoolInterface as its type. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
97-97: Parameter $authCache of method Colopl\Spanner\Connection::__construct() has invalid type Psr\Cache\CacheItemPoolInterface. (class.notFound)
97-97: Parameter $authCache of method Colopl\Spanner\Connection::__construct() has invalid type Psr\Cache\CacheItemPoolInterface. (class.notFound)
97-97: Parameter $sessionPool of method Colopl\Spanner\Connection::__construct() has invalid type Google\Cloud\Spanner\Session\SessionPoolInterface. (class.notFound)
97-97: Parameter $sessionPool of method Colopl\Spanner\Connection::__construct() has invalid type Google\Cloud\Spanner\Session\SessionPoolInterface. (class.notFound)
102-102: Colopl\Spanner\Connection::__construct() calls parent::__construct() but Colopl\Spanner\Connection does not extend any class. (class.noParent)
109-109: Method Colopl\Spanner\Connection::getSpannerClient() has invalid return type Google\Cloud\Spanner\SpannerClient. (class.notFound)
109-109: PHPDoc tag @throws with type Google\Cloud\Core\Exception\GoogleException is not subtype of Throwable (throws.notThrowable)
116-116: Instantiated class Google\Cloud\Spanner\SpannerClient not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
124-124: Method Colopl\Spanner\Connection::getSpannerDatabase() has invalid return type Google\Cloud\Spanner\Database. (class.notFound)
124-124: Method Colopl\Spanner\Connection::getSpannerDatabase() has invalid return type Google\Cloud\Spanner\Database. (class.notFound)
133-133: Method Colopl\Spanner\Connection::getDatabaseContext() has invalid return type Google\Cloud\Spanner\Database. (class.notFound)
133-133: Method Colopl\Spanner\Connection::getDatabaseContext() has invalid return type Google\Cloud\Spanner\Database. (class.notFound)
133-133: Method Colopl\Spanner\Connection::getDatabaseContext() has invalid return type Google\Cloud\Spanner\Transaction. (class.notFound)
133-133: Method Colopl\Spanner\Connection::getDatabaseContext() has invalid return type Google\Cloud\Spanner\Transaction. (class.notFound)
149-149: Method Colopl\Spanner\Connection::reconnect() has no return type specified. (missingType.return)
156-156: Access to an undefined property Colopl\Spanner\Connection::$database. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
156-156: Call to method connect() on an unknown class Google\Cloud\Spanner\SpannerClient. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
162-162: Method Colopl\Spanner\Connection::reconnectIfMissingConnection() has no return type specified. (missingType.return)
172-172: Method Colopl\Spanner\Connection::disconnect() has no return type specified. (missingType.return)
175-175: Call to method close() on an unknown class Google\Cloud\Spanner\Database. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
187-187: Call to an undefined method Colopl\Spanner\Query\Grammar::setConnection(). (method.notFound)
188-188: Call to an undefined method Colopl\Spanner\Connection::withTablePrefix(). (method.notFound)
199-199: Call to an undefined method Colopl\Spanner\Schema\Grammar::setConnection(). (method.notFound)
200-200: Call to an undefined method Colopl\Spanner\Connection::withTablePrefix(). (method.notFound)
210-210: Access to an undefined property Colopl\Spanner\Connection::$schemaGrammar. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
211-211: Call to an undefined method Colopl\Spanner\Connection::useDefaultSchemaGrammar(). (method.notFound)
214-214: Class Colopl\Spanner\Schema\Builder does not have a constructor and must be instantiated without any parameters. (new.noConstructor)
229-229: Method Colopl\Spanner\Connection::table() has parameter $as with no type specified. (missingType.parameter)
229-229: Method Colopl\Spanner\Connection::table() has parameter $table with no type specified. (missingType.parameter)
231-231: Call to an undefined method Colopl\Spanner\Query\Builder::from(). (method.notFound)
240-240: Call to an undefined method Colopl\Spanner\Connection::getPostProcessor(). (method.notFound)
240-240: Call to an undefined method Colopl\Spanner\Connection::getQueryGrammar(). (method.notFound)
240-240: Class Colopl\Spanner\Query\Builder does not have a constructor and must be instantiated without any parameters. (new.noConstructor)
246-246: Method Colopl\Spanner\Connection::select() has parameter $bindings with no type specified. (missingType.parameter)
246-246: Method Colopl\Spanner\Connection::select() has parameter $query with no type specified. (missingType.parameter)
246-246: Method Colopl\Spanner\Connection::select() has parameter $useReadPdo with no type specified. (missingType.parameter)
254-254: Method Colopl\Spanner\Connection::cursor() has parameter $bindings with no type specified. (missingType.parameter)
254-254: Method Colopl\Spanner\Connection::cursor() has parameter $query with no type specified. (missingType.parameter)
254-254: Method Colopl\Spanner\Connection::cursor() has parameter $useReadPdo with no type specified. (missingType.parameter)
267-267: Call to an undefined method Colopl\Spanner\Connection::run(). (method.notFound)
268-268: Call to an undefined method Colopl\Spanner\Connection::pretending(). (method.notFound)
282-282: Call to an undefined method Colopl\Spanner\Connection::run(). (method.notFound)
283-283: Call to an undefined method Colopl\Spanner\Connection::pretending(). (method.notFound)
292-292: Method Colopl\Spanner\Connection::statement() has parameter $bindings with no type specified. (missingType.parameter)
292-292: Method Colopl\Spanner\Connection::statement() has parameter $query with no type specified. (missingType.parameter)
313-313: Method Colopl\Spanner\Connection::affectingStatement() has parameter $bindings with no type specified. (missingType.parameter)
313-313: Method Colopl\Spanner\Connection::affectingStatement() has parameter $query with no type specified. (missingType.parameter)
317-317: Call to an undefined method Colopl\Spanner\Connection::run(). (method.notFound)
318-318: Call to an undefined method Colopl\Spanner\Connection::pretending(). (method.notFound)
334-334: Call to an undefined method Colopl\Spanner\Connection::pretending(). (method.notFound)
349-349: Method Colopl\Spanner\Connection::unprepared() has parameter $query with no type specified. (missingType.parameter)
357-357: Method Colopl\Spanner\Connection::getDatabaseName() has no return type specified. (missingType.return)
359-359: Call to method name() on an unknown class Google\Cloud\Spanner\Database. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
367-367: Method Colopl\Spanner\Connection::setDatabaseName() has parameter $database with no type specified. (missingType.parameter)
407-407: Method Colopl\Spanner\Connection::prepareBindings() has no return type specified. (missingType.return)
409-409: Call to an undefined method Colopl\Spanner\Connection::getQueryGrammar(). (method.notFound)
418-418: Parameter $grammar of method Colopl\Spanner\Connection::prepareBinding() has invalid type Illuminate\Database\Query\Grammars\Grammar. (class.notFound)
420-420: Class Illuminate\Contracts\Support\Arrayable not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
421-421: Call to method toArray() on an unknown class Illuminate\Contracts\Support\Arrayable. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
428-428: Instantiated class Google\Cloud\Spanner\Timestamp not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
446-446: Method Colopl\Spanner\Connection::escape() has no return type specified. (missingType.return)
446-446: Method Colopl\Spanner\Connection::escape() has parameter $binary with no type specified. (missingType.parameter)
450-450: Colopl\Spanner\Connection::escape() calls parent::escape() but Colopl\Spanner\Connection does not extend any class. (class.noParent)
474-474: Method Colopl\Spanner\Connection::escapeBool() has no return type specified. (missingType.return)
474-474: Method Colopl\Spanner\Connection::escapeBool() has parameter $value with no type specified. (missingType.parameter)
482-482: Method Colopl\Spanner\Connection::escapeString() has no return type specified. (missingType.return)
482-482: Method Colopl\Spanner\Connection::escapeString() has parameter $value with no type specified. (missingType.parameter)
492-492: Method Colopl\Spanner\Connection::runQueryCallback() has no return type specified. (missingType.return)
492-492: Method Colopl\Spanner\Connection::runQueryCallback() has parameter $bindings with no type specified. (missingType.parameter)
492-492: Method Colopl\Spanner\Connection::runQueryCallback() has parameter $query with no type specified. (missingType.parameter)
505-505: Caught class Google\Cloud\Core\Exception\AbortedException not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
506-506: Throwing object of an unknown class Google\Cloud\Core\Exception\AbortedException. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
513-513: Instantiated class Illuminate\Database\QueryException not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
513-513: Throwing object of an unknown class Illuminate\Database\QueryException. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
514-514: Call to an undefined method Colopl\Spanner\Connection::getName(). (method.notFound)
549-549: PHPDoc tag @throws with type Google\Cloud\Core\Exception\AbortedException|Google\Cloud\Core\Exception\NotFoundException|InvalidArgumentException is not subtype of Throwable (throws.notThrowable)
589-589: Call to method execute() on an unknown class Google\Cloud\Spanner\Transaction. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
593-593: Call to method snapshot() on an unknown class Google\Cloud\Spanner\Database. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
596-596: Call to method execute() on an unknown class Google\Cloud\Spanner\Database. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
606-606: Call to method batch() on an unknown class Google\Cloud\Spanner\SpannerClient. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
607-607: Access to an undefined property Colopl\Spanner\Connection::$database. (property.notFound)
Learn more: https://phpstan.org/blog/solving-phpstan-access-to-undefined-property
623-623: Parameter $transaction of method Colopl\Spanner\Connection::executeDml() has invalid type Google\Cloud\Spanner\Transaction. (class.notFound)
623-623: Parameter $transaction of method Colopl\Spanner\Connection::executeDml() has invalid type Google\Cloud\Spanner\Transaction. (class.notFound)
625-625: Call to method executeUpdate() on an unknown class Google\Cloud\Spanner\Transaction. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
626-626: Call to an undefined method Colopl\Spanner\Connection::recordsHaveBeenModified(). (method.notFound)
636-636: Parameter $transaction of method Colopl\Spanner\Connection::executeBatchDml() has invalid type Google\Cloud\Spanner\Transaction. (class.notFound)
636-636: Parameter $transaction of method Colopl\Spanner\Connection::executeBatchDml() has invalid type Google\Cloud\Spanner\Transaction. (class.notFound)
638-638: Call to method executeUpdateBatch() on an unknown class Google\Cloud\Spanner\Transaction. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
644-644: Instantiated class Google\Cloud\Core\Exception\ConflictException not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
644-644: Throwing object of an unknown class Google\Cloud\Core\Exception\ConflictException. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
653-653: Call to an undefined method Colopl\Spanner\Connection::recordsHaveBeenModified(). (method.notFound)
689-689: Class Illuminate\Database\QueryException not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
690-690: Call to method getPrevious() on an unknown class Illuminate\Database\QueryException. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
693-693: Class Google\Cloud\Core\Exception\NotFoundException not found. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
694-694: Call to method getMessage() on an unknown class Google\Cloud\Core\Exception\NotFoundException. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
Additional comments not posted (4)
src/Query/Concerns/UsesSnapshot.php (1)
45-48
: The methodsnapshotEnabled
is correctly implemented.src/Query/Builder.php (2)
32-32
: The integration of theUsesSnapshot
trait is correctly implemented.
193-196
: The updates to therunSelect
method to support snapshot queries are correctly implemented.src/Connection.php (1)
581-595
: The modifications in theexecuteQuery
method to support snapshot queries are correctly implemented.Tools
PHPStan
589-589: Call to method execute() on an unknown class Google\Cloud\Spanner\Transaction. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
593-593: Call to method snapshot() on an unknown class Google\Cloud\Spanner\Database. (class.notFound)
Learn more at https://phpstan.org/user-guide/discovering-symbols
src/Query/Concerns/UsesSnapshot.php
Outdated
public function useSnapshot(?TimestampBoundInterface $timestampBound = null): static | ||
{ | ||
$this->useSnapshot = true; | ||
if ($timestampBound !== null) { | ||
$this->withStaleness($timestampBound); | ||
} | ||
return $this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undefined method withStaleness
used in useSnapshot
.
Please ensure that withStaleness
is defined or properly inherited. If it's part of another trait or class, consider using PHPDoc @method
tag to clarify its availability.
@taka-oyama anything I can do to help this PR be ready for merge? |
Unfortunately, I'm going to be on paternity leave for about a month, so I won't be able to work on this until august. The reason there is no progress here is because I tried to use SingleUse Transaction to implement this, but there seems to be a bug in |
Is this just in the emulator? Or on real Spanner instances too? |
@taka-oyama any updates on this PR? |
49d9f30
to
d8a7a7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM.
Co-authored-by: halnique <[email protected]>
Fix: #145
Checklist
Reference
Summary by CodeRabbit
UNNEST
for large datasets.