fix #453 by sending the request to the db (instead of using the cached data)
This commit is contained in:
@@ -178,7 +178,7 @@ app dbStructure conf reqBody req =
|
|||||||
else return notFound
|
else return notFound
|
||||||
|
|
||||||
(ActionRead, TargetRoot, Nothing) -> do
|
(ActionRead, TargetRoot, Nothing) -> do
|
||||||
body <- encode <$> accessibleTables (filter ((== cs schema) . tableSchema) (dbTables dbStructure))
|
body <- encode <$> accessibleTables (cs schema)
|
||||||
return $ responseLBS status200 [jsonH] $ cs body
|
return $ responseLBS status200 [jsonH] $ cs body
|
||||||
|
|
||||||
(ActionUnknown _, _, _) -> return notFound
|
(ActionUnknown _, _, _) -> return notFound
|
||||||
|
|||||||
@@ -71,25 +71,33 @@ doesProcReturnJWT = doesProc [H.stmt|
|
|||||||
AND pg_catalog.pg_get_function_result(p.oid) like '%jwt_claims'
|
AND pg_catalog.pg_get_function_result(p.oid) like '%jwt_claims'
|
||||||
|]
|
|]
|
||||||
|
|
||||||
accessibleTables :: [Table] -> H.Tx P.Postgres s [Table]
|
accessibleTables :: Schema -> H.Tx P.Postgres s [Table]
|
||||||
accessibleTables allTabs = do
|
accessibleTables schema = do
|
||||||
accessible <- H.listEx $ [H.stmt|
|
rows <- H.listEx $
|
||||||
SELECT
|
[H.stmt|
|
||||||
n.nspname AS table_schema,
|
select
|
||||||
c.relname AS table_name
|
n.nspname as table_schema,
|
||||||
FROM pg_class c
|
relname as table_name,
|
||||||
JOIN pg_namespace n ON n.oid = c.relnamespace
|
c.relkind = 'r' or (c.relkind IN ('v', 'f')) and (pg_relation_is_updatable(c.oid::regclass, false) & 8) = 8
|
||||||
WHERE
|
or (exists (
|
||||||
c.relkind IN ('v','r','m') AND
|
select 1
|
||||||
n.nspname NOT IN ('pg_catalog', 'information_schema') AND (
|
from pg_trigger
|
||||||
pg_has_role(c.relowner, 'USAGE'::text) OR
|
where pg_trigger.tgrelid = c.oid and (pg_trigger.tgtype::integer & 69) = 69)
|
||||||
has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text) OR
|
) as insertable
|
||||||
has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES'::text)
|
from
|
||||||
|
pg_class c
|
||||||
|
join pg_namespace n on n.oid = c.relnamespace
|
||||||
|
where
|
||||||
|
c.relkind in ('v', 'r', 'm')
|
||||||
|
and n.nspname = ?
|
||||||
|
and (
|
||||||
|
pg_has_role(c.relowner, 'USAGE'::text)
|
||||||
|
or has_table_privilege(c.oid, 'SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER'::text)
|
||||||
|
or has_any_column_privilege(c.oid, 'SELECT, INSERT, UPDATE, REFERENCES'::text)
|
||||||
)
|
)
|
||||||
ORDER BY table_schema, table_name
|
order by relname
|
||||||
|]
|
|] schema
|
||||||
let isAccessible table = isJust $ find (\(s,n) -> tableSchema table == s && tableName table == n) accessible
|
return $ map tableFromRow rows
|
||||||
return $ filter isAccessible allTabs
|
|
||||||
|
|
||||||
synonymousColumns :: [(Column,Column)] -> [Column] -> [[Column]]
|
synonymousColumns :: [(Column,Column)] -> [Column] -> [[Column]]
|
||||||
synonymousColumns allSyns cols = synCols'
|
synonymousColumns allSyns cols = synCols'
|
||||||
|
|||||||
Reference in New Issue
Block a user