scala - Slick: query multiple tables/databases with getting column names -


I have methods in my play app that query database tables with more than one hundred columns. I can not define the case class for each such question, because it will be just ridiculously large and the database will have to change with each change in the table.

I am using this approach, where the result of the query looks like this:

  Map (column name 1 - & gt; column Val1, columnName2 - & gt; ; columnVal2, ...)   

Example code:

  Built-in value getListStringResult = GetResult [list [any]] (R => ( 1 to r.numColumns) .map (_ = & gt; r nxtibz) .toList) def GetSomething (): map [string, any] = db.extension {val column = MTable.getTables (none, none , None, none) .list.filter (_name.name == "myTable"). Head.getColumns .list.map (_ column) val results = sql Choose "Meritable 1" from "[" [list]]. FirstOption.map (column zip _ toMap) .get}   

This is not a problem when the query runs on only one database and a single table. I need to use multiple tables and databases in my query like this:

  def getSomething (): Map [string, any] = DB.withSession {// The line below is not multiple tables / database Val column = MTable.getTables (None, None, To No, none) is now valid because of .list.filter (_name.name == "table1"). Head.getColumns.list.map (_ column) Val result = sql "SELECT * FROM db1.table1" JOIN Db2.table2 ON db2.table2.col1 = db1.table1.col1 LIMIT 1 ". [List [Any]]. FirstOption.map (Column zip _ toMap) .get}   

The same approach can not be used to retrieve column names. This problem does not exist when using some things like PHP PDO or Java JDBCTemplate - they retrieve the column names without any extra effort.

My question is: How can I get it cleverly?

  import scala. Slick.jdbc {GetResult, PositionedResult} Object ResultMap extends to GetResult [Map [string, any]] {FRF applied (PR: postable result) = {val RS = PRRR //    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -