Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
fix for Laravel 10
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkingshott committed Apr 18, 2023
1 parent 01d9d9a commit c4cfa0b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion .php-cs-fixer.cache

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"php": "^7.4|^8.0"
},
"require-dev": {
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.0"
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^10.0"
},
"extra": {
"laravel": {
Expand All @@ -39,4 +39,4 @@
"test": "vendor/bin/phpunit"
},
"minimum-stability": "stable"
}
}
13 changes: 7 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage/>
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
8 changes: 4 additions & 4 deletions src/Macros/WhereFuzzy.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ protected static function calculateTotalRelevanceColumn($builder): bool
// search for fuzzy_relevance_* columns and _fuzzy_relevance_ position
foreach ($builder->columns as $as => $column) {
if ($column instanceof Expression) {
if (stripos($column->getValue(), 'AS fuzzy_relevance_')) {
if (stripos($column->getValue(DB::getQueryGrammar()), 'AS fuzzy_relevance_')) {
$matches = [];

preg_match('/AS (fuzzy_relevance_.*)$/', $column->getValue(), $matches);
preg_match('/AS (fuzzy_relevance_.*)$/', $column->getValue(DB::getQueryGrammar()), $matches);

if (! empty($matches[1])) {
$existingRelevanceColumns[$as] = $matches[1];
}
} elseif (stripos($column->getValue(), 'AS _fuzzy_relevance_')) {
} elseif (stripos($column->getValue(DB::getQueryGrammar()), 'AS _fuzzy_relevance_')) {
$sumColumnIdx = $as;
}
}
Expand All @@ -112,7 +112,7 @@ protected static function calculateTotalRelevanceColumn($builder): bool
foreach ($existingRelevanceColumns as $as => $column) {
$relevanceTotalColumn .= (! empty($relevanceTotalColumn) ? ' + ' : '')
. '('
. str_ireplace(' AS ' . $column, '', $builder->columns[$as]->getValue())
. str_ireplace(' AS ' . $column, '', $builder->columns[$as]->getValue(DB::getQueryGrammar()))
. ')';
}

Expand Down

0 comments on commit c4cfa0b

Please sign in to comment.