FieldSelectorMacros

zio.blocks.projection.FieldSelectorMacros

Scala 3 macro implementations that turn a field selector such as _.userCount into the name of the field, checked at compile time.

They back the selector-based methods of FieldUpdate (increment, decrement, setValue, maxValue, minValue) and the HandlerBuilder.update macro, so that a misspelled field is a compile error and not a runtime failure. The selector must be a lambda that reads a field, such as _.userCount. Only the last field name of the selector is used, so _.stats.userCount gives userCount. A selector that is not a lambda, or that reads no field, such as x => x, is rejected with a compile error.

Field names are mapped to SQL snake_case column names with SqlNameMapper.SnakeCase, for example userCount becomes user_count. The name is worked out at compile time and appears as a string literal in the expanded code, so no reflection happens at runtime.

Attributes

Source
FieldSelectorMacros.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def decrementImpl[A](selector: Expr[A => Any], by: Expr[Long])(using evidence$1: Type[A], q: Quotes): Expr[Decrement]

Attributes

Source
FieldSelectorMacros.scala
def extractAndMapFieldImpl[A](selector: Expr[A => Any])(using evidence$1: Type[A], q: Quotes): Expr[String]

Attributes

Source
FieldSelectorMacros.scala
def extractFieldNameImpl[A](selector: Expr[A => Any])(using evidence$1: Type[A], q: Quotes): Expr[String]

Attributes

Source
FieldSelectorMacros.scala
def incrementImpl[A](selector: Expr[A => Any], by: Expr[Long])(using evidence$1: Type[A], q: Quotes): Expr[Increment]

Attributes

Source
FieldSelectorMacros.scala
def maxValueImpl[A](selector: Expr[A => Any], value: Expr[Long])(using evidence$1: Type[A], q: Quotes): Expr[Max]

Attributes

Source
FieldSelectorMacros.scala
def minValueImpl[A](selector: Expr[A => Any], value: Expr[Long])(using evidence$1: Type[A], q: Quotes): Expr[Min]

Attributes

Source
FieldSelectorMacros.scala
def setValueImpl[A](selector: Expr[A => Any], value: Expr[Any])(using evidence$1: Type[A], q: Quotes): Expr[Set]

Attributes

Source
FieldSelectorMacros.scala