Skip to content

Commit 8e6b5b4

Browse files
AdalbertMemSQLAdalbert Makarovych
and
Adalbert Makarovych
authored
Added Laravel 11 support (#82)
* Added Laravel 11 support --------- Co-authored-by: Adalbert Makarovych <[email protected]> Co-authored-by: AdalbertMemSQL <[email protected]>
1 parent 68f7e89 commit 8e6b5b4

File tree

9 files changed

+98
-20
lines changed

9 files changed

+98
-20
lines changed

.devcontainer/devcontainer.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
// Update VARIANT to pick a PHP version: 8, 8.1, 8.0, 7, 7.4
99
// Append -bullseye or -buster to pin to an OS version.
1010
// Use -bullseye variants on local on arm64/Apple Silicon.
11-
"VARIANT": "8.1"
11+
"VARIANT": "8.2"
1212
}
1313
},
14-
1514
// Set *default* container specific settings.json values on container create.
1615
"customizations": {
1716
"vscode": {
1817
"settings": {
1918
"php.validate.executablePath": "/usr/local/bin/php"
2019
},
21-
2220
// Add the IDs of extensions you want installed when the container is created.
2321
"extensions": [
2422
"xdebug.php-debug",
@@ -27,8 +25,7 @@
2725
]
2826
}
2927
},
30-
3128
// Use 'postCreateCommand' to run commands after the container is created.
3229
"postCreateCommand": "composer install",
3330
"forwardPorts": []
34-
}
31+
}

.github/workflows/tests.yml

+22-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php: [7.3, 7.4, 8.0, 8.1]
22-
laravel: [8.*, 9.*, 10.*]
21+
php: [7.3, 7.4, 8.0, 8.1, 8.2]
22+
laravel: [8.*, 9.*, 10.*, 11.*]
2323
dependency-version: [prefer-lowest, prefer-stable]
2424
include:
2525
- laravel: 8.*
@@ -31,12 +31,18 @@ jobs:
3131
- laravel: 10.*
3232
testbench: 8.*
3333

34+
- laravel: 11.*
35+
testbench: 9.*
36+
3437
exclude:
3538
# Laravel 8.0 has type incompatibilities with PHP 8.1.
3639
- laravel: 8.*
3740
php: 8.1
3841
dependency-version: prefer-lowest
3942

43+
- laravel: 8.*
44+
php: 8.2
45+
4046
# Laravel 9 requires PHP 8.0.
4147
- laravel: 9.*
4248
php: 7.3
@@ -53,13 +59,25 @@ jobs:
5359

5460
- laravel: 10.*
5561
php: 8.0
62+
63+
# Laravel 11 requires PHP 8.2
64+
- laravel: 11.*
65+
php: 7.3
66+
67+
- laravel: 11.*
68+
php: 7.4
69+
70+
- laravel: 11.*
71+
php: 8.0
72+
73+
- laravel: 11.*
74+
php: 8.1
5675

5776
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
5877

5978
services:
6079
singlestore:
61-
# check for new versions at https://github.com/singlestore-labs/singlestoredb-dev-image/pkgs/container/singlestoredb-dev/versions
62-
image: ghcr.io/singlestore-labs/singlestoredb-dev:0.1.3
80+
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
6381
ports:
6482
- "3306:3306"
6583
env:

composer.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
],
2626
"require": {
2727
"php": "^7.3|^8.0",
28-
"illuminate/container": "^8.0|^9.0|^10.0",
29-
"illuminate/database": "^8.0|^9.0|^10.0",
30-
"illuminate/events": "^8.0|^9.0|^10.0",
31-
"illuminate/support": "^8.0|^9.0|^10.0"
28+
"illuminate/container": "^8.0|^9.0|^10.0|^11.0",
29+
"illuminate/database": "^8.0|^9.0|^10.0|^11.0",
30+
"illuminate/events": "^8.0|^9.0|^10.0|^11.0",
31+
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
3232
},
3333
"require-dev": {
3434
"mockery/mockery": "^1.5",
35-
"orchestra/testbench": "^6.0|^7.0|^8.0",
36-
"phpunit/phpunit": "^8.5.23|^9.5"
35+
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
36+
"phpunit/phpunit": "^8.5.23|^9.5|^10.5"
3737
},
3838
"config": {
3939
"sort-packages": true
@@ -47,4 +47,4 @@
4747
},
4848
"minimum-stability": "dev",
4949
"prefer-stable": true
50-
}
50+
}

