Testing DB join queries over connections with SQLite :memory: databases

Posted 3 months ago by phikhi

In my application I have this query which uses joins over a different mysql connection.

DB::connection('tenant1')->table('stats AS t')
            ->select(['user_id', 'u.created_at'])
            ->join(config('database.connections.tenant2.database').'.users AS u', 't.user_id', '=', 'u.uid')
            ->whereBetween('event_date', $datesInterval)

It works perfectly in the application context.

But when it comes to testing. I use sqlite for each connections. And each connection uses :memory: databases.

When the test runs it tells me that it cannot find the join table : :memory:.users

Did anyone had this same issue, and a possible solution ?

Or will I be forced to use mysql for my tests too ?

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

Reply to

Use Markdown with GitHub-flavored code blocks.