bencarter78
4 years ago
367
1
Testing

Testing CONCAT queries with SQLite

Posted 4 years ago by bencarter78

Hi

I am testing my application and have set it up to use a sqlite in-memory database. How would you go about testing the following knowing that the CONCAT doesn't work in sqlite (it's || instead)? Is there a way round this?

<?php

namespace App\Repositories;

use App\Models\Contact;

class Contacts extends EloquentRepository
{
    protected $model;

    function __construct(Contact $model)
    {
        $this->model = $model;
    }

    public function search($term, $orgId = null)
    {
        return $this->model->where(DB::raw(CONCAT('first_name', ' ', 'surname'), 'LIKE', "%$term%")->get();
    }

Please sign in or create an account to participate in this conversation.