This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git log --no-merges '--format=format:* [``%h``](https://github.com/slick/slick/commit/%H) %s' 2.0.0-RC1..head|gsed 's/\*/\\\*/2g'|gsed 's/\[/\\\[/2g'|gsed 's/\]/\\\]/2g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
/** | |
* tuple helpers for safely adding and matching elements | |
*/ | |
package object tuples{ | |
// first element extractor | |
object +:{ | |
def unapply[T1,T2](t: Tuple2[T1,T2]) = Some( t._1, Tuple1(t._2) ) | |
def unapply[T1,T2,T3](t: Tuple3[T1,T2,T3]) = Some( t._1, Tuple2(t._2,t._3) ) | |
def unapply[T1,T2,T3,T4](t: Tuple4[T1,T2,T3,T4]) = Some( t._1, Tuple3(t._2,t._3,t._4) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.slick.driver.JdbcProfile | |
import scala.slick.ast.BaseTypedType | |
trait Profile { | |
val profile: JdbcProfile | |
} | |
trait TableComponent extends Profile { | |
import profile.simple._ | |
trait TypedId{ def id:Long } | |
trait Entity[ID]{ | |
def id : Option[ID] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.slick.lifted._ | |
import scala.slick.ast._ | |
import scala.slick.driver._ | |
/** Extends QueryInvoker to allow overriding used SQL statement when executing a query */ | |
trait OverridingInvoker extends BasicDriver{ | |
// get the extended QueryInvoker into the .simple._ implicits | |
override val Implicit: Implicits = new Implicits | |
override val simple: Implicits with SimpleQL = new Implicits with SimpleQL | |
class Implicits extends super.Implicits { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
body = STDIN.read | |
body.gsub!(/\{\{\{([^\n]+?)\}\}\}/, '`\1`') | |
body.gsub!(/\{\{\{(.+?)\}\}\}/m){|m| m.each_line.map{|x| "\t#{x}".gsub(/[\{\}]{3}/,'')}.join} | |
body.gsub!(/\=\=\=\=\s(.+?)\s\=\=\=\=/, '### \1') | |
body.gsub!(/\=\=\=\s(.+?)\s\=\=\=/, '## \1') | |
body.gsub!(/\=\=\s(.+?)\s\=\=/, '# \1') | |
body.gsub!(/\=\s(.+?)\s\=[\s\n]*/, '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.slick.lifted.CanBeQueryCondition | |
// optionally filter on a column with a supplied predicate | |
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) { | |
def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = { | |
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this) | |
} | |
} | |
// example use case | |
import java.sql.Date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Please comment in case of typos or bugs | |
import scala.slick.driver.H2Driver._ | |
val db = Database.for...(...) | |
case class Record( ... ) | |
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){ | |
... | |
def * = ... <> (Record.tupled,Record.unapply) | |
// place additional methods here which return values of type Column |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Part1(i1: Int, i2: String) | |
case class Part2(i1: String, i2: Int) | |
case class Whole(p1: Part1, p2: Part2) | |
class Tuple2Mapper[Entity,Component1,Tuple1,Component2,Tuple2]( | |
entityFactory: (Component1,Component2) => Entity, | |
entityExtractor: Entity => Option[(Component1,Component2)], | |
component1factory: Tuple1 => Component1, | |
component1extractor: Component1 => Option[Tuple1], | |
component2factory: Tuple2 => Component2, | |
component2extractor: Component2 => Option[Tuple2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Monoid[M] { | |
def zero: M | |
def add(m1: M, m2: M): M | |
} | |
trait Foldable[F[_]] { | |
def foldl[A, B](as: F[A], z: B, f: (B, A) => B): B | |
} | |
def mapReduce[F[_], A, B](as: F[A], m: Monoid[A]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.slick.lifted.{TableQuery => _} | |
import scala.slick.ast._ | |
import scala.slick.driver._ | |
import scala.language.implicitConversions | |
/** Extends QueryInvoker to allow overriding used SQL statement when executing a query */ | |
trait OverridingInvoker extends JdbcDriver{ | |
// get the extended QueryInvoker into the .simple._ implicits | |
override val Implicit: Implicits = new Implicits | |
override val simple: Implicits with SimpleQL = new Implicits with SimpleQL |
OlderNewer