Skip to content

Laravel 12 support #99

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

Merged
merged 6 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 4 additions & 58 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
laravel: [8.*, 9.*, 10.*, 11.*]
php: [8.2, 8.3, 8.4]
laravel: [12.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: 6.*

- laravel: 9.*
testbench: 7.*

- 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: 8.*
php: 8.3

- laravel: 8.*
php: 8.4

# Laravel 9 requires PHP 8.0.
- laravel: 9.*
php: 7.3

- laravel: 9.*
php: 7.4

# Laravel 10 requires PHP 8.1
- laravel: 10.*
php: 7.3

- laravel: 10.*
php: 7.4

- 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
- laravel: 12.*
testbench: 10.*

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

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
}
],
"require": {
"php": "^7.3|^8.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"
"php": "^8.2",
"illuminate/container": "^12.0",
"illuminate/database": "^12.0",
"illuminate/events": "^12.0",
"illuminate/support": "^12.0"
},
"require-dev": {
"mockery/mockery": "^1.5",
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
"phpunit/phpunit": "^8.5.23|^9.5|^10.5"
"mockery/mockery": "^1.6.10",
"orchestra/testbench": "^10.0.0",
"phpunit/phpunit": "^10.5.35|^11.5.3|^12.0.1"
},
"config": {
"sort-packages": true
Expand Down
14 changes: 5 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false"
backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false"
stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="unit">
<directory>tests/Unit</directory>
Expand Down
69 changes: 0 additions & 69 deletions src/Connect/Connection.php

This file was deleted.

57 changes: 57 additions & 0 deletions src/Connect/SingleStoreConnection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace SingleStore\Laravel\Connect;

use Illuminate\Database\MySqlConnection;
use SingleStore\Laravel\Query\SingleStoreQueryBuilder;
use SingleStore\Laravel\Query\SingleStoreQueryGrammar;
use SingleStore\Laravel\Schema\SingleStoreSchemaBuilder;
use SingleStore\Laravel\Schema\SingleStoreSchemaGrammar;

class SingleStoreConnection extends MySqlConnection
{
public function getSchemaBuilder()
{
if ($this->schemaGrammar === null) {
$this->useDefaultSchemaGrammar();
}

return new SingleStoreSchemaBuilder($this);
}

/**
* Get the default query grammar instance.
*
* @return SingleStoreQueryGrammar
*/
protected function getDefaultQueryGrammar()
{
return new SingleStoreQueryGrammar(
connection: $this,
ignoreOrderByInDeletes: $this->getConfig('ignore_order_by_in_deletes'),
ignoreOrderByInUpdates: $this->getConfig('ignore_order_by_in_updates')
);
}

/**
* Get the default schema grammar instance.
*
* @return SingleStoreSchemaGrammar
*/
protected function getDefaultSchemaGrammar()
{
return new SingleStoreSchemaGrammar($this);
}

/**
* Get a new query builder instance.
*/
public function query()
{
return new SingleStoreQueryBuilder(
$this,
$this->getQueryGrammar(),
$this->getPostProcessor()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

use Illuminate\Database\Connectors\MySqlConnector;

class Connector extends MySqlConnector {}
class SingleStoreConnector extends MySqlConnector {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\Query\Builder as BaseBuilder;

class Builder extends BaseBuilder
class SingleStoreQueryBuilder extends BaseBuilder
{
public $options;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
namespace SingleStore\Laravel\Query;

use Exception;
use Illuminate\Database\Connection;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Grammars\MySqlGrammar;
use Illuminate\Support\Facades\Log;

class Grammar extends MySqlGrammar
class SingleStoreQueryGrammar extends MySqlGrammar
{
private $ignoreOrderByInDeletes;

private $ignoreOrderByInUpdates;

public function __construct($ignoreOrderByInDeletes, $ignoreOrderByInUpdates)
public function __construct(Connection $connection, $ignoreOrderByInDeletes, $ignoreOrderByInUpdates)
{
parent::__construct($connection);

$this->ignoreOrderByInDeletes = $ignoreOrderByInDeletes;
$this->ignoreOrderByInUpdates = $ignoreOrderByInUpdates;
}
Expand Down
10 changes: 4 additions & 6 deletions src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
namespace SingleStore\Laravel\Schema;

use Exception;
use Illuminate\Database\Connection;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint as BaseBlueprint;
use Illuminate\Database\Schema\Grammars\Grammar;
use SingleStore\Laravel\Schema\Blueprint\AddsTableFlags;
use SingleStore\Laravel\Schema\Blueprint\InlinesIndexes;
use SingleStore\Laravel\Schema\Blueprint\ModifiesIndexes;
Expand Down Expand Up @@ -52,16 +50,16 @@ public function point($column, $srid = null)
*
* @return void
*/
public function build(Connection $connection, Grammar $grammar)
public function build()
{
try {
parent::build($connection, $grammar);
parent::build();
} catch (QueryException $exception) {
if (str_contains($exception->getMessage(), 'FULLTEXT KEY with unsupported type')) {
throw new Exception('FULLTEXT is not supported when using the utf8mb4 collation.');
} else {
throw $exception;
}

throw $exception;
}
}
}
15 changes: 5 additions & 10 deletions src/Schema/Blueprint/InlinesIndexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace SingleStore\Laravel\Schema\Blueprint;

use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Grammars\Grammar;
use Illuminate\Foundation\Application;
use Illuminate\Support\Arr;
use SingleStore\Laravel\Schema\Blueprint as SingleStoreBlueprint;

Expand Down Expand Up @@ -109,13 +107,9 @@ protected function addFluentSingleStoreIndexes()
}
}

public function toSql(Connection $connection, Grammar $grammar)
public function toSql()
{
if (version_compare(Application::VERSION, '10.0.0', '>=')) {
$this->addImpliedCommands($connection, $grammar);
} else {
$this->addImpliedCommands($grammar);
}
$this->addImpliedCommands();
$this->addFluentSingleStoreIndexes();

$statements = [];
Expand All @@ -129,9 +123,10 @@ public function toSql(Connection $connection, Grammar $grammar)
$method = 'compile'.ucfirst($command->name);
$isIndex = $this->isIndexCommand($command);

if (method_exists($grammar, $method) || $grammar::hasMacro($method)) {
if (! is_null($sql = $grammar->$method($this, $command, $connection))) {
if (method_exists($this->grammar, $method) || $this->grammar::hasMacro($method)) {
if (! is_null($sql = $this->grammar->$method($this, $command))) {
$statements = array_merge($statements, (array) $sql);

if ($isIndex) {
array_push($indexStatementKeys, count($statements) - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Closure;
use Illuminate\Database\Schema\MySqlBuilder;

class Builder extends MySqlBuilder
class SingleStoreSchemaBuilder extends MySqlBuilder
{
/**
* @param string $table
Expand Down
Loading