also fix broken text env

After the last couple of commits the tests ran correctly only on a
fresh db, in addition, the roles within the db were not created/dropped
on each request and we need that since their privileges differ and we
need to to have an absolute clean db on each execution
This commit is contained in:
Ruslan Talpa
2016-12-18 15:46:53 -08:00
committed by Joe Nelson
parent e364cbc3ff
commit 16fd3a57ff
12 changed files with 106 additions and 84 deletions
+5 -2
View File
@@ -62,6 +62,7 @@ import PostgREST.QueryBuilder ( callProc
, createReadStatement
, createWriteStatement
, ResultsWithCount
, returningF
)
import PostgREST.Types
import PostgREST.OpenAPI
@@ -262,8 +263,9 @@ app dbStructure conf apiRequest =
mapSnd f (a, b) = (a, f b)
readDbRequest = DbRead <$> readRequest (configMaxRows conf) (dbRelations dbStructure) (map (mapSnd pdReturnType) $ dbProcs dbStructure) apiRequest
mutateDbRequest = DbMutate <$> mutateRequest apiRequest
selectQuery = requestToQuery schema False <$> readDbRequest
mutateQuery = requestToQuery schema False <$> mutateDbRequest
returningSql = returningF (iTarget apiRequest) (iPreferRepresentation apiRequest) <$> readDbRequest
selectQuery = requestToQuery schema False "" <$> readDbRequest
mutateQuery = requestToQuery schema False <$> returningSql <*> mutateDbRequest
countQuery = requestToCountQuery schema <$> readDbRequest
readSqlParts = (,) <$> selectQuery <*> countQuery
mutateSqlParts = (,) <$> selectQuery <*> mutateQuery
@@ -288,6 +290,7 @@ responseContentTypeOrError accepts action = serves contentTypesForRequest accept
"None of these Content-Types are available: " <> failed
Just ct -> Right ct
splitKeyValue :: BS.ByteString -> (BS.ByteString, BS.ByteString)
splitKeyValue kv = (k, BS.tail v)
where (k, v) = BS.break (== '=') kv