Skip to content

Scout Import fails with eager loaded relationships #12

Open
@nhuebnereagle

Description

@nhuebnereagle

First - Thank you for making a PostgreSql extension for Scout! I was able to resolve the issue, but still reporting it in case it's something in Scout or the driver. If I need to bring this over to Scout, let me know and I can do that.

The following code in my model was causing a PostgreSql error. This code automatically loads my relationships when I pull back a record:

Model Relationships Causing Error

protected $with = [
    'category',
    'attachments',
];

Here's the error I would get when attempting a Scout Import using the Command Line command:

PostgreSql Error

SQLSTATE[HY093]: Invalid parameter number: parameter was not defined (SQL: select to_tsvector(COALESCE(english, get_current_ts_config()), 177) || to_tsvector(COALESCE(english, get_current_ts_config()), 2017-05-25 09:46:03) || to_tsvector(COALESCE(english, get_current_ts_config()), 2017-05-25 09:46:03) || to_tsvector(COALESCE(english, get_current_ts_config()), ) || to_tsvector(COALESCE(english, get_current_ts_config()), ) || to_tsvector(COALESCE(english, get_current_ts_config()), ) || to_tsvector(COALESCE(english, get_current_ts_config()), 1) || to_tsvector(COALESCE(english, get_current_ts_config()), Videos) || to_tsvector(COALESCE(english, get_current_ts_config()), 23) || to_tsvector(COALESCE(english, get_current_ts_config()), <pTest Article Content</p>) || to_tsvector(COALESCE(english, get_current_ts_config()), ) || to_tsvector(COALESCE(english, get_current_ts_config()), 23) || to_tsvector(COALESCE(2017-05-23 16:26:58, get_current_ts_config()), 2017-05-23 16:26:58) || to_tsvector(COALESCE(, get_current_ts_config()), ) AS tsvector limit 1)

After commenting out the above code from my model I was able to import successfully:

Success

#> php artisan scout:import "App\Data\Models\HelpCenter\Article" 

Imported [App\Data\Models\HelpCenter\Article] models up to ID: 235
All [App\Data\Models\HelpCenter\Article] records have been imported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions