slick

Slick 2.0 - update two or more columns

*爱你&永不变心* 提交于 2019-12-25 04:29:28
问题 I know I can update two columns in Slick 2.0 with: val q = for (user <- Users if user.id === id) yield (user.name, user.city) q.update((newName, newCity)) But I've seen something like this working as well which is IMO much nicer syntax: Users.filter(_.id === id).map(u => u.name ~ u.city).update(newName, newCity) This gives me the following error: value ~ is not a member of shortcut.db.Tables.profile.simple.Column I have imported PostgresDriver.simple._ and I just can't figure out why. I also

Use table name instead of its Alias in the postgres Query

喜欢而已 提交于 2019-12-25 04:04:31
问题 I am having a problem with building postgres query. I am using Slick in Scala to connect to the database. However, in a few cases, I need to manually add some extra where clause to the slick generated query. Slick is generating the query with alias for the columns, but while appending the extra where condition, I do not know the alias name slick has given. So I am trying to use the table name and column name directly, but facing issues with the query. SELECT x2.x3, x2.x4, x5.x6 FROM ( SELECT

Customizing Slick Generator

和自甴很熟 提交于 2019-12-25 03:05:30
问题 I'm using the Slick generator to generate my tabble definitions based on my database and I would like to change a thing in the generated code. When it generates the classes it does not put my auto increment keys as Option[Int] = None in the case classes... Is there a way to do that? And maybe add an autoinc method in the table definition that returns the generated id like this for example: def autoInc = id.? ~ name <> (User, User.unapply _) returning id 回答1: The code generator already

Slick Grid 2 grids displayed, losing focus on second grid

荒凉一梦 提交于 2019-12-24 21:27:05
问题 I have been using slick grid, which is excellent, but have a really minor niggling issue which I can't seem to halt. I display two grids, one is editable and as items are 'Approved' they are then moved to the second grid, which is read-only. All good so far... But whilst Testing it has become apparent that when clicking on cells within the second grid which have checkboxes in them the focus gets reset to the first grid if the checkbox is clicked within the cell. If they click anywhere else it

Converting scala.slick.lifted.Query to a case class

风流意气都作罢 提交于 2019-12-24 17:26:15
问题 I have a slick table "UserSchema" as follows: class UserSchema(tag: Tag) extends Table[User](tag, "users") { def name = column[String]("name", O.NotNull) def password = column[String]("password", O.NotNull) def graduatingYear = column[Int]("graduating_year", O.NotNull) def id = column[Int]("id", O.NotNull, O.PrimaryKey, O.AutoInc) def * = (name, password, graduatingYear, id.?) <> (User.tupled, User.unapply) } My "User" case class is as follows: case class User(name: String, password: String,

Problems with Scala Play Framework Slick Session

こ雲淡風輕ζ 提交于 2019-12-24 17:06:02
问题 I'm creating an application in Scala using Play 2.2. I'm using play-slick 0.5.0.8 as my MySQL DB connector. I have the following application controller: package controllers import models._ import models.database._ import play.api._ import play.api.mvc._ import play.api.Play.current import play.api.db.slick._ object Application extends Controller { // WORKS: def test = DBAction { implicit session => Ok(views.html.test(Cameras.findById(1))) } // DOES NOT WORK: def photo = Action { val p =

Remove alias in Slick generated queries

回眸只為那壹抹淺笑 提交于 2019-12-24 15:07:01
问题 I am using Slick for database operations in my application (using Postgres as the database). I am facing some issues while trying to build generalized queries. I have asked a question in SO for using the table name instead of alias (here), but found out that its no possible. So I am now trying to fix the issue in the Slick side. def ++= (selectStatement:String) ={ this.customSelectStatement = Some(selectStatement + " E where " + getQuery(filterPropertyList)) } filterQuery ++= (TableQuery

Slick silently fails to save and doesn't' throw an exception

允我心安 提交于 2019-12-24 12:25:55
问题 I just ran into a very scary situation with slick. My table definition referred to a wrong column and I noticed that the inserts where not inserting yet there was no error/exception about the issue. It just "silently" failed. Is this normal slick behaviour? So my table definition was like: def expiredAt = column[Timestamp]["created_at"] def createdAt = column[Timestamp]["created_at"] As you can see, the column referenced for both is the same column "created_at". When I changed the expiredAt

Scala Slick implicit conversion of multiple types in raw SQL query

谁说我不能喝 提交于 2019-12-24 10:57:39
问题 I'm working on a Scala Play Framework 2.2 project, and I'm using play-slick 0.5.0.8 as my DB access layer. I have the following code in one of my DAO objects: def randomByBlahAndDate(blah: Blah, newerThan: LocalDate)(implicit s: Session): Option[Photo] = { sql"select * from photos where blah = $blah and imgDate > $newerThan order by rand()".as[Photo].headOption } As you can see, it does some tricky stuff like ordering by rand(), which is why I decided to go the raw SQL route. In any case, I

Slick slider centerMode

岁酱吖の 提交于 2019-12-24 10:46:44
问题 I've been trying to create something like this using slick.js, and i really can't get my head around it. I have got the current code in place. How to make the center slide image 100% width and height and add paddings to the slide? It seems to be not working. I'd really appreciate any help. Thanks. $('.slider').slick({ centerMode: true, centerPadding: '30px', slidesToShow: 3, adaptiveHeight: false }); .slick-slide img { max-width: 100%; transition: transform 0.5s; } .slick-slide.slick-center