Questions tagged [scalaquery]

ScalaQuery is a typesafe API / DSL (domain specific language) built on top of JDBC for accessing relational databases in Scala.

The low-level JDBC API is powerful but comes with a lot of verbosity. ScalaQuery was designed from the ground up to reduce the amount of boilerplate required and make use of Scala's features to provide a more natural fit for database access in a Scala environment.

The basic idea is that tables in the database get represented as objects extending a Table trait. This object can then be used in for comprehension extremely similar to normal Scala collection.

ScalaQuery is not an ORM, i.e. it doesn't do caching, tracking of objects for change or similar things. It is more a way to replace or generate SQL.

NOTE: Since early 2012, ScalaQuery has evolved into Slick.

99 questions
1
vote
1 answer

ScalaQuery with play2.1.4

I am migrating play2.0 app to play2.1 which has a lot of scalaquery implemented . with all the migration changes its finally compiled ( not using anorm) the scalaqueries are still there . play compile and stage is successful but its giving…
vipin
  • 152
  • 12
1
vote
1 answer

Scala Slick Comprehension issues

I have the following in a library: Case Class: case class Foo( id: Option[Long], bar: Long ... ) Table: object Foos extends Mapper[Foo]("foo"){ //I'm using slick-inegration so the id is free def bar = column[Long]("bar") def cols = bar ~…
kelf
  • 472
  • 4
  • 9
1
vote
1 answer

How can I limit my query by date using ScalaQuery

I'm using Scalaquery and have run into a problem when I attempt to limit my query based on a date field. I'm using Scala 2.9.2, ScalaQuery 2.9.1:0.10.0-M1 Consider the code below: case class MyCase (opr_date: Date) object MyClass extends…
myio561
  • 23
  • 4
1
vote
1 answer

Unpack a NamedColumn in a condition of a for-loop in ScalaQuery

I am quite new to Scala and ScalaQuery, using it a couple of weeks now. I am trying to figure out a condition in a query by calling a function, but I get a NamedColumn[T] instead of T, how to unpack it? See 2nd link, line 20: package with…
Jasper
  • 478
  • 6
  • 19
1
vote
1 answer

ScalaQuery and Play framework: Best practice for handling unassigned (AutoInc) primary keys

I am using Play 2.0.2 with ScalaQuery 0.9.5. I have the following simple model code: case class Task(id: Long, name: String) object Task extends Table[(Long, String)]("task") { lazy val database = Database.forDataSource(DB.getDataSource()) def id…
avanwyk
  • 700
  • 6
  • 13
1
vote
2 answers

Conditionally enhancing ScalaQuery queries

I have a query I'm conditionally enhancing dependent on the presence or absence of count and offset parameters. val retrieveCustomer: (Option[String], Option[Int], Option[Int]) => List[Customer] = { ( customerId : Option[String], count :…
Rasputin Jones
  • 1,427
  • 2
  • 16
  • 24
1
vote
1 answer

Scala query generating invalid SQL

I'm using scalaquery to connect to both oracle and postgres servers. This behaviour is occuring for both Oracle and Postgres, but it's only valid (and still incorrect) SQL in Postgres. At some point, I'm running a query in scalaquery of the…
Squidly
  • 2,707
  • 19
  • 43
1
vote
3 answers

Select * or Equivalent in Scala Query

I've got this ScalaQuery model in Playframework 2 object User { implicit object UserFormat extends Format[User] { def reads(json: JsValue) : User = User( None, (json \ "firstName").as[String], (json \…
Rasputin Jones
  • 1,427
  • 2
  • 16
  • 24
1
vote
0 answers

List[Map[String,A]] to database table in scalaquery

I just learnt about scalaquery yesterday and it seems useful. I'd like to convert a List[Map[String,A]] (where A is a primitive type - Int, Float, String etc. and the set of keys in each of the maps are the same) to a database table. I couldn't find…
0
votes
1 answer

Test for table/view existence with Scalaquery & create if not present

I am writing some tests to automate checking if a database (a MS SQL Server instance) has certain views, and if it does not, creating those views using the BasicTable object. Something like: @Test def CheckAndBuildViewsOnDB() = { …
Noel
  • 2,061
  • 4
  • 31
  • 47
0
votes
2 answers

scalaquery how to create datetime

I foundout that scalaquery uses java.sql.date as the date object. But it drops time when I create java.sql.date. Is there any way that I can use to create mysql datetime field in scalaquery?
tiran
  • 2,389
  • 1
  • 16
  • 28
0
votes
5 answers

How smart are databases like MySQL and H2 when it comes to minimizing redundancy?

I'm new to databases, and this question has to do with how smart I can expect databases to be. Here by "databases" I mean "something like" MySQL or H2 (I actually have no idea if these two are similar, just that they are popular). I'm actually using…
emchristiansen
  • 3,550
  • 3
  • 26
  • 40
0
votes
1 answer

SLICK: To insert value in 3 different tables using one slick api call

The question is related to slick: I have three tables: 1) Users 2)Team2members 3)Team2Owners In my post request to users, I am passing values of memberOf and managerOf, these values will be inserted in the tables Team2members and Team2Owners…
0
votes
1 answer

Do DBIOActions composed in for comprehensions always run sequentially?

I know that Futures in Scala, when grouped in for comprehensions, run sequentially unless they are declared outside of the for comprehension (as this article explains). Do DBIOActions work the same way? e.g. in the following query, is query1…
Will
  • 1
  • 1
0
votes
1 answer

Do Aggregation with Slick

My database structure looks like this: id | content I what to get the entry with max id (not just id). I read the answer How to make aggregations with slick, but I found there is no first method in the statement:…
huangbiubiu
  • 1,252
  • 20
  • 37