constrain cast parameters to letters only
This commit is contained in:
@@ -143,7 +143,8 @@ select table params =
|
|||||||
selectTerm :: QualifiedIdentifier -> T.Text -> PStmt
|
selectTerm :: QualifiedIdentifier -> T.Text -> PStmt
|
||||||
selectTerm table col =
|
selectTerm table col =
|
||||||
case T.splitOn "::" col of
|
case T.splitOn "::" col of
|
||||||
[colName,castTo] -> B.Stmt ("CAST (" <> pgFmtJsonbPath table (cs colName) <> " AS " <> castTo <> " )" <> asT (jsonbPath colName)) empty True
|
[colName,castTo] -> B.Stmt ("CAST (" <> pgFmtJsonbPath table (cs colName) <> " AS " <> castToSafe <> " )" <> asT (jsonbPath colName)) empty True
|
||||||
|
where castToSafe = T.filter ( `elem` ['a'..'z'] ) castTo
|
||||||
_-> B.Stmt (pgFmtJsonbPath table (cs col) <> asT (jsonbPath col)) empty True
|
_-> B.Stmt (pgFmtJsonbPath table (cs col) <> asT (jsonbPath col)) empty True
|
||||||
where
|
where
|
||||||
jsonbPath :: T.Text -> Maybe JsonbPath
|
jsonbPath :: T.Text -> Maybe JsonbPath
|
||||||
|
|||||||
Reference in New Issue
Block a user