Skip to content

Commit

Permalink
Fixed data editor errors when trying to edit the schema_migrations table
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Jan 6, 2022
1 parent b0d2e56 commit 7ea0b83
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions IHP/IDE/Data/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,26 @@ fetchRows :: FromRow r => PG.Connection -> Text -> IO [r]
fetchRows connection tableName = do
pkFields <- tablePrimaryKeyFields connection tableName
let query = "SELECT * FROM " <> tableName <> " ORDER BY " <> intercalate ", " pkFields
let query = "SELECT * FROM "
<> tableName
<> (if null pkFields
then ""
else " ORDER BY " <> intercalate ", " pkFields
)
PG.query_ connection (PG.Query . cs $! query)
fetchRowsPage :: FromRow r => PG.Connection -> Text -> Int -> Int -> IO [r]
fetchRowsPage connection tableName page rows = do
pkFields <- tablePrimaryKeyFields connection tableName
let slice = " OFFSET " <> show (page * rows - rows) <> " ROWS FETCH FIRST " <> show rows <> " ROWS ONLY"
let query = "SELECT * FROM " <> tableName <> " ORDER BY " <> intercalate ", " pkFields <> slice
let query = "SELECT * FROM "
<> tableName
<> (if null pkFields
then ""
else " ORDER BY " <> intercalate ", " pkFields
)
<> slice
PG.query_ connection (PG.Query . cs $! query)
Expand Down

0 comments on commit 7ea0b83

Please sign in to comment.