project-m36-1.1.1: Relational Algebra Engine
Safe HaskellSafe-Inferred
LanguageHaskell2010

ProjectM36.SQL.Convert

Synopsis

Documentation

insertColumnAlias :: TableAlias -> AttributeName -> ColumnAlias -> ColumnName -> ConvertM () Source #

Used to note if columns are remapped to different attributes in order to mitigate attribute naming conflicts.

withSubSelect :: ConvertM a -> ConvertM (a, ColumnAliasRenameMap) Source #

Pass state down to subselect, but discard any state changes from the subselect processing.

insertTable :: TableAlias -> RelationalExpr -> Attributes -> ConvertM ColumnAliasMap Source #

Insert another table into the TableContext. Returns an alias map of any columns which could conflict with column names already present in the TableContext so that they can be optionally renamed.

noteColumnMention :: Maybe TableAlias -> ColumnName -> Maybe ColumnAlias -> ConvertM ColumnAlias Source #

When a column is mentioned, it may need to be aliased. The table name must already be in the table context so that we can identify that the attribute exists. Without a table name, we must look for a uniquely named column amongst all tables. Thus, we pre-emptively eliminate duplicate column names.

findColumn :: ColumnName -> ConvertM [TableAlias] Source #

Find a column name or column alias in the underlying table context. Returns key into table context.

findColumn' :: ColumnName -> TableContext -> [TableAlias] Source #

non ConvertM version of findColumn

attributeNameForColumnName :: ColumnName -> ConvertM AttributeName Source #

Search the TableContext for a column alias remapping for the given column name. This function can change the state context if column names conflict.

convertSubSelect :: TypeForRelExprF -> Select -> ConvertM RelationalExpr Source #

Slightly different processing for subselects.

convertTableRef :: TypeForRelExprF -> TableRef -> ConvertM (TableAlias, RelationalExpr) Source #

Convert TableRefs after the first one (assumes all additional TableRefs are for joins). Returns the qualified name key that was added to the map, the underlying relexpr (not aliased so that it can used for extracting type information), and the new table context map

commonAttributeNames :: TypeForRelExprF -> RelationalExpr -> RelationalExpr -> ConvertM (Set AttributeName, Set AttributeName, Set AttributeName) Source #

Used in join condition detection necessary for renames to enable natural joins.

renameIdentifier :: (ColumnName -> ColumnName) -> ScalarExpr -> ScalarExpr Source #

Used to remap SQL qualified names to new names to prevent conflicts in join conditions.

needsToRenameAllAttributes :: RestrictionExpr -> Bool Source #

If the restriction includes a EXISTS expression, we must rename all attributes at the top-level to prevent conflicts.

data GroupByInfo Source #

Validated "group by" and "having" data

Constructors

GroupByInfo 

Fields

Instances

Instances details
Show GroupByInfo Source # 
Instance details

Defined in ProjectM36.SQL.Convert

Eq GroupByInfo Source # 
Instance details

Defined in ProjectM36.SQL.Convert

containsProjScalarExpr :: ProjectionScalarExpr -> ProjectionScalarExpr -> Bool Source #

Returns True iff a projection scalar expr within a larger expression. Used for group by aggregation validation.