joist-orm 1.294.0 → 2.0.0
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/build/{drivers/PostgresDriver.d.ts → PostgresDriver.d.ts} +1 -4
- package/build/PostgresDriver.d.ts.map +1 -0
- package/build/{drivers/PostgresDriver.js → PostgresDriver.js} +49 -58
- package/build/PostgresDriver.js.map +1 -0
- package/build/codegen.d.ts +2 -0
- package/build/codegen.d.ts.map +1 -0
- package/build/codegen.js +29 -0
- package/build/codegen.js.map +1 -0
- package/build/graphql-codegen-export.d.ts +2 -0
- package/build/graphql-codegen-export.d.ts.map +1 -0
- package/build/{drivers/index.js → graphql-codegen-export.js} +3 -5
- package/build/graphql-codegen-export.js.map +1 -0
- package/build/graphql-export.d.ts +2 -0
- package/build/graphql-export.d.ts.map +1 -0
- package/build/graphql-export.js +19 -0
- package/build/graphql-export.js.map +1 -0
- package/build/index.d.ts +3 -128
- package/build/index.d.ts.map +1 -1
- package/build/index.js +8 -284
- package/build/index.js.map +1 -1
- package/build/knex-export.d.ts +2 -0
- package/build/knex-export.d.ts.map +1 -0
- package/build/knex-export.js +19 -0
- package/build/knex-export.js.map +1 -0
- package/build/pg-migrate.d.ts +2 -0
- package/build/pg-migrate.d.ts.map +1 -0
- package/build/pg-migrate.js +30 -0
- package/build/pg-migrate.js.map +1 -0
- package/build/postgres-driver.d.ts +2 -0
- package/build/postgres-driver.d.ts.map +1 -0
- package/build/postgres-driver.js +7 -0
- package/build/postgres-driver.js.map +1 -0
- package/build/tests-export.d.ts +2 -0
- package/build/tests-export.d.ts.map +1 -0
- package/build/tests-export.js +19 -0
- package/build/tests-export.js.map +1 -0
- package/package.json +85 -16
- package/build/AliasAssigner.d.ts +0 -7
- package/build/AliasAssigner.d.ts.map +0 -1
- package/build/AliasAssigner.js +0 -30
- package/build/AliasAssigner.js.map +0 -1
- package/build/Aliases.d.ts +0 -110
- package/build/Aliases.d.ts.map +0 -1
- package/build/Aliases.js +0 -456
- package/build/Aliases.js.map +0 -1
- package/build/BaseEntity.d.ts +0 -66
- package/build/BaseEntity.d.ts.map +0 -1
- package/build/BaseEntity.js +0 -120
- package/build/BaseEntity.js.map +0 -1
- package/build/ConditionBuilder.d.ts +0 -50
- package/build/ConditionBuilder.d.ts.map +0 -1
- package/build/ConditionBuilder.js +0 -178
- package/build/ConditionBuilder.js.map +0 -1
- package/build/Entity.d.ts +0 -38
- package/build/Entity.d.ts.map +0 -1
- package/build/Entity.js +0 -8
- package/build/Entity.js.map +0 -1
- package/build/EntityFields.d.ts +0 -37
- package/build/EntityFields.d.ts.map +0 -1
- package/build/EntityFields.js +0 -3
- package/build/EntityFields.js.map +0 -1
- package/build/EntityFilter.d.ts +0 -113
- package/build/EntityFilter.d.ts.map +0 -1
- package/build/EntityFilter.js +0 -3
- package/build/EntityFilter.js.map +0 -1
- package/build/EntityGraphQLFilter.d.ts +0 -51
- package/build/EntityGraphQLFilter.d.ts.map +0 -1
- package/build/EntityGraphQLFilter.js +0 -54
- package/build/EntityGraphQLFilter.js.map +0 -1
- package/build/EntityManager.d.ts +0 -734
- package/build/EntityManager.d.ts.map +0 -1
- package/build/EntityManager.js +0 -2075
- package/build/EntityManager.js.map +0 -1
- package/build/EntityMetadata.d.ts +0 -185
- package/build/EntityMetadata.d.ts.map +0 -1
- package/build/EntityMetadata.js +0 -61
- package/build/EntityMetadata.js.map +0 -1
- package/build/EnumMetadata.d.ts +0 -15
- package/build/EnumMetadata.d.ts.map +0 -1
- package/build/EnumMetadata.js +0 -3
- package/build/EnumMetadata.js.map +0 -1
- package/build/FlushLock.d.ts +0 -26
- package/build/FlushLock.d.ts.map +0 -1
- package/build/FlushLock.js +0 -57
- package/build/FlushLock.js.map +0 -1
- package/build/HintTree.d.ts +0 -42
- package/build/HintTree.d.ts.map +0 -1
- package/build/HintTree.js +0 -64
- package/build/HintTree.js.map +0 -1
- package/build/IndexManager.d.ts +0 -30
- package/build/IndexManager.d.ts.map +0 -1
- package/build/IndexManager.js +0 -206
- package/build/IndexManager.js.map +0 -1
- package/build/InstanceData.d.ts +0 -59
- package/build/InstanceData.d.ts.map +0 -1
- package/build/InstanceData.js +0 -162
- package/build/InstanceData.js.map +0 -1
- package/build/IsLoadedCache.d.ts +0 -32
- package/build/IsLoadedCache.d.ts.map +0 -1
- package/build/IsLoadedCache.js +0 -80
- package/build/IsLoadedCache.js.map +0 -1
- package/build/JoinRows.d.ts +0 -75
- package/build/JoinRows.d.ts.map +0 -1
- package/build/JoinRows.js +0 -246
- package/build/JoinRows.js.map +0 -1
- package/build/PluginManager.d.ts +0 -90
- package/build/PluginManager.d.ts.map +0 -1
- package/build/PluginManager.js +0 -97
- package/build/PluginManager.js.map +0 -1
- package/build/QueryParser.d.ts +0 -271
- package/build/QueryParser.d.ts.map +0 -1
- package/build/QueryParser.js +0 -853
- package/build/QueryParser.js.map +0 -1
- package/build/QueryParser.pruning.d.ts +0 -5
- package/build/QueryParser.pruning.d.ts.map +0 -1
- package/build/QueryParser.pruning.js +0 -118
- package/build/QueryParser.pruning.js.map +0 -1
- package/build/QueryVisitor.d.ts +0 -19
- package/build/QueryVisitor.d.ts.map +0 -1
- package/build/QueryVisitor.js +0 -84
- package/build/QueryVisitor.js.map +0 -1
- package/build/ReactionsManager.d.ts +0 -84
- package/build/ReactionsManager.d.ts.map +0 -1
- package/build/ReactionsManager.js +0 -308
- package/build/ReactionsManager.js.map +0 -1
- package/build/Todo.d.ts +0 -31
- package/build/Todo.d.ts.map +0 -1
- package/build/Todo.js +0 -73
- package/build/Todo.js.map +0 -1
- package/build/caches.d.ts +0 -6
- package/build/caches.d.ts.map +0 -1
- package/build/caches.js +0 -42
- package/build/caches.js.map +0 -1
- package/build/changes.d.ts +0 -79
- package/build/changes.d.ts.map +0 -1
- package/build/changes.js +0 -251
- package/build/changes.js.map +0 -1
- package/build/config.d.ts +0 -237
- package/build/config.d.ts.map +0 -1
- package/build/config.js +0 -298
- package/build/config.js.map +0 -1
- package/build/config.test.d.ts +0 -2
- package/build/config.test.d.ts.map +0 -1
- package/build/config.test.js +0 -53
- package/build/config.test.js.map +0 -1
- package/build/configure.d.ts +0 -13
- package/build/configure.d.ts.map +0 -1
- package/build/configure.js +0 -329
- package/build/configure.js.map +0 -1
- package/build/dataloaders/findByUniqueDataLoader.d.ts +0 -7
- package/build/dataloaders/findByUniqueDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findByUniqueDataLoader.js +0 -47
- package/build/dataloaders/findByUniqueDataLoader.js.map +0 -1
- package/build/dataloaders/findCountDataLoader.d.ts +0 -7
- package/build/dataloaders/findCountDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findCountDataLoader.js +0 -74
- package/build/dataloaders/findCountDataLoader.js.map +0 -1
- package/build/dataloaders/findDataLoader.d.ts +0 -37
- package/build/dataloaders/findDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findDataLoader.js +0 -337
- package/build/dataloaders/findDataLoader.js.map +0 -1
- package/build/dataloaders/findIdsDataLoader.d.ts +0 -7
- package/build/dataloaders/findIdsDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findIdsDataLoader.js +0 -74
- package/build/dataloaders/findIdsDataLoader.js.map +0 -1
- package/build/dataloaders/findOrCreateDataLoader.d.ts +0 -13
- package/build/dataloaders/findOrCreateDataLoader.d.ts.map +0 -1
- package/build/dataloaders/findOrCreateDataLoader.js +0 -174
- package/build/dataloaders/findOrCreateDataLoader.js.map +0 -1
- package/build/dataloaders/lensDataLoader.d.ts +0 -12
- package/build/dataloaders/lensDataLoader.d.ts.map +0 -1
- package/build/dataloaders/lensDataLoader.js +0 -180
- package/build/dataloaders/lensDataLoader.js.map +0 -1
- package/build/dataloaders/loadDataLoader.d.ts +0 -11
- package/build/dataloaders/loadDataLoader.d.ts.map +0 -1
- package/build/dataloaders/loadDataLoader.js +0 -54
- package/build/dataloaders/loadDataLoader.js.map +0 -1
- package/build/dataloaders/manyToManyDataLoader.d.ts +0 -8
- package/build/dataloaders/manyToManyDataLoader.d.ts.map +0 -1
- package/build/dataloaders/manyToManyDataLoader.js +0 -74
- package/build/dataloaders/manyToManyDataLoader.js.map +0 -1
- package/build/dataloaders/manyToManyFindDataLoader.d.ts +0 -8
- package/build/dataloaders/manyToManyFindDataLoader.d.ts.map +0 -1
- package/build/dataloaders/manyToManyFindDataLoader.js +0 -70
- package/build/dataloaders/manyToManyFindDataLoader.js.map +0 -1
- package/build/dataloaders/oneToManyDataLoader.d.ts +0 -7
- package/build/dataloaders/oneToManyDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToManyDataLoader.js +0 -60
- package/build/dataloaders/oneToManyDataLoader.js.map +0 -1
- package/build/dataloaders/oneToManyFindDataLoader.d.ts +0 -8
- package/build/dataloaders/oneToManyFindDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToManyFindDataLoader.js +0 -71
- package/build/dataloaders/oneToManyFindDataLoader.js.map +0 -1
- package/build/dataloaders/oneToOneDataLoader.d.ts +0 -7
- package/build/dataloaders/oneToOneDataLoader.d.ts.map +0 -1
- package/build/dataloaders/oneToOneDataLoader.js +0 -59
- package/build/dataloaders/oneToOneDataLoader.js.map +0 -1
- package/build/dataloaders/populateDataLoader.d.ts +0 -13
- package/build/dataloaders/populateDataLoader.d.ts.map +0 -1
- package/build/dataloaders/populateDataLoader.js +0 -148
- package/build/dataloaders/populateDataLoader.js.map +0 -1
- package/build/dataloaders/recursiveChildrenDataLoader.d.ts +0 -7
- package/build/dataloaders/recursiveChildrenDataLoader.d.ts.map +0 -1
- package/build/dataloaders/recursiveChildrenDataLoader.js +0 -77
- package/build/dataloaders/recursiveChildrenDataLoader.js.map +0 -1
- package/build/dataloaders/recursiveParentsDataLoader.d.ts +0 -7
- package/build/dataloaders/recursiveParentsDataLoader.d.ts.map +0 -1
- package/build/dataloaders/recursiveParentsDataLoader.js +0 -59
- package/build/dataloaders/recursiveParentsDataLoader.js.map +0 -1
- package/build/defaults.d.ts +0 -54
- package/build/defaults.d.ts.map +0 -1
- package/build/defaults.js +0 -282
- package/build/defaults.js.map +0 -1
- package/build/driverApi.d.ts +0 -19
- package/build/driverApi.d.ts.map +0 -1
- package/build/driverApi.js +0 -17
- package/build/driverApi.js.map +0 -1
- package/build/drivers/Driver.d.ts +0 -26
- package/build/drivers/Driver.d.ts.map +0 -1
- package/build/drivers/Driver.js +0 -3
- package/build/drivers/Driver.js.map +0 -1
- package/build/drivers/EntityWriter.d.ts +0 -64
- package/build/drivers/EntityWriter.d.ts.map +0 -1
- package/build/drivers/EntityWriter.js +0 -237
- package/build/drivers/EntityWriter.js.map +0 -1
- package/build/drivers/IdAssigner.d.ts +0 -50
- package/build/drivers/IdAssigner.d.ts.map +0 -1
- package/build/drivers/IdAssigner.js +0 -133
- package/build/drivers/IdAssigner.js.map +0 -1
- package/build/drivers/PostgresDriver.d.ts.map +0 -1
- package/build/drivers/PostgresDriver.js.map +0 -1
- package/build/drivers/buildRawQuery.d.ts +0 -20
- package/build/drivers/buildRawQuery.d.ts.map +0 -1
- package/build/drivers/buildRawQuery.js +0 -148
- package/build/drivers/buildRawQuery.js.map +0 -1
- package/build/drivers/buildUtils.d.ts +0 -4
- package/build/drivers/buildUtils.d.ts.map +0 -1
- package/build/drivers/buildUtils.js +0 -79
- package/build/drivers/buildUtils.js.map +0 -1
- package/build/drivers/index.d.ts +0 -5
- package/build/drivers/index.d.ts.map +0 -1
- package/build/drivers/index.js.map +0 -1
- package/build/fields.d.ts +0 -24
- package/build/fields.d.ts.map +0 -1
- package/build/fields.js +0 -162
- package/build/fields.js.map +0 -1
- package/build/getProperties.d.ts +0 -28
- package/build/getProperties.d.ts.map +0 -1
- package/build/getProperties.js +0 -141
- package/build/getProperties.js.map +0 -1
- package/build/json.d.ts +0 -77
- package/build/json.d.ts.map +0 -1
- package/build/json.js +0 -116
- package/build/json.js.map +0 -1
- package/build/k.d.ts +0 -2
- package/build/k.d.ts.map +0 -1
- package/build/k.js +0 -9
- package/build/k.js.map +0 -1
- package/build/keys.d.ts +0 -49
- package/build/keys.d.ts.map +0 -1
- package/build/keys.js +0 -195
- package/build/keys.js.map +0 -1
- package/build/keywords.d.ts +0 -5
- package/build/keywords.d.ts.map +0 -1
- package/build/keywords.js +0 -124
- package/build/keywords.js.map +0 -1
- package/build/loadHints.d.ts +0 -112
- package/build/loadHints.d.ts.map +0 -1
- package/build/loadHints.js +0 -75
- package/build/loadHints.js.map +0 -1
- package/build/loadLens.d.ts +0 -66
- package/build/loadLens.d.ts.map +0 -1
- package/build/loadLens.js +0 -287
- package/build/loadLens.js.map +0 -1
- package/build/logging/FactoryLogger.d.ts +0 -24
- package/build/logging/FactoryLogger.d.ts.map +0 -1
- package/build/logging/FactoryLogger.js +0 -77
- package/build/logging/FactoryLogger.js.map +0 -1
- package/build/logging/FieldLogger.d.ts +0 -27
- package/build/logging/FieldLogger.d.ts.map +0 -1
- package/build/logging/FieldLogger.js +0 -69
- package/build/logging/FieldLogger.js.map +0 -1
- package/build/logging/ReactionLogger.d.ts +0 -23
- package/build/logging/ReactionLogger.d.ts.map +0 -1
- package/build/logging/ReactionLogger.js +0 -65
- package/build/logging/ReactionLogger.js.map +0 -1
- package/build/newEntity.d.ts +0 -45
- package/build/newEntity.d.ts.map +0 -1
- package/build/newEntity.js +0 -106
- package/build/newEntity.js.map +0 -1
- package/build/newTestInstance.d.ts +0 -193
- package/build/newTestInstance.d.ts.map +0 -1
- package/build/newTestInstance.js +0 -738
- package/build/newTestInstance.js.map +0 -1
- package/build/normalizeHints.d.ts +0 -16
- package/build/normalizeHints.d.ts.map +0 -1
- package/build/normalizeHints.js +0 -31
- package/build/normalizeHints.js.map +0 -1
- package/build/plugins/ImmutableEntitiesPlugin.d.ts +0 -9
- package/build/plugins/ImmutableEntitiesPlugin.d.ts.map +0 -1
- package/build/plugins/ImmutableEntitiesPlugin.js +0 -21
- package/build/plugins/ImmutableEntitiesPlugin.js.map +0 -1
- package/build/plugins/PreloadPlugin.d.ts +0 -69
- package/build/plugins/PreloadPlugin.d.ts.map +0 -1
- package/build/plugins/PreloadPlugin.js +0 -3
- package/build/plugins/PreloadPlugin.js.map +0 -1
- package/build/preloading/JsonAggregatePreloader.d.ts +0 -16
- package/build/preloading/JsonAggregatePreloader.d.ts.map +0 -1
- package/build/preloading/JsonAggregatePreloader.js +0 -238
- package/build/preloading/JsonAggregatePreloader.js.map +0 -1
- package/build/preloading/canPreload.d.ts +0 -3
- package/build/preloading/canPreload.d.ts.map +0 -1
- package/build/preloading/canPreload.js +0 -21
- package/build/preloading/canPreload.js.map +0 -1
- package/build/preloading/partitionHint.d.ts +0 -5
- package/build/preloading/partitionHint.d.ts.map +0 -1
- package/build/preloading/partitionHint.js +0 -56
- package/build/preloading/partitionHint.js.map +0 -1
- package/build/reactiveHints.d.ts +0 -129
- package/build/reactiveHints.d.ts.map +0 -1
- package/build/reactiveHints.js +0 -458
- package/build/reactiveHints.js.map +0 -1
- package/build/relations/AbstractPropertyImpl.d.ts +0 -8
- package/build/relations/AbstractPropertyImpl.d.ts.map +0 -1
- package/build/relations/AbstractPropertyImpl.js +0 -15
- package/build/relations/AbstractPropertyImpl.js.map +0 -1
- package/build/relations/AbstractRelationImpl.d.ts +0 -36
- package/build/relations/AbstractRelationImpl.d.ts.map +0 -1
- package/build/relations/AbstractRelationImpl.js +0 -19
- package/build/relations/AbstractRelationImpl.js.map +0 -1
- package/build/relations/Collection.d.ts +0 -28
- package/build/relations/Collection.d.ts.map +0 -1
- package/build/relations/Collection.js +0 -18
- package/build/relations/Collection.js.map +0 -1
- package/build/relations/CustomCollection.d.ts +0 -69
- package/build/relations/CustomCollection.d.ts.map +0 -1
- package/build/relations/CustomCollection.js +0 -166
- package/build/relations/CustomCollection.js.map +0 -1
- package/build/relations/CustomReference.d.ts +0 -71
- package/build/relations/CustomReference.d.ts.map +0 -1
- package/build/relations/CustomReference.js +0 -152
- package/build/relations/CustomReference.js.map +0 -1
- package/build/relations/LargeCollection.d.ts +0 -19
- package/build/relations/LargeCollection.d.ts.map +0 -1
- package/build/relations/LargeCollection.js +0 -3
- package/build/relations/LargeCollection.js.map +0 -1
- package/build/relations/ManyToManyCollection.d.ts +0 -44
- package/build/relations/ManyToManyCollection.d.ts.map +0 -1
- package/build/relations/ManyToManyCollection.js +0 -268
- package/build/relations/ManyToManyCollection.js.map +0 -1
- package/build/relations/ManyToManyLargeCollection.d.ts +0 -30
- package/build/relations/ManyToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/ManyToManyLargeCollection.js +0 -119
- package/build/relations/ManyToManyLargeCollection.js.map +0 -1
- package/build/relations/ManyToOneReference.d.ts +0 -121
- package/build/relations/ManyToOneReference.d.ts.map +0 -1
- package/build/relations/ManyToOneReference.js +0 -389
- package/build/relations/ManyToOneReference.js.map +0 -1
- package/build/relations/OneToManyCollection.d.ts +0 -58
- package/build/relations/OneToManyCollection.d.ts.map +0 -1
- package/build/relations/OneToManyCollection.js +0 -347
- package/build/relations/OneToManyCollection.js.map +0 -1
- package/build/relations/OneToManyLargeCollection.d.ts +0 -26
- package/build/relations/OneToManyLargeCollection.d.ts.map +0 -1
- package/build/relations/OneToManyLargeCollection.js +0 -102
- package/build/relations/OneToManyLargeCollection.js.map +0 -1
- package/build/relations/OneToOneReference.d.ts +0 -93
- package/build/relations/OneToOneReference.d.ts.map +0 -1
- package/build/relations/OneToOneReference.js +0 -228
- package/build/relations/OneToOneReference.js.map +0 -1
- package/build/relations/PolymorphicReference.d.ts +0 -89
- package/build/relations/PolymorphicReference.d.ts.map +0 -1
- package/build/relations/PolymorphicReference.js +0 -244
- package/build/relations/PolymorphicReference.js.map +0 -1
- package/build/relations/ReactiveField.d.ts +0 -87
- package/build/relations/ReactiveField.d.ts.map +0 -1
- package/build/relations/ReactiveField.js +0 -149
- package/build/relations/ReactiveField.js.map +0 -1
- package/build/relations/ReactiveGetter.d.ts +0 -30
- package/build/relations/ReactiveGetter.d.ts.map +0 -1
- package/build/relations/ReactiveGetter.js +0 -38
- package/build/relations/ReactiveGetter.js.map +0 -1
- package/build/relations/ReactiveManyToMany.d.ts +0 -56
- package/build/relations/ReactiveManyToMany.d.ts.map +0 -1
- package/build/relations/ReactiveManyToMany.js +0 -243
- package/build/relations/ReactiveManyToMany.js.map +0 -1
- package/build/relations/ReactiveManyToManyOtherSide.d.ts +0 -47
- package/build/relations/ReactiveManyToManyOtherSide.d.ts.map +0 -1
- package/build/relations/ReactiveManyToManyOtherSide.js +0 -155
- package/build/relations/ReactiveManyToManyOtherSide.js.map +0 -1
- package/build/relations/ReactiveQueryField.d.ts +0 -41
- package/build/relations/ReactiveQueryField.d.ts.map +0 -1
- package/build/relations/ReactiveQueryField.js +0 -125
- package/build/relations/ReactiveQueryField.js.map +0 -1
- package/build/relations/ReactiveReference.d.ts +0 -119
- package/build/relations/ReactiveReference.d.ts.map +0 -1
- package/build/relations/ReactiveReference.js +0 -333
- package/build/relations/ReactiveReference.js.map +0 -1
- package/build/relations/ReadOnlyCollection.d.ts +0 -19
- package/build/relations/ReadOnlyCollection.d.ts.map +0 -1
- package/build/relations/ReadOnlyCollection.js +0 -15
- package/build/relations/ReadOnlyCollection.js.map +0 -1
- package/build/relations/RecursiveCollection.d.ts +0 -84
- package/build/relations/RecursiveCollection.d.ts.map +0 -1
- package/build/relations/RecursiveCollection.js +0 -296
- package/build/relations/RecursiveCollection.js.map +0 -1
- package/build/relations/Reference.d.ts +0 -35
- package/build/relations/Reference.d.ts.map +0 -1
- package/build/relations/Reference.js +0 -21
- package/build/relations/Reference.js.map +0 -1
- package/build/relations/Relation.d.ts +0 -14
- package/build/relations/Relation.d.ts.map +0 -1
- package/build/relations/Relation.js +0 -12
- package/build/relations/Relation.js.map +0 -1
- package/build/relations/hasAsyncMethod.d.ts +0 -27
- package/build/relations/hasAsyncMethod.d.ts.map +0 -1
- package/build/relations/hasAsyncMethod.js +0 -47
- package/build/relations/hasAsyncMethod.js.map +0 -1
- package/build/relations/hasAsyncProperty.d.ts +0 -49
- package/build/relations/hasAsyncProperty.d.ts.map +0 -1
- package/build/relations/hasAsyncProperty.js +0 -98
- package/build/relations/hasAsyncProperty.js.map +0 -1
- package/build/relations/hasManyDerived.d.ts +0 -22
- package/build/relations/hasManyDerived.d.ts.map +0 -1
- package/build/relations/hasManyDerived.js +0 -32
- package/build/relations/hasManyDerived.js.map +0 -1
- package/build/relations/hasManyThrough.d.ts +0 -10
- package/build/relations/hasManyThrough.d.ts.map +0 -1
- package/build/relations/hasManyThrough.js +0 -24
- package/build/relations/hasManyThrough.js.map +0 -1
- package/build/relations/hasOneDerived.d.ts +0 -12
- package/build/relations/hasOneDerived.d.ts.map +0 -1
- package/build/relations/hasOneDerived.js +0 -24
- package/build/relations/hasOneDerived.js.map +0 -1
- package/build/relations/hasOneThrough.d.ts +0 -10
- package/build/relations/hasOneThrough.d.ts.map +0 -1
- package/build/relations/hasOneThrough.js +0 -24
- package/build/relations/hasOneThrough.js.map +0 -1
- package/build/relations/index.d.ts +0 -28
- package/build/relations/index.d.ts.map +0 -1
- package/build/relations/index.js +0 -88
- package/build/relations/index.js.map +0 -1
- package/build/rules.d.ts +0 -123
- package/build/rules.d.ts.map +0 -1
- package/build/rules.js +0 -231
- package/build/rules.js.map +0 -1
- package/build/runtimeConfig.d.ts +0 -17
- package/build/runtimeConfig.d.ts.map +0 -1
- package/build/runtimeConfig.js +0 -18
- package/build/runtimeConfig.js.map +0 -1
- package/build/serde.d.ts +0 -277
- package/build/serde.d.ts.map +0 -1
- package/build/serde.js +0 -517
- package/build/serde.js.map +0 -1
- package/build/temporal.d.ts +0 -16
- package/build/temporal.d.ts.map +0 -1
- package/build/temporal.js +0 -48
- package/build/temporal.js.map +0 -1
- package/build/temporalMappers.d.ts +0 -25
- package/build/temporalMappers.d.ts.map +0 -1
- package/build/temporalMappers.js +0 -59
- package/build/temporalMappers.js.map +0 -1
- package/build/typeMap.d.ts +0 -68
- package/build/typeMap.d.ts.map +0 -1
- package/build/typeMap.js +0 -3
- package/build/typeMap.js.map +0 -1
- package/build/unnest.d.ts +0 -13
- package/build/unnest.d.ts.map +0 -1
- package/build/unnest.js +0 -85
- package/build/unnest.js.map +0 -1
- package/build/upsert.d.ts +0 -42
- package/build/upsert.d.ts.map +0 -1
- package/build/upsert.js +0 -265
- package/build/upsert.js.map +0 -1
- package/build/utils.d.ts +0 -58
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -236
- package/build/utils.js.map +0 -1
- package/build/withLoaded.d.ts +0 -56
- package/build/withLoaded.d.ts.map +0 -1
- package/build/withLoaded.js +0 -76
- package/build/withLoaded.js.map +0 -1
package/build/QueryParser.js
DELETED
|
@@ -1,853 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.skipCondition = void 0;
|
|
4
|
-
exports.parseFindQuery = parseFindQuery;
|
|
5
|
-
exports.parseAlias = parseAlias;
|
|
6
|
-
exports.parseEntityFilter = parseEntityFilter;
|
|
7
|
-
exports.parseValueFilter = parseValueFilter;
|
|
8
|
-
exports.mapToDb = mapToDb;
|
|
9
|
-
exports.maybeAddOrderBy = maybeAddOrderBy;
|
|
10
|
-
exports.addTablePerClassJoinsAndClassTag = addTablePerClassJoinsAndClassTag;
|
|
11
|
-
exports.maybeAddNotSoftDeleted = maybeAddNotSoftDeleted;
|
|
12
|
-
exports.getTables = getTables;
|
|
13
|
-
exports.makeLike = makeLike;
|
|
14
|
-
const joist_utils_1 = require("joist-utils");
|
|
15
|
-
const Aliases_1 = require("./Aliases");
|
|
16
|
-
const Entity_1 = require("./Entity");
|
|
17
|
-
const EntityMetadata_1 = require("./EntityMetadata");
|
|
18
|
-
const QueryParser_pruning_1 = require("./QueryParser.pruning");
|
|
19
|
-
const QueryVisitor_1 = require("./QueryVisitor");
|
|
20
|
-
const configure_1 = require("./configure");
|
|
21
|
-
const index_1 = require("./index");
|
|
22
|
-
const keywords_1 = require("./keywords");
|
|
23
|
-
const utils_1 = require("./utils");
|
|
24
|
-
/** A marker condition for alias methods to indicate they should be skipped/pruned. */
|
|
25
|
-
exports.skipCondition = {
|
|
26
|
-
kind: "column",
|
|
27
|
-
alias: "skip",
|
|
28
|
-
column: "skip",
|
|
29
|
-
dbType: "skip",
|
|
30
|
-
cond: undefined,
|
|
31
|
-
};
|
|
32
|
-
/** Parses an `em.find` filter into a `ParsedFindQuery` AST for simpler execution. */
|
|
33
|
-
function parseFindQuery(meta, filter, opts = {}) {
|
|
34
|
-
const selects = [];
|
|
35
|
-
const tables = [];
|
|
36
|
-
const orderBys = [];
|
|
37
|
-
const query = { selects, tables, orderBys };
|
|
38
|
-
const { orderBy = undefined, conditions: optsExpression = undefined, softDeletes = "exclude", pruneJoins = true, keepAliases = [], } = opts;
|
|
39
|
-
const cb = new index_1.ConditionBuilder();
|
|
40
|
-
const aliases = {};
|
|
41
|
-
function getAlias(tableName) {
|
|
42
|
-
const abbrev = (0, utils_1.abbreviation)(tableName);
|
|
43
|
-
const i = aliases[abbrev] || 0;
|
|
44
|
-
aliases[abbrev] = i + 1;
|
|
45
|
-
return i === 0 ? abbrev : `${abbrev}${i}`;
|
|
46
|
-
}
|
|
47
|
-
function maybeAddNotSoftDeleted(meta, alias) {
|
|
48
|
-
if (filterSoftDeletes(meta, softDeletes)) {
|
|
49
|
-
const column = meta.allFields[(0, EntityMetadata_1.getBaseMeta)(meta).timestampFields.deletedAt].serde?.columns[0];
|
|
50
|
-
cb.addSimpleCondition({
|
|
51
|
-
kind: "column",
|
|
52
|
-
alias,
|
|
53
|
-
column: column.columnName,
|
|
54
|
-
dbType: column.dbType,
|
|
55
|
-
cond: { kind: "is-null" },
|
|
56
|
-
pruneable: true,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function addTable(meta, alias, join, col1, col2, filter, fieldName) {
|
|
61
|
-
// look at filter, is it `{ book: "b2" }` or `{ book: { ... } }`
|
|
62
|
-
const ef = parseEntityFilter(meta, filter);
|
|
63
|
-
if (!ef && join !== "primary" && !(0, Aliases_1.isAlias)(filter)) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (join === "primary") {
|
|
67
|
-
tables.push({ alias, table: meta.tableName, join });
|
|
68
|
-
addTablePerClassJoinsAndClassTag(query, meta, alias, true);
|
|
69
|
-
}
|
|
70
|
-
else if (meta.inheritanceType === "cti" && fieldName && !(fieldName in meta.fields)) {
|
|
71
|
-
// For cti, our meta might be a subtype while the FK is actually on the base table. This should only be the case
|
|
72
|
-
// when the fk is on another table (e.g. o2o/o2m). In these cases, we'll be passed a field name and can verify if
|
|
73
|
-
// its directly in our meta, if not we should assume it's in the base type and join that in first.
|
|
74
|
-
meta.baseTypes.forEach((bt, i) => {
|
|
75
|
-
tables.push({
|
|
76
|
-
alias: `${alias}_b${i}`,
|
|
77
|
-
table: bt.tableName,
|
|
78
|
-
join: "outer",
|
|
79
|
-
col1,
|
|
80
|
-
col2: `${(0, keywords_1.kq)(`${alias}_b${i}`)}.${col2.split(".")[1]}`,
|
|
81
|
-
distinct: false,
|
|
82
|
-
});
|
|
83
|
-
// and we still need to join in our subtype as well in case its own fields are queried against
|
|
84
|
-
tables.push({
|
|
85
|
-
alias: `${alias}`,
|
|
86
|
-
table: meta.tableName,
|
|
87
|
-
join: "outer",
|
|
88
|
-
col1: (0, keywords_1.kqDot)(alias, "id"),
|
|
89
|
-
col2: (0, keywords_1.kqDot)(`${alias}_b${i}`, "id"),
|
|
90
|
-
distinct: false,
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else if (join === "lateral" || join === "cross") {
|
|
95
|
-
(0, utils_1.fail)("Unexpected lateral join");
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
tables.push({ alias, table: meta.tableName, join, col1, col2 });
|
|
99
|
-
// Maybe only do this if we're the primary, or have a field that needs it?
|
|
100
|
-
addTablePerClassJoinsAndClassTag(query, meta, alias, false);
|
|
101
|
-
}
|
|
102
|
-
if (needsStiDiscriminator(meta)) {
|
|
103
|
-
addStiSubtypeFilter(cb, meta, alias);
|
|
104
|
-
}
|
|
105
|
-
maybeAddNotSoftDeleted(meta, alias);
|
|
106
|
-
// The user's locally declared aliases, i.e. `const [a, b] = aliases(Author, Book)`,
|
|
107
|
-
// aren't guaranteed to line up with the aliases we've assigned internally, like `a`
|
|
108
|
-
// might actually be `a1` if there are two `authors` tables in the query, so push the
|
|
109
|
-
// canonical alias value for the current clause into the Alias.
|
|
110
|
-
if (filter && typeof filter === "object" && "as" in filter && (0, Aliases_1.isAlias)(filter.as)) {
|
|
111
|
-
(0, Aliases_1.getAliasMgmt)(filter.as).setAlias(meta, alias);
|
|
112
|
-
}
|
|
113
|
-
else if ((0, Aliases_1.isAlias)(filter)) {
|
|
114
|
-
(0, Aliases_1.getAliasMgmt)(filter).setAlias(meta, alias);
|
|
115
|
-
}
|
|
116
|
-
if (ef && ef.kind === "join") {
|
|
117
|
-
// subFilter really means we're matching against the entity columns/further joins
|
|
118
|
-
Object.keys(ef.subFilter).forEach((key) => {
|
|
119
|
-
// Skip the `{ as: ... }` alias binding
|
|
120
|
-
if (key === "as")
|
|
121
|
-
return;
|
|
122
|
-
const field = meta.allFields[key] ??
|
|
123
|
-
meta.polyComponentFields?.[key] ??
|
|
124
|
-
(0, utils_1.fail)(`Field '${key}' not found on ${meta.tableName}`);
|
|
125
|
-
const fa = `${alias}${field.aliasSuffix}`;
|
|
126
|
-
if (field.kind === "primitive" || field.kind === "primaryKey" || field.kind === "enum") {
|
|
127
|
-
const column = field.serde.columns[0];
|
|
128
|
-
parseValueFilter(ef.subFilter[key]).forEach((filter) => {
|
|
129
|
-
cb.addValueFilter(fa, column, filter);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
else if (field.kind === "m2o") {
|
|
133
|
-
const column = field.serde.columns[0];
|
|
134
|
-
const sub = ef.subFilter[key];
|
|
135
|
-
const joinKind = field.required && join !== "outer" ? "inner" : "outer";
|
|
136
|
-
if ((0, Aliases_1.isAlias)(sub)) {
|
|
137
|
-
const a = getAlias(field.otherMetadata().tableName);
|
|
138
|
-
addTable(field.otherMetadata(), a, joinKind, (0, keywords_1.kqDot)(fa, column.columnName), (0, keywords_1.kqDot)(a, "id"), sub);
|
|
139
|
-
}
|
|
140
|
-
const f = parseEntityFilter(field.otherMetadata(), sub);
|
|
141
|
-
// Probe the filter and see if it's just an id (...and not soft deleted), if so we can avoid the join
|
|
142
|
-
if (!f) {
|
|
143
|
-
// skip
|
|
144
|
-
}
|
|
145
|
-
else if (f.kind === "join" || filterSoftDeletes(field.otherMetadata(), softDeletes)) {
|
|
146
|
-
const a = getAlias(field.otherMetadata().tableName);
|
|
147
|
-
addTable(field.otherMetadata(), a, joinKind, (0, keywords_1.kqDot)(fa, column.columnName), (0, keywords_1.kqDot)(a, "id"), sub);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
cb.addValueFilter(fa, column, f);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
else if (field.kind === "poly") {
|
|
154
|
-
const f = parseEntityFilter(meta, ef.subFilter[key]);
|
|
155
|
-
if (!f) {
|
|
156
|
-
// skip
|
|
157
|
-
}
|
|
158
|
-
else if (f.kind === "join") {
|
|
159
|
-
throw new Error("Joins through polys are not supported");
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
// We're left with basically a ValueFilter against the ids
|
|
163
|
-
// For now only support eq/ne/in/is-null
|
|
164
|
-
if (f.kind === "eq" || f.kind === "ne") {
|
|
165
|
-
if (isNilIdValue(f.value))
|
|
166
|
-
return;
|
|
167
|
-
const comp = field.components.find((p) => {
|
|
168
|
-
const otherMeta = p.otherMetadata();
|
|
169
|
-
const cstr = (0, index_1.getConstructorFromTaggedId)(f.value);
|
|
170
|
-
// tagged ids from subclasses always map to the base class, so we should compare to the base class if we don't directly match
|
|
171
|
-
return otherMeta.cstr === cstr || otherMeta.baseType === cstr.name;
|
|
172
|
-
});
|
|
173
|
-
if (!comp)
|
|
174
|
-
(0, utils_1.fail)(`Invalid tagged id passed to ${meta.type}.${key}: ${f.value}`);
|
|
175
|
-
const column = field.serde.columns.find((c) => c.columnName === comp.columnName);
|
|
176
|
-
cb.addValueFilter(fa, column, f);
|
|
177
|
-
}
|
|
178
|
-
else if (f.kind === "is-null") {
|
|
179
|
-
// Add a condition for every component--these can be AND-d with the rest of the simple/inline conditions
|
|
180
|
-
field.components.forEach((comp) => {
|
|
181
|
-
const column = field.serde.columns.find((c) => c.columnName === comp.columnName);
|
|
182
|
-
cb.addSimpleCondition({
|
|
183
|
-
kind: "column",
|
|
184
|
-
alias: fa,
|
|
185
|
-
column: comp.columnName,
|
|
186
|
-
dbType: column.dbType,
|
|
187
|
-
cond: f,
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
else if (f.kind === "not-null") {
|
|
192
|
-
const conditions = field.components.map((comp) => {
|
|
193
|
-
const column = field.serde.columns.find((c) => c.columnName === comp.columnName);
|
|
194
|
-
return {
|
|
195
|
-
kind: "column",
|
|
196
|
-
alias: fa,
|
|
197
|
-
column: comp.columnName,
|
|
198
|
-
dbType: column.dbType,
|
|
199
|
-
cond: { kind: "not-null" },
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
cb.addParsedExpression({ kind: "exp", op: "or", conditions });
|
|
203
|
-
}
|
|
204
|
-
else if (f.kind === "in") {
|
|
205
|
-
// Split up the ids by constructor
|
|
206
|
-
const idsByConstructor = (0, joist_utils_1.groupBy)(f.value, (id) => (0, index_1.getConstructorFromTaggedId)(id).name);
|
|
207
|
-
// Or together `parent_book_id in (1,2,3) OR parent_author_id IN (4,5,6)`
|
|
208
|
-
// ...if there is a `parent IN [b:1, b:2, a:1, null]` we'd need to pull the `null` out and do an `OR (all columns are null)`...
|
|
209
|
-
const conditions = Object.entries(idsByConstructor).map(([cstrName, ids]) => {
|
|
210
|
-
const column = field.serde.columns.find(
|
|
211
|
-
// tagged ids from subclasses always map to the base class, so we should compare to the base class if we don't directly match
|
|
212
|
-
(c) => c.otherMetadata().cstr.name === cstrName || c.otherMetadata().baseType === cstrName) ?? (0, utils_1.fail)(`Invalid tagged ids passed to ${meta.type}.${key}: ${ids}`);
|
|
213
|
-
return {
|
|
214
|
-
kind: "column",
|
|
215
|
-
alias: fa,
|
|
216
|
-
column: column.columnName,
|
|
217
|
-
dbType: column.dbType,
|
|
218
|
-
cond: mapToDb(column, { kind: "in", value: ids }),
|
|
219
|
-
};
|
|
220
|
-
});
|
|
221
|
-
if (conditions.length > 0) {
|
|
222
|
-
cb.addParsedExpression({ kind: "exp", op: "or", conditions });
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
throw new Error(`Filters on polys for ${f.kind} are not supported`);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
else if (field.kind === "o2o") {
|
|
231
|
-
// We have to always join into o2os, i.e. we can't probe the filter like we do for m2os
|
|
232
|
-
const otherMeta = field.otherMetadata();
|
|
233
|
-
const a = getAlias(otherMeta.tableName);
|
|
234
|
-
const otherField = otherMeta.allFields[field.otherFieldName];
|
|
235
|
-
const otherColumn =
|
|
236
|
-
// if our other is a poly, we need to find a matching column rather than just picking the first
|
|
237
|
-
otherField.kind === "poly"
|
|
238
|
-
? otherField.components.find((c) => c.otherMetadata() === meta || c.otherMetadata() === (0, EntityMetadata_1.getBaseMeta)(meta)).columnName
|
|
239
|
-
: otherField.serde.columns[0].columnName;
|
|
240
|
-
addTable(field.otherMetadata(), a, "outer", (0, keywords_1.kqDot)(alias, "id"), (0, keywords_1.kqDot)(a, otherColumn), ef.subFilter[key], field.otherFieldName);
|
|
241
|
-
}
|
|
242
|
-
else if (field.kind === "o2m") {
|
|
243
|
-
const a = getAlias(field.otherMetadata().tableName);
|
|
244
|
-
const otherField = field.otherMetadata().allFields[field.otherFieldName];
|
|
245
|
-
let otherColumn = otherField.serde.columns[0].columnName;
|
|
246
|
-
// If the other field is a poly, we need to find the right column
|
|
247
|
-
if (otherField.kind === "poly") {
|
|
248
|
-
// For a subcomponent that matches field's metadata
|
|
249
|
-
const otherComponent = otherField.components.find((c) => c.otherMetadata() === meta) ??
|
|
250
|
-
(0, utils_1.fail)(`No poly component found for ${otherField.fieldName}`);
|
|
251
|
-
otherColumn = otherComponent.columnName;
|
|
252
|
-
}
|
|
253
|
-
addTable(field.otherMetadata(), a, "outer", (0, keywords_1.kqDot)(alias, "id"), (0, keywords_1.kqDot)(a, otherColumn), ef.subFilter[key], field.otherFieldName);
|
|
254
|
-
}
|
|
255
|
-
else if (field.kind === "m2m") {
|
|
256
|
-
// Always join into the m2m table
|
|
257
|
-
const ja = getAlias(field.joinTableName);
|
|
258
|
-
tables.push({
|
|
259
|
-
alias: ja,
|
|
260
|
-
join: "outer",
|
|
261
|
-
table: field.joinTableName,
|
|
262
|
-
col1: (0, keywords_1.kqDot)(alias, "id"),
|
|
263
|
-
col2: (0, keywords_1.kqDot)(ja, field.columnNames[0]),
|
|
264
|
-
});
|
|
265
|
-
// But conditionally join into the alias table
|
|
266
|
-
const sub = ef.subFilter[key];
|
|
267
|
-
if ((0, Aliases_1.isAlias)(sub)) {
|
|
268
|
-
const a = getAlias(field.otherMetadata().tableName);
|
|
269
|
-
addTable(field.otherMetadata(), a, "outer", (0, keywords_1.kqDot)(ja, field.columnNames[1]), (0, keywords_1.kqDot)(a, "id"), sub);
|
|
270
|
-
}
|
|
271
|
-
const f = parseEntityFilter(field.otherMetadata(), sub);
|
|
272
|
-
// Probe the filter and see if it's just an id, if so we can avoid the join
|
|
273
|
-
if (!f) {
|
|
274
|
-
// skip
|
|
275
|
-
}
|
|
276
|
-
else if (f.kind === "join" || filterSoftDeletes(field.otherMetadata(), softDeletes)) {
|
|
277
|
-
const a = getAlias(field.otherMetadata().tableName);
|
|
278
|
-
addTable(field.otherMetadata(), a, "outer", (0, keywords_1.kqDot)(ja, field.columnNames[1]), (0, keywords_1.kqDot)(a, "id"), ef.subFilter[key]);
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
const meta = field.otherMetadata();
|
|
282
|
-
// We normally don't have `columns` for m2m fields, b/c they don't go through normal serde
|
|
283
|
-
// codepaths, so make one up to leverage the existing `mapToDb` function.
|
|
284
|
-
const column = {
|
|
285
|
-
columnName: field.columnNames[1],
|
|
286
|
-
dbType: meta.idDbType,
|
|
287
|
-
mapToDb(value) {
|
|
288
|
-
// Check for `typeof value === number` in case this is a new entity, and we've been given the nilIdValue
|
|
289
|
-
return value === null || isNilIdValue(value)
|
|
290
|
-
? value
|
|
291
|
-
: (0, index_1.keyToNumber)(meta, (0, index_1.maybeResolveReferenceToId)(value));
|
|
292
|
-
},
|
|
293
|
-
};
|
|
294
|
-
cb.addSimpleCondition({
|
|
295
|
-
kind: "column",
|
|
296
|
-
alias: ja,
|
|
297
|
-
column: field.columnNames[1],
|
|
298
|
-
dbType: meta.idDbType,
|
|
299
|
-
cond: mapToDb(column, f),
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
throw new Error(`Unsupported field ${key}`);
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
else if (ef) {
|
|
309
|
-
const column = meta.fields["id"].serde.columns[0];
|
|
310
|
-
cb.addValueFilter(alias, column, ef);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
function addOrderBy(meta, alias, orderBy) {
|
|
314
|
-
const entries = Object.entries(orderBy);
|
|
315
|
-
if (entries.length === 0)
|
|
316
|
-
return;
|
|
317
|
-
for (const [key, value] of entries) {
|
|
318
|
-
if (!value)
|
|
319
|
-
continue; // prune undefined
|
|
320
|
-
const field = meta.allFields[key] ?? (0, utils_1.fail)(`${key} not found on ${meta.tableName}`);
|
|
321
|
-
if (field.kind === "primitive" || field.kind === "primaryKey" || field.kind === "enum") {
|
|
322
|
-
const column = field.serde.columns[0];
|
|
323
|
-
orderBys.push({
|
|
324
|
-
alias: `${alias}${field.aliasSuffix ?? ""}`,
|
|
325
|
-
column: column.columnName,
|
|
326
|
-
order: value,
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
else if (field.kind === "m2o") {
|
|
330
|
-
// Do we already this table joined in?
|
|
331
|
-
let table = tables.find((t) => t.table === field.otherMetadata().tableName);
|
|
332
|
-
if (table) {
|
|
333
|
-
addOrderBy(field.otherMetadata(), table.alias, value);
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
const table = field.otherMetadata().tableName;
|
|
337
|
-
const a = getAlias(table);
|
|
338
|
-
const column = field.serde.columns[0].columnName;
|
|
339
|
-
// If we don't have a join, don't force this to be an inner join
|
|
340
|
-
tables.push({
|
|
341
|
-
alias: a,
|
|
342
|
-
table,
|
|
343
|
-
join: "outer",
|
|
344
|
-
col1: (0, keywords_1.kqDot)(alias, column),
|
|
345
|
-
col2: (0, keywords_1.kqDot)(a, "id"),
|
|
346
|
-
distinct: false,
|
|
347
|
-
});
|
|
348
|
-
addOrderBy(field.otherMetadata(), a, value);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
throw new Error(`Unsupported field ${key}`);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
// always add the main table
|
|
357
|
-
const alias = getAlias(meta.tableName);
|
|
358
|
-
selects.push(`${(0, keywords_1.kq)(alias)}.*`);
|
|
359
|
-
addTable(meta, alias, "primary", "n/a", "n/a", filter);
|
|
360
|
-
// If they passed extra `conditions: ...`, parse that
|
|
361
|
-
if (optsExpression) {
|
|
362
|
-
cb.maybeAddExpression(optsExpression);
|
|
363
|
-
}
|
|
364
|
-
Object.assign(query, {
|
|
365
|
-
condition: cb.toExpressionFilter(),
|
|
366
|
-
});
|
|
367
|
-
if (query.tables.some((t) => t.join === "outer")) {
|
|
368
|
-
maybeAddIdNotNulls(query);
|
|
369
|
-
}
|
|
370
|
-
if (orderBy) {
|
|
371
|
-
if (Array.isArray(orderBy)) {
|
|
372
|
-
for (const ob of orderBy)
|
|
373
|
-
addOrderBy(meta, alias, ob);
|
|
374
|
-
}
|
|
375
|
-
else {
|
|
376
|
-
addOrderBy(meta, alias, orderBy);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
maybeAddOrderBy(query, meta, alias);
|
|
380
|
-
if (pruneJoins) {
|
|
381
|
-
(0, QueryParser_pruning_1.pruneUnusedJoins)(query, keepAliases);
|
|
382
|
-
}
|
|
383
|
-
return query;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Look for conditions doing `some_column IS NULL` in an outer join that
|
|
387
|
-
* need an `id IS NOT NULL` to make sure they don't match inadvertently on
|
|
388
|
-
* the child row simply not existing.
|
|
389
|
-
*
|
|
390
|
-
* Note: Instead of injecting an extra `id IS NOT NULL` condition, I had tried
|
|
391
|
-
* using all INNER JOINs and flipping joins to OUTER only if the user explicit
|
|
392
|
-
* had `id IS NULL` in their filter, but that didn't work for queries that wanted
|
|
393
|
-
* to do an `OR` across two different children (which queries both children being
|
|
394
|
-
* OUTER JOINs, and detecting that case seemed complicated).
|
|
395
|
-
*/
|
|
396
|
-
function maybeAddIdNotNulls(query) {
|
|
397
|
-
(0, QueryVisitor_1.visitConditions)(query, {
|
|
398
|
-
visitCond(c) {
|
|
399
|
-
// Check `c.prunable` to make sure we don't catch our injected `deleted_at is null` conditions
|
|
400
|
-
if (c.cond.kind !== "is-null" || c.column === "id" || c.pruneable) {
|
|
401
|
-
return c;
|
|
402
|
-
}
|
|
403
|
-
// This is an `some_column IS NULL`, is it in an outer join?
|
|
404
|
-
const table = query.tables.find((t) => t.alias === c.alias);
|
|
405
|
-
if (table && table.join === "outer") {
|
|
406
|
-
const meta = (0, configure_1.getMetadataForTable)(table.table);
|
|
407
|
-
return {
|
|
408
|
-
kind: "exp",
|
|
409
|
-
op: "and",
|
|
410
|
-
conditions: [
|
|
411
|
-
c,
|
|
412
|
-
{
|
|
413
|
-
kind: "column",
|
|
414
|
-
alias: c.alias,
|
|
415
|
-
column: "id",
|
|
416
|
-
dbType: meta.idDbType,
|
|
417
|
-
cond: { kind: "not-null" },
|
|
418
|
-
},
|
|
419
|
-
],
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
return c;
|
|
423
|
-
},
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
/** Returns the `a` from `"a".*`. */
|
|
427
|
-
function parseAlias(alias) {
|
|
428
|
-
return alias.split(".")[0].replaceAll(`"`, "");
|
|
429
|
-
}
|
|
430
|
-
/** Parses an entity filter, which could be "just an id", an array of ids, or a nested filter. */
|
|
431
|
-
function parseEntityFilter(meta, filter) {
|
|
432
|
-
if (filter === undefined) {
|
|
433
|
-
// This matches legacy `em.find(Book, { author: undefined })` behavior
|
|
434
|
-
return undefined;
|
|
435
|
-
}
|
|
436
|
-
else if ((0, Aliases_1.isAlias)(filter)) {
|
|
437
|
-
// We're just binding an alias to this position in the join tree
|
|
438
|
-
return undefined;
|
|
439
|
-
}
|
|
440
|
-
else if (filter === null) {
|
|
441
|
-
return { kind: "is-null" };
|
|
442
|
-
}
|
|
443
|
-
else if (typeof filter === "string" || typeof filter === "number") {
|
|
444
|
-
return { kind: "eq", value: filter };
|
|
445
|
-
}
|
|
446
|
-
else if (typeof filter === "boolean") {
|
|
447
|
-
return filter ? { kind: "not-null" } : { kind: "is-null" };
|
|
448
|
-
}
|
|
449
|
-
else if (Array.isArray(filter)) {
|
|
450
|
-
return {
|
|
451
|
-
kind: "in",
|
|
452
|
-
value: filter.map((v) => {
|
|
453
|
-
return (0, Entity_1.isEntity)(v) ? (v.idTaggedMaybe ?? nilIdValue(meta)) : v;
|
|
454
|
-
}),
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
else if ((0, Entity_1.isEntity)(filter)) {
|
|
458
|
-
return { kind: "eq", value: filter.idTaggedMaybe || nilIdValue(meta) };
|
|
459
|
-
}
|
|
460
|
-
else if (typeof filter === "object") {
|
|
461
|
-
// Looking for `{ firstName: "f1" }` or `{ ne: "f1" }`
|
|
462
|
-
const keys = Object.keys(filter);
|
|
463
|
-
// Special case only looking at `ne`
|
|
464
|
-
if (keys.length === 1 && keys[0] === "ne") {
|
|
465
|
-
const value = filter["ne"];
|
|
466
|
-
if (value === undefined) {
|
|
467
|
-
return undefined;
|
|
468
|
-
}
|
|
469
|
-
else if (value === null) {
|
|
470
|
-
return { kind: "not-null" };
|
|
471
|
-
}
|
|
472
|
-
else if (typeof value === "string" || typeof value === "number") {
|
|
473
|
-
return { kind: "ne", value };
|
|
474
|
-
}
|
|
475
|
-
else if ((0, Entity_1.isEntity)(value)) {
|
|
476
|
-
return { kind: "ne", value: value.idTaggedMaybe || nilIdValue(meta) };
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
throw new Error(`Unsupported "ne" value ${value}`);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
// Special case only looking at `id`
|
|
483
|
-
if (keys.length === 1 && keys[0] === "id") {
|
|
484
|
-
const value = filter["id"];
|
|
485
|
-
if (value === undefined) {
|
|
486
|
-
return undefined;
|
|
487
|
-
}
|
|
488
|
-
else if (value === null) {
|
|
489
|
-
return { kind: "is-null" };
|
|
490
|
-
}
|
|
491
|
-
else if (typeof value === "string" || typeof value === "number") {
|
|
492
|
-
return { kind: "eq", value };
|
|
493
|
-
}
|
|
494
|
-
else if ((0, Entity_1.isEntity)(value)) {
|
|
495
|
-
return { kind: "eq", value: value.idTaggedMaybe || nilIdValue(meta) };
|
|
496
|
-
}
|
|
497
|
-
else {
|
|
498
|
-
return parseValueFilter(value)[0];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
// Look for subFilter values being EntityFilter-ish instances like ManyToOneReference
|
|
502
|
-
// that have an id, and so structurally match the entity filter without really being filters,
|
|
503
|
-
// and convert them over here before getting into parseValueFilter.
|
|
504
|
-
const subFilter = {};
|
|
505
|
-
for (const [key, value] of Object.entries(filter)) {
|
|
506
|
-
if (value && typeof value === "object" && !(0, joist_utils_1.isPlainObject)(value) && "idTaggedMaybe" in value) {
|
|
507
|
-
subFilter[key] = value.idTaggedMaybe || nilIdValue(meta);
|
|
508
|
-
}
|
|
509
|
-
else {
|
|
510
|
-
subFilter[key] = value;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return { kind: "join", subFilter };
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
throw new Error(`Unrecognized filter ${filter}`);
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
/**
|
|
520
|
-
* We use this value if users include new (id-less) entities as em.find conditions.
|
|
521
|
-
*
|
|
522
|
-
* The idea is that this condition would never be met, but we still want to do the em.find
|
|
523
|
-
* query in case it's in an `OR` clause that would match false, but some other part of the
|
|
524
|
-
* clause would match. I.e. instead of just skipping the DB query all together, which is
|
|
525
|
-
* also something we could consider doing.
|
|
526
|
-
*
|
|
527
|
-
* For int IDs we use -1, and for uuid IDs, we use the nil UUID value:
|
|
528
|
-
*
|
|
529
|
-
* https://en.wikipedia.org/wiki/Universally_unique_identifier#Nil_UUID
|
|
530
|
-
*/
|
|
531
|
-
function nilIdValue(meta) {
|
|
532
|
-
switch (meta.idDbType) {
|
|
533
|
-
case "int":
|
|
534
|
-
case "bigint":
|
|
535
|
-
return -1;
|
|
536
|
-
case "uuid":
|
|
537
|
-
return "00000000-0000-0000-0000-000000000000";
|
|
538
|
-
case "text":
|
|
539
|
-
return "0";
|
|
540
|
-
default:
|
|
541
|
-
return (0, utils_1.assertNever)(meta.idDbType);
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
function isNilIdValue(value) {
|
|
545
|
-
return value === -1 || value === "00000000-0000-0000-0000-000000000000";
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Parses the many/hodgepodge (ergonomic!) patterns of value filters into a `ParsedValueFilter[]`.
|
|
549
|
-
*
|
|
550
|
-
* Note we return an array because filter might be a `ValueGraphQLFilter` that is allowed to have
|
|
551
|
-
* multiple conditions, i.e. `{ lt: 10, gt: 5 }`.
|
|
552
|
-
*/
|
|
553
|
-
function parseValueFilter(filter) {
|
|
554
|
-
if (filter === null) {
|
|
555
|
-
return [{ kind: "is-null" }];
|
|
556
|
-
}
|
|
557
|
-
else if (filter === undefined) {
|
|
558
|
-
// This is legacy behavior where `em.find(Book, { author: undefined })` would match all books
|
|
559
|
-
return [];
|
|
560
|
-
}
|
|
561
|
-
else if (Array.isArray(filter)) {
|
|
562
|
-
return [{ kind: "in", value: filter }];
|
|
563
|
-
}
|
|
564
|
-
else if ((0, joist_utils_1.isPlainObject)(filter)) {
|
|
565
|
-
const keys = Object.keys(filter);
|
|
566
|
-
if (keys.length === 0) {
|
|
567
|
-
// Should this be an error?
|
|
568
|
-
return [];
|
|
569
|
-
}
|
|
570
|
-
else if (keys.length === 2 && "op" in filter && "value" in filter) {
|
|
571
|
-
// Probe for `findGql` op & value
|
|
572
|
-
const { op, value } = filter;
|
|
573
|
-
if (value === null) {
|
|
574
|
-
return [{ kind: "is-null" }];
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
return [{ kind: op, value: value ?? null }];
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
else if (keys.length === 2 && "gte" in filter && "lte" in filter) {
|
|
581
|
-
const { gte, lte } = filter;
|
|
582
|
-
return [{ kind: "between", value: [gte, lte] }];
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
return Object.entries(filter)
|
|
586
|
-
.map(([key, value]) => {
|
|
587
|
-
// Always do condition pruning on the value
|
|
588
|
-
if (value === undefined) {
|
|
589
|
-
return undefined;
|
|
590
|
-
}
|
|
591
|
-
switch (key) {
|
|
592
|
-
case "eq":
|
|
593
|
-
if (value === null) {
|
|
594
|
-
return { kind: "is-null" };
|
|
595
|
-
}
|
|
596
|
-
else {
|
|
597
|
-
return { kind: "eq", value: filter[key] };
|
|
598
|
-
}
|
|
599
|
-
case "ne":
|
|
600
|
-
if (value === null) {
|
|
601
|
-
return { kind: "not-null" };
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
return { kind: "ne", value: filter[key] ?? null };
|
|
605
|
-
}
|
|
606
|
-
case "in":
|
|
607
|
-
case "nin":
|
|
608
|
-
case "gt":
|
|
609
|
-
case "gte":
|
|
610
|
-
case "lt":
|
|
611
|
-
case "lte":
|
|
612
|
-
case "like":
|
|
613
|
-
case "nlike":
|
|
614
|
-
case "ilike":
|
|
615
|
-
case "nilike":
|
|
616
|
-
case "regex":
|
|
617
|
-
case "nregex":
|
|
618
|
-
case "iregex":
|
|
619
|
-
case "niregex":
|
|
620
|
-
case "contains":
|
|
621
|
-
case "overlaps":
|
|
622
|
-
case "containedBy":
|
|
623
|
-
return { kind: key, value: filter[key] };
|
|
624
|
-
case "pathExists":
|
|
625
|
-
return { kind: "jsonPathExists", value: filter[key] };
|
|
626
|
-
case "pathIsTrue":
|
|
627
|
-
return { kind: "jsonPathPredicate", value: filter[key] };
|
|
628
|
-
case "search":
|
|
629
|
-
return { kind: "ilike", value: makeLike(filter[key]) };
|
|
630
|
-
case "between":
|
|
631
|
-
return { kind: key, value: filter[key] };
|
|
632
|
-
default:
|
|
633
|
-
throw new Error(`Unsupported value filter key ${key}`);
|
|
634
|
-
}
|
|
635
|
-
})
|
|
636
|
-
.filter(index_1.isDefined);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
else {
|
|
640
|
-
// This is a primitive like a string, number
|
|
641
|
-
return [{ kind: "eq", value: filter }];
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
/** Converts domain-level values like string ids/enums into their db equivalent. */
|
|
645
|
-
function mapToDb(column, filter) {
|
|
646
|
-
// ...to teach this `mapToDb` function to handle/rewrite `in: [1, null]` handling, we'd need to:
|
|
647
|
-
// 1. return a maybe-simple/maybe-nested condition, so basically a `ParsedExpressionCondition`, because
|
|
648
|
-
// this would let `in` return an `{ or: ... }` to all the callers.
|
|
649
|
-
// 2. also return `{ parsed: ParsedExpressionCondition, simples: SimpleCondition[] }` tuple, for the
|
|
650
|
-
// alias `addCondition` processing to track the `simples` and rewrite their alias when later bound.
|
|
651
|
-
switch (filter.kind) {
|
|
652
|
-
case "eq":
|
|
653
|
-
case "gt":
|
|
654
|
-
case "gte":
|
|
655
|
-
case "ne":
|
|
656
|
-
case "lt":
|
|
657
|
-
case "lte":
|
|
658
|
-
case "like":
|
|
659
|
-
case "nlike":
|
|
660
|
-
case "ilike":
|
|
661
|
-
case "nilike":
|
|
662
|
-
case "regex":
|
|
663
|
-
case "nregex":
|
|
664
|
-
case "iregex":
|
|
665
|
-
case "niregex":
|
|
666
|
-
filter.value = column.mapToDb(filter.value);
|
|
667
|
-
return filter;
|
|
668
|
-
case "in":
|
|
669
|
-
if (column.isArray) {
|
|
670
|
-
// Arrays need a special operator
|
|
671
|
-
return { kind: "contains", value: column.mapToDb(filter.value) };
|
|
672
|
-
}
|
|
673
|
-
else {
|
|
674
|
-
filter.value = filter.value.map((v) => column.mapToDb(v));
|
|
675
|
-
}
|
|
676
|
-
return filter;
|
|
677
|
-
case "nin":
|
|
678
|
-
if (column.isArray) {
|
|
679
|
-
// Arrays need a special operator
|
|
680
|
-
throw new Error("The nin operator is not supported on array columns yet");
|
|
681
|
-
}
|
|
682
|
-
else {
|
|
683
|
-
filter.value = filter.value.map((v) => column.mapToDb(v));
|
|
684
|
-
}
|
|
685
|
-
return filter;
|
|
686
|
-
case "contains":
|
|
687
|
-
case "ncontains":
|
|
688
|
-
case "overlaps":
|
|
689
|
-
case "noverlaps":
|
|
690
|
-
case "containedBy":
|
|
691
|
-
const supportsContains = column.isArray || column.dbType === "jsonb";
|
|
692
|
-
if (!supportsContains) {
|
|
693
|
-
throw new Error(`${filter.kind} is only unsupported on array or jsonb columns`);
|
|
694
|
-
}
|
|
695
|
-
if (column.isArray) {
|
|
696
|
-
filter.value = column.mapToDb(filter.value);
|
|
697
|
-
}
|
|
698
|
-
else {
|
|
699
|
-
// leave jsonb values alone
|
|
700
|
-
}
|
|
701
|
-
return filter;
|
|
702
|
-
case "between":
|
|
703
|
-
filter.value = [column.mapToDb(filter.value[0]), column.mapToDb(filter.value[1])];
|
|
704
|
-
return filter;
|
|
705
|
-
case "is-null":
|
|
706
|
-
case "not-null":
|
|
707
|
-
case "jsonPathExists":
|
|
708
|
-
case "jsonPathPredicate":
|
|
709
|
-
return filter;
|
|
710
|
-
default:
|
|
711
|
-
throw (0, utils_1.assertNever)(filter);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
/** Adds any user-configured default order, plus an "always order by id" for determinism. */
|
|
715
|
-
function maybeAddOrderBy(query, meta, alias) {
|
|
716
|
-
const { orderBys } = query;
|
|
717
|
-
if (meta.orderBy) {
|
|
718
|
-
const field = meta.allFields[meta.orderBy] ?? (0, utils_1.fail)(`${meta.orderBy} not found on ${meta.tableName}`);
|
|
719
|
-
const column = field.serde.columns[0].columnName;
|
|
720
|
-
const hasAlready = orderBys.find((o) => o.alias === alias && o.column === column);
|
|
721
|
-
if (!hasAlready) {
|
|
722
|
-
orderBys.push({ alias, column, order: "ASC" });
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
// Even if they already added orders, add id as the last one to get deterministic output
|
|
726
|
-
const hasIdOrder = orderBys.find((o) => o.alias === alias && o.column === "id");
|
|
727
|
-
if (!hasIdOrder) {
|
|
728
|
-
orderBys.push({ alias, column: "id", order: "ASC" });
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
function addTablePerClassJoinsAndClassTag(query, meta, alias, isPrimary) {
|
|
732
|
-
if (!needsClassPerTableJoins(meta))
|
|
733
|
-
return;
|
|
734
|
-
const { selects, tables } = query;
|
|
735
|
-
// When `.load(SmallPublisher)` is called, join in base tables like `Publisher`
|
|
736
|
-
meta.baseTypes.forEach((bt, i) => {
|
|
737
|
-
if (isPrimary) {
|
|
738
|
-
selects.push(`${alias}_b${i}.*`);
|
|
739
|
-
}
|
|
740
|
-
tables.push({
|
|
741
|
-
alias: `${alias}_b${i}`,
|
|
742
|
-
table: bt.tableName,
|
|
743
|
-
join: "outer",
|
|
744
|
-
col1: (0, keywords_1.kqDot)(alias, "id"),
|
|
745
|
-
col2: `${alias}_b${i}.id`,
|
|
746
|
-
distinct: false,
|
|
747
|
-
});
|
|
748
|
-
});
|
|
749
|
-
// We always join in the base table in case a query happens to use
|
|
750
|
-
// it as a filter, but we only need to do the subtype joins + selects
|
|
751
|
-
// if this is the primary table
|
|
752
|
-
if (isPrimary) {
|
|
753
|
-
// Watch for subTypes that share column names. It'd be great to do
|
|
754
|
-
// this statically at codegen time, like a meta.sharedSubtypeColumns.
|
|
755
|
-
const stColumns = [];
|
|
756
|
-
// When `.load(Publisher)` is called, join in sub tables like `SmallPublisher` and `LargePublisher`
|
|
757
|
-
meta.subTypes.forEach((st, i) => {
|
|
758
|
-
const stAlias = `${alias}_s${i}`;
|
|
759
|
-
selects.push(`${stAlias}.*`);
|
|
760
|
-
tables.push({
|
|
761
|
-
alias: stAlias,
|
|
762
|
-
table: st.tableName,
|
|
763
|
-
join: "outer",
|
|
764
|
-
col1: (0, keywords_1.kqDot)(alias, "id"),
|
|
765
|
-
col2: `${alias}_s${i}.id`,
|
|
766
|
-
distinct: false,
|
|
767
|
-
});
|
|
768
|
-
for (const field of Object.values(st.fields)) {
|
|
769
|
-
if (field.fieldName !== "id" && field.serde) {
|
|
770
|
-
for (const c of field.serde?.columns) {
|
|
771
|
-
stColumns.push({ stAlias, columnName: c.columnName });
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
// Nominate a specific `id` column to avoid ambiguity
|
|
777
|
-
selects.push(`${(0, keywords_1.kq)(alias)}.id as id`);
|
|
778
|
-
// Add an explicit coalesce for shared columns
|
|
779
|
-
Object.values((0, joist_utils_1.groupBy)(stColumns, (c) => c.columnName))
|
|
780
|
-
.filter((columns) => columns.length > 1)
|
|
781
|
-
.forEach((columns) => {
|
|
782
|
-
const { columnName } = columns[0];
|
|
783
|
-
selects.push(`COALESCE(${columns.map((c) => `${c.stAlias}.${columnName}`).join(", ")}) as ${columnName}`);
|
|
784
|
-
});
|
|
785
|
-
// If our meta has no subtypes, we're a left type and don't need a __class
|
|
786
|
-
const cases = meta.subTypes.map((st, i) => `WHEN ${alias}_s${i}.id IS NOT NULL THEN '${st.type}'`);
|
|
787
|
-
if (cases.length > 0) {
|
|
788
|
-
selects.push(`CASE ${cases.join(" ")} ELSE '_' END as __class`);
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
function maybeAddNotSoftDeleted(conditions, meta, alias, softDeletes) {
|
|
793
|
-
if (filterSoftDeletes(meta, softDeletes)) {
|
|
794
|
-
const column = meta.allFields[(0, EntityMetadata_1.getBaseMeta)(meta).timestampFields.deletedAt].serde?.columns[0];
|
|
795
|
-
conditions.push({
|
|
796
|
-
kind: "column",
|
|
797
|
-
alias,
|
|
798
|
-
column: column.columnName,
|
|
799
|
-
dbType: column.dbType,
|
|
800
|
-
cond: { kind: "is-null" },
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
function filterSoftDeletes(meta, softDeletes) {
|
|
805
|
-
return (softDeletes === "exclude" &&
|
|
806
|
-
!!(0, EntityMetadata_1.getBaseMeta)(meta).timestampFields?.deletedAt &&
|
|
807
|
-
// We don't support CTI subtype soft-delete filtering yet
|
|
808
|
-
(meta.inheritanceType !== "cti" || meta.baseTypes.length === 0));
|
|
809
|
-
}
|
|
810
|
-
function getTables(query) {
|
|
811
|
-
let primary;
|
|
812
|
-
const joins = [];
|
|
813
|
-
const laterals = [];
|
|
814
|
-
const crosses = [];
|
|
815
|
-
for (const table of query.tables) {
|
|
816
|
-
if (table.join === "primary") {
|
|
817
|
-
primary = table;
|
|
818
|
-
}
|
|
819
|
-
else if (table.join === "lateral") {
|
|
820
|
-
laterals.push(table);
|
|
821
|
-
}
|
|
822
|
-
else if (table.join === "cross") {
|
|
823
|
-
crosses.push(table);
|
|
824
|
-
}
|
|
825
|
-
else {
|
|
826
|
-
joins.push(table);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
return [primary, joins, laterals, crosses];
|
|
830
|
-
}
|
|
831
|
-
function needsClassPerTableJoins(meta) {
|
|
832
|
-
return meta.inheritanceType === "cti" && (meta.subTypes.length > 0 || meta.baseTypes.length > 0);
|
|
833
|
-
}
|
|
834
|
-
function needsStiDiscriminator(meta) {
|
|
835
|
-
return meta.inheritanceType === "sti" && !meta.stiDiscriminatorField;
|
|
836
|
-
}
|
|
837
|
-
function addStiSubtypeFilter(cb, subtypeMeta, alias) {
|
|
838
|
-
const baseMeta = (0, EntityMetadata_1.getBaseMeta)(subtypeMeta);
|
|
839
|
-
const column = baseMeta.fields[baseMeta.stiDiscriminatorField].serde?.columns[0];
|
|
840
|
-
cb.addSimpleCondition({
|
|
841
|
-
kind: "column",
|
|
842
|
-
alias,
|
|
843
|
-
column: column.columnName,
|
|
844
|
-
dbType: column.dbType,
|
|
845
|
-
cond: { kind: "eq", value: subtypeMeta.stiDiscriminatorValue },
|
|
846
|
-
pruneable: true,
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
|
-
/** Converts a search term like `foo bar` into a SQL `like` pattern like `%foo%bar%`. */
|
|
850
|
-
function makeLike(search) {
|
|
851
|
-
return search ? `%${search.replace(/\s+/g, "%")}%` : undefined;
|
|
852
|
-
}
|
|
853
|
-
//# sourceMappingURL=QueryParser.js.map
|