mysql/h2: how do i know which one is being used?

10 views
Skip to first unread message

Mohit Jaggi

unread,
May 7, 2018, 5:01:08 PM5/7/18
to Slick / ScalaQuery
I have a table project_permissions with two fields: project_id and user_id. An entry here indicates that a user is allowed to access this project.

I am writing a DAO to aggregate user_id after grouping by project_id. The goal is to get a list of allowed users for a project for display on a UI. My production DB is mysql which supports JSON_ARRAYAGG but I use H2 for unit tests which has a different approach i.e. ARRAY_AGG. Slick does not provide a wrapper to abstract out this difference. So I am using sql"..." directly. I will have a different query in test than in production (bad, bad, I know!) and want to find out at runtime which backend is being used. 

val query = if(backend is mysql) sql".....JSON_ARRAYAGG..." else sql"....ARRAY_AGG..."

How can I check the backend DB?

If you have suggestions on how to approach this cleanly, I will appreciate those too!
Reply all
Reply to author
Forward
0 new messages