pmatseykanets / laravel-scout-postgres

PostgreSQL Full Text Search Engine for Laravel Scout
MIT License
159 stars 36 forks source link

Scout 9 #48

Open robert-abram opened 2 years ago

robert-abram commented 2 years ago

Helo, when scout 9.x will be support ?

devNoiseConsulting commented 2 years ago

Would like to 2nd this question/issue. Laravel 8 is going to stop getting bug fixes next week (July 26, 2022). This package is useful to me and would like to continue using it in the newer versions of Laravel.

AlbinoDrought commented 2 years ago

If you don't care about new Scout 9 features and just want to upgrade, this patch implements stubs for the new Scout 9 methods:

From 91743119444f97a6f289e17827cfc8309f51d1cd Mon Sep 17 00:00:00 2001
From: AlbinoDrought <snip>
Date: Fri, 5 Aug 2022 07:38:13 -0700
Subject: [PATCH] feat: Laravel 9 support

---
 composer.json          | 10 +++++-----
 src/PostgresEngine.php | 21 +++++++++++++++++++--
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/composer.json b/composer.json
index 305a86c..5007ed1 100644
--- a/composer.json
+++ b/composer.json
@@ -23,11 +23,11 @@
         }
     ],
     "require": {
-        "php": "^7.2|^8.0",
-        "illuminate/contracts": "~6.0|~7.0|~8.0",
-        "illuminate/database": "~6.0|~7.0|~8.0",
-        "illuminate/support": "~6.0|~7.0|~8.0",
-        "laravel/scout": "~7.0|~8.0"
+        "php": "^8.0",
+        "illuminate/contracts": "^9.0",
+        "illuminate/database": "^9.0",
+        "illuminate/support": "^9.0",
+        "laravel/scout": "^9.0"
     },
     "require-dev": {
         "phpunit/phpunit": "^8.3",
diff --git a/src/PostgresEngine.php b/src/PostgresEngine.php
index b92b3e0..8504090 100644
--- a/src/PostgresEngine.php
+++ b/src/PostgresEngine.php
@@ -6,6 +6,7 @@ use Illuminate\Database\ConnectionResolverInterface;
 use Illuminate\Database\Eloquent\Collection;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Arr;
+use Illuminate\Support\LazyCollection;
 use Laravel\Scout\Builder;
 use Laravel\Scout\Engines\Engine;
 use ScoutEngines\Postgres\TsQuery\PhraseToTsQuery;
@@ -75,7 +76,6 @@ class PostgresEngine extends Engine
      * Perform update of the given model.
      *
      * @param \Illuminate\Database\Eloquent\Model $model
-     * @return bool
      */
     protected function performUpdate(Model $model)
     {
@@ -339,6 +339,24 @@ class PostgresEngine extends Engine
             });
     }

+    public function lazyMap(Builder $builder, $results, $model)
+    {
+        // not supported
+        return new LazyCollection(
+            $this->map($builder, $results, $model)
+        );
+    }
+
+    public function createIndex($name, array $options = [])
+    {
+        return null;
+    }
+
+    public function deleteIndex($name)
+    {
+        return null;
+    }
+
     /**
      * Connect to the database.
      */
@@ -389,7 +407,6 @@ class PostgresEngine extends Engine
      * Get rank function.
      *
      * @param \Illuminate\Database\Eloquent\Model $model
-     * @return int
      */
     protected function rankFunction(Model $model)
     {
-- 
2.37.1

(the changed PHPDoc is due to Psalm complaints, rankFunction actually returns string, performUpdate actually returns int|bool)

AlbinoDrought commented 1 year ago

Following the above patch to Scout 9, the BC-break changes in Laravel 10 and Scout 10 do not impact this package:

From da73332097fbff3a694f3fb7d0a08e01a78066be Mon Sep 17 00:00:00 2001
From: AlbinoDrought <snip>
Date: Thu, 16 Mar 2023 11:15:06 -0700
Subject: [PATCH] feat: Laravel 10, Scout 10 support

---
 composer.json | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/composer.json b/composer.json
index 5007ed1..6146c4f 100644
--- a/composer.json
+++ b/composer.json
@@ -24,10 +24,10 @@
     ],
     "require": {
         "php": "^8.0",
-        "illuminate/contracts": "^9.0",
-        "illuminate/database": "^9.0",
-        "illuminate/support": "^9.0",
-        "laravel/scout": "^9.0"
+        "illuminate/contracts": "^10.0 || ^9.0",
+        "illuminate/database": "^10.0 || ^9.0",
+        "illuminate/support": "^10.0 || ^9.0",
+        "laravel/scout": "^10.0 || ^9.0"
     },
     "require-dev": {
         "phpunit/phpunit": "^8.3",
-- 
2.38.1
devNoiseConsulting commented 1 year ago

@AlbinoDrought I've not seen any responses or updates, I've forked this project and am trying to update/maintain the driver.