pgFmtIdent always quotes #388
This commit is contained in:
@@ -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
|
- Detect relations event when authenticator does not have rights to intermediate tables - @ruslantalpa
|
||||||
- Ensure db connections released on sigint - @begriffs
|
- Ensure db connections released on sigint - @begriffs
|
||||||
- Fix #396 include records with missing parents - @ruslantalpa
|
- Fix #396 include records with missing parents - @ruslantalpa
|
||||||
|
- `pgFmtIdent` always quotes #388 - @calebmer
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Allow order by computed columns - @diogob
|
- Allow order by computed columns - @diogob
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ import Data.Tree (Tree(..))
|
|||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
import PostgREST.Types
|
import PostgREST.Types
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Text.Regex.TDFA ((=~))
|
|
||||||
import qualified Data.ByteString.Char8 as BS
|
|
||||||
import Data.Scientific ( FPFormat (..)
|
import Data.Scientific ( FPFormat (..)
|
||||||
, formatScientific
|
, formatScientific
|
||||||
, isInteger
|
, isInteger
|
||||||
@@ -166,12 +164,7 @@ operators = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
pgFmtIdent :: SqlFragment -> SqlFragment
|
pgFmtIdent :: SqlFragment -> SqlFragment
|
||||||
pgFmtIdent x =
|
pgFmtIdent x = "\"" <> replace "\"" "\"\"" (trimNullChars $ cs 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
|
|
||||||
|
|
||||||
pgFmtLit :: SqlFragment -> SqlFragment
|
pgFmtLit :: SqlFragment -> SqlFragment
|
||||||
pgFmtLit x =
|
pgFmtLit x =
|
||||||
|
|||||||
Reference in New Issue
Block a user