From 4c74e54ae17a730dbdb51e17c6ec22eabf09f191 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Mon, 5 Jan 2015 22:37:49 -0800 Subject: [PATCH] Do not add WHERE clause if only param is order Fixes #119 --- postgrest.cabal | 2 +- src/PgQuery.hs | 2 +- test/Feature/QuerySpec.hs | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/postgrest.cabal b/postgrest.cabal index 7c4a50f08..b32f1b3f3 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -1,5 +1,5 @@ name: postgrest -version: 0.2.4.9 +version: 0.2.4.10 synopsis: The database is your api license: MIT license-file: LICENSE diff --git a/src/PgQuery.hs b/src/PgQuery.hs index 7bad71e7f..06a8957e7 100644 --- a/src/PgQuery.hs +++ b/src/PgQuery.hs @@ -43,7 +43,7 @@ limitT r q = whereT :: Net.Query -> StatementT whereT params q = - if L.null params + if L.null cols then q else q <> (" where ",[],mempty) <> conjunction where diff --git a/test/Feature/QuerySpec.hs b/test/Feature/QuerySpec.hs index ce0e0e75d..6efaceca6 100644 --- a/test/Feature/QuerySpec.hs +++ b/test/Feature/QuerySpec.hs @@ -39,6 +39,9 @@ spec = beforeAll (clearTable "items" >> createItems 15) , matchHeaders = ["Content-Range" <:> "0-1/2"] } + it "without other constraints" $ + get "/items?order=asc.id" `shouldRespondWith` 200 + describe "Canonical location" $ do it "Sets Content-Location with alphabetized params" $ get "/no_pk?b=eq.1&a=eq.1"