mirror of
https://github.com/Airsequel/AirGQL.git
synced 2025-08-01 10:36:44 +03:00
Ensure sql names are always quoted properly
This commit is contained in:
parent
0d52017745
commit
d3378c7ecd
2 changed files with 21 additions and 23 deletions
|
@ -312,10 +312,10 @@ getTableNames connection = do
|
|||
getColumnNames :: Connection -> Text -> IO [Text]
|
||||
getColumnNames connection tableName = do
|
||||
results :: [SS.Only Text] <-
|
||||
query_
|
||||
SS.query
|
||||
connection
|
||||
$ SS.Query
|
||||
$ "SELECT name FROM pragma_table_xinfo(" <> quoteText tableName <> ")"
|
||||
"SELECT name FROM pragma_table_xinfo(?)"
|
||||
[tableName]
|
||||
pure (SS.fromOnly <$> results)
|
||||
|
||||
|
||||
|
@ -492,10 +492,10 @@ getTableUniqueIndexConstraints connection tableName = do
|
|||
( SS.query
|
||||
connection
|
||||
[SS.sql|
|
||||
SELECT sql
|
||||
FROM sqlite_master
|
||||
WHERE tbl_name = ? AND type = 'index'
|
||||
|]
|
||||
SELECT sql
|
||||
FROM sqlite_master
|
||||
WHERE tbl_name = ? AND type = 'index'
|
||||
|]
|
||||
[tableName]
|
||||
)
|
||||
(\_ -> pure [])
|
||||
|
@ -760,20 +760,18 @@ getColumnsFromParsedTableEntry
|
|||
-> IO [ColumnEntry]
|
||||
getColumnsFromParsedTableEntry connection tableEntry = do
|
||||
keyColumns :: [[SQLData]] <-
|
||||
query_ connection $
|
||||
SS.Query $
|
||||
"SELECT * FROM pragma_index_info("
|
||||
<> quoteText tableEntry.tbl_name
|
||||
<> ")"
|
||||
SS.query
|
||||
connection
|
||||
"SELECT * FROM pragma_index_info(?)"
|
||||
[tableEntry.tbl_name]
|
||||
|
||||
-- TODO: Catch only SQL specific exceptions
|
||||
colEntriesRaw :: [ColumnEntryRaw] <-
|
||||
catchAll
|
||||
( query_ connection $
|
||||
SS.Query $
|
||||
"SELECT * FROM pragma_table_xinfo("
|
||||
<> quoteText tableEntry.tbl_name
|
||||
<> ")"
|
||||
( SS.query
|
||||
connection
|
||||
"SELECT * FROM pragma_table_xinfo(?)"
|
||||
[tableEntry.tbl_name]
|
||||
)
|
||||
( \exception -> do
|
||||
P.putErrText $ show exception
|
||||
|
|
|
@ -2137,12 +2137,12 @@ testSuite = do
|
|||
conn <- open testDbPath
|
||||
let
|
||||
sqlQuery =
|
||||
[raw|
|
||||
CREATE TABLE IF NOT EXISTS checks (
|
||||
color TEXT CHECK ( color IN ('red', 'green', 'blue') )
|
||||
)
|
||||
|]
|
||||
execute_ conn $ SS.Query sqlQuery
|
||||
[sql|
|
||||
CREATE TABLE IF NOT EXISTS checks (
|
||||
color TEXT CHECK ( color IN ('red', 'green', 'blue') )
|
||||
)
|
||||
|]
|
||||
execute_ conn sqlQuery
|
||||
execute_ conn "DELETE FROM checks"
|
||||
execute_
|
||||
conn
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue