hssqlppp-0.6.0: SQL parser and type checker

Safe HaskellNone
LanguageHaskell2010

Database.HsSqlPpp.Syntax

Contents

Description

This module contains the ast node data types. They are very permissive, in that they allow a lot of invalid SQL to be represented. The type checking process should catch all invalid trees, but doesn't quite manage at the moment. Sorry about all the seemingly pointless type synonyms below, they are an artefact of using UUAGC. You can see labels for the fields by looking at the ag source here: https://github.com/JakeWheat/hssqlppp/blob/master/src/Database/HsSqlPpp/Internals/AstInternal.ag

Synopsis

Name and TypeName

Scalar expressions

Query expressions

data QueryExpr Source

Constructors

Select 

Fields

ann :: Annotation
 
selDistinct :: Distinct
 
selSelectList :: SelectList
 
selTref :: TableRefList
 
selWhere :: MaybeBoolExpr
 
selGroupBy :: ScalarExprList
 
selHaving :: MaybeBoolExpr
 
selOrderBy :: ScalarExprDirectionPairList
 
selLimit :: MaybeScalarExpr
 
selOffset :: MaybeScalarExpr
 
selOption :: [QueryHint]
 
CombineQueryExpr 
Values 

Fields

ann :: Annotation
 
qeValues :: ScalarExprListList
 
WithQueryExpr 

Fields

ann :: Annotation
 
withs :: WithQueryList
 
withQe :: QueryExpr
 

makeSelect :: QueryExpr Source

'default' valued select, use for creating select values

makeSelect :: QueryExpr
makeSelect = Select
             {ann = emptyAnnotation
             ,selDistinct = All
             ,selSelectList = (SelectList emptyAnnotation [])
             ,selTref = []
             ,selWhere = Nothing
             ,selGroupBy = []
             ,selHaving = Nothing
             ,selOrderBy = []
             ,selLimit = Nothing
             ,selOffset = Nothing
             ,selOption = []}

On its own, it isn't valid syntax: to use it you have to replace the select list at minimum

use something like this

s = makeSelect {selSelectList = sl [se $ i "a"]
               ,selTref = [tref "t"]}
    where
        a = emptyAnnotation
        sl = SelectList a
        se = SelExp a
        i = Identifier a
        tref t = Tref a (Name a [Nmc t])

Statements

data Statement Source

Constructors

QueryStatement Annotation QueryExpr 
Insert Annotation Name [NameComponent] QueryExpr MaybeSelectList 
Update Annotation Name SetClauseList TableRefList MaybeBoolExpr MaybeSelectList 
Delete Annotation Name TableRefList MaybeBoolExpr MaybeSelectList 
CopyFrom Annotation Name [NameComponent] CopyFromSource [CopyFromOption] 
CopyData Annotation String 
CopyTo Annotation CopyToSource String [CopyToOption] 
Truncate Annotation [Name] RestartIdentity Cascade 
CreateTable Annotation Name AttributeDefList ConstraintList MaybeTablePartitionDef Replace 
AlterTable Annotation Name AlterTableOperation 
AlterDatabase Annotation Name AlterDatabaseOperation 
CreateSequence Annotation Name Integer (Maybe Integer) (Maybe Integer) Integer Integer 
AlterSequence Annotation Name AlterSequenceOperation 
CreateTableAs Annotation Name Replace QueryExpr 
CreateView Annotation Name MaybeNameComponentList QueryExpr 
AlterView Annotation Name MaybeNameComponentList QueryExpr 
CreateType Annotation Name TypeAttributeDefList 
CreateUser Annotation Name String 
CreateLogin Annotation Name String 
AlterUser Annotation Name String 
AlterLogin Annotation Name String 
CreateSchema Annotation NameComponent (Maybe Name) 
AlterSchema Annotation NameComponent AlterSchemaOperation 
CreateFunction Annotation Name ParamDefList TypeName Replace Language FnBody Volatility 
CreateDomain Annotation Name TypeName String MaybeBoolExpr 
CreateLanguage Annotation String 
CreateTrigger Annotation NameComponent TriggerWhen [TriggerEvent] Name TriggerFire Name ScalarExprList 
DropFunction Annotation IfExists NameTypeNameListPairList Cascade 
DropSomething Annotation DropType IfExists [Name] Cascade 
DropTrigger Annotation IfExists NameComponent Name Cascade 
CreateDatabase Annotation Name 
Set Annotation String [SetValue] 
Notify Annotation String 
Into Annotation Bool [Name] Statement 
Assignment Annotation Name ScalarExpr 
Return Annotation MaybeScalarExpr 
ReturnNext Annotation ScalarExpr 
ReturnQuery Annotation QueryExpr 
Raise Annotation RaiseType String ScalarExprList 
NullStatement Annotation 
Perform Annotation ScalarExpr 
Execute Annotation ScalarExpr 
ForQueryStatement Annotation (Maybe String) NameComponent QueryExpr StatementList 
ForIntegerStatement Annotation (Maybe String) NameComponent ScalarExpr ScalarExpr StatementList 
LoopStatement Annotation (Maybe String) StatementList 
WhileStatement Annotation (Maybe String) ScalarExpr StatementList 
ContinueStatement Annotation (Maybe String) 
ExitStatement Annotation (Maybe String) 
CaseStatementSimple Annotation ScalarExpr ScalarExprListStatementListTripleList StatementList 
CaseStatement Annotation ScalarExprListStatementListTripleList StatementList 
If Annotation ScalarExprStatementListPairList StatementList 
Block Annotation (Maybe String) VarDefList StatementList 
AntiStatement String 
DeclareStatement Annotation [(String, TypeName, Maybe ScalarExpr)] 
ExecStatement Annotation Name ScalarExprList 
CreateIndexTSQL Annotation NameComponent Name [NameComponent] 

dml components

ddl components

function ddl components

PlPgsql components

utility

misc