src/Schema/Blueprint.php

+21-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ class Blueprint extends BaseBlueprint
1717

1818
public const INDEX_PLACEHOLDER = '__singlestore_indexes__';
1919

20-
public function geography($column)
20+
/**
21+
* Create a new geography column on the table.
22+
*
23+
* @param string $column
24+
* @param string|null $subtype
25+
* @param int $srid
26+
* @return \Illuminate\Database\Schema\ColumnDefinition
27+
*/
28+
public function geography($column, $subtype = null, $srid = 4326)
2129
{
2230
return $this->addColumn('geography', $column);
2331
}
@@ -27,6 +35,18 @@ public function geographyPoint($column)
2735
return $this->point($column);
2836
}
2937

38+
/**
39+
* Create a new point column on the table.
40+
*
41+
* @param string $column
42+
* @param int|null $srid
43+
* @return \Illuminate\Database\Schema\ColumnDefinition
44+
*/
45+
public function point($column, $srid = null)
46+
{
47+
return $this->addColumn('point', $column);
48+
}
49+
3050
/**
3151
* Execute the blueprint against the database.
3252
*

src/Schema/Builder.php

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ protected function createBlueprint($table, ?Closure $callback = null)
2424
return parent::createBlueprint($table, $callback);
2525
}
2626

27+
public function getAllTables()
28+
{
29+
return $this->connection->select(
30+
'SHOW FULL TABLES WHERE table_type = \'BASE TABLE\''
31+
);
32+
}
33+
2734
/**
2835
* Drop all tables from the database.
2936
*

src/Schema/Grammar.php

+25-2
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,32 @@ public function compileRename(Blueprint $blueprint, Fluent $command)
241241
*/
242242
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
243243
{
244-
return sprintf('alter table %s change %s %s',
244+
return sprintf(
245+
'alter table %s change %s %s',
245246
$this->wrapTable($blueprint),
246247
$this->wrap($command->from),
247-
$this->wrap($command->to));
248+
$this->wrap($command->to)
249+
);
250+
}
251+
252+
/**
253+
* Compile the query to determine the columns.
254+
*
255+
* @param string $database
256+
* @param string $table
257+
* @return string
258+
*/
259+
public function compileColumns($database, $table)
260+
{
261+
return sprintf(
262+
'select column_name as `name`, data_type as `type_name`, column_type as `type`, '
263+
.'collation_name as `collation`, is_nullable as `nullable`, '
264+
.'column_default as `default`, column_comment as `comment`, '
265+
.'"" as `expression`, extra as `extra` '
266+
.'from information_schema.columns where table_schema = %s and table_name = %s '
267+
.'order by ordinal_position asc',
268+
$this->quoteString($database),
269+
$this->quoteString($table)
270+
);
248271
}
249272
}

tests/BaseTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace SingleStore\Laravel\Tests;
44

5+
use Illuminate\Support\Facades\DB;
56
use Orchestra\Testbench\TestCase;
67
use PDO;
78
use SingleStore\Laravel\SingleStoreProvider;
@@ -35,4 +36,9 @@ public function getEnvironmentSetUp($app)
3536
$app['config']->set('database.connections.mysql.driver', 'singlestore');
3637
$app['config']->set('database.connections.mysql.options.'.PDO::ATTR_EMULATE_PREPARES, true);
3738
}
39+
40+
public function singlestoreVersion()
41+
{
42+
return DB::select('SELECT @@memsql_version AS version')[0]->version;
43+
}
3844
}

tests/Hybrid/FulltextTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ public function throws_exception_when_using_an_unsupported_collation()
120120
return;
121121
}
122122

123+
if (version_compare(parent::singlestoreVersion(), '8.1.0', '>=')) {
124+
// fulltext with utf8mb4_general_ci is supported in newer SingleStore
125+
$this->markTestSkipped('requires lower SingleStore version');
126+
127+
return;
128+
}
129+
123130
try {
124131
// The default collation is utf8mb4_general_ci, which is unsupported for FULLTEXT
125132
$this->createTable(function (Blueprint $table) {

tests/Hybrid/RenameTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use SingleStore\Laravel\Schema\Blueprint;
77
use SingleStore\Laravel\Tests\BaseTest;
88

9-
class RenameTableTest extends BaseTest
9+
class RenameTest extends BaseTest
1010
{
1111
use HybridTestHelpers;
1212

0 commit comments

Comments
 (0)