I have defined a slick table as below on DB view. Every day we create a dated view matching the same structure with name appended with date as T_SUMMARY_ i.e.T_SUMMARY_20131213.
Is there a way in slick where table name can be dynamically overridden to generate required query for a correct dated view.
object TSummary extends Table[(String)]("T_SUMMARY")
{
def id = column[String]("ROWID", O.PrimaryKey)
def tNum = column[Int]("T_NUM")
def tName = column[Int]("T_NAME")
def * = id
}
In Slick 1.0.1:
def mkSummaryTable(name: String) = new Table[(String)](name){
def id = column[String]("ROWID", O.PrimaryKey)
def tNum = column[Int]("T_NUM")
def tName = column[Int]("T_NAME")
def * = id
}
val current = mkSummaryTable("T_SUMMARY_20131213")
for( r <- Query(current) ) yield r.tName
For Slick 2.0 see https://groups.google.com/d/msg/scalaquery/95Z7AfxKP_4/omGnAtuN8FcJ:
class MyTable(tag: Tag, tableName: String) extends Table[(String)](tag, tableName){
def id = column[String]("ROWID", O.PrimaryKey)
def tNum = column[Int]("T_NUM")
def tName = column[Int]("T_NAME")
def * = id
}
val tQ = TableQuery[MyTable]((tag:Tag) => new MyTable(tag, "SomeTableName")) filter ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With