AliasedMappings

case class AliasedMappings(tableAliases: List[(List[String], String, String)], columnAliases: List[(List[String], ColumnRef, ColumnRef)], seenTables: List[String], nextFresh: Int)

Data structure managing DB table and column aliases.

Aliases are scoped by the result path, which is unique in the GraphQL output even in the presence of GraphQL field alises. Table aliases apply from the given output path and below.

Column aliases are synthesized whenever an SQL union has to be nested in a subquery and hence requires a uniform set of column names. These column aliases apply from the given path and above.

Tables are only aliased if they have already been seen in an depth-first in-order traversal of the output graph. This data structure also track the seen state for tables.

AliasedMappings also maintains the bookeeping information needed to supply arbitrary fresh names. Currently these are used to name identity/predicate joins.

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def aliasColumns(context: Context, cols: List[ColumnRef], aliasedCols: List[ColumnRef]): (AliasedMappings, List[ColumnRef])

Alias the given columns to the suppiled aliased columns from the context result path and above

Alias the given columns to the suppiled aliased columns from the context result path and above

def aliasTable(context: Context, table: String): (AliasedMappings, String)

Alias the given table at all the paths from the context result path and below

Alias the given table at all the paths from the context result path and below

def columnForAtomicField(context: Context, fieldName: String): Option[ColumnRef]

Returns the aliased column corresponding to the atomic field fieldName in context

Returns the aliased column corresponding to the atomic field fieldName in context

def columnForSqlTerm[T](context: Context, term: Term[T]): Option[ColumnRef]

Returns the aliased columns corresponding to term in context

Returns the aliased columns corresponding to term in context

def columnsForLeaf(context: Context, fieldName: String): List[ColumnRef]

Returns the columns for leaf field fieldName in context

Returns the columns for leaf field fieldName in context

def columnsForTerm(context: Context, term: Term[_]): List[ColumnRef]

Returns the aliased columns corresponding to term in context

Returns the aliased columns corresponding to term in context

def computeColumnAlias(table: String, col: ColumnRef): ColumnRef

Derive a column alias for the given column in new table table

Derive a column alias for the given column in new table table

def computeColumnAliases(table: String, cols: List[ColumnRef]): List[ColumnRef]

Derive column aliases for the given columns in new table table

Derive column aliases for the given columns in new table table

def containsNonLeafList(query: Query, context: Context): Boolean

Does the result of query in context contain lists of subobjects?

Does the result of query in context contain lists of subobjects?

def discriminatorColumnsForType(context: Context): List[ColumnRef]

Returns the discriminator columns for the context type

Returns the discriminator columns for the context type

def discriminatorForType(context: Context): Option[SqlDiscriminatedType]

Returns the discriminator for the type at context

Returns the discriminator for the type at context

def encoderForLeaf(tpe: Type): Option[Encoder[Any]]

Returns the Encoder for the given type

Returns the Encoder for the given type

def encoderForTerm(context: Context, term: Term[_]): Option[Encoder]

Returns the Encoder for the given term in context

Returns the Encoder for the given term in context

def fieldMapping(context: Context, fieldName: String): Option[FieldMapping]

Returns the field mapping for field fieldName in context if any

Returns the field mapping for field fieldName in context if any

def fieldMappingType(context: Context, fieldName: String): Option[FieldMappingType]

Return an indicator of the kind of field mapping correspoding to fieldName in context

Return an indicator of the kind of field mapping correspoding to fieldName in context

def fresh(prefix: String): (AliasedMappings, String)

Creates a fresh name of the form <prefix>_<unique>

Creates a fresh name of the form <prefix>_<unique>

def isAssociative(context: Context): Boolean

Is the context type mapped to an associative table?

Is the context type mapped to an associative table?

def isComputedField(context: Context, fieldName: String): Boolean

Is fieldName in context computed?

Is fieldName in context computed?

def isJsonb(context: Context, fieldName: String): Boolean

Is fieldName in context Jsonb?

Is fieldName in context Jsonb?

def isSqlTerm(context: Context, term: Term[_]): Boolean

Is term in contextexpressible in SQL?

Is term in contextexpressible in SQL?

def joinsForPath(context: Context, suffix: List[String]): (AliasedMappings, List[SqlJoin])

Returns the aliased joins for traversing the path suffix from the context path

Returns the aliased joins for traversing the path suffix from the context path

def joinsForSubObject(context: Context, fieldName: String, resultName: String, plural: Boolean): (AliasedMappings, List[SqlJoin])

Returns the aliased joins for constructing the subobject corresponding to the field fieldName in context

Returns the aliased joins for constructing the subobject corresponding to the field fieldName in context

def keyColumnsForType(context: Context): List[ColumnRef]

Returns the key columns for the context type

Returns the key columns for the context type

def nonLeafList(context: Context, fieldName: String): Boolean

Does the type of fieldName in context represent a list of subobjects?

Does the type of fieldName in context represent a list of subobjects?

def objectMapping(context: Context): Option[ObjectMapping]

Returns the object mapping for context if any

Returns the object mapping for context if any

def parentTableForType(context: Context): Option[TableRef]

Returns the fully aliased table for the type at context

Returns the fully aliased table for the type at context

def seenTable(table: String): AliasedMappings

Record that the given table has been seen and will require an alias if if referred to again.

Record that the given table has been seen and will require an alias if if referred to again.

Recover the unaliased form of the given column

Recover the unaliased form of the given column

def unaliasTable(table: String): String

Recover the unaliased name of the given table

Recover the unaliased name of the given table

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product