Allow using nulls order without explicit order direction, fix #552
This commit is contained in:
@@ -137,13 +137,14 @@ pOrderTerm :: Parser OrderTerm
|
||||
pOrderTerm =
|
||||
try ( do
|
||||
c <- pFieldName
|
||||
_ <- pDelimiter
|
||||
d <- (string "asc" *> pure OrderAsc)
|
||||
<|> (string "desc" *> pure OrderDesc)
|
||||
d <- optionMaybe (try $ pDelimiter *> (
|
||||
try(string "asc" *> pure OrderAsc)
|
||||
<|> try(string "desc" *> pure OrderDesc)
|
||||
))
|
||||
nls <- optionMaybe (pDelimiter *> (
|
||||
try(string "nullslast" *> pure OrderNullsLast)
|
||||
<|> try(string "nullsfirst" *> pure OrderNullsFirst)
|
||||
))
|
||||
return $ OrderTerm c d nls
|
||||
)
|
||||
<|> OrderTerm <$> (toS <$> pFieldName) <*> pure OrderAsc <*> pure Nothing
|
||||
<|> OrderTerm <$> (toS <$> pFieldName) <*> pure Nothing <*> pure Nothing
|
||||
|
||||
@@ -307,7 +307,7 @@ requestToQuery schema isParent (DbRead (Node (Select colSelects tbls conditions
|
||||
queryTerm :: OrderTerm -> Text
|
||||
queryTerm t = " "
|
||||
<> toS (pgFmtColumn qi $ otTerm t) <> " "
|
||||
<> show (otDirection t) <> " "
|
||||
<> maybe "" show (otDirection t) <> " "
|
||||
<> maybe "" show (otNullOrder t) <> " "
|
||||
(joins, selects) = foldr getQueryParts ([],[]) forest
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ instance Show OrderNulls where
|
||||
|
||||
data OrderTerm = OrderTerm {
|
||||
otTerm :: Text
|
||||
, otDirection :: OrderDirection
|
||||
, otDirection :: Maybe OrderDirection
|
||||
, otNullOrder :: Maybe OrderNulls
|
||||
} deriving (Show, Eq)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user