Saturday, 15 May 2010

scala - SLICK: A simple query using union and parameter lists -


I am new to SLICK (2.1) and lost in creating my first query using union Gone Because the parameters are made available through external (through a web interface), I set them as optional, please see the comment in the code below. How can one make a proper question?

My actual classroom is more complex which I simplify for this question.

  Case class MyStuff (id: int, value: ("ID", "Not Notull") value = Column [int] ("IIT", "IIT" VALUE ", O NotNull) def Text = column [string] ("TEXT", O NotNull) def * = (id, value, text). Shaped & lt;> (Mystuff.apply _). Tuplicated, Mystf.Anuply)} object myTable Tablekill ( Increase the new miteable (_)) {def getStuff (id: option [list [int]], value: option [list [int]] (built-in session: session): option [list [mystf]] = {/ * 1) If 'ID' is given, retrieve all the matched entries, if 2) If 'value' is given, then retrieve all the matched entries (if any), delete the union and duplicate entries with the results of the previous step 4) If neither 'id' and If 'value' is given, retrieve all entries. * /}}  

The getStuff is called like this:

db: session Database with {built-in session = & gt; Val myStuff = myTable.getStuff (...)}

You can use Inset Can assume that something else is a literal false and not only when the filter.

  if (id.mustified || values.isDefined) myTable.filter (line => ID.map (line.Id inset). GetOrElse (slick.lifted.LiteralColumn (wrong) )) MyTable.filter union (line = & gt; values.map (line.value in set_) GetOrElse (slick.lifted.LiteralColumn (wrong))) other myTable  

No comments:

Post a Comment