From 4c74e54ae17a730dbdb51e17c6ec22eabf09f191 Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Mon, 5 Jan 2015 22:37:49 -0800 Subject: [PATCH 1/2] 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" From d77924a9d1c955528f1c7dfbde9074a2fc94a41f Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Mon, 5 Jan 2015 23:03:51 -0800 Subject: [PATCH 2/2] Update links to binaries --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e655db0de..9986e3b0a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ your own projects. ### Usage -Download the binary ([OS X](http://bin.begriffs.com/dbapi/osx/postgrest-0.2.4.9.tar.xz) / [Ubuntu](http://bin.begriffs.com/dbapi/heroku/postgrest-0.2.4.9.tar.xz)) and invoke like so: +Download the binary ([OS X](http://bin.begriffs.com/dbapi/osx/postgrest-0.2.4.10.tar.xz) / [Ubuntu](http://bin.begriffs.com/dbapi/heroku/postgrest-0.2.4.10.tar.xz)) and invoke like so: ```bash postgrest --db-host localhost --db-port 5432 \