slick

what is the correct way to design a 'table to row' relationship?

丶灬走出姿态 提交于 2020-02-06 15:42:33
问题 I am trying to model the following in a postgres db. I have N number of 'datasets'. These datasets are things like survey results, national statistics, aggregated data etc. They each have a name a source insitution a method etc. This is the meta data of a dataset and I have tables created for this and tables for codifying the research methods etc. The 'root' meta-data table is called 'Datasets'. Each row represents one dataset. I then need to store and access the actual data associated with

Slick code generation for only a single schema

自古美人都是妖i 提交于 2020-02-03 22:51:28
问题 Is there a way to have Slick's code generation generate code for only a single schema? Say, public? I have extensions that create a whole ton of tables (eg postgis, pg_jobman) that make the code that slick generates gigantic. 回答1: Use this code with appropriate values and schema name, object CodeGenerator { def outputDir :String ="" def pkg:String ="" def schemaList:String = "schema1, schema2" def url:String = "dburl" def fileName:String ="" val user = "dbUsername" val password = "dbPassword"

Slick code generation for only a single schema

删除回忆录丶 提交于 2020-02-03 22:48:16
问题 Is there a way to have Slick's code generation generate code for only a single schema? Say, public? I have extensions that create a whole ton of tables (eg postgis, pg_jobman) that make the code that slick generates gigantic. 回答1: Use this code with appropriate values and schema name, object CodeGenerator { def outputDir :String ="" def pkg:String ="" def schemaList:String = "schema1, schema2" def url:String = "dburl" def fileName:String ="" val user = "dbUsername" val password = "dbPassword"

How to express Postgres arrays with Scala Slick

偶尔善良 提交于 2020-01-30 08:24:25
问题 I have a table in Postgres 9.5 with this structure: my_table (id Integer, images_ranks image_rank[]); where image_rank is: CREATE TYPE image_rank AS (image_url text, thumbnail_rank integer); I am struggling to express something like that in Slick (3.1): case class MyTable (id: Int, imagesRanks: Seq[Option[ImageRank]]) implicit val propertyMyTableResult = GetResult(r => MyTable(r.<<, r.<<) implicit val propertyImageRankResult = GetResult[Option[ImageRank]] { r => ImageRank(r.<<, r.<<)) } What

Scala slick update table after querying with a join

浪子不回头ぞ 提交于 2020-01-24 20:06:25
问题 I want to update a table but the row needs to be selected based on certain conditions. Following code compiles fine but throws run-time exception: play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[SlickException: A query for an UPDATE statement must resolve to a comprehension with a single table -- Unsupported shape: Comprehension s2, Some(Apply Function =), None, ConstArray(), None, None, None, None]] Here is the function (the intention is to allow update only for

Map inheritance in slick 2.0

£可爱£侵袭症+ 提交于 2020-01-24 15:40:32
问题 I know there are other questions in stack overflow, but None of them works for me. I'm trying to map a simple inheritance in slick projection I try hundreds of combinations, I can't make this compile. I end of with the follow code and the error bellow. I simplify the case classes because they have much more data. Without inheritance my other layers (controllers, services and interface) will have to deal with complexity, because in this case the model represents real objects that are in

Map inheritance in slick 2.0

空扰寡人 提交于 2020-01-24 15:40:26
问题 I know there are other questions in stack overflow, but None of them works for me. I'm trying to map a simple inheritance in slick projection I try hundreds of combinations, I can't make this compile. I end of with the follow code and the error bellow. I simplify the case classes because they have much more data. Without inheritance my other layers (controllers, services and interface) will have to deal with complexity, because in this case the model represents real objects that are in

Scala Slick: MTable.getTables return empty vector/list

无人久伴 提交于 2020-01-21 15:22:48
问题 Slick is returning result in DML queries, throwing exceptions while executing table creation actions, but the MTable.getTables return empty vector/list. I am using MySQL as SQL solution. println(Await.result(db.run(MTable.getTables), Duration.Inf)) Prints Vector() in console. 回答1: Honestly have the same issue, wen't through a ton of posts and ideas what could be wrong and nothing worked, don't want to waste time on it so the easy way around it is to just have something like using sql directly

Scala Slick: MTable.getTables return empty vector/list

冷暖自知 提交于 2020-01-21 15:21:39
问题 Slick is returning result in DML queries, throwing exceptions while executing table creation actions, but the MTable.getTables return empty vector/list. I am using MySQL as SQL solution. println(Await.result(db.run(MTable.getTables), Duration.Inf)) Prints Vector() in console. 回答1: Honestly have the same issue, wen't through a ton of posts and ideas what could be wrong and nothing worked, don't want to waste time on it so the easy way around it is to just have something like using sql directly

multiple joins with slick

杀马特。学长 韩版系。学妹 提交于 2020-01-20 18:30:09
问题 For joining between two tables is done like (for { (computer, company) <- Computers leftJoin Companies on (_.companyId === _.id) if computer.name.toLowerCase like filter.toLowerCase() } But in case if joining required between more tables what is the right way trying below but doesnt work (for { (computer, company,suppliers) <- Computers leftJoin Companies on (_.companyId === _.id) //not right leftjoin Suppliers on (_.suppId === _.id) if computer.name.toLowerCase like filter.toLowerCase() }