diff --git a/CHANGELOG.md b/CHANGELOG.md index 829fdc0e9..7dc28f4cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Detect relations event when authenticator does not have rights to intermediate tables - @ruslantalpa - Ensure db connections released on sigint - @begriffs - Fix #396 include records with missing parents - @ruslantalpa +- `pgFmtIdent` always quotes #388 - @calebmer ### Added - Allow order by computed columns - @diogob diff --git a/src/PostgREST/QueryBuilder.hs b/src/PostgREST/QueryBuilder.hs index 181cc4ae6..53ac899c9 100644 --- a/src/PostgREST/QueryBuilder.hs +++ b/src/PostgREST/QueryBuilder.hs @@ -46,8 +46,6 @@ import Data.Tree (Tree(..)) import qualified Data.Vector as V import PostgREST.Types import qualified Data.Map as M -import Text.Regex.TDFA ((=~)) -import qualified Data.ByteString.Char8 as BS import Data.Scientific ( FPFormat (..) , formatScientific , isInteger @@ -166,12 +164,7 @@ operators = [ ] pgFmtIdent :: SqlFragment -> SqlFragment -pgFmtIdent x = - let escaped = replace "\"" "\"\"" (trimNullChars $ cs x) in - if (cs escaped :: BS.ByteString) =~ danger - then "\"" <> escaped <> "\"" - else escaped - where danger = "^$|^[^a-z_]|[^a-z_0-9]" :: BS.ByteString +pgFmtIdent x = "\"" <> replace "\"" "\"\"" (trimNullChars $ cs x) <> "\"" pgFmtLit :: SqlFragment -> SqlFragment pgFmtLit x =