packages feed

hasql-th-0.5.1.3 / src / library / Hasql / TH / Extraction / ChildExprList.hs

{-# OPTIONS_GHC -Wno-unused-binds -Wno-unused-imports -Wno-name-shadowing -Wno-incomplete-patterns -Wno-unused-matches -Wno-missing-methods -Wno-unused-record-wildcards -Wno-redundant-constraints -Wno-deprecations -Wno-missing-signatures #-}module Hasql.TH.Extraction.ChildExprList whereimport Hasql.TH.Prelude hiding (bit, fromList, sortBy)import PostgresqlSyntax-- * Typesdata ChildExpr = AChildExpr AExpr | BChildExpr BExpr | CChildExpr CExpr  deriving (Show, Eq, Ord)-- |-- Dives one level of recursion.childExpr = \case  AChildExpr a -> aChildExpr a  BChildExpr a -> bChildExpr a  CChildExpr a -> cChildExpr aaChildExpr = \case  CExprAExpr a -> cChildExpr a  TypecastAExpr a b -> aExpr a <> typename b  CollateAExpr a b -> aExpr a <> anyName b  AtTimeZoneAExpr a b -> aExpr a <> aExpr b  PlusAExpr a -> aExpr a  MinusAExpr a -> aExpr a  SymbolicBinOpAExpr a b c -> aExpr a <> symbolicExprBinOp b <> aExpr c  PrefixQualOpAExpr a b -> qualOp a <> aExpr b  AndAExpr a b -> aExpr a <> aExpr b  OrAExpr a b -> aExpr a <> aExpr b  NotAExpr a -> aExpr a  VerbalExprBinOpAExpr a b c d e -> aExpr a <> verbalExprBinOp c <> aExpr d <> foldMap aExpr e  ReversableOpAExpr a b c -> aExpr a <> aExprReversableOp c  IsnullAExpr a -> aExpr a  NotnullAExpr a -> aExpr a  OverlapsAExpr a b -> row a <> row b  SubqueryAExpr a b c d -> aExpr a <> subqueryOp b <> subType c <> either selectWithParens aExpr d  UniqueAExpr a -> selectWithParens a  DefaultAExpr -> []bChildExpr = \case  CExprBExpr a -> cChildExpr a  TypecastBExpr a b -> bExpr a <> typename b  PlusBExpr a -> bExpr a  MinusBExpr a -> bExpr a  SymbolicBinOpBExpr a b c -> bExpr a <> symbolicExprBinOp b <> bExpr c  QualOpBExpr a b -> qualOp a <> bExpr b  IsOpBExpr a b c -> bExpr a <> bExprIsOp ccChildExpr = \case  ColumnrefCExpr a -> columnref a  AexprConstCExpr a -> aexprConst a  ParamCExpr a b -> foldMap indirection b  InParensCExpr a b -> aExpr a <> foldMap indirection b  CaseCExpr a -> caseExpr a  FuncCExpr a -> funcExpr a  SelectWithParensCExpr a b -> selectWithParens a <> foldMap indirection b  ExistsCExpr a -> selectWithParens a  ArrayCExpr a -> either selectWithParens arrayExpr a  ExplicitRowCExpr a -> explicitRow a  ImplicitRowCExpr a -> implicitRow a  GroupingCExpr a -> exprList apreparableStmt = \case  SelectPreparableStmt a -> selectStmt a  InsertPreparableStmt a -> insertStmt a  UpdatePreparableStmt a -> updateStmt a  DeletePreparableStmt a -> deleteStmt a  CallPreparableStmt a -> callStmt a-- * CallcallStmt (CallStmt a) = funcApplication a-- * InsertinsertStmt (InsertStmt a b c d e) =  foldMap withClause a    <> insertTarget b    <> insertRest c    <> foldMap onConflict d    <> foldMap returningClause einsertTarget (InsertTarget a b) = qualifiedName a <> colId binsertRest = \case  SelectInsertRest a b c -> foldMap insertColumnList a <> foldMap overrideKind b <> selectStmt c  DefaultValuesInsertRest -> []overrideKind _ = []insertColumnList (InsertColumnList a) = foldMap insertColumnItem ainsertColumnItem (InsertColumnItem a b) = colId a <> foldMap indirection bonConflict (OnConflict a b) = foldMap confExpr a <> onConflictDo bonConflictDo = \case  UpdateOnConflictDo b c -> setClauseList b <> foldMap aExpr c  NothingOnConflictDo -> []confExpr = \case  WhereConfExpr a b -> indexParams a <> foldMap aExpr b  ConstraintConfExpr a -> name areturningClause (ReturningClause a) = targetList a-- * UpdateupdateStmt (UpdateStmt a b c d e f) =  foldMap withClause a    <> relationExprOptAlias b    <> setClauseList c    <> foldMap fromClause d    <> foldMap whereOrCurrentClause e    <> foldMap returningClause fsetClauseList (SetClauseList a) = foldMap setClause asetClause = \case  TargetSetClause a b -> setTarget a <> aExpr b  TargetListSetClause a b -> setTargetList a <> aExpr bsetTarget (SetTarget a b) = colId a <> foldMap indirection bsetTargetList (SetTargetList a) = foldMap setTarget a-- * DeletedeleteStmt (DeleteStmt a b c d e) =  foldMap withClause a    <> relationExprOptAlias b    <> foldMap usingClause c    <> foldMap whereOrCurrentClause d    <> foldMap returningClause eusingClause (UsingClause a) = fromList a-- * SelectselectStmt = \case  NoParensSelectStmt a -> selectNoParens a  WithParensSelectStmt a -> selectWithParens aselectNoParens (SelectNoParens a b c d e) =  foldMap withClause a    <> selectClause b    <> foldMap sortClause c    <> foldMap selectLimit d    <> foldMap forLockingClause eselectWithParens = \case  NoParensSelectWithParens a -> selectNoParens a  WithParensSelectWithParens a -> selectWithParens awithClause (WithClause _ a) = foldMap commonTableExpr acommonTableExpr (CommonTableExpr a b c d) = preparableStmt dselectLimit = \case  LimitOffsetSelectLimit a b -> limitClause a <> offsetClause b  OffsetLimitSelectLimit a b -> offsetClause a <> limitClause b  LimitSelectLimit a -> limitClause a  OffsetSelectLimit a -> offsetClause alimitClause = \case  LimitLimitClause a b -> selectLimitValue a <> foldMap aExpr b  FetchOnlyLimitClause a b c -> foldMap selectFetchFirstValue boffsetClause = \case  ExprOffsetClause a -> aExpr a  FetchFirstOffsetClause a b -> selectFetchFirstValue aselectFetchFirstValue = \case  ExprSelectFetchFirstValue a -> cExpr a  NumSelectFetchFirstValue _ _ -> []selectLimitValue = \case  ExprSelectLimitValue a -> aExpr a  AllSelectLimitValue -> []forLockingClause = \case  ItemsForLockingClause a -> foldMap forLockingItem a  ReadOnlyForLockingClause -> []forLockingItem (ForLockingItem a b c) =  foldMap (foldMap qualifiedName) bselectClause = \case  SimpleSelectSelectClause a -> simpleSelect a  WithParensSelectClause a -> selectWithParens asimpleSelect = \case  NormalSimpleSelect a b c d e f g ->    foldMap targeting a      <> foldMap intoClause b      <> foldMap fromClause c      <> foldMap whereClause d      <> foldMap groupClause e      <> foldMap havingClause f      <> foldMap windowClause g  ValuesSimpleSelect a -> valuesClause a  TableSimpleSelect a -> relationExpr a  BinSimpleSelect _ a _ b -> selectClause a <> selectClause btargeting = \case  NormalTargeting a -> targetList a  AllTargeting a -> foldMap targetList a  DistinctTargeting a b -> foldMap exprList a <> targetList btargetList (TargetList a) = foldMap targetEl atargetEl = \case  AliasedExprTargetEl a _ -> aExpr a  ImplicitlyAliasedExprTargetEl a _ -> aExpr a  ExprTargetEl a -> aExpr a  AsteriskTargetEl -> []intoClause (IntoClause a) = optTempTableName afromClause (FromClause a) = fromList afromList (FromList a) = foldMap tableRef awhereClause (WhereClause a) = aExpr awhereOrCurrentClause = \case  ExprWhereOrCurrentClause a -> aExpr a  CursorWhereOrCurrentClause a -> cursorName agroupClause (GroupClause a) = foldMap groupByItem ahavingClause (HavingClause a) = aExpr awindowClause (WindowClause a) = foldMap windowDefinition avaluesClause (ValuesClause a) = foldMap exprList aoptTempTableName _ = []groupByItem = \case  ExprGroupByItem a -> aExpr a  EmptyGroupingSetGroupByItem -> []  RollupGroupByItem a -> exprList a  CubeGroupByItem a -> exprList a  GroupingSetsGroupByItem a -> foldMap groupByItem awindowDefinition (WindowDefinition _ a) = windowSpecification awindowSpecification (WindowSpecification _ a b c) = foldMap exprList a <> foldMap sortClause b <> foldMap frameClause cframeClause (FrameClause _ a _) = frameExtent aframeExtent = \case  SingularFrameExtent a -> frameBound a  BetweenFrameExtent a b -> frameBound a <> frameBound bframeBound = \case  UnboundedPrecedingFrameBound -> []  UnboundedFollowingFrameBound -> []  CurrentRowFrameBound -> []  PrecedingFrameBound a -> aExpr a  FollowingFrameBound a -> aExpr asortClause (SortClause a) = foldMap sortBy asortBy = \case  UsingSortBy a b c -> aExpr a <> qualAllOp b <> foldMap nullsOrder c  AscDescSortBy a b c -> aExpr a <> foldMap ascDesc b <> foldMap nullsOrder c-- * Table refstableRef = \case  RelationExprTableRef a b c -> relationExpr a <> foldMap aliasClause b <> foldMap tablesampleClause c  FuncTableRef a b c -> funcTable b <> foldMap funcAliasClause c  SelectTableRef _ a _ -> selectWithParens a  JoinTableRef a _ -> joinedTable arelationExpr = \case  SimpleRelationExpr a _ -> qualifiedName a  OnlyRelationExpr a _ -> qualifiedName arelationExprOptAlias (RelationExprOptAlias a b) = relationExpr a <> foldMap (colId . snd) btablesampleClause (TablesampleClause a b c) = funcName a <> exprList b <> foldMap repeatableClause crepeatableClause = aExprfuncTable = \case  FuncExprFuncTable a b -> funcExprWindowless a <> optOrdinality b  RowsFromFuncTable a b -> rowsfromList a <> optOrdinality browsfromItem (RowsfromItem a b) = funcExprWindowless a <> foldMap colDefList browsfromList (RowsfromList a) = foldMap rowsfromItem acolDefList = tableFuncElementListoptOrdinality = const []tableFuncElementList (TableFuncElementList a) = foldMap tableFuncElement atableFuncElement (TableFuncElement a b c) = colId a <> typename b <> foldMap collateClause ccollateClause = anyNamealiasClause = const []funcAliasClause = \case  AliasFuncAliasClause a -> aliasClause a  AsFuncAliasClause a -> tableFuncElementList a  AsColIdFuncAliasClause a b -> colId a <> tableFuncElementList b  ColIdFuncAliasClause a b -> colId a <> tableFuncElementList bjoinedTable = \case  InParensJoinedTable a -> joinedTable a  CrossJoinedTable a b -> tableRef a <> tableRef b  QualJoinedTable a _ b c -> tableRef a <> tableRef b <> joinQual c  NaturalJoinedTable a _ b -> tableRef a <> tableRef bjoinQual = \case  UsingJoinQual _ -> []  OnJoinQual a -> aExpr aexprList (ExprList a) = fmap AChildExpr (toList a)aExpr = pure . AChildExprbExpr = pure . BChildExprcExpr = pure . CChildExprfuncExpr = \case  ApplicationFuncExpr a b c d -> funcApplication a <> foldMap withinGroupClause b <> foldMap filterClause c <> foldMap overClause d  SubexprFuncExpr a -> funcExprCommonSubexpr afuncExprWindowless = \case  ApplicationFuncExprWindowless a -> funcApplication a  CommonSubexprFuncExprWindowless a -> funcExprCommonSubexpr awithinGroupClause = sortClausefilterClause a = aExpr aoverClause = \case  WindowOverClause a -> windowSpecification a  ColIdOverClause _ -> []funcExprCommonSubexpr = \case  CollationForFuncExprCommonSubexpr a -> aExpr a  CurrentDateFuncExprCommonSubexpr -> []  CurrentTimeFuncExprCommonSubexpr _ -> []  CurrentTimestampFuncExprCommonSubexpr _ -> []  LocalTimeFuncExprCommonSubexpr _ -> []  LocalTimestampFuncExprCommonSubexpr _ -> []  CurrentRoleFuncExprCommonSubexpr -> []  CurrentUserFuncExprCommonSubexpr -> []  SessionUserFuncExprCommonSubexpr -> []  UserFuncExprCommonSubexpr -> []  CurrentCatalogFuncExprCommonSubexpr -> []  CurrentSchemaFuncExprCommonSubexpr -> []  CastFuncExprCommonSubexpr a b -> aExpr a <> typename b  ExtractFuncExprCommonSubexpr a -> foldMap extractList a  OverlayFuncExprCommonSubexpr a -> overlayList a  PositionFuncExprCommonSubexpr a -> foldMap positionList a  SubstringFuncExprCommonSubexpr a -> foldMap substrList a  TreatFuncExprCommonSubexpr a b -> aExpr a <> typename b  TrimFuncExprCommonSubexpr a b -> foldMap trimModifier a <> trimList b  NullIfFuncExprCommonSubexpr a b -> aExpr a <> aExpr b  CoalesceFuncExprCommonSubexpr a -> exprList a  GreatestFuncExprCommonSubexpr a -> exprList a  LeastFuncExprCommonSubexpr a -> exprList aextractList (ExtractList a b) = extractArg a <> aExpr bextractArg _ = []overlayList (OverlayList a b c d) = foldMap aExpr ([a, b, c] <> toList d)positionList (PositionList a b) = bExpr a <> bExpr bsubstrList = \case  ExprSubstrList a b -> aExpr a <> substrListFromFor b  ExprListSubstrList a -> exprList asubstrListFromFor = \case  FromForSubstrListFromFor a b -> aExpr a <> aExpr b  ForFromSubstrListFromFor a b -> aExpr a <> aExpr b  FromSubstrListFromFor a -> aExpr a  ForSubstrListFromFor a -> aExpr atrimModifier _ = []trimList = \case  ExprFromExprListTrimList a b -> aExpr a <> exprList b  FromExprListTrimList a -> exprList a  ExprListTrimList a -> exprList awhenClause (WhenClause a b) = aExpr a <> aExpr bfuncApplication (FuncApplication a b) = funcName a <> foldMap funcApplicationParams bfuncApplicationParams = \case  NormalFuncApplicationParams _ a b -> foldMap funcArgExpr a <> foldMap sortClause b  VariadicFuncApplicationParams a b c -> foldMap (foldMap funcArgExpr) a <> funcArgExpr b <> foldMap sortClause c  StarFuncApplicationParams -> []funcArgExpr = \case  ExprFuncArgExpr a -> aExpr a  ColonEqualsFuncArgExpr _ a -> aExpr a  EqualsGreaterFuncArgExpr _ a -> aExpr acaseExpr (CaseExpr a b c) = foldMap aExpr a <> whenClauseList b <> foldMap aExpr cwhenClauseList (WhenClauseList a) = foldMap whenClause aarrayExpr = \case  ExprListArrayExpr a -> exprList a  ArrayExprListArrayExpr a -> arrayExprList a  EmptyArrayExpr -> []arrayExprList (ArrayExprList a) = foldMap arrayExpr ainExpr = \case  SelectInExpr a -> selectWithParens a  ExprListInExpr a -> exprList a-- * OperatorssymbolicExprBinOp = \case  MathSymbolicExprBinOp a -> mathOp a  QualSymbolicExprBinOp a -> qualOp aqualOp = \case  OpQualOp a -> op a  OperatorQualOp a -> anyOperator aqualAllOp = \case  AllQualAllOp a -> allOp a  AnyQualAllOp a -> anyOperator averbalExprBinOp = const []aExprReversableOp = \case  NullAExprReversableOp -> []  TrueAExprReversableOp -> []  FalseAExprReversableOp -> []  UnknownAExprReversableOp -> []  DistinctFromAExprReversableOp a -> aExpr a  OfAExprReversableOp a -> typeList a  BetweenAExprReversableOp a b c -> bExpr b <> aExpr c  BetweenSymmetricAExprReversableOp a b -> bExpr a <> aExpr b  InAExprReversableOp a -> inExpr a  DocumentAExprReversableOp -> []subqueryOp = \case  AllSubqueryOp a -> allOp a  AnySubqueryOp a -> anyOperator a  LikeSubqueryOp _ -> []  IlikeSubqueryOp _ -> []bExprIsOp = \case  DistinctFromBExprIsOp a -> bExpr a  OfBExprIsOp a -> typeList a  DocumentBExprIsOp -> []allOp = \case  OpAllOp a -> op a  MathAllOp a -> mathOp aanyOperator = \case  AllOpAnyOperator a -> allOp a  QualifiedAnyOperator a b -> colId a <> anyOperator bop = const []mathOp = const []-- * Rowsrow = \case  ExplicitRowRow a -> explicitRow a  ImplicitRowRow a -> implicitRow aexplicitRow = \case  EmptyExplicitRow -> []  ExprListExplicitRow a -> exprList aimplicitRow (ImplicitRow a b) = exprList a <> aExpr b-- * ConstantsaexprConst = \case  IAexprConst _ -> []  FAexprConst _ -> []  SAexprConst _ -> []  BAexprConst _ -> []  XAexprConst _ -> []  FuncAexprConst a b _ -> funcName a <> foldMap funcConstArgs b  ConstTypenameAexprConst a _ -> constTypename a  StringIntervalAexprConst _ a -> foldMap interval a  IntIntervalAexprConst _ _ -> []  BoolAexprConst _ -> []  NullAexprConst -> []funcConstArgs (FuncConstArgs a b) = foldMap funcArgExpr a <> foldMap sortClause bconstTypename = \case  NumericConstTypename a -> numeric a  ConstBitConstTypename a -> constBit a  ConstCharacterConstTypename a -> constCharacter a  ConstDatetimeConstTypename a -> constDatetime anumeric = \case  IntNumeric -> []  IntegerNumeric -> []  SmallintNumeric -> []  BigintNumeric -> []  RealNumeric -> []  FloatNumeric _ -> []  DoublePrecisionNumeric -> []  DecimalNumeric a -> foldMap exprList a  DecNumeric a -> foldMap exprList a  NumericNumeric a -> foldMap exprList a  BooleanNumeric -> []bit (Bit _ a) = foldMap exprList aconstBit = bitconstCharacter (ConstCharacter _ _) = []constDatetime _ = []interval _ = []-- * Namesident _ = []colId = identname = colIdcursorName = nameanyName (AnyName a b) = colId a <> foldMap attrs bcolumnref (Columnref a b) = colId a <> foldMap indirection bfuncName = \case  TypeFuncName a -> typeFunctionName a  IndirectedFuncName a b -> colId a <> indirection bqualifiedName = \case  SimpleQualifiedName _ -> []  IndirectedQualifiedName _ a -> indirection aindirection (Indirection a) = foldMap indirectionEl aindirectionEl = \case  AttrNameIndirectionEl _ -> []  AllIndirectionEl -> []  ExprIndirectionEl a -> aExpr a  SliceIndirectionEl a b -> foldMap aExpr a <> foldMap aExpr b-- * TypestypeList (TypeList a) = foldMap typename atypename (Typename a b c d) =  simpleTypename bsimpleTypename = \case  GenericTypeSimpleTypename a -> genericType a  NumericSimpleTypename a -> numeric a  BitSimpleTypename a -> bit a  CharacterSimpleTypename a -> character a  ConstDatetimeSimpleTypename a -> constDatetime a  ConstIntervalSimpleTypename a -> either (foldMap interval) (const []) aarrayBounds _ = []genericType (GenericType a b c) = typeFunctionName a <> foldMap attrs b <> foldMap typeModifiers ctypeFunctionName = identattrs (Attrs a) = foldMap attrName aattrName _ = []typeModifiers = exprListcharacter _ = []subType _ = []-- * IndexesindexParams (IndexParams a) = foldMap indexElem aindexElem (IndexElem a b c d e) = indexElemDef a <> foldMap anyName b <> foldMap anyName cindexElemDef = \case  IdIndexElemDef a -> colId a  FuncIndexElemDef a -> funcExprWindowless a  ExprIndexElemDef a -> aExpr aascDesc = const []nullsOrder = const []