InsertUpdateMacro

TODO Right now this is just insert but we can easily extend to update and delete

The function call that regularly drives query insertion is {code} query[T].insert(_.field1 -> value, _.field2 -> value, etc...) {code} Let's call this the field-insertion api.

This macro essentially takes an insert of the form query[T].insert(T(...)) and converts into the former form.

Once we've parsed an insert e.g. query[Person]insertValue(Person("Joe", "Bloggs")) we then need to synthesize the insertions that this would represent e.g. query[Person].insert(_.firstName -> "Joe", _.lastName -> "Bloggs")

Each function of field-insertion API basically takes the form {code} (v) => vAssignmentProperty -> assignmentValue (on the AST) {code}

Let's take a look at a slighly more complex example Given: {code} case class Person(name: String, age: Option[Age]); Age(value: Int) quote { query[Person].insert(Person("Joe", Age(345))) } {code}

This expands out into a series of statements which will be parsed to AST assignments This: (v: Person) => v.name -> (v:Person).name Will be parsed into this: {code} Assignment(Id(v), Prop(Id(v), name), Constant("Joe")) {code}

This: (v: Person) => v.age.map(v => v.value) -> Option(v:Age).map(v => v.value) Will be parsed into this: {code} Assignment(Id(v), OptionTableMap(Prop(Id(v), age), Id(v), Prop(Id(v), value)) OptionTableMap(OptionApply(CaseClass(value=345)), Id(v), Prop(Id(v), value)) ) {code}

The end result of this synthesis is a series of assignments for an insert for the given entity.

Another possiblity is that the entity is lifted: {code} case class Person(name: String, age: Option[Age]); Age(value: Int) quote { query[Person].insertValue(lift(Person("Joe", Age(345)))) } {code} TODO Finish doc

Note that as a result of the way this is implemented, if either the InsertMeta or the SchemaMeta is not inline, the entire resulting query will not be inline since they both will be summoned and used in the resulting expressions. It might be useful to introduce a configuration parameter to ignore non-inline InsertMetas or non-inline SchemaMetas. Or maybe this could even be an annotation.

class Object
trait Matchable
class Any

Type members

Classlikes

class Pipeline[T, A <: ([T] =>> Insert[T] | Update[T])](implicit evidence$1: Type[T], evidence$2: Type[A], x$1: Quotes) extends QuatMaking with QuatMakingBase

Perform the pipeline of creating an insert statement. The 'insertee' is the case class on which the SQL insert statement is based. The schema is based on the EntityQuery which could potentially be an unquoted QuerySchema.

Perform the pipeline of creating an insert statement. The 'insertee' is the case class on which the SQL insert statement is based. The schema is based on the EntityQuery which could potentially be an unquoted QuerySchema.

Value members

Concrete methods

def apply[T : Type, A <: ([T] =>> Insert[T] | Update[T]) : Type](entityRaw: Expr[EntityQuery[T]], bodyRaw: Expr[T])(implicit evidence$3: Type[T], evidence$4: Type[A], Quotes): Expr[A[T]]
def foo: Tuple2.type