@contember/engine-content-api 1.2.0-alpha.8 → 1.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/acl/EvaluatedPredicateReplacer.d.ts +2 -3
- package/dist/src/acl/EvaluatedPredicateReplacer.d.ts.map +1 -1
- package/dist/src/acl/EvaluatedPredicateReplacer.js +5 -14
- package/dist/src/acl/EvaluatedPredicateReplacer.js.map +1 -1
- package/dist/src/acl/PermissionFactory.d.ts.map +1 -1
- package/dist/src/acl/PermissionFactory.js +15 -11
- package/dist/src/acl/PermissionFactory.js.map +1 -1
- package/dist/src/acl/PredicateFactory.d.ts +9 -3
- package/dist/src/acl/PredicateFactory.d.ts.map +1 -1
- package/dist/src/acl/PredicateFactory.js +47 -36
- package/dist/src/acl/PredicateFactory.js.map +1 -1
- package/dist/src/acl/PredicatesInjector.d.ts +1 -1
- package/dist/src/acl/PredicatesInjector.d.ts.map +1 -1
- package/dist/src/acl/PredicatesInjector.js +13 -18
- package/dist/src/acl/PredicatesInjector.js.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts +0 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.d.ts.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js +26 -23
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.js.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.d.ts.map +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -1
- package/dist/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts +5 -4
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js +11 -14
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js +18 -14
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts +3 -3
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +3 -3
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts +5 -4
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.d.ts.map +1 -1
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js +11 -15
- package/dist/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.js.map +1 -1
- package/dist/src/input-validation/ColumnValueResolver.d.ts +4 -3
- package/dist/src/input-validation/ColumnValueResolver.d.ts.map +1 -1
- package/dist/src/input-validation/ColumnValueResolver.js.map +1 -1
- package/dist/src/input-validation/EntityRulesResolver.js +4 -4
- package/dist/src/input-validation/EntityRulesResolver.js.map +1 -1
- package/dist/src/input-validation/QueryAstFactory.js +1 -1
- package/dist/src/input-validation/QueryAstFactory.js.map +1 -1
- package/dist/src/input-validation/ValidationDataSelector.js +1 -1
- package/dist/src/input-validation/ValidationDataSelector.js.map +1 -1
- package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts +7 -8
- package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/src/input-validation/preValidation/CreateInputPreValidationProcessor.js.map +1 -1
- package/dist/src/input-validation/preValidation/InputPreValidator.js +4 -4
- package/dist/src/input-validation/preValidation/InputPreValidator.js.map +1 -1
- package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts +7 -8
- package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.d.ts.map +1 -1
- package/dist/src/input-validation/preValidation/UpdateInputPreValidationProcessor.js.map +1 -1
- package/dist/src/inputProcessing/CreateInputProcessor.d.ts +8 -9
- package/dist/src/inputProcessing/CreateInputProcessor.d.ts.map +1 -1
- package/dist/src/inputProcessing/CreateInputVisitor.d.ts +7 -7
- package/dist/src/inputProcessing/CreateInputVisitor.d.ts.map +1 -1
- package/dist/src/inputProcessing/CreateInputVisitor.js +15 -46
- package/dist/src/inputProcessing/CreateInputVisitor.js.map +1 -1
- package/dist/src/inputProcessing/UpdateInputProcessor.d.ts +8 -9
- package/dist/src/inputProcessing/UpdateInputProcessor.d.ts.map +1 -1
- package/dist/src/inputProcessing/UpdateInputVisitor.d.ts +7 -7
- package/dist/src/inputProcessing/UpdateInputVisitor.d.ts.map +1 -1
- package/dist/src/inputProcessing/UpdateInputVisitor.js +13 -28
- package/dist/src/inputProcessing/UpdateInputVisitor.js.map +1 -1
- package/dist/src/inputProcessing/index.d.ts +0 -1
- package/dist/src/inputProcessing/index.d.ts.map +1 -1
- package/dist/src/inputProcessing/index.js +0 -1
- package/dist/src/inputProcessing/index.js.map +1 -1
- package/dist/src/introspection/IntrospectionSchemaFactory.js +7 -7
- package/dist/src/introspection/IntrospectionSchemaFactory.js.map +1 -1
- package/dist/src/mapper/ErrorUtils.d.ts.map +1 -1
- package/dist/src/mapper/ErrorUtils.js +2 -2
- package/dist/src/mapper/ErrorUtils.js.map +1 -1
- package/dist/src/mapper/JunctionTableManager.js.map +1 -1
- package/dist/src/mapper/Mapper.d.ts +6 -6
- package/dist/src/mapper/Mapper.d.ts.map +1 -1
- package/dist/src/mapper/Mapper.js +26 -21
- package/dist/src/mapper/Mapper.js.map +1 -1
- package/dist/src/mapper/MapperContainer.d.ts.map +1 -1
- package/dist/src/mapper/MapperContainer.js +4 -4
- package/dist/src/mapper/MapperContainer.js.map +1 -1
- package/dist/src/mapper/Result.d.ts.map +1 -1
- package/dist/src/mapper/Result.js +2 -4
- package/dist/src/mapper/Result.js.map +1 -1
- package/dist/src/mapper/delete/DeleteExecutor.js +6 -6
- package/dist/src/mapper/delete/DeleteExecutor.js.map +1 -1
- package/dist/src/mapper/insert/InsertBuilder.d.ts +1 -1
- package/dist/src/mapper/insert/InsertBuilder.d.ts.map +1 -1
- package/dist/src/mapper/insert/InsertBuilder.js.map +1 -1
- package/dist/src/mapper/insert/SqlCreateInputProcessor.d.ts +4 -2
- package/dist/src/mapper/insert/SqlCreateInputProcessor.d.ts.map +1 -1
- package/dist/src/mapper/insert/SqlCreateInputProcessor.js.map +1 -1
- package/dist/src/mapper/select/JoinVisitor.d.ts +6 -6
- package/dist/src/mapper/select/JoinVisitor.d.ts.map +1 -1
- package/dist/src/mapper/select/JoinVisitor.js +6 -6
- package/dist/src/mapper/select/JoinVisitor.js.map +1 -1
- package/dist/src/mapper/select/Path.d.ts +1 -0
- package/dist/src/mapper/select/Path.d.ts.map +1 -1
- package/dist/src/mapper/select/Path.js +4 -1
- package/dist/src/mapper/select/Path.js.map +1 -1
- package/dist/src/mapper/select/RelationFetcher.d.ts +11 -19
- package/dist/src/mapper/select/RelationFetcher.d.ts.map +1 -1
- package/dist/src/mapper/select/RelationFetcher.js +34 -25
- package/dist/src/mapper/select/RelationFetcher.js.map +1 -1
- package/dist/src/mapper/select/SelectBuilder.d.ts +4 -1
- package/dist/src/mapper/select/SelectBuilder.d.ts.map +1 -1
- package/dist/src/mapper/select/SelectBuilder.js +52 -12
- package/dist/src/mapper/select/SelectBuilder.js.map +1 -1
- package/dist/src/mapper/select/SelectBuilderFactory.d.ts +2 -1
- package/dist/src/mapper/select/SelectBuilderFactory.d.ts.map +1 -1
- package/dist/src/mapper/select/SelectExecutionHandler.d.ts +16 -4
- package/dist/src/mapper/select/SelectExecutionHandler.d.ts.map +1 -1
- package/dist/src/mapper/select/SelectHydrator.d.ts +3 -2
- package/dist/src/mapper/select/SelectHydrator.d.ts.map +1 -1
- package/dist/src/mapper/select/SelectHydrator.js +6 -9
- package/dist/src/mapper/select/SelectHydrator.js.map +1 -1
- package/dist/src/mapper/select/WhereBuilder.d.ts +8 -4
- package/dist/src/mapper/select/WhereBuilder.d.ts.map +1 -1
- package/dist/src/mapper/select/WhereBuilder.js +137 -35
- package/dist/src/mapper/select/WhereBuilder.js.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitor.d.ts +10 -8
- package/dist/src/mapper/select/handlers/FieldsVisitor.d.ts.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitor.js +129 -94
- package/dist/src/mapper/select/handlers/FieldsVisitor.js.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitorFactory.d.ts.map +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitorFactory.js +1 -1
- package/dist/src/mapper/select/handlers/FieldsVisitorFactory.js.map +1 -1
- package/dist/src/mapper/select/handlers/MetaHandler.d.ts.map +1 -1
- package/dist/src/mapper/select/handlers/MetaHandler.js +6 -11
- package/dist/src/mapper/select/handlers/MetaHandler.js.map +1 -1
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.d.ts.map +1 -1
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.js +6 -0
- package/dist/src/mapper/select/optimizer/ConditionOptimizer.js.map +1 -1
- package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts +9 -1
- package/dist/src/mapper/select/optimizer/WhereOptimizer.d.ts.map +1 -1
- package/dist/src/mapper/select/optimizer/WhereOptimizer.js +127 -13
- package/dist/src/mapper/select/optimizer/WhereOptimizer.js.map +1 -1
- package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts +3 -0
- package/dist/src/mapper/select/optimizer/WhereReplacer.d.ts.map +1 -0
- package/dist/src/mapper/select/optimizer/WhereReplacer.js +46 -0
- package/dist/src/mapper/select/optimizer/WhereReplacer.js.map +1 -0
- package/dist/src/mapper/select/optimizer/helpers.d.ts +1 -1
- package/dist/src/mapper/select/optimizer/helpers.d.ts.map +1 -1
- package/dist/src/mapper/select/optimizer/helpers.js +8 -1
- package/dist/src/mapper/select/optimizer/helpers.js.map +1 -1
- package/dist/src/mapper/update/SqlUpdateInputProcessor.d.ts +2 -3
- package/dist/src/mapper/update/SqlUpdateInputProcessor.d.ts.map +1 -1
- package/dist/src/mapper/update/SqlUpdateInputProcessor.js +3 -4
- package/dist/src/mapper/update/SqlUpdateInputProcessor.js.map +1 -1
- package/dist/src/mapper/update/UpdateBuilder.js +3 -3
- package/dist/src/mapper/update/UpdateBuilder.js.map +1 -1
- package/dist/src/resolvers/ExecutionContainerFactory.d.ts +1 -1
- package/dist/src/resolvers/ExecutionContainerFactory.d.ts.map +1 -1
- package/dist/src/resolvers/GraphQlQueryAstFactory.d.ts +1 -2
- package/dist/src/resolvers/GraphQlQueryAstFactory.d.ts.map +1 -1
- package/dist/src/resolvers/GraphQlQueryAstFactory.js +2 -2
- package/dist/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
- package/dist/src/resolvers/MutationResolver.d.ts.map +1 -1
- package/dist/src/resolvers/MutationResolver.js +13 -2
- package/dist/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/src/resolvers/ReadHelpers.js +3 -3
- package/dist/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/src/resolvers/ReadResolver.js +2 -2
- package/dist/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/src/schema/EnumsProvider.d.ts.map +1 -1
- package/dist/src/schema/EnumsProvider.js +1 -2
- package/dist/src/schema/EnumsProvider.js.map +1 -1
- package/dist/src/schema/FieldAccessVisitor.d.ts +2 -2
- package/dist/src/schema/FieldAccessVisitor.d.ts.map +1 -1
- package/dist/src/schema/FieldAccessVisitor.js +2 -2
- package/dist/src/schema/FieldAccessVisitor.js.map +1 -1
- package/dist/src/schema/OrderByTypeProvider.d.ts +1 -1
- package/dist/src/schema/OrderByTypeProvider.d.ts.map +1 -1
- package/dist/src/schema/OrderByTypeProvider.js +2 -2
- package/dist/src/schema/OrderByTypeProvider.js.map +1 -1
- package/dist/src/schema/WhereTypeProvider.d.ts +1 -2
- package/dist/src/schema/WhereTypeProvider.d.ts.map +1 -1
- package/dist/src/schema/WhereTypeProvider.js +4 -4
- package/dist/src/schema/WhereTypeProvider.js.map +1 -1
- package/dist/src/schema/entities/FieldArgsVisitor.d.ts +4 -5
- package/dist/src/schema/entities/FieldArgsVisitor.d.ts.map +1 -1
- package/dist/src/schema/entities/FieldArgsVisitor.js +3 -3
- package/dist/src/schema/entities/FieldArgsVisitor.js.map +1 -1
- package/dist/src/schema/entities/FieldTypeVisitor.d.ts +3 -3
- package/dist/src/schema/entities/FieldTypeVisitor.d.ts.map +1 -1
- package/dist/src/schema/entities/FieldTypeVisitor.js +3 -3
- package/dist/src/schema/entities/FieldTypeVisitor.js.map +1 -1
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.d.ts +3 -3
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.js +3 -3
- package/dist/src/schema/mutations/CreateEntityInputFieldVisitor.js.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts +6 -6
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js +6 -6
- package/dist/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts +3 -3
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js +5 -5
- package/dist/src/schema/mutations/CreateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.d.ts +10 -4
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.js +3 -3
- package/dist/src/schema/mutations/UpdateEntityInputFieldVisitor.js.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts +6 -6
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js +6 -6
- package/dist/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.js.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts +2 -2
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.d.ts.map +1 -1
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js +2 -2
- package/dist/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.js.map +1 -1
- package/dist/src/schema/utils.d.ts +1 -1
- package/dist/src/schema/utils.d.ts.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/object.d.ts.map +1 -1
- package/dist/src/utils/object.js +3 -4
- package/dist/src/utils/object.js.map +1 -1
- package/dist/src/utils/uniqueWhereFields.js +3 -3
- package/dist/src/utils/uniqueWhereFields.js.map +1 -1
- package/dist/tests/cases/bugs/bug102.test.js +6 -6
- package/dist/tests/cases/bugs/bug102.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/delete/aclDelete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/additionalDeleteFilter.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/delete/additionalDeleteFilter.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/cascadeDelete.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/delete/cascadeDelete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/deleteById.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/delete/deleteById.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/orphanRemoval.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/delete/orphanRemoval.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/delete/setNullOnDelete.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/delete/setNullOnDelete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.js +51 -4
- package/dist/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js +26 -25
- package/dist/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js +9 -6
- package/dist/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.d.ts +2 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.d.ts.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.js +109 -0
- package/dist/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.js.map +1 -0
- package/dist/tests/cases/integration/graphQlRequests/query/filter/manyHasManyOwnerRelation.test.js +17 -15
- package/dist/tests/cases/integration/graphQlRequests/query/filter/manyHasManyOwnerRelation.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/filter/oneHasManyRelation.test.js +4 -5
- package/dist/tests/cases/integration/graphQlRequests/query/filter/oneHasManyRelation.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.js +9 -13
- package/dist/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/query/unique/oneHasManyUnique.test.js +5 -3
- package/dist/tests/cases/integration/graphQlRequests/query/unique/oneHasManyUnique.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/delete.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/delete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/delete.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/delete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/delete.test.js +10 -10
- package/dist/tests/cases/integration/graphQlRequests/update/manyHasOne/delete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/combination.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/combination.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/delete.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasMany/delete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/delete.test.js +5 -5
- package/dist/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/delete.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js +4 -4
- package/dist/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.js.map +1 -1
- package/dist/tests/cases/integration/graphQlSchema/model.js.map +1 -1
- package/dist/tests/cases/unit/conditionOptimizer.test.js +5 -0
- package/dist/tests/cases/unit/conditionOptimizer.test.js.map +1 -1
- package/dist/tests/cases/unit/permissionMerger.test.js +2 -0
- package/dist/tests/cases/unit/permissionMerger.test.js.map +1 -1
- package/dist/tests/cases/unit/predicatesFactory.test.js +7 -1
- package/dist/tests/cases/unit/predicatesFactory.test.js.map +1 -1
- package/dist/tests/cases/unit/predicatesInjector.test.js +105 -0
- package/dist/tests/cases/unit/predicatesInjector.test.js.map +1 -1
- package/dist/tests/cases/unit/whereBuilder.test.d.ts +2 -0
- package/dist/tests/cases/unit/whereBuilder.test.d.ts.map +1 -0
- package/dist/tests/cases/unit/whereBuilder.test.js +131 -0
- package/dist/tests/cases/unit/whereBuilder.test.js.map +1 -0
- package/dist/tests/cases/unit/whereOptimizer.test.js +187 -0
- package/dist/tests/cases/unit/whereOptimizer.test.js.map +1 -1
- package/dist/tests/src/test.js +2 -2
- package/dist/tests/src/test.js.map +1 -1
- package/dist/tests/src/testGraphql.d.ts.map +1 -1
- package/dist/tests/src/testGraphql.js +9 -5
- package/dist/tests/src/testGraphql.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -11
- package/src/acl/EvaluatedPredicateReplacer.ts +9 -15
- package/src/acl/PermissionFactory.ts +18 -13
- package/src/acl/PredicateFactory.ts +64 -40
- package/src/acl/PredicatesInjector.ts +18 -17
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneReducerExecutionHandler.ts +21 -28
- package/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.ts +1 -6
- package/src/extensions/paginatedHasMany/PaginatedHasManyCountVisitor.ts +10 -28
- package/src/extensions/paginatedHasMany/PaginatedHasManyExecutionHandler.ts +11 -8
- package/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.ts +4 -22
- package/src/extensions/paginatedHasMany/PaginatedHasManyNodesVisitor.ts +10 -29
- package/src/input-validation/ColumnValueResolver.ts +2 -3
- package/src/input-validation/EntityRulesResolver.ts +4 -4
- package/src/input-validation/QueryAstFactory.ts +1 -1
- package/src/input-validation/ValidationDataSelector.ts +1 -1
- package/src/input-validation/preValidation/CreateInputPreValidationProcessor.ts +7 -8
- package/src/input-validation/preValidation/InputPreValidator.ts +4 -4
- package/src/input-validation/preValidation/UpdateInputPreValidationProcessor.ts +7 -8
- package/src/inputProcessing/CreateInputProcessor.ts +8 -9
- package/src/inputProcessing/CreateInputVisitor.ts +27 -89
- package/src/inputProcessing/UpdateInputProcessor.ts +8 -9
- package/src/inputProcessing/UpdateInputVisitor.ts +25 -71
- package/src/inputProcessing/index.ts +0 -1
- package/src/introspection/IntrospectionSchemaFactory.ts +7 -7
- package/src/mapper/ErrorUtils.ts +2 -2
- package/src/mapper/JunctionTableManager.ts +3 -3
- package/src/mapper/Mapper.ts +34 -31
- package/src/mapper/MapperContainer.ts +7 -5
- package/src/mapper/Result.ts +2 -4
- package/src/mapper/delete/DeleteExecutor.ts +6 -6
- package/src/mapper/insert/InsertBuilder.ts +2 -2
- package/src/mapper/insert/SqlCreateInputProcessor.ts +3 -3
- package/src/mapper/select/JoinVisitor.ts +6 -33
- package/src/mapper/select/Path.ts +4 -1
- package/src/mapper/select/RelationFetcher.ts +49 -50
- package/src/mapper/select/SelectBuilder.ts +71 -13
- package/src/mapper/select/SelectBuilderFactory.ts +2 -1
- package/src/mapper/select/SelectExecutionHandler.ts +16 -8
- package/src/mapper/select/SelectHydrator.ts +15 -11
- package/src/mapper/select/WhereBuilder.ts +168 -61
- package/src/mapper/select/handlers/FieldsVisitor.ts +80 -111
- package/src/mapper/select/handlers/FieldsVisitorFactory.ts +1 -0
- package/src/mapper/select/handlers/MetaHandler.ts +6 -17
- package/src/mapper/select/optimizer/ConditionOptimizer.ts +6 -0
- package/src/mapper/select/optimizer/WhereOptimizer.ts +148 -21
- package/src/mapper/select/optimizer/WhereReplacer.ts +39 -0
- package/src/mapper/select/optimizer/helpers.ts +7 -3
- package/src/mapper/update/SqlUpdateInputProcessor.ts +4 -10
- package/src/mapper/update/UpdateBuilder.ts +3 -3
- package/src/resolvers/ExecutionContainerFactory.ts +1 -1
- package/src/resolvers/GraphQlQueryAstFactory.ts +5 -4
- package/src/resolvers/MutationResolver.ts +14 -4
- package/src/resolvers/ReadHelpers.ts +3 -3
- package/src/resolvers/ReadResolver.ts +2 -2
- package/src/schema/EnumsProvider.ts +2 -4
- package/src/schema/FieldAccessVisitor.ts +2 -2
- package/src/schema/OrderByTypeProvider.ts +10 -3
- package/src/schema/WhereTypeProvider.ts +5 -6
- package/src/schema/entities/FieldArgsVisitor.ts +4 -5
- package/src/schema/entities/FieldTypeVisitor.ts +3 -3
- package/src/schema/mutations/CreateEntityInputFieldVisitor.ts +3 -6
- package/src/schema/mutations/CreateEntityRelationAllowedOperationsVisitor.ts +6 -20
- package/src/schema/mutations/CreateEntityRelationInputFieldVisitor.ts +6 -20
- package/src/schema/mutations/UpdateEntityInputFieldVisitor.ts +3 -6
- package/src/schema/mutations/UpdateEntityRelationAllowedOperationsVisitor.ts +6 -20
- package/src/schema/mutations/UpdateEntityRelationInputFieldVisitor.ts +9 -14
- package/src/schema/utils.ts +1 -1
- package/src/tsconfig.json +6 -6
- package/src/utils/object.ts +6 -6
- package/src/utils/uniqueWhereFields.ts +3 -3
- package/tests/cases/bugs/bug102.test.ts +6 -6
- package/tests/cases/integration/graphQlRequests/delete/aclDelete.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/delete/additionalDeleteFilter.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/delete/cascadeDelete.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/delete/deleteById.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/delete/orphanRemoval.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/delete/setNullOnDelete.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/query/acl/differentRowAndFieldPredicate.test.ts +54 -4
- package/tests/cases/integration/graphQlRequests/query/acl/fieldRestrictedByLocale.test.ts +26 -25
- package/tests/cases/integration/graphQlRequests/query/acl/nestedPredicate.test.ts +9 -6
- package/tests/cases/integration/graphQlRequests/query/acl/rowPredicateSubset.test.ts +104 -0
- package/tests/cases/integration/graphQlRequests/query/filter/manyHasManyOwnerRelation.test.ts +17 -15
- package/tests/cases/integration/graphQlRequests/query/filter/oneHasManyRelation.test.ts +4 -5
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +9 -13
- package/tests/cases/integration/graphQlRequests/query/unique/oneHasManyUnique.test.ts +5 -3
- package/tests/cases/integration/graphQlRequests/update/manyHasManyInverse/delete.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/update/manyHasManyOwning/delete.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/update/manyHasOne/delete.test.ts +10 -10
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/combination.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/update/oneHasMany/delete.test.ts +5 -5
- package/tests/cases/integration/graphQlRequests/update/oneHasOneInverse/delete.test.ts +5 -5
- package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +2 -3
- package/tests/cases/unit/conditionOptimizer.test.ts +6 -0
- package/tests/cases/unit/permissionMerger.test.ts +2 -0
- package/tests/cases/unit/predicatesFactory.test.ts +8 -2
- package/tests/cases/unit/predicatesInjector.test.ts +97 -2
- package/tests/cases/unit/whereBuilder.test.ts +148 -0
- package/tests/cases/unit/whereOptimizer.test.ts +215 -0
- package/tests/src/test.ts +2 -2
- package/tests/src/testGraphql.ts +9 -5
- package/dist/src/inputProcessing/InputContext.d.ts +0 -43
- package/dist/src/inputProcessing/InputContext.d.ts.map +0 -1
- package/dist/src/inputProcessing/InputContext.js +0 -3
- package/dist/src/inputProcessing/InputContext.js.map +0 -1
- package/src/inputProcessing/InputContext.ts +0 -49
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { isIt } from '../../utils'
|
|
2
|
-
import { acceptFieldVisitor } from '@contember/schema-utils'
|
|
2
|
+
import { acceptFieldVisitor, isColumn } from '@contember/schema-utils'
|
|
3
3
|
import { Input, Model } from '@contember/schema'
|
|
4
4
|
import { Path, PathFactory } from './Path'
|
|
5
5
|
import { JoinBuilder } from './JoinBuilder'
|
|
6
6
|
import { ConditionBuilder } from './ConditionBuilder'
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
ConditionBuilder as SqlConditionBuilder,
|
|
9
|
+
Literal,
|
|
10
|
+
Operator,
|
|
11
|
+
QueryBuilder,
|
|
12
|
+
SelectBuilder, wrapIdentifier,
|
|
13
|
+
} from '@contember/database'
|
|
14
|
+
import { WhereOptimizationHints, WhereOptimizer } from './optimizer/WhereOptimizer'
|
|
9
15
|
|
|
10
16
|
export class WhereBuilder {
|
|
11
17
|
constructor(
|
|
@@ -14,6 +20,7 @@ export class WhereBuilder {
|
|
|
14
20
|
private readonly conditionBuilder: ConditionBuilder,
|
|
15
21
|
private readonly pathFactory: PathFactory,
|
|
16
22
|
private readonly whereOptimizer: WhereOptimizer,
|
|
23
|
+
private readonly useExistsInHasManyFilter: boolean,
|
|
17
24
|
) {}
|
|
18
25
|
|
|
19
26
|
public build(
|
|
@@ -21,35 +28,62 @@ export class WhereBuilder {
|
|
|
21
28
|
entity: Model.Entity,
|
|
22
29
|
path: Path,
|
|
23
30
|
where: Input.OptionalWhere,
|
|
24
|
-
|
|
31
|
+
optimizationHints: WhereOptimizationHints = {},
|
|
25
32
|
) {
|
|
26
|
-
|
|
33
|
+
const optimizedWhere = this.whereOptimizer.optimize(where, entity, optimizationHints)
|
|
34
|
+
return this.buildInternal({
|
|
35
|
+
entity,
|
|
36
|
+
path,
|
|
37
|
+
where: optimizedWhere,
|
|
38
|
+
callback: cb => qb.where(clause => cb(clause)),
|
|
39
|
+
allowManyJoin: false,
|
|
40
|
+
})
|
|
27
41
|
}
|
|
28
42
|
|
|
43
|
+
|
|
29
44
|
public buildAdvanced(
|
|
30
45
|
entity: Model.Entity,
|
|
31
46
|
path: Path,
|
|
32
47
|
where: Input.OptionalWhere,
|
|
33
48
|
callback: (clauseCb: (clause: SqlConditionBuilder) => SqlConditionBuilder) => SelectBuilder<SelectBuilder.Result>,
|
|
34
|
-
|
|
49
|
+
optimizationHints: WhereOptimizationHints = {},
|
|
50
|
+
) {
|
|
51
|
+
const optimizedWhere = this.whereOptimizer.optimize(where, entity, optimizationHints)
|
|
52
|
+
return this.buildInternal({
|
|
53
|
+
entity,
|
|
54
|
+
path,
|
|
55
|
+
where: optimizedWhere,
|
|
56
|
+
callback,
|
|
57
|
+
allowManyJoin: false,
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private buildInternal({
|
|
62
|
+
callback,
|
|
63
|
+
...args
|
|
64
|
+
}: { entity: Model.Entity; path: Path; where: Input.OptionalWhere; callback: (clauseCb: (clause: SqlConditionBuilder) => SqlConditionBuilder) => SelectBuilder<SelectBuilder.Result>; allowManyJoin: boolean },
|
|
35
65
|
) {
|
|
36
|
-
const optimizedWhere = this.whereOptimizer.optimize(where, entity)
|
|
37
66
|
const joinList: WhereJoinDefinition[] = []
|
|
38
67
|
|
|
39
|
-
const qbWithWhere = callback(clause => this.
|
|
68
|
+
const qbWithWhere = callback(clause => this.buildRecursive({
|
|
69
|
+
conditionBuilder: clause,
|
|
70
|
+
joinList: joinList,
|
|
71
|
+
...args,
|
|
72
|
+
}))
|
|
40
73
|
return joinList.reduce<SelectBuilder<SelectBuilder.Result>>(
|
|
41
74
|
(qb, { path, entity, relationName }) => this.joinBuilder.join(qb, path, entity, relationName),
|
|
42
75
|
qbWithWhere,
|
|
43
76
|
)
|
|
44
77
|
}
|
|
45
78
|
|
|
46
|
-
private
|
|
47
|
-
conditionBuilder
|
|
48
|
-
entity
|
|
49
|
-
path
|
|
50
|
-
where
|
|
51
|
-
|
|
52
|
-
|
|
79
|
+
private buildRecursive({
|
|
80
|
+
conditionBuilder,
|
|
81
|
+
entity,
|
|
82
|
+
path,
|
|
83
|
+
where,
|
|
84
|
+
joinList,
|
|
85
|
+
allowManyJoin,
|
|
86
|
+
}: { conditionBuilder: SqlConditionBuilder; entity: Model.Entity; path: Path; where: Input.OptionalWhere; joinList: WhereJoinDefinition[]; allowManyJoin: boolean },
|
|
53
87
|
): SqlConditionBuilder {
|
|
54
88
|
const tableName = path.alias
|
|
55
89
|
|
|
@@ -58,7 +92,14 @@ export class WhereBuilder {
|
|
|
58
92
|
conditionBuilder = conditionBuilder.and(clause =>
|
|
59
93
|
expr.reduce(
|
|
60
94
|
(clause2, where) =>
|
|
61
|
-
!where ? clause2 : this.
|
|
95
|
+
!where ? clause2 : this.buildRecursive({
|
|
96
|
+
conditionBuilder: clause2,
|
|
97
|
+
entity,
|
|
98
|
+
path,
|
|
99
|
+
where,
|
|
100
|
+
joinList,
|
|
101
|
+
allowManyJoin,
|
|
102
|
+
}),
|
|
62
103
|
clause,
|
|
63
104
|
),
|
|
64
105
|
)
|
|
@@ -70,7 +111,14 @@ export class WhereBuilder {
|
|
|
70
111
|
(clause2, where) =>
|
|
71
112
|
!where
|
|
72
113
|
? clause2
|
|
73
|
-
: clause2.and(clause3 => this.
|
|
114
|
+
: clause2.and(clause3 => this.buildRecursive({
|
|
115
|
+
conditionBuilder: clause3,
|
|
116
|
+
entity,
|
|
117
|
+
path,
|
|
118
|
+
where,
|
|
119
|
+
joinList,
|
|
120
|
+
allowManyJoin,
|
|
121
|
+
})),
|
|
74
122
|
clause,
|
|
75
123
|
),
|
|
76
124
|
)
|
|
@@ -78,7 +126,14 @@ export class WhereBuilder {
|
|
|
78
126
|
if (where.not !== undefined) {
|
|
79
127
|
const expr = where.not
|
|
80
128
|
conditionBuilder = conditionBuilder.not(clause =>
|
|
81
|
-
this.
|
|
129
|
+
this.buildRecursive({
|
|
130
|
+
conditionBuilder: clause,
|
|
131
|
+
entity,
|
|
132
|
+
path,
|
|
133
|
+
where: expr,
|
|
134
|
+
joinList,
|
|
135
|
+
allowManyJoin,
|
|
136
|
+
}),
|
|
82
137
|
)
|
|
83
138
|
}
|
|
84
139
|
|
|
@@ -87,12 +142,9 @@ export class WhereBuilder {
|
|
|
87
142
|
continue
|
|
88
143
|
}
|
|
89
144
|
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
targetEntity: Model.Entity,
|
|
94
|
-
): SqlConditionBuilder => {
|
|
95
|
-
const targetPath = path.for(fieldName)
|
|
145
|
+
const targetPath = path.for(fieldName)
|
|
146
|
+
|
|
147
|
+
const joinedWhere = ({ targetEntity, relation, entity }: Model.AnyRelationContext): SqlConditionBuilder => {
|
|
96
148
|
const relationWhere = where[fieldName] as Input.Where
|
|
97
149
|
if (Object.keys(relationWhere).length === 0) {
|
|
98
150
|
return conditionBuilder
|
|
@@ -112,36 +164,45 @@ export class WhereBuilder {
|
|
|
112
164
|
|
|
113
165
|
joinList.push({ path: targetPath, entity, relationName: relation.name })
|
|
114
166
|
|
|
115
|
-
return this.
|
|
167
|
+
return this.buildRecursive({
|
|
168
|
+
conditionBuilder,
|
|
169
|
+
entity: targetEntity,
|
|
170
|
+
path: targetPath,
|
|
171
|
+
where: relationWhere,
|
|
172
|
+
joinList,
|
|
173
|
+
allowManyJoin,
|
|
174
|
+
})
|
|
116
175
|
}
|
|
117
176
|
|
|
118
177
|
conditionBuilder = acceptFieldVisitor<SqlConditionBuilder>(this.schema, entity, fieldName, {
|
|
119
|
-
visitColumn: (entity, column) => {
|
|
178
|
+
visitColumn: ({ entity, column }) => {
|
|
120
179
|
const subWhere: Input.Condition<Input.ColumnValue> = where[column.name] as Input.Condition<Input.ColumnValue>
|
|
121
180
|
return this.conditionBuilder.build(conditionBuilder, tableName, column.columnName, column.columnType, subWhere)
|
|
122
181
|
},
|
|
123
182
|
visitOneHasOneInverse: joinedWhere,
|
|
124
183
|
visitOneHasOneOwning: joinedWhere,
|
|
125
184
|
visitManyHasOne: joinedWhere,
|
|
126
|
-
visitManyHasManyInverse:
|
|
127
|
-
if (allowManyJoin) {
|
|
128
|
-
return joinedWhere(
|
|
185
|
+
visitManyHasManyInverse: context => {
|
|
186
|
+
if (allowManyJoin && !this.useExistsInHasManyFilter) {
|
|
187
|
+
return joinedWhere(context)
|
|
129
188
|
}
|
|
189
|
+
|
|
130
190
|
const relationWhere = where[fieldName] as Input.Where
|
|
131
191
|
|
|
132
192
|
return conditionBuilder.exists(
|
|
133
193
|
this.createManyHasManySubquery(
|
|
134
194
|
[tableName, entity.primaryColumn],
|
|
135
195
|
relationWhere,
|
|
136
|
-
targetEntity,
|
|
137
|
-
targetRelation.joiningTable,
|
|
196
|
+
context.targetEntity,
|
|
197
|
+
context.targetRelation.joiningTable,
|
|
138
198
|
'inverse',
|
|
199
|
+
targetPath,
|
|
139
200
|
),
|
|
140
201
|
)
|
|
141
202
|
},
|
|
142
|
-
visitManyHasManyOwning:
|
|
143
|
-
if (allowManyJoin) {
|
|
144
|
-
return joinedWhere(
|
|
203
|
+
visitManyHasManyOwning: context => {
|
|
204
|
+
if (allowManyJoin && !this.useExistsInHasManyFilter) {
|
|
205
|
+
return joinedWhere(context)
|
|
145
206
|
}
|
|
146
207
|
|
|
147
208
|
const relationWhere = where[fieldName] as Input.Where
|
|
@@ -150,30 +211,40 @@ export class WhereBuilder {
|
|
|
150
211
|
this.createManyHasManySubquery(
|
|
151
212
|
[tableName, entity.primaryColumn],
|
|
152
213
|
relationWhere,
|
|
153
|
-
targetEntity,
|
|
154
|
-
relation.joiningTable,
|
|
214
|
+
context.targetEntity,
|
|
215
|
+
context.relation.joiningTable,
|
|
155
216
|
'owning',
|
|
217
|
+
targetPath,
|
|
156
218
|
),
|
|
157
219
|
)
|
|
158
220
|
},
|
|
159
|
-
visitOneHasMany:
|
|
160
|
-
if (allowManyJoin) {
|
|
161
|
-
return joinedWhere(
|
|
221
|
+
visitOneHasMany: context => {
|
|
222
|
+
if (allowManyJoin && !this.useExistsInHasManyFilter) {
|
|
223
|
+
return joinedWhere(context)
|
|
162
224
|
}
|
|
163
225
|
|
|
164
226
|
const relationWhere = where[fieldName] as Input.Where
|
|
165
227
|
|
|
228
|
+
const qb = this.hasRootIsNull(relationWhere, context.targetEntity)
|
|
229
|
+
? SelectBuilder.create()
|
|
230
|
+
.select(it => it.raw('1'))
|
|
231
|
+
.from(new Literal(`(select ${wrapIdentifier(tableName)}.${wrapIdentifier(entity.primaryColumn)})`), targetPath.for('tmp_').alias)
|
|
232
|
+
.leftJoin(context.targetEntity.tableName, targetPath.alias, it =>
|
|
233
|
+
it.columnsEq([targetPath.for('tmp_').alias, entity.primaryColumn], [targetPath.alias, context.targetRelation.joiningColumn.columnName]),
|
|
234
|
+
)
|
|
235
|
+
: SelectBuilder.create()
|
|
236
|
+
.select(it => it.raw('1'))
|
|
237
|
+
.from(context.targetEntity.tableName, targetPath.alias)
|
|
238
|
+
.where(it => it.columnsEq([tableName, entity.primaryColumn], [targetPath.alias, context.targetRelation.joiningColumn.columnName]))
|
|
239
|
+
|
|
166
240
|
return conditionBuilder.exists(
|
|
167
|
-
this.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
relationWhere,
|
|
175
|
-
true,
|
|
176
|
-
),
|
|
241
|
+
this.buildInternal({
|
|
242
|
+
entity: context.targetEntity,
|
|
243
|
+
path: targetPath,
|
|
244
|
+
where: relationWhere,
|
|
245
|
+
callback: cb => qb.where(clause => cb(clause)),
|
|
246
|
+
allowManyJoin: true,
|
|
247
|
+
}),
|
|
177
248
|
)
|
|
178
249
|
},
|
|
179
250
|
})
|
|
@@ -181,19 +252,22 @@ export class WhereBuilder {
|
|
|
181
252
|
return conditionBuilder
|
|
182
253
|
}
|
|
183
254
|
|
|
255
|
+
|
|
184
256
|
private createManyHasManySubquery(
|
|
185
257
|
outerColumn: QueryBuilder.ColumnIdentifier,
|
|
186
258
|
relationWhere: Input.Where,
|
|
187
259
|
targetEntity: Model.Entity,
|
|
188
260
|
joiningTable: Model.JoiningTable,
|
|
189
261
|
fromSide: 'owning' | 'inverse',
|
|
262
|
+
path: Path,
|
|
190
263
|
) {
|
|
191
264
|
const fromColumn = fromSide === 'owning' ? joiningTable.joiningColumn.columnName : joiningTable.inverseJoiningColumn.columnName
|
|
192
265
|
const toColumn = fromSide === 'owning' ? joiningTable.inverseJoiningColumn.columnName : joiningTable.joiningColumn.columnName
|
|
266
|
+
const junctionPath = path.for('junction_')
|
|
193
267
|
const qb = SelectBuilder.create<SelectBuilder.Result>()
|
|
194
|
-
.from(joiningTable.tableName,
|
|
268
|
+
.from(joiningTable.tableName, junctionPath.alias)
|
|
195
269
|
.select(it => it.raw('1'))
|
|
196
|
-
.where(it => it.columnsEq(outerColumn, [
|
|
270
|
+
.where(it => it.columnsEq(outerColumn, [junctionPath.alias, fromColumn]))
|
|
197
271
|
|
|
198
272
|
const primaryCondition = this.transformWhereToPrimaryCondition(relationWhere, targetEntity.primary)
|
|
199
273
|
if (primaryCondition !== null) {
|
|
@@ -201,20 +275,20 @@ export class WhereBuilder {
|
|
|
201
275
|
const columnType = (targetEntity.fields[targetEntity.primary] as Model.AnyColumn).columnType
|
|
202
276
|
|
|
203
277
|
return qb.where(condition =>
|
|
204
|
-
this.conditionBuilder.build(condition,
|
|
278
|
+
this.conditionBuilder.build(condition, junctionPath.alias, toColumn, columnType, primaryCondition),
|
|
205
279
|
)
|
|
206
280
|
}
|
|
207
281
|
|
|
208
|
-
const qbJoined = qb.join(targetEntity.tableName,
|
|
209
|
-
clause.compareColumns([
|
|
210
|
-
)
|
|
211
|
-
return this.buildAdvanced(
|
|
212
|
-
targetEntity,
|
|
213
|
-
this.pathFactory.create([], 'sub_'),
|
|
214
|
-
relationWhere,
|
|
215
|
-
cb => qbJoined.where(clause => cb(clause)),
|
|
216
|
-
true,
|
|
282
|
+
const qbJoined = qb.join(targetEntity.tableName, path.alias, clause =>
|
|
283
|
+
clause.compareColumns([junctionPath.alias, toColumn], Operator.eq, [path.alias, targetEntity.primary]),
|
|
217
284
|
)
|
|
285
|
+
return this.buildInternal({
|
|
286
|
+
entity: targetEntity,
|
|
287
|
+
path: this.pathFactory.create([], path.fullAlias),
|
|
288
|
+
where: relationWhere,
|
|
289
|
+
callback: cb => qbJoined.where(clause => cb(clause)),
|
|
290
|
+
allowManyJoin: true,
|
|
291
|
+
})
|
|
218
292
|
}
|
|
219
293
|
|
|
220
294
|
private transformWhereToPrimaryCondition(where: Input.Where, primaryField: string): Input.Condition<never> | null {
|
|
@@ -260,6 +334,39 @@ export class WhereBuilder {
|
|
|
260
334
|
}
|
|
261
335
|
return condition
|
|
262
336
|
}
|
|
337
|
+
|
|
338
|
+
private hasRootIsNull(where: Input.Where, entity: Model.Entity): boolean {
|
|
339
|
+
for (const key in where) {
|
|
340
|
+
if (key === 'and' || key === 'or') {
|
|
341
|
+
if (where[key]?.some(it => this.hasRootIsNull(it, entity))) {
|
|
342
|
+
return true
|
|
343
|
+
}
|
|
344
|
+
} else if (key === 'not') {
|
|
345
|
+
if (where.not && this.hasRootIsNull(where.not, entity)) {
|
|
346
|
+
return true
|
|
347
|
+
}
|
|
348
|
+
} else if (isColumn(entity.fields[key]) && this.conditionHasIsNull(where[key] as Input.Condition)) {
|
|
349
|
+
return true
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return false
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
private conditionHasIsNull(cond: Input.Condition): boolean {
|
|
356
|
+
if (cond.isNull !== undefined) {
|
|
357
|
+
return true
|
|
358
|
+
}
|
|
359
|
+
if (cond.and && cond.and.some(it => this.conditionHasIsNull(it))) {
|
|
360
|
+
return true
|
|
361
|
+
}
|
|
362
|
+
if (cond.or && cond.or.some(it => this.conditionHasIsNull(it))) {
|
|
363
|
+
return true
|
|
364
|
+
}
|
|
365
|
+
if (cond.not && this.conditionHasIsNull(cond.not)) {
|
|
366
|
+
return true
|
|
367
|
+
}
|
|
368
|
+
return false
|
|
369
|
+
}
|
|
263
370
|
}
|
|
264
371
|
|
|
265
372
|
export type WhereJoinDefinition = { path: Path; entity: Model.Entity; relationName: string }
|
|
@@ -13,132 +13,87 @@ export class FieldsVisitor implements Model.RelationByTypeVisitor<void>, Model.C
|
|
|
13
13
|
private readonly whereBuilder: WhereBuilder,
|
|
14
14
|
private readonly mapper: Mapper,
|
|
15
15
|
private readonly executionContext: SelectExecutionHandlerContext,
|
|
16
|
+
private readonly relationPath: Model.AnyRelationContext[],
|
|
16
17
|
) {}
|
|
17
18
|
|
|
18
|
-
visitColumn(entity
|
|
19
|
+
visitColumn({ entity, column }: Model.ColumnContext): void {
|
|
19
20
|
const columnPath = this.executionContext.path
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const columnAlias = columnPath.alias
|
|
21
|
+
const tableAlias = columnPath.back().alias
|
|
22
|
+
const columnAlias = columnPath.alias
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
column.name,
|
|
28
|
-
)
|
|
29
|
-
? this.predicateFactory.create(entity, Acl.Operation.read, [column.name])
|
|
30
|
-
: undefined
|
|
31
|
-
|
|
32
|
-
if (!fieldPredicate || Object.keys(fieldPredicate).length === 0) {
|
|
33
|
-
return qb.select([tableAlias, column.columnName], columnAlias)
|
|
34
|
-
}
|
|
35
|
-
return this.whereBuilder.buildAdvanced(entity, columnPath.back(), fieldPredicate, cb =>
|
|
36
|
-
qb.select(
|
|
37
|
-
expr =>
|
|
38
|
-
expr.case(caseExpr =>
|
|
39
|
-
caseExpr
|
|
40
|
-
.when(
|
|
41
|
-
whenExpr => whenExpr.selectCondition(cb),
|
|
42
|
-
thenExpr => thenExpr.select([tableAlias, column.columnName]),
|
|
43
|
-
)
|
|
44
|
-
.else(elseExpr => elseExpr.raw('null')),
|
|
45
|
-
),
|
|
46
|
-
columnAlias,
|
|
47
|
-
),
|
|
48
|
-
)
|
|
24
|
+
this.executionContext.addColumn({
|
|
25
|
+
query: qb => qb.select([tableAlias, column.columnName], columnAlias),
|
|
26
|
+
predicate: this.getRequiredPredicate(entity, column),
|
|
49
27
|
})
|
|
50
28
|
}
|
|
51
29
|
|
|
52
|
-
public visitManyHasManyInverse(
|
|
53
|
-
entity: Model.Entity,
|
|
54
|
-
relation: Model.ManyHasManyInverseRelation,
|
|
55
|
-
targetEntity: Model.Entity,
|
|
56
|
-
targetRelation: Model.ManyHasManyOwningRelation,
|
|
57
|
-
): void {
|
|
30
|
+
public visitManyHasManyInverse(relationContext: Model.ManyHasManyInverseContext): void {
|
|
58
31
|
const field = this.executionContext.objectNode
|
|
59
32
|
if (!field) {
|
|
60
33
|
throw new Error()
|
|
61
34
|
}
|
|
62
|
-
this.executionContext.addData(
|
|
63
|
-
entity.primary,
|
|
64
|
-
async ids =>
|
|
65
|
-
this.relationFetcher.fetchManyHasManyGroups(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
),
|
|
76
|
-
[],
|
|
77
|
-
)
|
|
35
|
+
this.executionContext.addData({
|
|
36
|
+
field: relationContext.entity.primary,
|
|
37
|
+
dataProvider: async ids =>
|
|
38
|
+
this.relationFetcher.fetchManyHasManyGroups({
|
|
39
|
+
mapper: this.mapper,
|
|
40
|
+
field: field,
|
|
41
|
+
relationContext,
|
|
42
|
+
relationPath: this.relationPath,
|
|
43
|
+
ids: ids,
|
|
44
|
+
}),
|
|
45
|
+
defaultValue: [],
|
|
46
|
+
predicate: this.getRequiredPredicate(relationContext.entity, relationContext.relation),
|
|
47
|
+
})
|
|
78
48
|
}
|
|
79
49
|
|
|
80
|
-
public visitManyHasManyOwning(
|
|
81
|
-
entity: Model.Entity,
|
|
82
|
-
relation: Model.ManyHasManyOwningRelation,
|
|
83
|
-
targetEntity: Model.Entity,
|
|
84
|
-
targetRelation: Model.ManyHasManyInverseRelation | null,
|
|
85
|
-
): void {
|
|
50
|
+
public visitManyHasManyOwning(relationContext: Model.ManyHasManyOwningContext): void {
|
|
86
51
|
const field = this.executionContext.objectNode
|
|
87
52
|
if (!field) {
|
|
88
53
|
throw new Error()
|
|
89
54
|
}
|
|
90
55
|
|
|
91
|
-
this.executionContext.addData(
|
|
92
|
-
entity.primary,
|
|
93
|
-
async ids =>
|
|
56
|
+
this.executionContext.addData({
|
|
57
|
+
field: relationContext.entity.primary,
|
|
58
|
+
dataProvider: async ids =>
|
|
94
59
|
this.relationFetcher.fetchManyHasManyGroups({
|
|
95
60
|
mapper: this.mapper,
|
|
96
61
|
field: field,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
targetRelation,
|
|
100
|
-
directionFrom: 'owning',
|
|
62
|
+
relationContext,
|
|
63
|
+
relationPath: this.relationPath,
|
|
101
64
|
ids: ids,
|
|
102
65
|
}),
|
|
103
|
-
[],
|
|
104
|
-
|
|
66
|
+
defaultValue: [],
|
|
67
|
+
predicate: this.getRequiredPredicate(relationContext.entity, relationContext.relation),
|
|
68
|
+
})
|
|
105
69
|
}
|
|
106
70
|
|
|
107
|
-
public visitOneHasMany(
|
|
108
|
-
entity: Model.Entity,
|
|
109
|
-
relation: Model.OneHasManyRelation,
|
|
110
|
-
targetEntity: Model.Entity,
|
|
111
|
-
targetRelation: Model.ManyHasOneRelation,
|
|
112
|
-
): void {
|
|
71
|
+
public visitOneHasMany(relationContext: Model.OneHasManyContext): void {
|
|
113
72
|
const field = this.executionContext.objectNode
|
|
114
73
|
if (!field) {
|
|
115
74
|
throw new Error()
|
|
116
75
|
}
|
|
117
76
|
|
|
118
|
-
this.executionContext.addData(
|
|
119
|
-
entity.primary,
|
|
120
|
-
async ids =>
|
|
77
|
+
this.executionContext.addData({
|
|
78
|
+
field: relationContext.entity.primary,
|
|
79
|
+
dataProvider: async ids =>
|
|
121
80
|
this.relationFetcher.fetchOneHasManyGroups({
|
|
122
81
|
mapper: this.mapper,
|
|
123
82
|
objectNode: field,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
targetRelation: targetRelation,
|
|
83
|
+
relationContext,
|
|
84
|
+
relationPath: this.relationPath,
|
|
127
85
|
ids: ids,
|
|
128
86
|
}),
|
|
129
|
-
[],
|
|
130
|
-
|
|
87
|
+
defaultValue: [],
|
|
88
|
+
predicate: this.getRequiredPredicate(relationContext.entity, relationContext.relation),
|
|
89
|
+
})
|
|
131
90
|
}
|
|
132
91
|
|
|
133
|
-
public visitOneHasOneInverse(
|
|
134
|
-
entity
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
): void {
|
|
139
|
-
this.executionContext.addData(
|
|
140
|
-
entity.primary,
|
|
141
|
-
async ids => {
|
|
92
|
+
public visitOneHasOneInverse(relationContext: Model.OneHasOneInverseContext): void {
|
|
93
|
+
const { entity, targetRelation, targetEntity } = relationContext
|
|
94
|
+
this.executionContext.addData({
|
|
95
|
+
field: entity.primary,
|
|
96
|
+
dataProvider: async ids => {
|
|
142
97
|
const idsWhere: Input.Where = {
|
|
143
98
|
[targetRelation.name]: {
|
|
144
99
|
[entity.primary]: {
|
|
@@ -155,21 +110,21 @@ export class FieldsVisitor implements Model.RelationByTypeVisitor<void>, Model.C
|
|
|
155
110
|
}
|
|
156
111
|
const objectWithWhere = field.withArg('filter', where)
|
|
157
112
|
|
|
158
|
-
return this.mapper.
|
|
113
|
+
return this.mapper.selectAssoc(targetEntity, objectWithWhere, [
|
|
114
|
+
...this.relationPath,
|
|
115
|
+
relationContext,
|
|
116
|
+
], targetRelation.name)
|
|
159
117
|
},
|
|
160
|
-
null,
|
|
161
|
-
|
|
118
|
+
defaultValue: null,
|
|
119
|
+
predicate: this.getRequiredPredicate(relationContext.entity, relationContext.relation),
|
|
120
|
+
})
|
|
162
121
|
}
|
|
163
122
|
|
|
164
|
-
public visitOneHasOneOwning(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
): void {
|
|
170
|
-
this.executionContext.addData(
|
|
171
|
-
relation.name,
|
|
172
|
-
async ids => {
|
|
123
|
+
public visitOneHasOneOwning(relationContext: Model.OneHasOneOwningContext): void {
|
|
124
|
+
const { relation, targetEntity } = relationContext
|
|
125
|
+
this.executionContext.addData({
|
|
126
|
+
field: relation.name,
|
|
127
|
+
dataProvider: async ids => {
|
|
173
128
|
const idsWhere: Input.Where = {
|
|
174
129
|
[targetEntity.primary]: {
|
|
175
130
|
in: ids,
|
|
@@ -184,16 +139,21 @@ export class FieldsVisitor implements Model.RelationByTypeVisitor<void>, Model.C
|
|
|
184
139
|
}
|
|
185
140
|
const objectWithWhere = objectNode.withArg('filter', where)
|
|
186
141
|
|
|
187
|
-
return this.mapper.
|
|
142
|
+
return this.mapper.selectAssoc(targetEntity, objectWithWhere, [
|
|
143
|
+
...this.relationPath,
|
|
144
|
+
relationContext,
|
|
145
|
+
], targetEntity.primary)
|
|
188
146
|
},
|
|
189
|
-
null,
|
|
190
|
-
|
|
147
|
+
defaultValue: null,
|
|
148
|
+
predicate: this.getRequiredPredicate(relationContext.entity, relationContext.relation),
|
|
149
|
+
})
|
|
191
150
|
}
|
|
192
151
|
|
|
193
|
-
public visitManyHasOne(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
152
|
+
public visitManyHasOne(relationContext: Model.ManyHasOneContext): void {
|
|
153
|
+
const { relation, targetEntity } = relationContext
|
|
154
|
+
this.executionContext.addData({
|
|
155
|
+
field: relation.name,
|
|
156
|
+
dataProvider: async ids => {
|
|
197
157
|
const idsWhere: Input.Where = {
|
|
198
158
|
[targetEntity.primary]: {
|
|
199
159
|
in: ids,
|
|
@@ -208,9 +168,18 @@ export class FieldsVisitor implements Model.RelationByTypeVisitor<void>, Model.C
|
|
|
208
168
|
}
|
|
209
169
|
const objectWithWhere = objectNode.withArg('filter', where)
|
|
210
170
|
|
|
211
|
-
return this.mapper.
|
|
171
|
+
return this.mapper.selectAssoc(targetEntity, objectWithWhere, [
|
|
172
|
+
...this.relationPath,
|
|
173
|
+
relationContext,
|
|
174
|
+
], targetEntity.primary)
|
|
212
175
|
},
|
|
213
|
-
null,
|
|
214
|
-
|
|
176
|
+
defaultValue: null,
|
|
177
|
+
predicate: this.getRequiredPredicate(relationContext.entity, relationContext.relation),
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private getRequiredPredicate(entity: Model.Entity, field: Model.AnyField): Acl.Predicate | undefined {
|
|
182
|
+
const fieldPredicate = this.predicateFactory.getFieldPredicate(entity, Acl.Operation.read, field.name)
|
|
183
|
+
return fieldPredicate.isSameAsPrimary ? undefined : fieldPredicate.predicate
|
|
215
184
|
}
|
|
216
185
|
}
|
|
@@ -32,25 +32,14 @@ export class MetaHandler implements SelectExecutionHandler<{}> {
|
|
|
32
32
|
metaPath: Path,
|
|
33
33
|
operation: Acl.Operation.read | Acl.Operation.update,
|
|
34
34
|
): void {
|
|
35
|
-
const { entity
|
|
35
|
+
const { entity } = context
|
|
36
36
|
if (entity.primary === fieldName) {
|
|
37
37
|
return
|
|
38
38
|
}
|
|
39
|
-
const fieldPredicate = this.predicateFactory.
|
|
40
|
-
context.addColumn(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
expr.selectCondition(condition => {
|
|
45
|
-
condition = cb(condition)
|
|
46
|
-
if (condition.isEmpty()) {
|
|
47
|
-
return condition.raw('true')
|
|
48
|
-
}
|
|
49
|
-
return condition
|
|
50
|
-
}),
|
|
51
|
-
metaPath.alias,
|
|
52
|
-
),
|
|
53
|
-
)
|
|
54
|
-
}, metaPath)
|
|
39
|
+
const fieldPredicate = this.predicateFactory.getFieldPredicate(entity, operation, fieldName)
|
|
40
|
+
context.addColumn({
|
|
41
|
+
path: metaPath,
|
|
42
|
+
valueGetter: context.addPredicate(fieldPredicate.predicate),
|
|
43
|
+
})
|
|
55
44
|
}
|
|
56
45
|
}
|
|
@@ -23,6 +23,12 @@ export class ConditionOptimizer {
|
|
|
23
23
|
} else if (key === 'or') {
|
|
24
24
|
return optimizeOr(value.map(it => this.optimize(it)))
|
|
25
25
|
|
|
26
|
+
} else if (key === 'in' && value.length === 0) {
|
|
27
|
+
return false
|
|
28
|
+
|
|
29
|
+
} else if (key === 'notIn' && value.length === 0) {
|
|
30
|
+
return true
|
|
31
|
+
|
|
26
32
|
} else if (key === 'not') {
|
|
27
33
|
return optimizeNot(this.optimize(value))
|
|
28
34
|
|