remove the db-embed-default-join config

This commit is contained in:
steve-chavez
2021-11-23 12:32:51 -05:00
committed by Steve Chavez
parent 1981160536
commit 1b48531369
19 changed files with 18 additions and 104 deletions
+1 -32
View File
@@ -240,38 +240,7 @@ spec =
]|]
{ matchHeaders = [matchContentTypeJson] }
notDefaultConfig :: SpecWith ((), Application)
notDefaultConfig =
describe "Embedding with a default inner join(db-embed-default-join = 'inner')" $ do
it "works on many-to-one relationships" $
get "/tasks?select=id,projects(id,clients(id))&projects.clients.id=eq.1" `shouldRespondWith`
[json|[
{"id":1,"projects":{"id":1,"clients":{"id":1}}},
{"id":2,"projects":{"id":1,"clients":{"id":1}}},
{"id":3,"projects":{"id":2,"clients":{"id":1}}},
{"id":4,"projects":{"id":2,"clients":{"id":1}}}]|]
{ matchHeaders = [matchContentTypeJson] }
it "works on one-to-many relationships" $
get "/entities?select=id,child_entities(id,grandchild_entities(id))&child_entities.grandchild_entities.id=in.(1,5)"
`shouldRespondWith`
[json|[
{
"id": 1,
"child_entities": [
{ "id": 1, "grandchild_entities": [ { "id": 1 } ] },
{ "id": 2, "grandchild_entities": [ { "id": 5 } ] }]
}
]|]
{ matchHeaders = [matchContentTypeJson] }
it "works on many-to-many relationships" $
get "/products?select=id,suppliers(id,trade_unions(id))&suppliers.trade_unions.id=eq.3"
`shouldRespondWith`
[json|[{"id":1,"suppliers":[{"id":2,"trade_unions":[{"id":3}]}]}] |]
{ matchHeaders = [matchContentTypeJson] }
it "can restore default left join behavior" $
it "can use default left join behavior explicitly" $
get "/projects?select=id,clients!left(id)" `shouldRespondWith`
[json|[
{"id":1,"clients":{"id":1}}, {"id":2,"clients":{"id":1}},
-5
View File
@@ -99,7 +99,6 @@ main = do
let withApp = app testCfg
maxRowsApp = app testMaxRowsCfg
embedInnerJoinApp = app testEmbedInnerJoinCfg
disabledOpenApi = app testDisabledOpenApiCfg
proxyApp = app testProxyCfg
noJwtApp = app testCfgNoJWT
@@ -219,10 +218,6 @@ main = do
parallel $ before testCfgLegacyGucsApp $
describe "Feature.LegacyGucsSpec" Feature.LegacyGucsSpec.spec
-- this test runs with db-embed-default-join = inner
before embedInnerJoinApp $
describe "Feature.EmbedInnerJoinSpecNotDefaultConfig" Feature.EmbedInnerJoinSpec.notDefaultConfig
-- Note: the rollback tests can not run in parallel, because they test persistance and
-- this results in race conditions
-5
View File
@@ -28,7 +28,6 @@ import PostgREST.Config (AppConfig (..),
OpenAPIMode (..),
parseSecret)
import PostgREST.DbStructure.Identifiers (QualifiedIdentifier (..))
import PostgREST.Request.Types (JoinType (..))
import Protolude hiding (toS)
import Protolude.Conv (toS)
@@ -90,7 +89,6 @@ _baseCfg = let secret = Just $ encodeUtf8 "reallyreallyreallyreallyverysafe" in
, configDbSchemas = fromList ["test"]
, configDbConfig = False
, configDbUri = mempty
, configDbEmbedDefaultJoin = JTLeft
, configDbUseLegacyGucs = True
, configFilePath = Nothing
, configJWKS = parseSecret <$> secret
@@ -128,9 +126,6 @@ testUnicodeCfg testDbConn = (testCfg testDbConn) { configDbSchemas = fromList ["
testMaxRowsCfg :: Text -> AppConfig
testMaxRowsCfg testDbConn = (testCfg testDbConn) { configDbMaxRows = Just 2 }
testEmbedInnerJoinCfg :: Text -> AppConfig
testEmbedInnerJoinCfg testDbConn = (testCfg testDbConn) { configDbEmbedDefaultJoin = JTInner }
testDisabledOpenApiCfg :: Text -> AppConfig
testDisabledOpenApiCfg testDbConn = (testCfg testDbConn) { configOpenApiMode = OADisabled }
@@ -12,7 +12,6 @@ db-schemas = "provided_through_alias"
db-config = "false"
db-tx-end = "commit"
db-uri = "required"
db-embed-default-join = "left"
db-use-legacy-gucs = true
jwt-aud = ""
jwt-role-claim-key = ".\"aliased\""
@@ -12,7 +12,6 @@ db-schemas = "required"
db-config = "false"
db-tx-end = "commit"
db-uri = "required"
db-embed-default-join = "left"
db-use-legacy-gucs = true
jwt-aud = ""
jwt-role-claim-key = ".\"role\""
@@ -12,7 +12,6 @@ db-schemas = "required"
db-config = "false"
db-tx-end = "commit"
db-uri = "required"
db-embed-default-join = "left"
db-use-legacy-gucs = true
jwt-aud = ""
jwt-role-claim-key = ".\"role\""
@@ -12,7 +12,6 @@ db-schemas = "required"
db-config = "false"
db-tx-end = "commit"
db-uri = "required"
db-embed-default-join = "left"
db-use-legacy-gucs = true
jwt-aud = ""
jwt-role-claim-key = ".\"role\""
@@ -12,7 +12,6 @@ db-schemas = "test,other_tenant1,other_tenant2"
db-config = "true"
db-tx-end = "rollback-allow-override"
db-uri = "<REPLACED_WITH_DB_URI>"
db-embed-default-join = "inner"
db-use-legacy-gucs = false
jwt-aud = "https://otherexample.org"
jwt-role-claim-key = ".\"other\".\"role\""
@@ -12,7 +12,6 @@ db-schemas = "test,tenant1,tenant2"
db-config = "true"
db-tx-end = "commit-allow-override"
db-uri = "<REPLACED_WITH_DB_URI>"
db-embed-default-join = "inner"
db-use-legacy-gucs = false
jwt-aud = "https://example.org"
jwt-role-claim-key = ".\"a\".\"role\""
@@ -12,7 +12,6 @@ db-schemas = "multi,tenant,setup"
db-config = "false"
db-tx-end = "rollback-allow-override"
db-uri = "tmp_db"
db-embed-default-join = "inner"
db-use-legacy-gucs = false
jwt-aud = "https://postgrest.org"
jwt-role-claim-key = ".\"user\"[0].\"real-role\""
@@ -12,7 +12,6 @@ db-schemas = "required"
db-config = "true"
db-tx-end = "commit"
db-uri = "required"
db-embed-default-join = "left"
db-use-legacy-gucs = true
jwt-aud = ""
jwt-role-claim-key = ".\"role\""
-1
View File
@@ -12,7 +12,6 @@ db-schemas = "multi, tenant,setup"
db-config = "false"
db-tx-end = "rollback-allow-override"
db-uri = "tmp_db"
db-embed-default-join = "inner"
db-use-legacy-gucs = false
jwt-aud = "https://postgrest.org"
jwt-role-claim-key = ".user[0].\"real-role\""
-15
View File
@@ -440,21 +440,6 @@ def test_invalid_openapi_mode(invalidopenapimodes, defaultenv):
print(line)
@pytest.mark.parametrize("invalidjointypes", FIXTURES["invalidjointypes"])
def test_invalid_db_embed_default_join(invalidjointypes, defaultenv):
"Given an invalid db-embed-default-join, Postgrest should exit with a non-zero exit code."
env = {
**defaultenv,
"PGRST_DB_EMBED_DEFAULT_JOIN": invalidjointypes,
}
with pytest.raises(PostgrestError):
dump = dumpconfig(CONFIGSDIR / "defaults.config", env=env)
for line in dump.split("\n"):
if line.startswith("db-embed-default-join"):
print(line)
def test_iat_claim(defaultenv):
"""
A claim with an 'iat' (issued at) attribute should be successful.