Skip to content

Commit 74a4b86

Browse files
authored
Normalize group hashes for singlestore connections (#225)
1 parent 62bd80e commit 74a4b86

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

composer-dependency-analyser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
->ignoreErrorsOnPackageAndPath('spatie/laravel-ignition', __DIR__.'/src/Location.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
1010
->ignoreErrorsOnPackageAndPath('livewire/livewire', __DIR__.'/src/NightwatchServiceProvider.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
1111
->ignoreErrorsOnPackageAndPath('livewire/livewire', __DIR__.'/src/Hooks/LivewireListener.php', [ErrorType::DEV_DEPENDENCY_IN_PROD])
12+
->ignoreErrorsOnPath(__DIR__.'/tests/Feature/Sensors/QuerySensorTest.php', [ErrorType::UNKNOWN_CLASS])
1213
->ignoreUnknownClasses(['Laravel\Octane\Events\RequestReceived']);

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"phpstan/phpstan": "^1.0",
4343
"phpunit/phpunit": "^10.0|^11.0",
4444
"ramsey/uuid": "^4.0",
45+
"singlestoredb/singlestoredb-laravel": "^1.0|^2.0",
4546
"spatie/laravel-ignition": "^2.0",
4647
"symfony/mailer": "^6.0|^7.0",
4748
"symfony/mime": "^6.0|^7.0",

src/Sensors/QuerySensor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function () use ($event, $record) {
7575

7676
private function hash(QueryExecuted $event, Query $record): string
7777
{
78-
if (! in_array($event->connection->getDriverName(), ['mariadb', 'mysql', 'pgsql', 'sqlite', 'sqlsrv'], true)) {
78+
if (! in_array($event->connection->getDriverName(), ['mariadb', 'mysql', 'pgsql', 'sqlite', 'sqlsrv', 'singlestore'], true)) {
7979
return hash('xxh128', "{$record->connection},{$record->sql}");
8080
}
8181

tests/Feature/Sensors/QuerySensorTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use MongoDB\Laravel\Connection as MongoDbConnection;
1818
use PDO;
1919
use PHPUnit\Framework\Attributes\DataProvider;
20+
use SingleStore\Laravel\Connect\Connection as LegacySingleStoreConnection;
21+
use SingleStore\Laravel\Connect\SingleStoreConnection;
2022
use Tests\TestCase;
2123

2224
use function base64_encode;
@@ -207,6 +209,15 @@ public static function whereInQueries(): iterable
207209
new SqlServerConnection('test', config: ['name' => 'foo', 'driver' => 'sqlsrv']),
208210
];
209211

212+
yield 'singlestore' => [
213+
'select * from `users` where `users`.`id` in (1, 2, 3) and `id` in (?, ?, ?)',
214+
hash('xxh128', 'foo,select * from `users` where `users`.`id` in (...?) and `id` in (...?)'),
215+
match (true) {
216+
class_exists(SingleStoreConnection::class) => new SingleStoreConnection('test', config: ['name' => 'foo', 'driver' => 'singlestore']),
217+
class_exists(LegacySingleStoreConnection::class) => new LegacySingleStoreConnection('test', config: ['name' => 'foo', 'driver' => 'singlestore']),
218+
},
219+
];
220+
210221
yield 'mongodb' => [
211222
'some mongo query in (1, 2, 3) and [id] in (?, ?, ?)',
212223
hash('xxh128', 'foo,some mongo query in (1, 2, 3) and [id] in (?, ?, ?)'),
@@ -276,6 +287,15 @@ public static function insertQueries(): iterable
276287
new SqlServerConnection('test', config: ['name' => 'foo', 'driver' => 'sqlsrv']),
277288
];
278289

290+
yield 'singlestore' => [
291+
'insert into `users` (`id`, `name`) values (?, ?)',
292+
hash('xxh128', 'foo,insert into `users` (`id`, `name`) values ...'),
293+
match (true) {
294+
class_exists(SingleStoreConnection::class) => new SingleStoreConnection('test', config: ['name' => 'foo', 'driver' => 'singlestore']),
295+
class_exists(LegacySingleStoreConnection::class) => new LegacySingleStoreConnection('test', config: ['name' => 'foo', 'driver' => 'singlestore']),
296+
},
297+
];
298+
279299
yield 'mongodb' => [
280300
'insert some mongo query values (?, ?), (?, ?)',
281301
hash('xxh128', 'foo,insert some mongo query values (?, ?), (?, ?)'),

0 commit comments

Comments
 (0)