refactor: move dumpQi to Config.hs and clarify quoteQi
The `dumpQi` function is only used in the `Config.hs` module, so it is moved there. This also adds a doctest for `quoteQi` and clarifies its usage. Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
This commit is contained in:
committed by
Steve Chavez
parent
a688878236
commit
db2be093b5
@@ -7,7 +7,6 @@ module PostgREST.SchemaCache.Identifiers
|
||||
, RelIdentifier(..)
|
||||
, Schema
|
||||
, TableName
|
||||
, dumpQi
|
||||
, escapeIdent
|
||||
, isAnyElement
|
||||
, quoteQi
|
||||
@@ -38,10 +37,12 @@ instance Hashable QualifiedIdentifier
|
||||
isAnyElement :: QualifiedIdentifier -> Bool
|
||||
isAnyElement y = QualifiedIdentifier "pg_catalog" "anyelement" == y
|
||||
|
||||
dumpQi :: QualifiedIdentifier -> Text
|
||||
dumpQi (QualifiedIdentifier s i) =
|
||||
(if T.null s then mempty else s <> ".") <> i
|
||||
|
||||
-- |
|
||||
-- Quote the qualified identifier when preparing the SQL. This avoids parse
|
||||
-- errors by postgres, for example on pg reserved words like "true" or "select".
|
||||
--
|
||||
-- >>> quoteQi (QualifiedIdentifier "" "true")
|
||||
-- "\"true\""
|
||||
quoteQi :: QualifiedIdentifier -> Text
|
||||
quoteQi (QualifiedIdentifier s i) =
|
||||
(if T.null s then mempty else escapeIdent s <> ".") <> escapeIdent i
|
||||
|
||||
Reference in New Issue
Block a user