Skip to content

Commit

Permalink
Added Laravel 11 support (#82)
Browse files Browse the repository at this point in the history
* Added Laravel 11 support

---------

Co-authored-by: Adalbert Makarovych <[email protected]>
Co-authored-by: AdalbertMemSQL <[email protected]>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent 68f7e89 commit 8e6b5b4
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 20 deletions.
7 changes: 2 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
// Update VARIANT to pick a PHP version: 8, 8.1, 8.0, 7, 7.4
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "8.1"
"VARIANT": "8.2"
}
},

// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"php.validate.executablePath": "/usr/local/bin/php"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"xdebug.php-debug",
Expand All @@ -27,8 +25,7 @@
]
}
},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "composer install",
"forwardPorts": []
}
}
26 changes: 22 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4, 8.0, 8.1]
laravel: [8.*, 9.*, 10.*]
php: [7.3, 7.4, 8.0, 8.1, 8.2]
laravel: [8.*, 9.*, 10.*, 11.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
Expand All @@ -31,12 +31,18 @@ jobs:
- laravel: 10.*
testbench: 8.*

- laravel: 11.*
testbench: 9.*

exclude:
# Laravel 8.0 has type incompatibilities with PHP 8.1.
- laravel: 8.*
php: 8.1
dependency-version: prefer-lowest

- laravel: 8.*
php: 8.2

# Laravel 9 requires PHP 8.0.
- laravel: 9.*
php: 7.3
Expand All @@ -53,13 +59,25 @@ jobs:

- laravel: 10.*
php: 8.0

# Laravel 11 requires PHP 8.2
- laravel: 11.*
php: 7.3

- laravel: 11.*
php: 7.4

- laravel: 11.*
php: 8.0

- laravel: 11.*
php: 8.1

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

services:
singlestore:
# check for new versions at https://github.com/singlestore-labs/singlestoredb-dev-image/pkgs/container/singlestoredb-dev/versions
image: ghcr.io/singlestore-labs/singlestoredb-dev:0.1.3
image: ghcr.io/singlestore-labs/singlestoredb-dev:latest
ports:
- "3306:3306"
env:
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
],
"require": {
"php": "^7.3|^8.0",
"illuminate/container": "^8.0|^9.0|^10.0",
"illuminate/database": "^8.0|^9.0|^10.0",
"illuminate/events": "^8.0|^9.0|^10.0",
"illuminate/support": "^8.0|^9.0|^10.0"
"illuminate/container": "^8.0|^9.0|^10.0|^11.0",
"illuminate/database": "^8.0|^9.0|^10.0|^11.0",
"illuminate/events": "^8.0|^9.0|^10.0|^11.0",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
},
"require-dev": {
"mockery/mockery": "^1.5",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"phpunit/phpunit": "^8.5.23|^9.5"
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
"phpunit/phpunit": "^8.5.23|^9.5|^10.5"
},
"config": {
"sort-packages": true
Expand All @@ -47,4 +47,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
22 changes: 21 additions & 1 deletion src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ class Blueprint extends BaseBlueprint

public const INDEX_PLACEHOLDER = '__singlestore_indexes__';

public function geography($column)
/**
* Create a new geography column on the table.
*
* @param string $column
* @param string|null $subtype
* @param int $srid
* @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function geography($column, $subtype = null, $srid = 4326)
{
return $this->addColumn('geography', $column);
}
Expand All @@ -27,6 +35,18 @@ public function geographyPoint($column)
return $this->point($column);
}

/**
* Create a new point column on the table.
*
* @param string $column
* @param int|null $srid
* @return \Illuminate\Database\Schema\ColumnDefinition
*/
public function point($column, $srid = null)
{
return $this->addColumn('point', $column);
}

/**
* Execute the blueprint against the database.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Schema/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ protected function createBlueprint($table, ?Closure $callback = null)
return parent::createBlueprint($table, $callback);
}

public function getAllTables()
{
return $this->connection->select(
'SHOW FULL TABLES WHERE table_type = \'BASE TABLE\''
);
}

/**
* Drop all tables from the database.
*
Expand Down
27 changes: 25 additions & 2 deletions src/Schema/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,32 @@ public function compileRename(Blueprint $blueprint, Fluent $command)
*/
public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
{
return sprintf('alter table %s change %s %s',
return sprintf(
'alter table %s change %s %s',
$this->wrapTable($blueprint),
$this->wrap($command->from),
$this->wrap($command->to));
$this->wrap($command->to)
);
}

/**
* Compile the query to determine the columns.
*
* @param string $database
* @param string $table
* @return string
*/
public function compileColumns($database, $table)
{
return sprintf(
'select column_name as `name`, data_type as `type_name`, column_type as `type`, '
.'collation_name as `collation`, is_nullable as `nullable`, '
.'column_default as `default`, column_comment as `comment`, '
.'"" as `expression`, extra as `extra` '
.'from information_schema.columns where table_schema = %s and table_name = %s '
.'order by ordinal_position asc',
$this->quoteString($database),
$this->quoteString($table)
);
}
}
6 changes: 6 additions & 0 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SingleStore\Laravel\Tests;

use Illuminate\Support\Facades\DB;
use Orchestra\Testbench\TestCase;
use PDO;
use SingleStore\Laravel\SingleStoreProvider;
Expand Down Expand Up @@ -35,4 +36,9 @@ public function getEnvironmentSetUp($app)
$app['config']->set('database.connections.mysql.driver', 'singlestore');
$app['config']->set('database.connections.mysql.options.'.PDO::ATTR_EMULATE_PREPARES, true);
}

public function singlestoreVersion()
{
return DB::select('SELECT @@memsql_version AS version')[0]->version;
}
}
7 changes: 7 additions & 0 deletions tests/Hybrid/FulltextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ public function throws_exception_when_using_an_unsupported_collation()
return;
}

if (version_compare(parent::singlestoreVersion(), '8.1.0', '>=')) {
// fulltext with utf8mb4_general_ci is supported in newer SingleStore
$this->markTestSkipped('requires lower SingleStore version');

return;
}

try {
// The default collation is utf8mb4_general_ci, which is unsupported for FULLTEXT
$this->createTable(function (Blueprint $table) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Hybrid/RenameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use SingleStore\Laravel\Schema\Blueprint;
use SingleStore\Laravel\Tests\BaseTest;

class RenameTableTest extends BaseTest
class RenameTest extends BaseTest
{
use HybridTestHelpers;

Expand Down

0 comments on commit 8e6b5b4

Please sign in to comment.