Skip to content

Commit

Permalink
ID-1064 Use UNION ALL in listResourcesV2 query
Browse files Browse the repository at this point in the history
  • Loading branch information
tlangs committed Feb 5, 2024
1 parent a91acd0 commit 2aea82e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@ class PostgresAccessPolicyDAO(
$notNullConstraintPolicyAction
"""

val includePublicPolicyActionQuery = samsqls"union $publicPolicyActionQuery"
val includePublicPolicyActionQuery = samsqls"union all $publicPolicyActionQuery"
val publicResourcesQuery = samsql"$publicRoleActionQuery $includePublicPolicyActionQuery"

readOnlyTransaction("filterResourcesPublic", samRequestContext) { implicit session =>
Expand Down Expand Up @@ -1836,7 +1836,7 @@ class PostgresAccessPolicyDAO(
$notNullConstraintPolicyAction
"""

val includePolicyActionQuery = if (roles.isEmpty) samsqls"union $policyActionQuery" else samsqls""
val includePolicyActionQuery = if (roles.isEmpty) samsqls"union all $policyActionQuery" else samsqls""
val query =
samsqls"""$policyRoleActionQuery
$includePolicyActionQuery"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,44 @@ class ResourceServiceUnitSpec extends AnyFlatSpec with Matchers with ScalaFuture
),
// Testable DB Results
FilterResourcesResult(testResourceId, resourceTypeName, Some(testPolicy1), Some(readerRoleName), Some(readAction), false, None, false, false),
FilterResourcesResult(
testResourceId,
resourceTypeName,
Some(testPolicy1),
Some(readerRoleName),
Some(readAction),
false,
None,
false,
false
), // testing duplicate row results
FilterResourcesResult(
testResourceId,
resourceTypeName,
Some(testPolicy1),
Some(readerRoleName),
Some(readAction),
false,
None,
false,
false
), // testing duplicate row results
FilterResourcesResult(testResourceId, resourceTypeName, Some(testPolicy2), Some(nothingRoleName), None, true, None, false, false),
FilterResourcesResult(testResourceId, resourceTypeName, Some(testPolicy3), None, None, false, None, false, false),
FilterResourcesResult(testResourceId, resourceTypeName, Some(testPolicy4), Some(ownerRoleName), Some(readAction), false, None, false, false),
FilterResourcesResult(testResourceId, resourceTypeName, Some(testPolicy4), Some(ownerRoleName), Some(writeAction), false, None, false, false),
FilterResourcesResult(testResourceId, resourceTypeName, Some(testPolicy5), None, Some(readAction), true, None, false, false),
FilterResourcesResult(
testResourceId,
resourceTypeName,
Some(testPolicy5),
None,
Some(readAction),
true,
None,
false,
false
), // testing duplicate row results
// Auth Domain Results
FilterResourcesResult(
testResourceId2,
Expand Down

0 comments on commit 2aea82e

Please sign in to comment.