@@ -81,8 +81,8 @@ import Droplet.Language.Internal.Condition (BinaryOperator(..), Exists, In, IsNu
81
81
import Droplet.Language.Internal.Definition (class AppendPath , class IsNullable , class ToParameters , class ToType , class ToValue , class UnwrapDefinition , class UnwrapNullable , C , Column , Composite , Constraint , Default , E (..), ForeignKey , Identity , Path , PrimaryKey , Star , Table , Unique )
82
82
import Droplet.Language.Internal.Definition as DLID
83
83
import Droplet.Language.Internal.Function (Aggregate (..), PgFunction (..))
84
- import Droplet.Language.Internal.Syntax (class ConstraintsToRowList , class OnlyAggregations , class JoinedToMaybe , class QueryOptionallyAliased , class ToProjection , class ToSingleColumn , class UniqueColumnNames , Add , Alter (..), As (..), Create , DefaultValues (..), Delete (..), Distinct (..), Drop , From (..), GroupBy (..), Inclusion (..), Inner , Insert (..), Into (..), Join (..), Limit (..), Offset (..), On (..), OrderBy (..), Outer , Plan , Prepare (..), Returning (..), Select (..), Set (..), Side , Sort (..), T (..), Union (..), Update (..), Values (..), Where (..))
85
- import Droplet.Language.Internal.Token (addKeyword , allKeyword , alterKeyword , andKeyword , asKeyword , ascKeyword , atSymbol , byKeyword , closeBracket , comma , constraintKeyword , countFunctionName , createKeyword , lesserEqualsThanSymbol , greaterEqualsThanSymbol , defaultKeyword , deleteKeyword , descKeyword , distinctKeyword , dotSymbol , dropKeyword , equalsSymbol , existsKeyword , foreignKeyKeyword , fromKeyword , greaterThanSymbol , groupByKeyword , identityKeyword , inKeyword , innerKeyword , insertKeyword , isNullKeyword , isNotNullKeyword , joinKeyword , leftKeyword , lesserThanSymbol , limitKeyword , notEqualsSymbol , notKeyword , notNullKeyword , offsetKeyword , onKeyword , openBracket , orKeyword , orderKeyword , parameterSymbol , primaryKeyKeyword , quoteSymbol , referencesKeyword , returningKeyword , selectKeyword , setKeyword , space , starSymbol , string_aggFunctionName , tableKeyword , unionKeyword , uniqueKeyword , updateKeyword , valuesKeyword , whereKeyword )
84
+ import Droplet.Language.Internal.Syntax (class ConstraintsToRowList , class JoinedToMaybe , class OnlyAggregations , class QueryOptionallyAliased , class ToProjection , class ToSingleColumn , class UniqueColumnNames , Add , Alter (..), As (..), Create , DefaultValues (..), Delete (..), Distinct (..), Drop , From (..), GroupBy (..), Inclusion (..), Inner , Insert (..), Into (..), Join (..), Limit (..), Offset (..), On (..), OrderBy (..), Outer , Plan , Prepare (..), Returning (..), Select (..), Set (..), Side , Sort (..), T (..), Union (..), Update (..), Values (..), Where (..))
85
+ import Droplet.Language.Internal.Token (addKeyword , allKeyword , alterKeyword , andKeyword , array_aggFunctionName , asKeyword , ascKeyword , atSymbol , byKeyword , closeBracket , comma , constraintKeyword , countFunctionName , createKeyword , defaultKeyword , deleteKeyword , descKeyword , distinctKeyword , dotSymbol , dropKeyword , equalsSymbol , existsKeyword , foreignKeyKeyword , fromKeyword , greaterEqualsThanSymbol , greaterThanSymbol , groupByKeyword , identityKeyword , inKeyword , innerKeyword , insertKeyword , isNotNullKeyword , isNullKeyword , joinKeyword , leftKeyword , lesserEqualsThanSymbol , lesserThanSymbol , limitKeyword , notEqualsSymbol , notKeyword , notNullKeyword , offsetKeyword , onKeyword , openBracket , orKeyword , orderKeyword , parameterSymbol , primaryKeyKeyword , quoteSymbol , referencesKeyword , returningKeyword , selectKeyword , setKeyword , space , starSymbol , string_aggFunctionName , tableKeyword , unionKeyword , uniqueKeyword , updateKeyword , valuesKeyword , whereKeyword )
86
86
import Foreign (Foreign )
87
87
import Prelude (class Show , Unit , bind , discard , map , otherwise , pure , show , ($), (<$>), (<<<), (<>), (==), (||))
88
88
import Prim.Boolean (False , True )
@@ -779,6 +779,10 @@ instance (Reflectable alias String, Reflectable name String) ⇒ NameList (Path
779
779
instance NameList Star where
780
780
nameList _ = starSymbol
781
781
782
+ -- e.g. array_agg (field order by field)
783
+ instance (NameList f , NameList g ) ⇒ NameList (OrderBy f g ) where
784
+ nameList (OrderBy f g) = nameList g <> orderKeyword <> byKeyword <> nameList f
785
+
782
786
instance (NameList f , NameList rest ) ⇒ NameList (Tuple f rest ) where
783
787
nameList (Tuple f rest) = nameList f <> comma <> nameList rest
784
788
@@ -1132,6 +1136,7 @@ printAggregation = case _ of
1132
1136
StringAgg f rest → do
1133
1137
nrest ← argumentList rest
1134
1138
pure $ string_aggFunctionName <> openBracket <> nameList f <> comma <> nrest <> closeBracket
1139
+ ArrayAgg f → pure $ array_aggFunctionName <> openBracket <> nameList f <> closeBracket
1135
1140
1136
1141
printFunction ∷ ∀ inp fields args out . ArgumentList args ⇒ PgFunction inp args fields out → State QueryState String
1137
1142
printFunction (PgFunction name args) = do
0 commit comments