This is working as expected as I can browse table data from both databases in the “all” view and within a custom segment using the Simple query. However, if I use a custom SQL query (one that worked prior to adding the second database), I receive an error.
My expectation is that the segment with custom SQL would continue to work after adding a second database.
Actual behavior
Receive error in Forest Admin UI and on server output.
[forest] 🌳🌳🌳 Invalid SQL query for this Live Query segment:
relation "exchanges" does not exist
Executing (default): select * from exchanges where description is null
Context
Please provide any relevant information about your setup.
The table name is exchanges so it needs the s and I’ve tried with and without the schema. This exact same query worked prior to migrating to a multi-database setup. I feel like the raw SQL is getting confused as to what database to use but that’s just a hunch.
I confirmed it is trying to use only the first database connection and after flipping my two databases, I am able to query the exchanges table without error. However, I always get No Exchanges match the segment when running the query even the table has data matching the query conditions. Pasting the exact same query from the server log into my SQL editor returns the correct data as expected.
I guess your new issue would deserve a new post if it persists.
Are you sure you don’t have additional filtering with your live query segment (filters, scopes,…) that could explain that you have no results displayed in your admin panel?
I am sure about no additional filters. However, this still feels like a bug? I flipped my connections to get custom SQL segments working for this database but I need to do the same for my other database and am unable to do so.
Is there any additional information available here? I am still running into the original issue of not being able to use multiple databases in SQL query segments at the same time.
Unfortunately, as you experienced, SQL queries are not well supported on multiple database projects.
Only the first connection tables can be queried with the current implementation.
This support cannot be done with a simple patch, it needs some kind of product design and additional features to deliver the best experience possible.
This is a topic will should start to tackle in September.