diff --git a/src/PostgREST/App.hs b/src/PostgREST/App.hs index 932b5bc94..e9793a65e 100644 --- a/src/PostgREST/App.hs +++ b/src/PostgREST/App.hs @@ -59,16 +59,6 @@ import Prelude app :: DbStructure -> AppConfig -> BL.ByteString -> DbRole -> Request -> H.Tx P.Postgres s Response app dbstructure conf reqBody dbrole req = case (path, verb) of - -- ([], _) -> do - -- body <- encode <$> tables (cs schema) - -- return $ responseLBS status200 [jsonH] $ cs body - - -- ([table], "OPTIONS") -> do - -- let qt = qualify table - -- cols <- columns qt - -- pkey <- map cs <$> primaryKeyColumns qt - -- return $ responseLBS status200 [jsonH, allOrigins] - -- $ encode (TableOptions cols pkey) ([], _) -> do let body = encode $ filter (filterTableAcl dbrole) $ filter (((cs schema)==).tableSchema) allTables @@ -96,9 +86,6 @@ app dbstructure conf reqBody dbrole req = ) <> commaq <> ( bodyForAccept contentType qt -- TODO! when in csv mode, the first row (columns) is not correct when requesting sub tables . limitT range - -- . orderT (orderParse qq) - -- . whereT qt qq - -- $ select qt qq $ qs ) -- return $ responseLBS status200 [contentTypeH] (cs $ show $ B.stmtTemplate q) @@ -135,39 +122,6 @@ app dbstructure conf reqBody dbrole req = queries = (,) <$> query <*> countQuery - -- - -- let qt = qualify table - -- from = fromMaybe 0 $ rangeOffset <$> range - -- query = B.Stmt "select " V.empty True <> - -- parentheticT ( - -- whereT qt qq $ countRows qt - -- ) <> commaq <> ( - -- bodyForAccept contentType qt - -- . limitT range - -- . orderT (orderParse qq) - -- . whereT qt qq - -- $ select qt qq - -- ) - -- row <- H.maybeEx query - -- let (tableTotal, queryTotal, body) = - -- fromMaybe (0, 0, Just "" :: Maybe Text) row - -- to = from+queryTotal-1 - -- contentRange = contentRangeH from to tableTotal - -- status = rangeStatus from to tableTotal - -- canonical = urlEncodeVars - -- . sortBy (comparing fst) - -- . map (join (***) cs) - -- . parseSimpleQuery - -- $ rawQueryString req - -- return $ responseLBS status - -- [contentTypeH, contentRange, - -- ("Content-Location", - -- "/" <> cs table <> - -- if Prelude.null canonical then "" else "?" <> cs canonical - -- ) - -- ] (cs $ fromMaybe "[]" body) - - (["postgrest", "users"], "POST") -> do let user = decode reqBody :: Maybe AuthUser diff --git a/src/PostgREST/Functions.hs b/src/PostgREST/Functions.hs index 42c06a831..d109de671 100644 --- a/src/PostgREST/Functions.hs +++ b/src/PostgREST/Functions.hs @@ -117,19 +117,6 @@ dbRequestToCountQuery (Node (Select mainTable _ _ conditions _ _) _) = dbRequestToQuery :: DbRequest -> PStmt dbRequestToQuery (Node (Select mainTable colSelects tbls conditions _ ord) forest) = orderT (fromMaybe [] ord) query - -- case relation of - -- Nothing ->B.Stmt ("SELECT " - -- <> "(" - -- <> dbRequestToCountQuery r - -- <> ")," - -- <> "pg_catalog.count(t)," - -- <> "array_to_json(array_agg(row_to_json(t)))::CHARACTER VARYING AS json " - -- <> "FROM (" - -- <> query - -- <> ") t;" - -- ) V.empty True - -- - -- _ -> B.Stmt query V.empty True where query = B.Stmt qStr V.empty True diff --git a/src/PostgREST/PgStructure.hs b/src/PostgREST/PgStructure.hs index 9cd82e449..54e257ece 100644 --- a/src/PostgREST/PgStructure.hs +++ b/src/PostgREST/PgStructure.hs @@ -212,17 +212,3 @@ allprimaryKeys = do ) |] return $ map pkFromRow pks - --- alltablesAcl :: H.Tx P.Postgres s [(Text, Text, Text)] --- alltablesAcl = do --- acl <- H.listEx $ [H.stmt| --- SELECT --- table_schema, --- table_name, --- grantee as role --- FROM information_schema.role_table_grants --- WHERE --- table_schema NOT IN ('pg_catalog', 'information_schema') AND --- privilege_type = 'SELECT' --- |] --- return acl