taon-typeorm 21.0.12 → 21.0.18
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/browser/package.json +1 -1
- package/browser-prod/README.md +24 -0
- package/browser-prod/fesm2022/taon-typeorm-browser.mjs +30417 -0
- package/browser-prod/fesm2022/taon-typeorm-browser.mjs.map +1 -0
- package/browser-prod/types/taon-typeorm-browser.d.ts +12402 -0
- package/lib/build-info._auto-generated_.d.ts +5 -1
- package/lib/build-info._auto-generated_.js +6 -2
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/env/env.angular-node-app.d.ts +30 -29
- package/lib/env/env.angular-node-app.js +32 -31
- package/lib/env/env.angular-node-app.js.map +1 -1
- package/lib/env/env.docs-webapp.d.ts +30 -29
- package/lib/env/env.docs-webapp.js +32 -31
- package/lib/env/env.docs-webapp.js.map +1 -1
- package/lib/env/env.electron-app.d.ts +30 -29
- package/lib/env/env.electron-app.js +32 -31
- package/lib/env/env.electron-app.js.map +1 -1
- package/lib/env/env.mobile-app.d.ts +30 -29
- package/lib/env/env.mobile-app.js +32 -31
- package/lib/env/env.mobile-app.js.map +1 -1
- package/lib/env/env.npm-lib-and-cli-tool.d.ts +30 -29
- package/lib/env/env.npm-lib-and-cli-tool.js +32 -31
- package/lib/env/env.npm-lib-and-cli-tool.js.map +1 -1
- package/lib/env/env.vscode-plugin.d.ts +30 -29
- package/lib/env/env.vscode-plugin.js +32 -31
- package/lib/env/env.vscode-plugin.js.map +1 -1
- package/lib/index._auto-generated_.js +1 -1
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib-prod/build-info._auto-generated_.d.ts +24 -0
- package/lib-prod/build-info._auto-generated_.js +30 -0
- package/lib-prod/build-info._auto-generated_.js.map +1 -0
- package/lib-prod/env/env.angular-node-app.d.ts +64 -0
- package/lib-prod/env/env.angular-node-app.js +71 -0
- package/lib-prod/env/env.angular-node-app.js.map +1 -0
- package/lib-prod/env/env.docs-webapp.d.ts +64 -0
- package/lib-prod/env/env.docs-webapp.js +71 -0
- package/lib-prod/env/env.docs-webapp.js.map +1 -0
- package/lib-prod/env/env.electron-app.d.ts +64 -0
- package/lib-prod/env/env.electron-app.js +71 -0
- package/lib-prod/env/env.electron-app.js.map +1 -0
- package/lib-prod/env/env.mobile-app.d.ts +64 -0
- package/lib-prod/env/env.mobile-app.js +71 -0
- package/lib-prod/env/env.mobile-app.js.map +1 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.d.ts +64 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +71 -0
- package/lib-prod/env/env.npm-lib-and-cli-tool.js.map +1 -0
- package/lib-prod/env/env.vscode-plugin.d.ts +64 -0
- package/lib-prod/env/env.vscode-plugin.js +71 -0
- package/lib-prod/env/env.vscode-plugin.js.map +1 -0
- package/lib-prod/env/index.d.ts +6 -0
- package/lib-prod/env/index.js +23 -0
- package/lib-prod/env/index.js.map +1 -0
- package/lib-prod/index._auto-generated_.d.ts +0 -0
- package/lib-prod/index._auto-generated_.js +6 -0
- package/lib-prod/index._auto-generated_.js.map +1 -0
- package/lib-prod/index.d.ts +1 -0
- package/lib-prod/index.js +18 -0
- package/lib-prod/index.js.map +1 -0
- package/lib-prod/typeorm/cache/DbQueryResultCache.d.ts +52 -0
- package/lib-prod/typeorm/cache/DbQueryResultCache.js +278 -0
- package/lib-prod/typeorm/cache/DbQueryResultCache.js.map +1 -0
- package/lib-prod/typeorm/cache/QueryResultCache.d.ts +39 -0
- package/lib-prod/typeorm/cache/QueryResultCache.js +3 -0
- package/lib-prod/typeorm/cache/QueryResultCache.js.map +1 -0
- package/lib-prod/typeorm/cache/QueryResultCacheFactory.d.ts +13 -0
- package/lib-prod/typeorm/cache/QueryResultCacheFactory.js +42 -0
- package/lib-prod/typeorm/cache/QueryResultCacheFactory.js.map +1 -0
- package/lib-prod/typeorm/cache/QueryResultCacheOptions.d.ts +26 -0
- package/lib-prod/typeorm/cache/QueryResultCacheOptions.js +3 -0
- package/lib-prod/typeorm/cache/QueryResultCacheOptions.js.map +1 -0
- package/lib-prod/typeorm/cache/RedisQueryResultCache.d.ts +65 -0
- package/lib-prod/typeorm/cache/RedisQueryResultCache.js +212 -0
- package/lib-prod/typeorm/cache/RedisQueryResultCache.js.map +1 -0
- package/lib-prod/typeorm/cli-ts-node-commonjs.d.ts +2 -0
- package/lib-prod/typeorm/cli-ts-node-commonjs.js +8 -0
- package/lib-prod/typeorm/cli-ts-node-commonjs.js.map +1 -0
- package/lib-prod/typeorm/cli-ts-node-esm.d.ts +2 -0
- package/lib-prod/typeorm/cli-ts-node-esm.js +24 -0
- package/lib-prod/typeorm/cli-ts-node-esm.js.map +1 -0
- package/lib-prod/typeorm/cli.d.ts +2 -0
- package/lib-prod/typeorm/cli.js +43 -0
- package/lib-prod/typeorm/cli.js.map +1 -0
- package/lib-prod/typeorm/commands/CacheClearCommand.d.ts +12 -0
- package/lib-prod/typeorm/commands/CacheClearCommand.js +51 -0
- package/lib-prod/typeorm/commands/CacheClearCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/CommandUtils.d.ts +24 -0
- package/lib-prod/typeorm/commands/CommandUtils.js +87 -0
- package/lib-prod/typeorm/commands/CommandUtils.js.map +1 -0
- package/lib-prod/typeorm/commands/EntityCreateCommand.d.ts +13 -0
- package/lib-prod/typeorm/commands/EntityCreateCommand.js +50 -0
- package/lib-prod/typeorm/commands/EntityCreateCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/InitCommand.d.ts +69 -0
- package/lib-prod/typeorm/commands/InitCommand.js +617 -0
- package/lib-prod/typeorm/commands/InitCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/MigrationCreateCommand.d.ts +22 -0
- package/lib-prod/typeorm/commands/MigrationCreateCommand.js +88 -0
- package/lib-prod/typeorm/commands/MigrationCreateCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/MigrationGenerateCommand.d.ts +38 -0
- package/lib-prod/typeorm/commands/MigrationGenerateCommand.js +206 -0
- package/lib-prod/typeorm/commands/MigrationGenerateCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/MigrationRevertCommand.d.ts +16 -0
- package/lib-prod/typeorm/commands/MigrationRevertCommand.js +75 -0
- package/lib-prod/typeorm/commands/MigrationRevertCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/MigrationRunCommand.d.ts +16 -0
- package/lib-prod/typeorm/commands/MigrationRunCommand.js +79 -0
- package/lib-prod/typeorm/commands/MigrationRunCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/MigrationShowCommand.d.ts +12 -0
- package/lib-prod/typeorm/commands/MigrationShowCommand.js +46 -0
- package/lib-prod/typeorm/commands/MigrationShowCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/QueryCommand.d.ts +14 -0
- package/lib-prod/typeorm/commands/QueryCommand.js +66 -0
- package/lib-prod/typeorm/commands/QueryCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/SchemaDropCommand.d.ts +12 -0
- package/lib-prod/typeorm/commands/SchemaDropCommand.js +47 -0
- package/lib-prod/typeorm/commands/SchemaDropCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/SchemaLogCommand.d.ts +12 -0
- package/lib-prod/typeorm/commands/SchemaLogCommand.js +71 -0
- package/lib-prod/typeorm/commands/SchemaLogCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/SchemaSyncCommand.d.ts +12 -0
- package/lib-prod/typeorm/commands/SchemaSyncCommand.js +47 -0
- package/lib-prod/typeorm/commands/SchemaSyncCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/SubscriberCreateCommand.d.ts +13 -0
- package/lib-prod/typeorm/commands/SubscriberCreateCommand.js +50 -0
- package/lib-prod/typeorm/commands/SubscriberCreateCommand.js.map +1 -0
- package/lib-prod/typeorm/commands/VersionCommand.d.ts +10 -0
- package/lib-prod/typeorm/commands/VersionCommand.js +56 -0
- package/lib-prod/typeorm/commands/VersionCommand.js.map +1 -0
- package/lib-prod/typeorm/common/DeepPartial.d.ts +6 -0
- package/lib-prod/typeorm/common/DeepPartial.js +3 -0
- package/lib-prod/typeorm/common/DeepPartial.js.map +1 -0
- package/lib-prod/typeorm/common/EntityTarget.d.ts +9 -0
- package/lib-prod/typeorm/common/EntityTarget.js +3 -0
- package/lib-prod/typeorm/common/EntityTarget.js.map +1 -0
- package/lib-prod/typeorm/common/MixedList.d.ts +8 -0
- package/lib-prod/typeorm/common/MixedList.js +3 -0
- package/lib-prod/typeorm/common/MixedList.js.map +1 -0
- package/lib-prod/typeorm/common/NonNever.d.ts +6 -0
- package/lib-prod/typeorm/common/NonNever.js +3 -0
- package/lib-prod/typeorm/common/NonNever.js.map +1 -0
- package/lib-prod/typeorm/common/ObjectLiteral.d.ts +6 -0
- package/lib-prod/typeorm/common/ObjectLiteral.js +3 -0
- package/lib-prod/typeorm/common/ObjectLiteral.js.map +1 -0
- package/lib-prod/typeorm/common/ObjectType.d.ts +6 -0
- package/lib-prod/typeorm/common/ObjectType.js +3 -0
- package/lib-prod/typeorm/common/ObjectType.js.map +1 -0
- package/lib-prod/typeorm/common/RelationType.d.ts +14 -0
- package/lib-prod/typeorm/common/RelationType.js +3 -0
- package/lib-prod/typeorm/common/RelationType.js.map +1 -0
- package/lib-prod/typeorm/connection/BaseConnectionOptions.d.ts +7 -0
- package/lib-prod/typeorm/connection/BaseConnectionOptions.js +3 -0
- package/lib-prod/typeorm/connection/BaseConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/connection/Connection.d.ts +10 -0
- package/lib-prod/typeorm/connection/Connection.js +15 -0
- package/lib-prod/typeorm/connection/Connection.js.map +1 -0
- package/lib-prod/typeorm/connection/ConnectionManager.d.ts +33 -0
- package/lib-prod/typeorm/connection/ConnectionManager.js +63 -0
- package/lib-prod/typeorm/connection/ConnectionManager.js.map +1 -0
- package/lib-prod/typeorm/connection/ConnectionMetadataBuilder.d.ts +24 -0
- package/lib-prod/typeorm/connection/ConnectionMetadataBuilder.js +74 -0
- package/lib-prod/typeorm/connection/ConnectionMetadataBuilder.js.map +1 -0
- package/lib-prod/typeorm/connection/ConnectionOptions.d.ts +9 -0
- package/lib-prod/typeorm/connection/ConnectionOptions.js +3 -0
- package/lib-prod/typeorm/connection/ConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/connection/ConnectionOptionsReader.d.ts +64 -0
- package/lib-prod/typeorm/connection/ConnectionOptionsReader.js +227 -0
- package/lib-prod/typeorm/connection/ConnectionOptionsReader.js.map +1 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsEnvReader.d.ts +30 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsEnvReader.js +110 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsEnvReader.js.map +1 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsXmlReader.d.ts +16 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsXmlReader.js +69 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsXmlReader.js.map +1 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsYmlReader.d.ts +12 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsYmlReader.js +31 -0
- package/lib-prod/typeorm/connection/options-reader/ConnectionOptionsYmlReader.js.map +1 -0
- package/lib-prod/typeorm/constants.d.ts +1 -0
- package/lib-prod/typeorm/constants.js +6 -0
- package/lib-prod/typeorm/constants.js.map +1 -0
- package/lib-prod/typeorm/container.d.ts +39 -0
- package/lib-prod/typeorm/container.js +57 -0
- package/lib-prod/typeorm/container.js.map +1 -0
- package/lib-prod/typeorm/data-source/BaseDataSourceOptions.d.ts +171 -0
- package/lib-prod/typeorm/data-source/BaseDataSourceOptions.js +3 -0
- package/lib-prod/typeorm/data-source/BaseDataSourceOptions.js.map +1 -0
- package/lib-prod/typeorm/data-source/DataSource.d.ts +260 -0
- package/lib-prod/typeorm/data-source/DataSource.js +528 -0
- package/lib-prod/typeorm/data-source/DataSource.js.map +1 -0
- package/lib-prod/typeorm/data-source/DataSourceOptions.d.ts +22 -0
- package/lib-prod/typeorm/data-source/DataSourceOptions.js +4 -0
- package/lib-prod/typeorm/data-source/DataSourceOptions.js.map +1 -0
- package/lib-prod/typeorm/data-source/index.d.ts +2 -0
- package/lib-prod/typeorm/data-source/index.js +19 -0
- package/lib-prod/typeorm/data-source/index.js.map +1 -0
- package/lib-prod/typeorm/decorator/Check.d.ts +12 -0
- package/lib-prod/typeorm/decorator/Check.js +26 -0
- package/lib-prod/typeorm/decorator/Check.js.map +1 -0
- package/lib-prod/typeorm/decorator/EntityRepository.d.ts +9 -0
- package/lib-prod/typeorm/decorator/EntityRepository.js +20 -0
- package/lib-prod/typeorm/decorator/EntityRepository.js.map +1 -0
- package/lib-prod/typeorm/decorator/Exclusion.d.ts +12 -0
- package/lib-prod/typeorm/decorator/Exclusion.js +26 -0
- package/lib-prod/typeorm/decorator/Exclusion.js.map +1 -0
- package/lib-prod/typeorm/decorator/Generated.d.ts +10 -0
- package/lib-prod/typeorm/decorator/Generated.js +23 -0
- package/lib-prod/typeorm/decorator/Generated.js.map +1 -0
- package/lib-prod/typeorm/decorator/Index.d.ts +49 -0
- package/lib-prod/typeorm/decorator/Index.js +54 -0
- package/lib-prod/typeorm/decorator/Index.js.map +1 -0
- package/lib-prod/typeorm/decorator/Unique.d.ts +21 -0
- package/lib-prod/typeorm/decorator/Unique.js +49 -0
- package/lib-prod/typeorm/decorator/Unique.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/Column.d.ts +74 -0
- package/lib-prod/typeorm/decorator/columns/Column.js +77 -0
- package/lib-prod/typeorm/decorator/columns/Column.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/CreateDateColumn.d.ts +7 -0
- package/lib-prod/typeorm/decorator/columns/CreateDateColumn.js +20 -0
- package/lib-prod/typeorm/decorator/columns/CreateDateColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/DeleteDateColumn.d.ts +6 -0
- package/lib-prod/typeorm/decorator/columns/DeleteDateColumn.js +19 -0
- package/lib-prod/typeorm/decorator/columns/DeleteDateColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/ObjectIdColumn.d.ts +6 -0
- package/lib-prod/typeorm/decorator/columns/ObjectIdColumn.js +26 -0
- package/lib-prod/typeorm/decorator/columns/ObjectIdColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/PrimaryColumn.d.ts +21 -0
- package/lib-prod/typeorm/decorator/columns/PrimaryColumn.js +62 -0
- package/lib-prod/typeorm/decorator/columns/PrimaryColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/PrimaryGeneratedColumn.d.ts +24 -0
- package/lib-prod/typeorm/decorator/columns/PrimaryGeneratedColumn.js +58 -0
- package/lib-prod/typeorm/decorator/columns/PrimaryGeneratedColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/UpdateDateColumn.d.ts +6 -0
- package/lib-prod/typeorm/decorator/columns/UpdateDateColumn.js +19 -0
- package/lib-prod/typeorm/decorator/columns/UpdateDateColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/VersionColumn.d.ts +7 -0
- package/lib-prod/typeorm/decorator/columns/VersionColumn.js +20 -0
- package/lib-prod/typeorm/decorator/columns/VersionColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/ViewColumn.d.ts +5 -0
- package/lib-prod/typeorm/decorator/columns/ViewColumn.js +18 -0
- package/lib-prod/typeorm/decorator/columns/ViewColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/columns/VirtualColumn.d.ts +10 -0
- package/lib-prod/typeorm/decorator/columns/VirtualColumn.js +48 -0
- package/lib-prod/typeorm/decorator/columns/VirtualColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/entity/ChildEntity.d.ts +4 -0
- package/lib-prod/typeorm/decorator/entity/ChildEntity.js +24 -0
- package/lib-prod/typeorm/decorator/entity/ChildEntity.js.map +1 -0
- package/lib-prod/typeorm/decorator/entity/Entity.d.ts +11 -0
- package/lib-prod/typeorm/decorator/entity/Entity.js +30 -0
- package/lib-prod/typeorm/decorator/entity/Entity.js.map +1 -0
- package/lib-prod/typeorm/decorator/entity/TableInheritance.d.ts +8 -0
- package/lib-prod/typeorm/decorator/entity/TableInheritance.js +21 -0
- package/lib-prod/typeorm/decorator/entity/TableInheritance.js.map +1 -0
- package/lib-prod/typeorm/decorator/entity-view/ViewEntity.d.ts +11 -0
- package/lib-prod/typeorm/decorator/entity-view/ViewEntity.js +31 -0
- package/lib-prod/typeorm/decorator/entity-view/ViewEntity.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/AfterInsert.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/AfterInsert.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/AfterInsert.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/AfterLoad.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/AfterLoad.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/AfterLoad.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/AfterRecover.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/AfterRecover.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/AfterRecover.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/AfterRemove.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/AfterRemove.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/AfterRemove.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/AfterSoftRemove.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/AfterSoftRemove.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/AfterSoftRemove.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/AfterUpdate.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/AfterUpdate.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/AfterUpdate.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeInsert.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeInsert.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeInsert.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeRecover.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeRecover.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeRecover.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeRemove.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeRemove.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeRemove.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeSoftRemove.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeSoftRemove.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeSoftRemove.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeUpdate.d.ts +4 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeUpdate.js +18 -0
- package/lib-prod/typeorm/decorator/listeners/BeforeUpdate.js.map +1 -0
- package/lib-prod/typeorm/decorator/listeners/EventSubscriber.d.ts +5 -0
- package/lib-prod/typeorm/decorator/listeners/EventSubscriber.js +16 -0
- package/lib-prod/typeorm/decorator/listeners/EventSubscriber.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnCommonOptions.d.ts +57 -0
- package/lib-prod/typeorm/decorator/options/ColumnCommonOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnCommonOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnEmbeddedOptions.d.ts +16 -0
- package/lib-prod/typeorm/decorator/options/ColumnEmbeddedOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnEmbeddedOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnEnumOptions.d.ts +13 -0
- package/lib-prod/typeorm/decorator/options/ColumnEnumOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnEnumOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnHstoreOptions.d.ts +10 -0
- package/lib-prod/typeorm/decorator/options/ColumnHstoreOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnHstoreOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnNumericOptions.d.ts +24 -0
- package/lib-prod/typeorm/decorator/options/ColumnNumericOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnNumericOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnOptions.d.ts +158 -0
- package/lib-prod/typeorm/decorator/options/ColumnOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnWithLengthOptions.d.ts +10 -0
- package/lib-prod/typeorm/decorator/options/ColumnWithLengthOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnWithLengthOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ColumnWithWidthOptions.d.ts +19 -0
- package/lib-prod/typeorm/decorator/options/ColumnWithWidthOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ColumnWithWidthOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/EntityOptions.d.ts +42 -0
- package/lib-prod/typeorm/decorator/options/EntityOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/EntityOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/IndexOptions.d.ts +52 -0
- package/lib-prod/typeorm/decorator/options/IndexOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/IndexOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/JoinColumnOptions.d.ts +17 -0
- package/lib-prod/typeorm/decorator/options/JoinColumnOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/JoinColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/JoinTableMultipleColumnsOptions.d.ts +29 -0
- package/lib-prod/typeorm/decorator/options/JoinTableMultipleColumnsOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/JoinTableMultipleColumnsOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/JoinTableOptions.d.ts +29 -0
- package/lib-prod/typeorm/decorator/options/JoinTableOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/JoinTableOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnIdentityOptions.d.ts +26 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnIdentityOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnIdentityOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnNumericOptions.d.ts +31 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnNumericOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnNumericOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnUUIDOptions.d.ts +17 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnUUIDOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/PrimaryGeneratedColumnUUIDOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/RelationOptions.d.ts +64 -0
- package/lib-prod/typeorm/decorator/options/RelationOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/RelationOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/SpatialColumnOptions.d.ts +15 -0
- package/lib-prod/typeorm/decorator/options/SpatialColumnOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/SpatialColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/TransactionOptions.d.ts +5 -0
- package/lib-prod/typeorm/decorator/options/TransactionOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/TransactionOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/UniqueOptions.d.ts +10 -0
- package/lib-prod/typeorm/decorator/options/UniqueOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/UniqueOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ValueTransformer.d.ts +13 -0
- package/lib-prod/typeorm/decorator/options/ValueTransformer.js +3 -0
- package/lib-prod/typeorm/decorator/options/ValueTransformer.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ViewColumnOptions.d.ts +15 -0
- package/lib-prod/typeorm/decorator/options/ViewColumnOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ViewColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/ViewEntityOptions.d.ts +39 -0
- package/lib-prod/typeorm/decorator/options/ViewEntityOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/ViewEntityOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/options/VirtualColumnOptions.d.ts +27 -0
- package/lib-prod/typeorm/decorator/options/VirtualColumnOptions.js +3 -0
- package/lib-prod/typeorm/decorator/options/VirtualColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/JoinColumn.d.ts +19 -0
- package/lib-prod/typeorm/decorator/relations/JoinColumn.js +26 -0
- package/lib-prod/typeorm/decorator/relations/JoinColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/JoinTable.d.ts +17 -0
- package/lib-prod/typeorm/decorator/relations/JoinTable.js +32 -0
- package/lib-prod/typeorm/decorator/relations/JoinTable.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/ManyToMany.d.ts +14 -0
- package/lib-prod/typeorm/decorator/relations/ManyToMany.js +45 -0
- package/lib-prod/typeorm/decorator/relations/ManyToMany.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/ManyToOne.d.ts +14 -0
- package/lib-prod/typeorm/decorator/relations/ManyToOne.js +45 -0
- package/lib-prod/typeorm/decorator/relations/ManyToOne.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/OneToMany.d.ts +8 -0
- package/lib-prod/typeorm/decorator/relations/OneToMany.js +36 -0
- package/lib-prod/typeorm/decorator/relations/OneToMany.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/OneToOne.d.ts +12 -0
- package/lib-prod/typeorm/decorator/relations/OneToOne.js +44 -0
- package/lib-prod/typeorm/decorator/relations/OneToOne.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/RelationCount.d.ts +7 -0
- package/lib-prod/typeorm/decorator/relations/RelationCount.js +21 -0
- package/lib-prod/typeorm/decorator/relations/RelationCount.js.map +1 -0
- package/lib-prod/typeorm/decorator/relations/RelationId.d.ts +7 -0
- package/lib-prod/typeorm/decorator/relations/RelationId.js +21 -0
- package/lib-prod/typeorm/decorator/relations/RelationId.js.map +1 -0
- package/lib-prod/typeorm/decorator/tree/Tree.d.ts +9 -0
- package/lib-prod/typeorm/decorator/tree/Tree.js +20 -0
- package/lib-prod/typeorm/decorator/tree/Tree.js.map +1 -0
- package/lib-prod/typeorm/decorator/tree/TreeChildren.d.ts +7 -0
- package/lib-prod/typeorm/decorator/tree/TreeChildren.js +39 -0
- package/lib-prod/typeorm/decorator/tree/TreeChildren.js.map +1 -0
- package/lib-prod/typeorm/decorator/tree/TreeLevelColumn.d.ts +4 -0
- package/lib-prod/typeorm/decorator/tree/TreeLevelColumn.js +18 -0
- package/lib-prod/typeorm/decorator/tree/TreeLevelColumn.js.map +1 -0
- package/lib-prod/typeorm/decorator/tree/TreeParent.d.ts +8 -0
- package/lib-prod/typeorm/decorator/tree/TreeParent.js +38 -0
- package/lib-prod/typeorm/decorator/tree/TreeParent.js.map +1 -0
- package/lib-prod/typeorm/driver/Driver.d.ts +207 -0
- package/lib-prod/typeorm/driver/Driver.js +3 -0
- package/lib-prod/typeorm/driver/Driver.js.map +1 -0
- package/lib-prod/typeorm/driver/DriverFactory.d.ts +11 -0
- package/lib-prod/typeorm/driver/DriverFactory.js +116 -0
- package/lib-prod/typeorm/driver/DriverFactory.js.map +1 -0
- package/lib-prod/typeorm/driver/DriverUtils.d.ts +61 -0
- package/lib-prod/typeorm/driver/DriverUtils.js +227 -0
- package/lib-prod/typeorm/driver/DriverUtils.js.map +1 -0
- package/lib-prod/typeorm/driver/Query.d.ts +9 -0
- package/lib-prod/typeorm/driver/Query.js +17 -0
- package/lib-prod/typeorm/driver/Query.js.map +1 -0
- package/lib-prod/typeorm/driver/SqlInMemory.d.ts +8 -0
- package/lib-prod/typeorm/driver/SqlInMemory.js +12 -0
- package/lib-prod/typeorm/driver/SqlInMemory.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnection.d.ts +13 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnection.js +19 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnection.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.d.ts +35 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.js +3 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnectionOptions.d.ts +35 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnectionOptions.js +4 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlDriver.d.ts +250 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlDriver.js +880 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.d.ts +327 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.js +1702 -0
- package/lib-prod/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresConnectionOptions.d.ts +35 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresDriver.d.ts +70 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresDriver.js +107 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.d.ts +48 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.js +139 -0
- package/lib-prod/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions.d.ts +60 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3Driver.d.ts +59 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3Driver.js +155 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.d.ts +32 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js +130 -0
- package/lib-prod/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorConnectionOptions.d.ts +31 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorDriver.d.ts +27 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorDriver.js +83 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorQueryRunner.d.ts +33 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorQueryRunner.js +97 -0
- package/lib-prod/typeorm/driver/capacitor/CapacitorQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachConnectionCredentialsOptions.d.ts +34 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachConnectionCredentialsOptions.js +3 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachConnectionOptions.d.ts +44 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachDriver.d.ts +261 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachDriver.js +796 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachQueryRunner.d.ts +358 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachQueryRunner.js +2144 -0
- package/lib-prod/typeorm/driver/cockroachdb/CockroachQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/cordova/CordovaConnectionOptions.d.ts +24 -0
- package/lib-prod/typeorm/driver/cordova/CordovaConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/cordova/CordovaConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/cordova/CordovaDriver.d.ts +25 -0
- package/lib-prod/typeorm/driver/cordova/CordovaDriver.js +80 -0
- package/lib-prod/typeorm/driver/cordova/CordovaDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/cordova/CordovaQueryRunner.d.ts +80 -0
- package/lib-prod/typeorm/driver/cordova/CordovaQueryRunner.js +161 -0
- package/lib-prod/typeorm/driver/cordova/CordovaQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/expo/ExpoConnectionOptions.d.ts +19 -0
- package/lib-prod/typeorm/driver/expo/ExpoConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/expo/ExpoConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/expo/ExpoDriver.d.ts +21 -0
- package/lib-prod/typeorm/driver/expo/ExpoDriver.js +80 -0
- package/lib-prod/typeorm/driver/expo/ExpoDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/expo/ExpoQueryRunner.d.ts +57 -0
- package/lib-prod/typeorm/driver/expo/ExpoQueryRunner.js +165 -0
- package/lib-prod/typeorm/driver/expo/ExpoQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/mongodb/MongoConnectionOptions.d.ts +278 -0
- package/lib-prod/typeorm/driver/mongodb/MongoConnectionOptions.js +4 -0
- package/lib-prod/typeorm/driver/mongodb/MongoConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/mongodb/MongoDriver.d.ts +224 -0
- package/lib-prod/typeorm/driver/mongodb/MongoDriver.js +452 -0
- package/lib-prod/typeorm/driver/mongodb/MongoDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/mongodb/MongoQueryRunner.d.ts +548 -0
- package/lib-prod/typeorm/driver/mongodb/MongoQueryRunner.js +747 -0
- package/lib-prod/typeorm/driver/mongodb/MongoQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/mongodb/typings.d.ts +5350 -0
- package/lib-prod/typeorm/driver/mongodb/typings.js +4 -0
- package/lib-prod/typeorm/driver/mongodb/typings.js.map +1 -0
- package/lib-prod/typeorm/driver/mysql/MysqlConnectionCredentialsOptions.d.ts +39 -0
- package/lib-prod/typeorm/driver/mysql/MysqlConnectionCredentialsOptions.js +4 -0
- package/lib-prod/typeorm/driver/mysql/MysqlConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/mysql/MysqlConnectionOptions.d.ts +126 -0
- package/lib-prod/typeorm/driver/mysql/MysqlConnectionOptions.js +4 -0
- package/lib-prod/typeorm/driver/mysql/MysqlConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/mysql/MysqlDriver.d.ts +262 -0
- package/lib-prod/typeorm/driver/mysql/MysqlDriver.js +1116 -0
- package/lib-prod/typeorm/driver/mysql/MysqlDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/mysql/MysqlQueryRunner.d.ts +328 -0
- package/lib-prod/typeorm/driver/mysql/MysqlQueryRunner.js +2109 -0
- package/lib-prod/typeorm/driver/mysql/MysqlQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptConnectionOptions.d.ts +45 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptDriver.d.ts +44 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptDriver.js +105 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptQueryRunner.d.ts +29 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptQueryRunner.js +91 -0
- package/lib-prod/typeorm/driver/nativescript/NativescriptQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/oracle/OracleConnectionCredentialsOptions.d.ts +41 -0
- package/lib-prod/typeorm/driver/oracle/OracleConnectionCredentialsOptions.js +4 -0
- package/lib-prod/typeorm/driver/oracle/OracleConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/oracle/OracleConnectionOptions.d.ts +37 -0
- package/lib-prod/typeorm/driver/oracle/OracleConnectionOptions.js +4 -0
- package/lib-prod/typeorm/driver/oracle/OracleConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/oracle/OracleDriver.d.ts +240 -0
- package/lib-prod/typeorm/driver/oracle/OracleDriver.js +856 -0
- package/lib-prod/typeorm/driver/oracle/OracleDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/oracle/OracleQueryRunner.d.ts +333 -0
- package/lib-prod/typeorm/driver/oracle/OracleQueryRunner.js +1844 -0
- package/lib-prod/typeorm/driver/oracle/OracleQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/postgres/PostgresConnectionCredentialsOptions.d.ts +34 -0
- package/lib-prod/typeorm/driver/postgres/PostgresConnectionCredentialsOptions.js +4 -0
- package/lib-prod/typeorm/driver/postgres/PostgresConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/postgres/PostgresConnectionOptions.d.ts +67 -0
- package/lib-prod/typeorm/driver/postgres/PostgresConnectionOptions.js +4 -0
- package/lib-prod/typeorm/driver/postgres/PostgresConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/postgres/PostgresDriver.d.ts +290 -0
- package/lib-prod/typeorm/driver/postgres/PostgresDriver.js +1286 -0
- package/lib-prod/typeorm/driver/postgres/PostgresDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/postgres/PostgresQueryRunner.d.ts +398 -0
- package/lib-prod/typeorm/driver/postgres/PostgresQueryRunner.js +2612 -0
- package/lib-prod/typeorm/driver/postgres/PostgresQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeConnectionOptions.d.ts +24 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeDriver.d.ts +25 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeDriver.js +84 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeQueryRunner.d.ts +29 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeQueryRunner.js +91 -0
- package/lib-prod/typeorm/driver/react-native/ReactNativeQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/sap/SapConnectionCredentialsOptions.d.ts +45 -0
- package/lib-prod/typeorm/driver/sap/SapConnectionCredentialsOptions.js +3 -0
- package/lib-prod/typeorm/driver/sap/SapConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/sap/SapConnectionOptions.d.ts +60 -0
- package/lib-prod/typeorm/driver/sap/SapConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/sap/SapConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/sap/SapDriver.d.ts +216 -0
- package/lib-prod/typeorm/driver/sap/SapDriver.js +681 -0
- package/lib-prod/typeorm/driver/sap/SapDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/sap/SapQueryRunner.d.ts +348 -0
- package/lib-prod/typeorm/driver/sap/SapQueryRunner.js +2031 -0
- package/lib-prod/typeorm/driver/sap/SapQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/spanner/SpannerConnectionCredentialsOptions.d.ts +17 -0
- package/lib-prod/typeorm/driver/spanner/SpannerConnectionCredentialsOptions.js +3 -0
- package/lib-prod/typeorm/driver/spanner/SpannerConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/spanner/SpannerConnectionOptions.d.ts +121 -0
- package/lib-prod/typeorm/driver/spanner/SpannerConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/spanner/SpannerConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/spanner/SpannerDriver.d.ts +241 -0
- package/lib-prod/typeorm/driver/spanner/SpannerDriver.js +641 -0
- package/lib-prod/typeorm/driver/spanner/SpannerDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/spanner/SpannerQueryRunner.d.ts +349 -0
- package/lib-prod/typeorm/driver/spanner/SpannerQueryRunner.js +1466 -0
- package/lib-prod/typeorm/driver/spanner/SpannerQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteConnectionOptions.d.ts +42 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteDriver.d.ts +59 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteDriver.js +159 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteQueryRunner.d.ts +27 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteQueryRunner.js +108 -0
- package/lib-prod/typeorm/driver/sqlite/SqliteQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.d.ts +237 -0
- package/lib-prod/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.js +713 -0
- package/lib-prod/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.d.ts +301 -0
- package/lib-prod/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1505 -0
- package/lib-prod/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsConnectionOptions.d.ts +46 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsConnectionOptions.js +3 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsDriver.d.ts +67 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsDriver.js +292 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsQueryRunner.d.ts +35 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsQueryRunner.js +116 -0
- package/lib-prod/typeorm/driver/sqljs/SqljsQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/MssqlParameter.d.ts +44 -0
- package/lib-prod/typeorm/driver/sqlserver/MssqlParameter.js +26 -0
- package/lib-prod/typeorm/driver/sqlserver/MssqlParameter.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerConnectionCredentialsOptions.d.ts +49 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerConnectionCredentialsOptions.js +4 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerConnectionOptions.d.ts +237 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerConnectionOptions.js +4 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerDriver.d.ts +253 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerDriver.js +921 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerDriver.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerQueryRunner.d.ts +356 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerQueryRunner.js +2442 -0
- package/lib-prod/typeorm/driver/sqlserver/SqlServerQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.d.ts +10 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.js +3 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.d.ts +20 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.js +3 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.d.ts +16 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.js +3 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.d.ts +17 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.js +3 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryServicePrincipalSecret.d.ts +17 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryServicePrincipalSecret.js +3 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryServicePrincipalSecret.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/DefaultAuthentication.d.ts +13 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/DefaultAuthentication.js +3 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/DefaultAuthentication.js.map +1 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/NtlmAuthentication.d.ts +19 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/NtlmAuthentication.js +3 -0
- package/lib-prod/typeorm/driver/sqlserver/authentication/NtlmAuthentication.js.map +1 -0
- package/lib-prod/typeorm/driver/types/ColumnTypes.d.ts +25 -0
- package/lib-prod/typeorm/driver/types/ColumnTypes.js +3 -0
- package/lib-prod/typeorm/driver/types/ColumnTypes.js.map +1 -0
- package/lib-prod/typeorm/driver/types/CteCapabilities.d.ts +18 -0
- package/lib-prod/typeorm/driver/types/CteCapabilities.js +3 -0
- package/lib-prod/typeorm/driver/types/CteCapabilities.js.map +1 -0
- package/lib-prod/typeorm/driver/types/DataTypeDefaults.d.ts +8 -0
- package/lib-prod/typeorm/driver/types/DataTypeDefaults.js +3 -0
- package/lib-prod/typeorm/driver/types/DataTypeDefaults.js.map +1 -0
- package/lib-prod/typeorm/driver/types/DatabaseType.d.ts +4 -0
- package/lib-prod/typeorm/driver/types/DatabaseType.js +3 -0
- package/lib-prod/typeorm/driver/types/DatabaseType.js.map +1 -0
- package/lib-prod/typeorm/driver/types/IsolationLevel.d.ts +1 -0
- package/lib-prod/typeorm/driver/types/IsolationLevel.js +3 -0
- package/lib-prod/typeorm/driver/types/IsolationLevel.js.map +1 -0
- package/lib-prod/typeorm/driver/types/MappedColumnTypes.d.ts +112 -0
- package/lib-prod/typeorm/driver/types/MappedColumnTypes.js +3 -0
- package/lib-prod/typeorm/driver/types/MappedColumnTypes.js.map +1 -0
- package/lib-prod/typeorm/driver/types/MetadataTableType.d.ts +5 -0
- package/lib-prod/typeorm/driver/types/MetadataTableType.js +10 -0
- package/lib-prod/typeorm/driver/types/MetadataTableType.js.map +1 -0
- package/lib-prod/typeorm/driver/types/ReplicationMode.d.ts +1 -0
- package/lib-prod/typeorm/driver/types/ReplicationMode.js +3 -0
- package/lib-prod/typeorm/driver/types/ReplicationMode.js.map +1 -0
- package/lib-prod/typeorm/driver/types/UpsertType.d.ts +1 -0
- package/lib-prod/typeorm/driver/types/UpsertType.js +3 -0
- package/lib-prod/typeorm/driver/types/UpsertType.js.map +1 -0
- package/lib-prod/typeorm/entity-manager/EntityManager.d.ts +357 -0
- package/lib-prod/typeorm/entity-manager/EntityManager.js +791 -0
- package/lib-prod/typeorm/entity-manager/EntityManager.js.map +1 -0
- package/lib-prod/typeorm/entity-manager/EntityManagerFactory.d.ts +12 -0
- package/lib-prod/typeorm/entity-manager/EntityManagerFactory.js +27 -0
- package/lib-prod/typeorm/entity-manager/EntityManagerFactory.js.map +1 -0
- package/lib-prod/typeorm/entity-manager/MongoEntityManager.d.ts +300 -0
- package/lib-prod/typeorm/entity-manager/MongoEntityManager.js +733 -0
- package/lib-prod/typeorm/entity-manager/MongoEntityManager.js.map +1 -0
- package/lib-prod/typeorm/entity-manager/SqljsEntityManager.d.ts +26 -0
- package/lib-prod/typeorm/entity-manager/SqljsEntityManager.js +44 -0
- package/lib-prod/typeorm/entity-manager/SqljsEntityManager.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchema.d.ts +9 -0
- package/lib-prod/typeorm/entity-schema/EntitySchema.js +15 -0
- package/lib-prod/typeorm/entity-schema/EntitySchema.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaCheckOptions.d.ts +10 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaCheckOptions.js +3 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaCheckOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaColumnOptions.d.ts +174 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaColumnOptions.js +3 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.d.ts +18 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.js +22 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaEmbeddedError.d.ts +6 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaEmbeddedError.js +17 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaEmbeddedError.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaExclusionOptions.d.ts +10 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaExclusionOptions.js +3 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaExclusionOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaIndexOptions.d.ts +53 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaIndexOptions.js +3 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaIndexOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaOptions.d.ts +103 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaOptions.js +90 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaRelationIdOptions.d.ts +15 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaRelationIdOptions.js +3 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaRelationIdOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaRelationOptions.d.ts +95 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaRelationOptions.js +3 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaRelationOptions.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaTransformer.d.ts +13 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaTransformer.js +284 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaTransformer.js.map +1 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaUniqueOptions.d.ts +17 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaUniqueOptions.js +3 -0
- package/lib-prod/typeorm/entity-schema/EntitySchemaUniqueOptions.js.map +1 -0
- package/lib-prod/typeorm/error/AlreadyHasActiveConnectionError.d.ts +7 -0
- package/lib-prod/typeorm/error/AlreadyHasActiveConnectionError.js +15 -0
- package/lib-prod/typeorm/error/AlreadyHasActiveConnectionError.js.map +1 -0
- package/lib-prod/typeorm/error/CannotAttachTreeChildrenEntityError.d.ts +7 -0
- package/lib-prod/typeorm/error/CannotAttachTreeChildrenEntityError.js +15 -0
- package/lib-prod/typeorm/error/CannotAttachTreeChildrenEntityError.js.map +1 -0
- package/lib-prod/typeorm/error/CannotConnectAlreadyConnectedError.d.ts +7 -0
- package/lib-prod/typeorm/error/CannotConnectAlreadyConnectedError.js +14 -0
- package/lib-prod/typeorm/error/CannotConnectAlreadyConnectedError.js.map +1 -0
- package/lib-prod/typeorm/error/CannotCreateEntityIdMapError.d.ts +9 -0
- package/lib-prod/typeorm/error/CannotCreateEntityIdMapError.js +20 -0
- package/lib-prod/typeorm/error/CannotCreateEntityIdMapError.js.map +1 -0
- package/lib-prod/typeorm/error/CannotDetermineEntityError.d.ts +7 -0
- package/lib-prod/typeorm/error/CannotDetermineEntityError.js +15 -0
- package/lib-prod/typeorm/error/CannotDetermineEntityError.js.map +1 -0
- package/lib-prod/typeorm/error/CannotExecuteNotConnectedError.d.ts +7 -0
- package/lib-prod/typeorm/error/CannotExecuteNotConnectedError.js +14 -0
- package/lib-prod/typeorm/error/CannotExecuteNotConnectedError.js.map +1 -0
- package/lib-prod/typeorm/error/CannotGetEntityManagerNotConnectedError.d.ts +7 -0
- package/lib-prod/typeorm/error/CannotGetEntityManagerNotConnectedError.js +14 -0
- package/lib-prod/typeorm/error/CannotGetEntityManagerNotConnectedError.js.map +1 -0
- package/lib-prod/typeorm/error/CannotReflectMethodParameterTypeError.d.ts +8 -0
- package/lib-prod/typeorm/error/CannotReflectMethodParameterTypeError.js +17 -0
- package/lib-prod/typeorm/error/CannotReflectMethodParameterTypeError.js.map +1 -0
- package/lib-prod/typeorm/error/CircularRelationsError.d.ts +7 -0
- package/lib-prod/typeorm/error/CircularRelationsError.js +15 -0
- package/lib-prod/typeorm/error/CircularRelationsError.js.map +1 -0
- package/lib-prod/typeorm/error/ColumnTypeUndefinedError.d.ts +8 -0
- package/lib-prod/typeorm/error/ColumnTypeUndefinedError.js +18 -0
- package/lib-prod/typeorm/error/ColumnTypeUndefinedError.js.map +1 -0
- package/lib-prod/typeorm/error/ConnectionIsNotSetError.d.ts +7 -0
- package/lib-prod/typeorm/error/ConnectionIsNotSetError.js +14 -0
- package/lib-prod/typeorm/error/ConnectionIsNotSetError.js.map +1 -0
- package/lib-prod/typeorm/error/ConnectionNotFoundError.d.ts +7 -0
- package/lib-prod/typeorm/error/ConnectionNotFoundError.js +14 -0
- package/lib-prod/typeorm/error/ConnectionNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/CustomRepositoryCannotInheritRepositoryError.d.ts +7 -0
- package/lib-prod/typeorm/error/CustomRepositoryCannotInheritRepositoryError.js +17 -0
- package/lib-prod/typeorm/error/CustomRepositoryCannotInheritRepositoryError.js.map +1 -0
- package/lib-prod/typeorm/error/CustomRepositoryDoesNotHaveEntityError.d.ts +7 -0
- package/lib-prod/typeorm/error/CustomRepositoryDoesNotHaveEntityError.js +17 -0
- package/lib-prod/typeorm/error/CustomRepositoryDoesNotHaveEntityError.js.map +1 -0
- package/lib-prod/typeorm/error/CustomRepositoryNotFoundError.d.ts +7 -0
- package/lib-prod/typeorm/error/CustomRepositoryNotFoundError.js +17 -0
- package/lib-prod/typeorm/error/CustomRepositoryNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/DataTypeNotSupportedError.d.ts +7 -0
- package/lib-prod/typeorm/error/DataTypeNotSupportedError.js +13 -0
- package/lib-prod/typeorm/error/DataTypeNotSupportedError.js.map +1 -0
- package/lib-prod/typeorm/error/DriverOptionNotSetError.d.ts +7 -0
- package/lib-prod/typeorm/error/DriverOptionNotSetError.js +15 -0
- package/lib-prod/typeorm/error/DriverOptionNotSetError.js.map +1 -0
- package/lib-prod/typeorm/error/DriverPackageNotInstalledError.d.ts +7 -0
- package/lib-prod/typeorm/error/DriverPackageNotInstalledError.js +15 -0
- package/lib-prod/typeorm/error/DriverPackageNotInstalledError.js.map +1 -0
- package/lib-prod/typeorm/error/EntityMetadataNotFoundError.d.ts +6 -0
- package/lib-prod/typeorm/error/EntityMetadataNotFoundError.js +28 -0
- package/lib-prod/typeorm/error/EntityMetadataNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/EntityNotFoundError.d.ts +10 -0
- package/lib-prod/typeorm/error/EntityNotFoundError.js +39 -0
- package/lib-prod/typeorm/error/EntityNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/EntityPropertyNotFoundError.d.ts +8 -0
- package/lib-prod/typeorm/error/EntityPropertyNotFoundError.js +16 -0
- package/lib-prod/typeorm/error/EntityPropertyNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/FindRelationsNotFoundError.d.ts +7 -0
- package/lib-prod/typeorm/error/FindRelationsNotFoundError.js +22 -0
- package/lib-prod/typeorm/error/FindRelationsNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/ForbiddenTransactionModeOverrideError.d.ts +8 -0
- package/lib-prod/typeorm/error/ForbiddenTransactionModeOverrideError.js +15 -0
- package/lib-prod/typeorm/error/ForbiddenTransactionModeOverrideError.js.map +1 -0
- package/lib-prod/typeorm/error/InitializedRelationError.d.ts +11 -0
- package/lib-prod/typeorm/error/InitializedRelationError.js +19 -0
- package/lib-prod/typeorm/error/InitializedRelationError.js.map +1 -0
- package/lib-prod/typeorm/error/InsertValuesMissingError.d.ts +7 -0
- package/lib-prod/typeorm/error/InsertValuesMissingError.js +15 -0
- package/lib-prod/typeorm/error/InsertValuesMissingError.js.map +1 -0
- package/lib-prod/typeorm/error/LimitOnUpdateNotSupportedError.d.ts +7 -0
- package/lib-prod/typeorm/error/LimitOnUpdateNotSupportedError.js +14 -0
- package/lib-prod/typeorm/error/LimitOnUpdateNotSupportedError.js.map +1 -0
- package/lib-prod/typeorm/error/LockNotSupportedOnGivenDriverError.d.ts +7 -0
- package/lib-prod/typeorm/error/LockNotSupportedOnGivenDriverError.js +14 -0
- package/lib-prod/typeorm/error/LockNotSupportedOnGivenDriverError.js.map +1 -0
- package/lib-prod/typeorm/error/MetadataAlreadyExistsError.d.ts +4 -0
- package/lib-prod/typeorm/error/MetadataAlreadyExistsError.js +17 -0
- package/lib-prod/typeorm/error/MetadataAlreadyExistsError.js.map +1 -0
- package/lib-prod/typeorm/error/MetadataWithSuchNameAlreadyExistsError.d.ts +4 -0
- package/lib-prod/typeorm/error/MetadataWithSuchNameAlreadyExistsError.js +15 -0
- package/lib-prod/typeorm/error/MetadataWithSuchNameAlreadyExistsError.js.map +1 -0
- package/lib-prod/typeorm/error/MissingDeleteDateColumnError.d.ts +5 -0
- package/lib-prod/typeorm/error/MissingDeleteDateColumnError.js +11 -0
- package/lib-prod/typeorm/error/MissingDeleteDateColumnError.js.map +1 -0
- package/lib-prod/typeorm/error/MissingDriverError.d.ts +7 -0
- package/lib-prod/typeorm/error/MissingDriverError.js +15 -0
- package/lib-prod/typeorm/error/MissingDriverError.js.map +1 -0
- package/lib-prod/typeorm/error/MissingJoinColumnError.d.ts +6 -0
- package/lib-prod/typeorm/error/MissingJoinColumnError.js +22 -0
- package/lib-prod/typeorm/error/MissingJoinColumnError.js.map +1 -0
- package/lib-prod/typeorm/error/MissingJoinTableError.d.ts +6 -0
- package/lib-prod/typeorm/error/MissingJoinTableError.js +22 -0
- package/lib-prod/typeorm/error/MissingJoinTableError.js.map +1 -0
- package/lib-prod/typeorm/error/MissingPrimaryColumnError.d.ts +5 -0
- package/lib-prod/typeorm/error/MissingPrimaryColumnError.js +12 -0
- package/lib-prod/typeorm/error/MissingPrimaryColumnError.js.map +1 -0
- package/lib-prod/typeorm/error/MustBeEntityError.d.ts +7 -0
- package/lib-prod/typeorm/error/MustBeEntityError.js +14 -0
- package/lib-prod/typeorm/error/MustBeEntityError.js.map +1 -0
- package/lib-prod/typeorm/error/NamingStrategyNotFoundError.d.ts +7 -0
- package/lib-prod/typeorm/error/NamingStrategyNotFoundError.js +20 -0
- package/lib-prod/typeorm/error/NamingStrategyNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/NestedSetMultipleRootError.d.ts +4 -0
- package/lib-prod/typeorm/error/NestedSetMultipleRootError.js +11 -0
- package/lib-prod/typeorm/error/NestedSetMultipleRootError.js.map +1 -0
- package/lib-prod/typeorm/error/NoConnectionForRepositoryError.d.ts +7 -0
- package/lib-prod/typeorm/error/NoConnectionForRepositoryError.js +15 -0
- package/lib-prod/typeorm/error/NoConnectionForRepositoryError.js.map +1 -0
- package/lib-prod/typeorm/error/NoConnectionOptionError.d.ts +7 -0
- package/lib-prod/typeorm/error/NoConnectionOptionError.js +15 -0
- package/lib-prod/typeorm/error/NoConnectionOptionError.js.map +1 -0
- package/lib-prod/typeorm/error/NoNeedToReleaseEntityManagerError.d.ts +7 -0
- package/lib-prod/typeorm/error/NoNeedToReleaseEntityManagerError.js +16 -0
- package/lib-prod/typeorm/error/NoNeedToReleaseEntityManagerError.js.map +1 -0
- package/lib-prod/typeorm/error/NoVersionOrUpdateDateColumnError.d.ts +7 -0
- package/lib-prod/typeorm/error/NoVersionOrUpdateDateColumnError.js +14 -0
- package/lib-prod/typeorm/error/NoVersionOrUpdateDateColumnError.js.map +1 -0
- package/lib-prod/typeorm/error/OffsetWithoutLimitNotSupportedError.d.ts +7 -0
- package/lib-prod/typeorm/error/OffsetWithoutLimitNotSupportedError.js +16 -0
- package/lib-prod/typeorm/error/OffsetWithoutLimitNotSupportedError.js.map +1 -0
- package/lib-prod/typeorm/error/OptimisticLockCanNotBeUsedError.d.ts +7 -0
- package/lib-prod/typeorm/error/OptimisticLockCanNotBeUsedError.js +14 -0
- package/lib-prod/typeorm/error/OptimisticLockCanNotBeUsedError.js.map +1 -0
- package/lib-prod/typeorm/error/OptimisticLockVersionMismatchError.d.ts +7 -0
- package/lib-prod/typeorm/error/OptimisticLockVersionMismatchError.js +14 -0
- package/lib-prod/typeorm/error/OptimisticLockVersionMismatchError.js.map +1 -0
- package/lib-prod/typeorm/error/PersistedEntityNotFoundError.d.ts +7 -0
- package/lib-prod/typeorm/error/PersistedEntityNotFoundError.js +14 -0
- package/lib-prod/typeorm/error/PersistedEntityNotFoundError.js.map +1 -0
- package/lib-prod/typeorm/error/PessimisticLockTransactionRequiredError.d.ts +7 -0
- package/lib-prod/typeorm/error/PessimisticLockTransactionRequiredError.js +14 -0
- package/lib-prod/typeorm/error/PessimisticLockTransactionRequiredError.js.map +1 -0
- package/lib-prod/typeorm/error/PrimaryColumnCannotBeNullableError.d.ts +4 -0
- package/lib-prod/typeorm/error/PrimaryColumnCannotBeNullableError.js +12 -0
- package/lib-prod/typeorm/error/PrimaryColumnCannotBeNullableError.js.map +1 -0
- package/lib-prod/typeorm/error/QueryFailedError.d.ts +10 -0
- package/lib-prod/typeorm/error/QueryFailedError.js +32 -0
- package/lib-prod/typeorm/error/QueryFailedError.js.map +1 -0
- package/lib-prod/typeorm/error/QueryRunnerAlreadyReleasedError.d.ts +4 -0
- package/lib-prod/typeorm/error/QueryRunnerAlreadyReleasedError.js +11 -0
- package/lib-prod/typeorm/error/QueryRunnerAlreadyReleasedError.js.map +1 -0
- package/lib-prod/typeorm/error/QueryRunnerProviderAlreadyReleasedError.d.ts +7 -0
- package/lib-prod/typeorm/error/QueryRunnerProviderAlreadyReleasedError.js +15 -0
- package/lib-prod/typeorm/error/QueryRunnerProviderAlreadyReleasedError.js.map +1 -0
- package/lib-prod/typeorm/error/RepositoryNotTreeError.d.ts +8 -0
- package/lib-prod/typeorm/error/RepositoryNotTreeError.js +31 -0
- package/lib-prod/typeorm/error/RepositoryNotTreeError.js.map +1 -0
- package/lib-prod/typeorm/error/ReturningStatementNotSupportedError.d.ts +8 -0
- package/lib-prod/typeorm/error/ReturningStatementNotSupportedError.js +15 -0
- package/lib-prod/typeorm/error/ReturningStatementNotSupportedError.js.map +1 -0
- package/lib-prod/typeorm/error/SubjectRemovedAndUpdatedError.d.ts +8 -0
- package/lib-prod/typeorm/error/SubjectRemovedAndUpdatedError.js +15 -0
- package/lib-prod/typeorm/error/SubjectRemovedAndUpdatedError.js.map +1 -0
- package/lib-prod/typeorm/error/SubjectWithoutIdentifierError.d.ts +10 -0
- package/lib-prod/typeorm/error/SubjectWithoutIdentifierError.js +16 -0
- package/lib-prod/typeorm/error/SubjectWithoutIdentifierError.js.map +1 -0
- package/lib-prod/typeorm/error/TransactionAlreadyStartedError.d.ts +7 -0
- package/lib-prod/typeorm/error/TransactionAlreadyStartedError.js +14 -0
- package/lib-prod/typeorm/error/TransactionAlreadyStartedError.js.map +1 -0
- package/lib-prod/typeorm/error/TransactionNotStartedError.d.ts +7 -0
- package/lib-prod/typeorm/error/TransactionNotStartedError.js +14 -0
- package/lib-prod/typeorm/error/TransactionNotStartedError.js.map +1 -0
- package/lib-prod/typeorm/error/TreeRepositoryNotSupportedError.d.ts +5 -0
- package/lib-prod/typeorm/error/TreeRepositoryNotSupportedError.js +11 -0
- package/lib-prod/typeorm/error/TreeRepositoryNotSupportedError.js.map +1 -0
- package/lib-prod/typeorm/error/TypeORMError.d.ts +4 -0
- package/lib-prod/typeorm/error/TypeORMError.js +22 -0
- package/lib-prod/typeorm/error/TypeORMError.js.map +1 -0
- package/lib-prod/typeorm/error/UpdateValuesMissingError.d.ts +4 -0
- package/lib-prod/typeorm/error/UpdateValuesMissingError.js +11 -0
- package/lib-prod/typeorm/error/UpdateValuesMissingError.js.map +1 -0
- package/lib-prod/typeorm/error/UsingJoinColumnIsNotAllowedError.d.ts +6 -0
- package/lib-prod/typeorm/error/UsingJoinColumnIsNotAllowedError.js +12 -0
- package/lib-prod/typeorm/error/UsingJoinColumnIsNotAllowedError.js.map +1 -0
- package/lib-prod/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.d.ts +6 -0
- package/lib-prod/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.js +13 -0
- package/lib-prod/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.js.map +1 -0
- package/lib-prod/typeorm/error/UsingJoinTableIsNotAllowedError.d.ts +6 -0
- package/lib-prod/typeorm/error/UsingJoinTableIsNotAllowedError.js +13 -0
- package/lib-prod/typeorm/error/UsingJoinTableIsNotAllowedError.js.map +1 -0
- package/lib-prod/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.d.ts +6 -0
- package/lib-prod/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.js +13 -0
- package/lib-prod/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.js.map +1 -0
- package/lib-prod/typeorm/error/index.d.ts +61 -0
- package/lib-prod/typeorm/error/index.js +78 -0
- package/lib-prod/typeorm/error/index.js.map +1 -0
- package/lib-prod/typeorm/find-options/EqualOperator.d.ts +5 -0
- package/lib-prod/typeorm/find-options/EqualOperator.js +12 -0
- package/lib-prod/typeorm/find-options/EqualOperator.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindManyOptions.d.ts +14 -0
- package/lib-prod/typeorm/find-options/FindManyOptions.js +3 -0
- package/lib-prod/typeorm/find-options/FindManyOptions.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOneOptions.d.ts +88 -0
- package/lib-prod/typeorm/find-options/FindOneOptions.js +3 -0
- package/lib-prod/typeorm/find-options/FindOneOptions.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOperator.d.ts +65 -0
- package/lib-prod/typeorm/find-options/FindOperator.js +109 -0
- package/lib-prod/typeorm/find-options/FindOperator.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOperatorType.d.ts +4 -0
- package/lib-prod/typeorm/find-options/FindOperatorType.js +3 -0
- package/lib-prod/typeorm/find-options/FindOperatorType.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOptionsOrder.d.ts +18 -0
- package/lib-prod/typeorm/find-options/FindOptionsOrder.js +3 -0
- package/lib-prod/typeorm/find-options/FindOptionsOrder.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOptionsRelations.d.ts +18 -0
- package/lib-prod/typeorm/find-options/FindOptionsRelations.js +3 -0
- package/lib-prod/typeorm/find-options/FindOptionsRelations.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOptionsSelect.d.ts +18 -0
- package/lib-prod/typeorm/find-options/FindOptionsSelect.js +3 -0
- package/lib-prod/typeorm/find-options/FindOptionsSelect.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOptionsUtils.d.ts +190 -0
- package/lib-prod/typeorm/find-options/FindOptionsUtils.js +319 -0
- package/lib-prod/typeorm/find-options/FindOptionsUtils.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindOptionsWhere.d.ts +13 -0
- package/lib-prod/typeorm/find-options/FindOptionsWhere.js +3 -0
- package/lib-prod/typeorm/find-options/FindOptionsWhere.js.map +1 -0
- package/lib-prod/typeorm/find-options/FindTreeOptions.d.ts +13 -0
- package/lib-prod/typeorm/find-options/FindTreeOptions.js +3 -0
- package/lib-prod/typeorm/find-options/FindTreeOptions.js.map +1 -0
- package/lib-prod/typeorm/find-options/JoinOptions.d.ts +76 -0
- package/lib-prod/typeorm/find-options/JoinOptions.js +3 -0
- package/lib-prod/typeorm/find-options/JoinOptions.js.map +1 -0
- package/lib-prod/typeorm/find-options/OrderByCondition.d.ts +17 -0
- package/lib-prod/typeorm/find-options/OrderByCondition.js +3 -0
- package/lib-prod/typeorm/find-options/OrderByCondition.js.map +1 -0
- package/lib-prod/typeorm/find-options/mongodb/MongoFindManyOptions.d.ts +14 -0
- package/lib-prod/typeorm/find-options/mongodb/MongoFindManyOptions.js +3 -0
- package/lib-prod/typeorm/find-options/mongodb/MongoFindManyOptions.js.map +1 -0
- package/lib-prod/typeorm/find-options/mongodb/MongoFindOneOptions.d.ts +11 -0
- package/lib-prod/typeorm/find-options/mongodb/MongoFindOneOptions.js +3 -0
- package/lib-prod/typeorm/find-options/mongodb/MongoFindOneOptions.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/And.d.ts +2 -0
- package/lib-prod/typeorm/find-options/operator/And.js +8 -0
- package/lib-prod/typeorm/find-options/operator/And.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/Any.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/Any.js +12 -0
- package/lib-prod/typeorm/find-options/operator/Any.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/ArrayContainedBy.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/ArrayContainedBy.js +12 -0
- package/lib-prod/typeorm/find-options/operator/ArrayContainedBy.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/ArrayContains.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/ArrayContains.js +12 -0
- package/lib-prod/typeorm/find-options/operator/ArrayContains.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/ArrayOverlap.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/ArrayOverlap.js +12 -0
- package/lib-prod/typeorm/find-options/operator/ArrayOverlap.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/Between.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/Between.js +12 -0
- package/lib-prod/typeorm/find-options/operator/Between.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/Equal.d.ts +11 -0
- package/lib-prod/typeorm/find-options/operator/Equal.js +16 -0
- package/lib-prod/typeorm/find-options/operator/Equal.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/ILike.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/ILike.js +12 -0
- package/lib-prod/typeorm/find-options/operator/ILike.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/In.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/In.js +12 -0
- package/lib-prod/typeorm/find-options/operator/In.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/IsNull.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/IsNull.js +12 -0
- package/lib-prod/typeorm/find-options/operator/IsNull.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/LessThan.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/LessThan.js +12 -0
- package/lib-prod/typeorm/find-options/operator/LessThan.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/LessThanOrEqual.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/LessThanOrEqual.js +12 -0
- package/lib-prod/typeorm/find-options/operator/LessThanOrEqual.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/Like.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/Like.js +12 -0
- package/lib-prod/typeorm/find-options/operator/Like.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/MoreThan.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/MoreThan.js +12 -0
- package/lib-prod/typeorm/find-options/operator/MoreThan.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/MoreThanOrEqual.d.ts +6 -0
- package/lib-prod/typeorm/find-options/operator/MoreThanOrEqual.js +12 -0
- package/lib-prod/typeorm/find-options/operator/MoreThanOrEqual.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/Not.d.ts +7 -0
- package/lib-prod/typeorm/find-options/operator/Not.js +13 -0
- package/lib-prod/typeorm/find-options/operator/Not.js.map +1 -0
- package/lib-prod/typeorm/find-options/operator/Raw.d.ts +18 -0
- package/lib-prod/typeorm/find-options/operator/Raw.js +11 -0
- package/lib-prod/typeorm/find-options/operator/Raw.js.map +1 -0
- package/lib-prod/typeorm/globals.d.ts +118 -0
- package/lib-prod/typeorm/globals.js +185 -0
- package/lib-prod/typeorm/globals.js.map +1 -0
- package/lib-prod/typeorm/index.d.ts +173 -0
- package/lib-prod/typeorm/index.js +211 -0
- package/lib-prod/typeorm/index.js.map +1 -0
- package/lib-prod/typeorm/logger/AdvancedConsoleLogger.d.ts +41 -0
- package/lib-prod/typeorm/logger/AdvancedConsoleLogger.js +122 -0
- package/lib-prod/typeorm/logger/AdvancedConsoleLogger.js.map +1 -0
- package/lib-prod/typeorm/logger/DebugLogger.d.ts +40 -0
- package/lib-prod/typeorm/logger/DebugLogger.js +94 -0
- package/lib-prod/typeorm/logger/DebugLogger.js.map +1 -0
- package/lib-prod/typeorm/logger/FileLogger.d.ts +46 -0
- package/lib-prod/typeorm/logger/FileLogger.js +137 -0
- package/lib-prod/typeorm/logger/FileLogger.js.map +1 -0
- package/lib-prod/typeorm/logger/Logger.d.ts +31 -0
- package/lib-prod/typeorm/logger/Logger.js +3 -0
- package/lib-prod/typeorm/logger/Logger.js.map +1 -0
- package/lib-prod/typeorm/logger/LoggerFactory.d.ts +11 -0
- package/lib-prod/typeorm/logger/LoggerFactory.js +39 -0
- package/lib-prod/typeorm/logger/LoggerFactory.js.map +1 -0
- package/lib-prod/typeorm/logger/LoggerOptions.d.ts +13 -0
- package/lib-prod/typeorm/logger/LoggerOptions.js +3 -0
- package/lib-prod/typeorm/logger/LoggerOptions.js.map +1 -0
- package/lib-prod/typeorm/logger/SimpleConsoleLogger.d.ts +41 -0
- package/lib-prod/typeorm/logger/SimpleConsoleLogger.js +121 -0
- package/lib-prod/typeorm/logger/SimpleConsoleLogger.js.map +1 -0
- package/lib-prod/typeorm/metadata/CheckMetadata.d.ts +39 -0
- package/lib-prod/typeorm/metadata/CheckMetadata.js +59 -0
- package/lib-prod/typeorm/metadata/CheckMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/ColumnMetadata.d.ts +315 -0
- package/lib-prod/typeorm/metadata/ColumnMetadata.js +791 -0
- package/lib-prod/typeorm/metadata/ColumnMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/EmbeddedMetadata.d.ts +165 -0
- package/lib-prod/typeorm/metadata/EmbeddedMetadata.js +260 -0
- package/lib-prod/typeorm/metadata/EmbeddedMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/EntityListenerMetadata.d.ts +48 -0
- package/lib-prod/typeorm/metadata/EntityListenerMetadata.js +88 -0
- package/lib-prod/typeorm/metadata/EntityListenerMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/EntityMetadata.d.ts +561 -0
- package/lib-prod/typeorm/metadata/EntityMetadata.js +829 -0
- package/lib-prod/typeorm/metadata/EntityMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/ExclusionMetadata.d.ts +39 -0
- package/lib-prod/typeorm/metadata/ExclusionMetadata.js +59 -0
- package/lib-prod/typeorm/metadata/ExclusionMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/ForeignKeyMetadata.d.ts +77 -0
- package/lib-prod/typeorm/metadata/ForeignKeyMetadata.js +93 -0
- package/lib-prod/typeorm/metadata/ForeignKeyMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/IndexMetadata.d.ts +111 -0
- package/lib-prod/typeorm/metadata/IndexMetadata.js +196 -0
- package/lib-prod/typeorm/metadata/IndexMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/RelationCountMetadata.d.ts +46 -0
- package/lib-prod/typeorm/metadata/RelationCountMetadata.js +69 -0
- package/lib-prod/typeorm/metadata/RelationCountMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/RelationIdMetadata.d.ts +53 -0
- package/lib-prod/typeorm/metadata/RelationIdMetadata.js +92 -0
- package/lib-prod/typeorm/metadata/RelationIdMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/RelationMetadata.d.ts +290 -0
- package/lib-prod/typeorm/metadata/RelationMetadata.js +534 -0
- package/lib-prod/typeorm/metadata/RelationMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/UniqueMetadata.d.ts +65 -0
- package/lib-prod/typeorm/metadata/UniqueMetadata.js +133 -0
- package/lib-prod/typeorm/metadata/UniqueMetadata.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/ClosureTreeOptions.d.ts +10 -0
- package/lib-prod/typeorm/metadata/types/ClosureTreeOptions.js +3 -0
- package/lib-prod/typeorm/metadata/types/ClosureTreeOptions.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/DeferrableType.d.ts +4 -0
- package/lib-prod/typeorm/metadata/types/DeferrableType.js +3 -0
- package/lib-prod/typeorm/metadata/types/DeferrableType.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/EventListenerTypes.d.ts +20 -0
- package/lib-prod/typeorm/metadata/types/EventListenerTypes.js +21 -0
- package/lib-prod/typeorm/metadata/types/EventListenerTypes.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/OnDeleteType.d.ts +4 -0
- package/lib-prod/typeorm/metadata/types/OnDeleteType.js +3 -0
- package/lib-prod/typeorm/metadata/types/OnDeleteType.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/OnUpdateType.d.ts +4 -0
- package/lib-prod/typeorm/metadata/types/OnUpdateType.js +3 -0
- package/lib-prod/typeorm/metadata/types/OnUpdateType.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/PropertyTypeInFunction.d.ts +4 -0
- package/lib-prod/typeorm/metadata/types/PropertyTypeInFunction.js +3 -0
- package/lib-prod/typeorm/metadata/types/PropertyTypeInFunction.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/RelationTypeInFunction.d.ts +5 -0
- package/lib-prod/typeorm/metadata/types/RelationTypeInFunction.js +3 -0
- package/lib-prod/typeorm/metadata/types/RelationTypeInFunction.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/RelationTypes.d.ts +4 -0
- package/lib-prod/typeorm/metadata/types/RelationTypes.js +3 -0
- package/lib-prod/typeorm/metadata/types/RelationTypes.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/TableTypes.d.ts +4 -0
- package/lib-prod/typeorm/metadata/types/TableTypes.js +3 -0
- package/lib-prod/typeorm/metadata/types/TableTypes.js.map +1 -0
- package/lib-prod/typeorm/metadata/types/TreeTypes.d.ts +5 -0
- package/lib-prod/typeorm/metadata/types/TreeTypes.js +3 -0
- package/lib-prod/typeorm/metadata/types/TreeTypes.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/CheckMetadataArgs.d.ts +17 -0
- package/lib-prod/typeorm/metadata-args/CheckMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/CheckMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/ColumnMetadataArgs.d.ts +25 -0
- package/lib-prod/typeorm/metadata-args/ColumnMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/ColumnMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/DiscriminatorValueMetadataArgs.d.ts +13 -0
- package/lib-prod/typeorm/metadata-args/DiscriminatorValueMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/DiscriminatorValueMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/EmbeddedMetadataArgs.d.ts +26 -0
- package/lib-prod/typeorm/metadata-args/EmbeddedMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/EmbeddedMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/EntityListenerMetadataArgs.d.ts +18 -0
- package/lib-prod/typeorm/metadata-args/EntityListenerMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/EntityListenerMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/EntityRepositoryMetadataArgs.d.ts +14 -0
- package/lib-prod/typeorm/metadata-args/EntityRepositoryMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/EntityRepositoryMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/EntitySubscriberMetadataArgs.d.ts +9 -0
- package/lib-prod/typeorm/metadata-args/EntitySubscriberMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/EntitySubscriberMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/ExclusionMetadataArgs.d.ts +17 -0
- package/lib-prod/typeorm/metadata-args/ExclusionMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/ExclusionMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/GeneratedMetadataArgs.d.ts +17 -0
- package/lib-prod/typeorm/metadata-args/GeneratedMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/GeneratedMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/IndexMetadataArgs.d.ts +70 -0
- package/lib-prod/typeorm/metadata-args/IndexMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/IndexMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/InheritanceMetadataArgs.d.ts +18 -0
- package/lib-prod/typeorm/metadata-args/InheritanceMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/InheritanceMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/JoinColumnMetadataArgs.d.ts +26 -0
- package/lib-prod/typeorm/metadata-args/JoinColumnMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/JoinColumnMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/JoinTableMetadataArgs.d.ts +37 -0
- package/lib-prod/typeorm/metadata-args/JoinTableMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/JoinTableMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/MetadataArgsStorage.d.ts +108 -0
- package/lib-prod/typeorm/metadata-args/MetadataArgsStorage.js +225 -0
- package/lib-prod/typeorm/metadata-args/MetadataArgsStorage.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/NamingStrategyMetadataArgs.d.ts +13 -0
- package/lib-prod/typeorm/metadata-args/NamingStrategyMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/NamingStrategyMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/RelationCountMetadataArgs.d.ts +26 -0
- package/lib-prod/typeorm/metadata-args/RelationCountMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/RelationCountMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/RelationIdMetadataArgs.d.ts +26 -0
- package/lib-prod/typeorm/metadata-args/RelationIdMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/RelationIdMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/RelationMetadataArgs.d.ts +55 -0
- package/lib-prod/typeorm/metadata-args/RelationMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/RelationMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/TableMetadataArgs.d.ts +61 -0
- package/lib-prod/typeorm/metadata-args/TableMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/TableMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/TransactionEntityMetadataArgs.d.ts +17 -0
- package/lib-prod/typeorm/metadata-args/TransactionEntityMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/TransactionEntityMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/TransactionRepositoryMetadataArgs.d.ts +25 -0
- package/lib-prod/typeorm/metadata-args/TransactionRepositoryMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/TransactionRepositoryMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/TreeMetadataArgs.d.ts +19 -0
- package/lib-prod/typeorm/metadata-args/TreeMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/TreeMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/UniqueMetadataArgs.d.ts +24 -0
- package/lib-prod/typeorm/metadata-args/UniqueMetadataArgs.js +3 -0
- package/lib-prod/typeorm/metadata-args/UniqueMetadataArgs.js.map +1 -0
- package/lib-prod/typeorm/metadata-args/types/ColumnMode.d.ts +7 -0
- package/lib-prod/typeorm/metadata-args/types/ColumnMode.js +3 -0
- package/lib-prod/typeorm/metadata-args/types/ColumnMode.js.map +1 -0
- package/lib-prod/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.d.ts +14 -0
- package/lib-prod/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.js +145 -0
- package/lib-prod/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.js.map +1 -0
- package/lib-prod/typeorm/metadata-builder/EntityMetadataBuilder.d.ts +57 -0
- package/lib-prod/typeorm/metadata-builder/EntityMetadataBuilder.js +750 -0
- package/lib-prod/typeorm/metadata-builder/EntityMetadataBuilder.js.map +1 -0
- package/lib-prod/typeorm/metadata-builder/EntityMetadataValidator.d.ts +23 -0
- package/lib-prod/typeorm/metadata-builder/EntityMetadataValidator.js +245 -0
- package/lib-prod/typeorm/metadata-builder/EntityMetadataValidator.js.map +1 -0
- package/lib-prod/typeorm/metadata-builder/JunctionEntityMetadataBuilder.d.ts +26 -0
- package/lib-prod/typeorm/metadata-builder/JunctionEntityMetadataBuilder.js +282 -0
- package/lib-prod/typeorm/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -0
- package/lib-prod/typeorm/metadata-builder/MetadataUtils.d.ts +23 -0
- package/lib-prod/typeorm/metadata-builder/MetadataUtils.js +43 -0
- package/lib-prod/typeorm/metadata-builder/MetadataUtils.js.map +1 -0
- package/lib-prod/typeorm/metadata-builder/RelationJoinColumnBuilder.d.ts +56 -0
- package/lib-prod/typeorm/metadata-builder/RelationJoinColumnBuilder.js +184 -0
- package/lib-prod/typeorm/metadata-builder/RelationJoinColumnBuilder.js.map +1 -0
- package/lib-prod/typeorm/migration/Migration.d.ts +24 -0
- package/lib-prod/typeorm/migration/Migration.js +39 -0
- package/lib-prod/typeorm/migration/Migration.js.map +1 -0
- package/lib-prod/typeorm/migration/MigrationExecutor.d.ts +99 -0
- package/lib-prod/typeorm/migration/MigrationExecutor.js +525 -0
- package/lib-prod/typeorm/migration/MigrationExecutor.js.map +1 -0
- package/lib-prod/typeorm/migration/MigrationInterface.d.ts +18 -0
- package/lib-prod/typeorm/migration/MigrationInterface.js +3 -0
- package/lib-prod/typeorm/migration/MigrationInterface.js.map +1 -0
- package/lib-prod/typeorm/naming-strategy/DefaultNamingStrategy.d.ts +49 -0
- package/lib-prod/typeorm/naming-strategy/DefaultNamingStrategy.js +145 -0
- package/lib-prod/typeorm/naming-strategy/DefaultNamingStrategy.js.map +1 -0
- package/lib-prod/typeorm/naming-strategy/NamingStrategyInterface.d.ts +116 -0
- package/lib-prod/typeorm/naming-strategy/NamingStrategyInterface.js +3 -0
- package/lib-prod/typeorm/naming-strategy/NamingStrategyInterface.js.map +1 -0
- package/lib-prod/typeorm/persistence/EntityPersistExecutor.d.ts +21 -0
- package/lib-prod/typeorm/persistence/EntityPersistExecutor.js +182 -0
- package/lib-prod/typeorm/persistence/EntityPersistExecutor.js.map +1 -0
- package/lib-prod/typeorm/persistence/Subject.d.ts +155 -0
- package/lib-prod/typeorm/persistence/Subject.js +275 -0
- package/lib-prod/typeorm/persistence/Subject.js.map +1 -0
- package/lib-prod/typeorm/persistence/SubjectChangeMap.d.ts +23 -0
- package/lib-prod/typeorm/persistence/SubjectChangeMap.js +3 -0
- package/lib-prod/typeorm/persistence/SubjectChangeMap.js.map +1 -0
- package/lib-prod/typeorm/persistence/SubjectChangedColumnsComputer.d.ts +18 -0
- package/lib-prod/typeorm/persistence/SubjectChangedColumnsComputer.js +209 -0
- package/lib-prod/typeorm/persistence/SubjectChangedColumnsComputer.js.map +1 -0
- package/lib-prod/typeorm/persistence/SubjectDatabaseEntityLoader.d.ts +35 -0
- package/lib-prod/typeorm/persistence/SubjectDatabaseEntityLoader.js +154 -0
- package/lib-prod/typeorm/persistence/SubjectDatabaseEntityLoader.js.map +1 -0
- package/lib-prod/typeorm/persistence/SubjectExecutor.d.ts +118 -0
- package/lib-prod/typeorm/persistence/SubjectExecutor.js +830 -0
- package/lib-prod/typeorm/persistence/SubjectExecutor.js.map +1 -0
- package/lib-prod/typeorm/persistence/SubjectTopoligicalSorter.d.ts +45 -0
- package/lib-prod/typeorm/persistence/SubjectTopoligicalSorter.js +185 -0
- package/lib-prod/typeorm/persistence/SubjectTopoligicalSorter.js.map +1 -0
- package/lib-prod/typeorm/persistence/subject-builder/CascadesSubjectBuilder.d.ts +19 -0
- package/lib-prod/typeorm/persistence/subject-builder/CascadesSubjectBuilder.js +107 -0
- package/lib-prod/typeorm/persistence/subject-builder/CascadesSubjectBuilder.js.map +1 -0
- package/lib-prod/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.d.ts +34 -0
- package/lib-prod/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.js +214 -0
- package/lib-prod/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.js.map +1 -0
- package/lib-prod/typeorm/persistence/subject-builder/OneToManySubjectBuilder.d.ts +27 -0
- package/lib-prod/typeorm/persistence/subject-builder/OneToManySubjectBuilder.js +181 -0
- package/lib-prod/typeorm/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -0
- package/lib-prod/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.d.ts +27 -0
- package/lib-prod/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js +155 -0
- package/lib-prod/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js.map +1 -0
- package/lib-prod/typeorm/persistence/tree/ClosureSubjectExecutor.d.ts +26 -0
- package/lib-prod/typeorm/persistence/tree/ClosureSubjectExecutor.js +241 -0
- package/lib-prod/typeorm/persistence/tree/ClosureSubjectExecutor.js.map +1 -0
- package/lib-prod/typeorm/persistence/tree/MaterializedPathSubjectExecutor.d.ts +18 -0
- package/lib-prod/typeorm/persistence/tree/MaterializedPathSubjectExecutor.js +110 -0
- package/lib-prod/typeorm/persistence/tree/MaterializedPathSubjectExecutor.js.map +1 -0
- package/lib-prod/typeorm/persistence/tree/NestedSetSubjectExecutor.d.ts +38 -0
- package/lib-prod/typeorm/persistence/tree/NestedSetSubjectExecutor.js +273 -0
- package/lib-prod/typeorm/persistence/tree/NestedSetSubjectExecutor.js.map +1 -0
- package/lib-prod/typeorm/platform/PlatformTools.d.ts +67 -0
- package/lib-prod/typeorm/platform/PlatformTools.js +363 -0
- package/lib-prod/typeorm/platform/PlatformTools.js.map +1 -0
- package/lib-prod/typeorm/query-builder/Alias.d.ts +22 -0
- package/lib-prod/typeorm/query-builder/Alias.js +40 -0
- package/lib-prod/typeorm/query-builder/Alias.js.map +1 -0
- package/lib-prod/typeorm/query-builder/Brackets.d.ts +16 -0
- package/lib-prod/typeorm/query-builder/Brackets.js +22 -0
- package/lib-prod/typeorm/query-builder/Brackets.js.map +1 -0
- package/lib-prod/typeorm/query-builder/DeleteQueryBuilder.d.ts +91 -0
- package/lib-prod/typeorm/query-builder/DeleteQueryBuilder.js +210 -0
- package/lib-prod/typeorm/query-builder/DeleteQueryBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/InsertOrUpdateOptions.d.ts +3 -0
- package/lib-prod/typeorm/query-builder/InsertOrUpdateOptions.js +3 -0
- package/lib-prod/typeorm/query-builder/InsertOrUpdateOptions.js.map +1 -0
- package/lib-prod/typeorm/query-builder/InsertQueryBuilder.d.ts +117 -0
- package/lib-prod/typeorm/query-builder/InsertQueryBuilder.js +746 -0
- package/lib-prod/typeorm/query-builder/InsertQueryBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/JoinAttribute.d.ts +83 -0
- package/lib-prod/typeorm/query-builder/JoinAttribute.js +194 -0
- package/lib-prod/typeorm/query-builder/JoinAttribute.js.map +1 -0
- package/lib-prod/typeorm/query-builder/JoinOptions.d.ts +3 -0
- package/lib-prod/typeorm/query-builder/JoinOptions.js +3 -0
- package/lib-prod/typeorm/query-builder/JoinOptions.js.map +1 -0
- package/lib-prod/typeorm/query-builder/NotBrackets.d.ts +8 -0
- package/lib-prod/typeorm/query-builder/NotBrackets.js +13 -0
- package/lib-prod/typeorm/query-builder/NotBrackets.js.map +1 -0
- package/lib-prod/typeorm/query-builder/QueryBuilder.d.ts +267 -0
- package/lib-prod/typeorm/query-builder/QueryBuilder.js +1082 -0
- package/lib-prod/typeorm/query-builder/QueryBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/QueryBuilderCte.d.ts +17 -0
- package/lib-prod/typeorm/query-builder/QueryBuilderCte.js +3 -0
- package/lib-prod/typeorm/query-builder/QueryBuilderCte.js.map +1 -0
- package/lib-prod/typeorm/query-builder/QueryBuilderUtils.d.ts +10 -0
- package/lib-prod/typeorm/query-builder/QueryBuilderUtils.js +31 -0
- package/lib-prod/typeorm/query-builder/QueryBuilderUtils.js.map +1 -0
- package/lib-prod/typeorm/query-builder/QueryExpressionMap.d.ts +305 -0
- package/lib-prod/typeorm/query-builder/QueryExpressionMap.js +410 -0
- package/lib-prod/typeorm/query-builder/QueryExpressionMap.js.map +1 -0
- package/lib-prod/typeorm/query-builder/QueryPartialEntity.d.ts +15 -0
- package/lib-prod/typeorm/query-builder/QueryPartialEntity.js +3 -0
- package/lib-prod/typeorm/query-builder/QueryPartialEntity.js.map +1 -0
- package/lib-prod/typeorm/query-builder/RelationIdLoader.d.ts +70 -0
- package/lib-prod/typeorm/query-builder/RelationIdLoader.js +501 -0
- package/lib-prod/typeorm/query-builder/RelationIdLoader.js.map +1 -0
- package/lib-prod/typeorm/query-builder/RelationLoader.d.ts +59 -0
- package/lib-prod/typeorm/query-builder/RelationLoader.js +282 -0
- package/lib-prod/typeorm/query-builder/RelationLoader.js.map +1 -0
- package/lib-prod/typeorm/query-builder/RelationQueryBuilder.d.ts +69 -0
- package/lib-prod/typeorm/query-builder/RelationQueryBuilder.js +164 -0
- package/lib-prod/typeorm/query-builder/RelationQueryBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/RelationRemover.d.ts +16 -0
- package/lib-prod/typeorm/query-builder/RelationRemover.js +144 -0
- package/lib-prod/typeorm/query-builder/RelationRemover.js.map +1 -0
- package/lib-prod/typeorm/query-builder/RelationUpdater.d.ts +16 -0
- package/lib-prod/typeorm/query-builder/RelationUpdater.js +153 -0
- package/lib-prod/typeorm/query-builder/RelationUpdater.js.map +1 -0
- package/lib-prod/typeorm/query-builder/ReturningResultsEntityUpdator.d.ts +30 -0
- package/lib-prod/typeorm/query-builder/ReturningResultsEntityUpdator.js +169 -0
- package/lib-prod/typeorm/query-builder/ReturningResultsEntityUpdator.js.map +1 -0
- package/lib-prod/typeorm/query-builder/SelectQuery.d.ts +5 -0
- package/lib-prod/typeorm/query-builder/SelectQuery.js +3 -0
- package/lib-prod/typeorm/query-builder/SelectQuery.js.map +1 -0
- package/lib-prod/typeorm/query-builder/SelectQueryBuilder.d.ts +669 -0
- package/lib-prod/typeorm/query-builder/SelectQueryBuilder.js +2516 -0
- package/lib-prod/typeorm/query-builder/SelectQueryBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/SelectQueryBuilderOption.d.ts +1 -0
- package/lib-prod/typeorm/query-builder/SelectQueryBuilderOption.js +3 -0
- package/lib-prod/typeorm/query-builder/SelectQueryBuilderOption.js.map +1 -0
- package/lib-prod/typeorm/query-builder/SoftDeleteQueryBuilder.d.ts +138 -0
- package/lib-prod/typeorm/query-builder/SoftDeleteQueryBuilder.js +381 -0
- package/lib-prod/typeorm/query-builder/SoftDeleteQueryBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/UpdateQueryBuilder.d.ts +143 -0
- package/lib-prod/typeorm/query-builder/UpdateQueryBuilder.js +541 -0
- package/lib-prod/typeorm/query-builder/UpdateQueryBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/WhereClause.d.ts +16 -0
- package/lib-prod/typeorm/query-builder/WhereClause.js +3 -0
- package/lib-prod/typeorm/query-builder/WhereClause.js.map +1 -0
- package/lib-prod/typeorm/query-builder/WhereExpressionBuilder.d.ts +126 -0
- package/lib-prod/typeorm/query-builder/WhereExpressionBuilder.js +3 -0
- package/lib-prod/typeorm/query-builder/WhereExpressionBuilder.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountAttribute.d.ts +53 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountAttribute.js +96 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountAttribute.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountLoadResult.d.ts +8 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountLoadResult.js +3 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountLoadResult.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountLoader.d.ts +11 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountLoader.js +170 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountLoader.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.d.ts +7 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.js +55 -0
- package/lib-prod/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdAttribute.d.ts +64 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdAttribute.js +107 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdAttribute.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdLoadResult.d.ts +5 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdLoadResult.js +3 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdLoadResult.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdLoader.d.ts +11 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdLoader.js +277 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdLoader.js.map +1 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.d.ts +7 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.js +55 -0
- package/lib-prod/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.js.map +1 -0
- package/lib-prod/typeorm/query-builder/result/DeleteResult.d.ts +16 -0
- package/lib-prod/typeorm/query-builder/result/DeleteResult.js +25 -0
- package/lib-prod/typeorm/query-builder/result/DeleteResult.js.map +1 -0
- package/lib-prod/typeorm/query-builder/result/InsertResult.d.ts +22 -0
- package/lib-prod/typeorm/query-builder/result/InsertResult.js +29 -0
- package/lib-prod/typeorm/query-builder/result/InsertResult.js.map +1 -0
- package/lib-prod/typeorm/query-builder/result/UpdateResult.d.ts +26 -0
- package/lib-prod/typeorm/query-builder/result/UpdateResult.js +35 -0
- package/lib-prod/typeorm/query-builder/result/UpdateResult.js.map +1 -0
- package/lib-prod/typeorm/query-builder/transformer/DocumentToEntityTransformer.d.ts +12 -0
- package/lib-prod/typeorm/query-builder/transformer/DocumentToEntityTransformer.js +189 -0
- package/lib-prod/typeorm/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -0
- package/lib-prod/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.d.ts +12 -0
- package/lib-prod/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.js +115 -0
- package/lib-prod/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.js.map +1 -0
- package/lib-prod/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.d.ts +14 -0
- package/lib-prod/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.js +88 -0
- package/lib-prod/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.js.map +1 -0
- package/lib-prod/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.d.ts +55 -0
- package/lib-prod/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js +424 -0
- package/lib-prod/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -0
- package/lib-prod/typeorm/query-runner/BaseQueryRunner.d.ts +203 -0
- package/lib-prod/typeorm/query-runner/BaseQueryRunner.js +462 -0
- package/lib-prod/typeorm/query-runner/BaseQueryRunner.js.map +1 -0
- package/lib-prod/typeorm/query-runner/QueryLock.d.ts +4 -0
- package/lib-prod/typeorm/query-runner/QueryLock.js +25 -0
- package/lib-prod/typeorm/query-runner/QueryLock.js.map +1 -0
- package/lib-prod/typeorm/query-runner/QueryResult.d.ts +17 -0
- package/lib-prod/typeorm/query-runner/QueryResult.js +22 -0
- package/lib-prod/typeorm/query-runner/QueryResult.js.map +1 -0
- package/lib-prod/typeorm/query-runner/QueryRunner.d.ts +359 -0
- package/lib-prod/typeorm/query-runner/QueryRunner.js +3 -0
- package/lib-prod/typeorm/query-runner/QueryRunner.js.map +1 -0
- package/lib-prod/typeorm/relation-path.d.ts +6 -0
- package/lib-prod/typeorm/relation-path.js +3 -0
- package/lib-prod/typeorm/relation-path.js.map +1 -0
- package/lib-prod/typeorm/repository/AbstractRepository.d.ts +51 -0
- package/lib-prod/typeorm/repository/AbstractRepository.js +98 -0
- package/lib-prod/typeorm/repository/AbstractRepository.js.map +1 -0
- package/lib-prod/typeorm/repository/BaseEntity.d.ts +297 -0
- package/lib-prod/typeorm/repository/BaseEntity.js +298 -0
- package/lib-prod/typeorm/repository/BaseEntity.js.map +1 -0
- package/lib-prod/typeorm/repository/EntityId.d.ts +2 -0
- package/lib-prod/typeorm/repository/EntityId.js +3 -0
- package/lib-prod/typeorm/repository/EntityId.js.map +1 -0
- package/lib-prod/typeorm/repository/FindTreesOptions.d.ts +9 -0
- package/lib-prod/typeorm/repository/FindTreesOptions.js +3 -0
- package/lib-prod/typeorm/repository/FindTreesOptions.js.map +1 -0
- package/lib-prod/typeorm/repository/MongoRepository.d.ts +262 -0
- package/lib-prod/typeorm/repository/MongoRepository.js +336 -0
- package/lib-prod/typeorm/repository/MongoRepository.js.map +1 -0
- package/lib-prod/typeorm/repository/RemoveOptions.d.ts +27 -0
- package/lib-prod/typeorm/repository/RemoveOptions.js +3 -0
- package/lib-prod/typeorm/repository/RemoveOptions.js.map +1 -0
- package/lib-prod/typeorm/repository/Repository.d.ts +291 -0
- package/lib-prod/typeorm/repository/Repository.js +307 -0
- package/lib-prod/typeorm/repository/Repository.js.map +1 -0
- package/lib-prod/typeorm/repository/SaveOptions.d.ts +35 -0
- package/lib-prod/typeorm/repository/SaveOptions.js +3 -0
- package/lib-prod/typeorm/repository/SaveOptions.js.map +1 -0
- package/lib-prod/typeorm/repository/TreeRepository.d.ts +55 -0
- package/lib-prod/typeorm/repository/TreeRepository.js +265 -0
- package/lib-prod/typeorm/repository/TreeRepository.js.map +1 -0
- package/lib-prod/typeorm/repository/UpsertOptions.d.ts +10 -0
- package/lib-prod/typeorm/repository/UpsertOptions.js +3 -0
- package/lib-prod/typeorm/repository/UpsertOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/MongoSchemaBuilder.d.ts +29 -0
- package/lib-prod/typeorm/schema-builder/MongoSchemaBuilder.js +66 -0
- package/lib-prod/typeorm/schema-builder/MongoSchemaBuilder.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/RdbmsSchemaBuilder.d.ts +144 -0
- package/lib-prod/typeorm/schema-builder/RdbmsSchemaBuilder.js +847 -0
- package/lib-prod/typeorm/schema-builder/RdbmsSchemaBuilder.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/SchemaBuilder.d.ts +14 -0
- package/lib-prod/typeorm/schema-builder/SchemaBuilder.js +3 -0
- package/lib-prod/typeorm/schema-builder/SchemaBuilder.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/TableCheckOptions.d.ts +17 -0
- package/lib-prod/typeorm/schema-builder/options/TableCheckOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/TableCheckOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/TableColumnOptions.d.ts +122 -0
- package/lib-prod/typeorm/schema-builder/options/TableColumnOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/TableColumnOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/TableExclusionOptions.d.ts +13 -0
- package/lib-prod/typeorm/schema-builder/options/TableExclusionOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/TableExclusionOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/TableForeignKeyOptions.d.ts +44 -0
- package/lib-prod/typeorm/schema-builder/options/TableForeignKeyOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/TableForeignKeyOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/TableIndexOptions.d.ts +44 -0
- package/lib-prod/typeorm/schema-builder/options/TableIndexOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/TableIndexOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/TableOptions.d.ts +61 -0
- package/lib-prod/typeorm/schema-builder/options/TableOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/TableOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/TableUniqueOptions.d.ts +18 -0
- package/lib-prod/typeorm/schema-builder/options/TableUniqueOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/TableUniqueOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/options/ViewOptions.d.ts +26 -0
- package/lib-prod/typeorm/schema-builder/options/ViewOptions.js +3 -0
- package/lib-prod/typeorm/schema-builder/options/ViewOptions.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/table/Table.d.ts +142 -0
- package/lib-prod/typeorm/schema-builder/table/Table.js +313 -0
- package/lib-prod/typeorm/schema-builder/table/Table.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/table/TableCheck.d.ts +29 -0
- package/lib-prod/typeorm/schema-builder/table/TableCheck.js +59 -0
- package/lib-prod/typeorm/schema-builder/table/TableCheck.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/table/TableColumn.d.ts +126 -0
- package/lib-prod/typeorm/schema-builder/table/TableColumn.js +199 -0
- package/lib-prod/typeorm/schema-builder/table/TableColumn.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/table/TableExclusion.d.ts +25 -0
- package/lib-prod/typeorm/schema-builder/table/TableExclusion.js +53 -0
- package/lib-prod/typeorm/schema-builder/table/TableExclusion.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/table/TableForeignKey.d.ts +57 -0
- package/lib-prod/typeorm/schema-builder/table/TableForeignKey.js +105 -0
- package/lib-prod/typeorm/schema-builder/table/TableForeignKey.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/table/TableIndex.d.ts +56 -0
- package/lib-prod/typeorm/schema-builder/table/TableIndex.js +102 -0
- package/lib-prod/typeorm/schema-builder/table/TableIndex.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/table/TableUnique.d.ts +30 -0
- package/lib-prod/typeorm/schema-builder/table/TableUnique.js +61 -0
- package/lib-prod/typeorm/schema-builder/table/TableUnique.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/util/TableUtils.d.ts +6 -0
- package/lib-prod/typeorm/schema-builder/util/TableUtils.js +40 -0
- package/lib-prod/typeorm/schema-builder/util/TableUtils.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/util/ViewUtils.d.ts +7 -0
- package/lib-prod/typeorm/schema-builder/util/ViewUtils.js +26 -0
- package/lib-prod/typeorm/schema-builder/util/ViewUtils.js.map +1 -0
- package/lib-prod/typeorm/schema-builder/view/View.d.ts +37 -0
- package/lib-prod/typeorm/schema-builder/view/View.js +77 -0
- package/lib-prod/typeorm/schema-builder/view/View.js.map +1 -0
- package/lib-prod/typeorm/subscriber/Broadcaster.d.ts +167 -0
- package/lib-prod/typeorm/subscriber/Broadcaster.js +613 -0
- package/lib-prod/typeorm/subscriber/Broadcaster.js.map +1 -0
- package/lib-prod/typeorm/subscriber/BroadcasterResult.d.ts +17 -0
- package/lib-prod/typeorm/subscriber/BroadcasterResult.js +27 -0
- package/lib-prod/typeorm/subscriber/BroadcasterResult.js.map +1 -0
- package/lib-prod/typeorm/subscriber/EntitySubscriberInterface.d.ts +92 -0
- package/lib-prod/typeorm/subscriber/EntitySubscriberInterface.js +3 -0
- package/lib-prod/typeorm/subscriber/EntitySubscriberInterface.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/InsertEvent.d.ts +31 -0
- package/lib-prod/typeorm/subscriber/event/InsertEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/InsertEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/LoadEvent.d.ts +31 -0
- package/lib-prod/typeorm/subscriber/event/LoadEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/LoadEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/RecoverEvent.d.ts +6 -0
- package/lib-prod/typeorm/subscriber/event/RecoverEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/RecoverEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/RemoveEvent.d.ts +40 -0
- package/lib-prod/typeorm/subscriber/event/RemoveEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/RemoveEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/SoftRemoveEvent.d.ts +6 -0
- package/lib-prod/typeorm/subscriber/event/SoftRemoveEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/SoftRemoveEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/TransactionCommitEvent.d.ts +22 -0
- package/lib-prod/typeorm/subscriber/event/TransactionCommitEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/TransactionCommitEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/TransactionRollbackEvent.d.ts +22 -0
- package/lib-prod/typeorm/subscriber/event/TransactionRollbackEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/TransactionRollbackEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/TransactionStartEvent.d.ts +22 -0
- package/lib-prod/typeorm/subscriber/event/TransactionStartEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/TransactionStartEvent.js.map +1 -0
- package/lib-prod/typeorm/subscriber/event/UpdateEvent.d.ts +46 -0
- package/lib-prod/typeorm/subscriber/event/UpdateEvent.js +3 -0
- package/lib-prod/typeorm/subscriber/event/UpdateEvent.js.map +1 -0
- package/lib-prod/typeorm/util/ApplyValueTransformers.d.ts +5 -0
- package/lib-prod/typeorm/util/ApplyValueTransformers.js +24 -0
- package/lib-prod/typeorm/util/ApplyValueTransformers.js.map +1 -0
- package/lib-prod/typeorm/util/DateUtils.d.ts +58 -0
- package/lib-prod/typeorm/util/DateUtils.js +225 -0
- package/lib-prod/typeorm/util/DateUtils.js.map +1 -0
- package/lib-prod/typeorm/util/DepGraph.d.ts +64 -0
- package/lib-prod/typeorm/util/DepGraph.js +227 -0
- package/lib-prod/typeorm/util/DepGraph.js.map +1 -0
- package/lib-prod/typeorm/util/DirectoryExportedClassesLoader.d.ts +9 -0
- package/lib-prod/typeorm/util/DirectoryExportedClassesLoader.js +70 -0
- package/lib-prod/typeorm/util/DirectoryExportedClassesLoader.js.map +1 -0
- package/lib-prod/typeorm/util/ImportUtils.d.ts +1 -0
- package/lib-prod/typeorm/util/ImportUtils.js +82 -0
- package/lib-prod/typeorm/util/ImportUtils.js.map +1 -0
- package/lib-prod/typeorm/util/InstanceChecker.d.ts +63 -0
- package/lib-prod/typeorm/util/InstanceChecker.js +116 -0
- package/lib-prod/typeorm/util/InstanceChecker.js.map +1 -0
- package/lib-prod/typeorm/util/ObjectUtils.d.ts +37 -0
- package/lib-prod/typeorm/util/ObjectUtils.js +40 -0
- package/lib-prod/typeorm/util/ObjectUtils.js.map +1 -0
- package/lib-prod/typeorm/util/OrmUtils.d.ts +52 -0
- package/lib-prod/typeorm/util/OrmUtils.js +347 -0
- package/lib-prod/typeorm/util/OrmUtils.js.map +1 -0
- package/lib-prod/typeorm/util/PathUtils.d.ts +10 -0
- package/lib-prod/typeorm/util/PathUtils.js +38 -0
- package/lib-prod/typeorm/util/PathUtils.js.map +1 -0
- package/lib-prod/typeorm/util/RandomGenerator.d.ts +15 -0
- package/lib-prod/typeorm/util/RandomGenerator.js +153 -0
- package/lib-prod/typeorm/util/RandomGenerator.js.map +1 -0
- package/lib-prod/typeorm/util/StringUtils.d.ts +63 -0
- package/lib-prod/typeorm/util/StringUtils.js +115 -0
- package/lib-prod/typeorm/util/StringUtils.js.map +1 -0
- package/lib-prod/typeorm/util/TreeRepositoryUtils.d.ts +23 -0
- package/lib-prod/typeorm/util/TreeRepositoryUtils.js +59 -0
- package/lib-prod/typeorm/util/TreeRepositoryUtils.js.map +1 -0
- package/lib-prod/typeorm/util/VersionUtils.d.ts +4 -0
- package/lib-prod/typeorm/util/VersionUtils.js +19 -0
- package/lib-prod/typeorm/util/VersionUtils.js.map +1 -0
- package/lib-prod/typeorm/util/escapeRegExp.d.ts +1 -0
- package/lib-prod/typeorm/util/escapeRegExp.js +9 -0
- package/lib-prod/typeorm/util/escapeRegExp.js.map +1 -0
- package/package.json +12 -4
- package/tmp-environment.json +43 -0
- package/websql/package.json +1 -1
- package/websql-prod/README.md +24 -0
- package/websql-prod/fesm2022/taon-typeorm-websql.mjs +30423 -0
- package/websql-prod/fesm2022/taon-typeorm-websql.mjs.map +1 -0
- package/websql-prod/types/taon-typeorm-websql.d.ts +12402 -0
|
@@ -0,0 +1,2612 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostgresQueryRunner = void 0;
|
|
4
|
+
const error_1 = require("../../error");
|
|
5
|
+
const QueryFailedError_1 = require("../../error/QueryFailedError");
|
|
6
|
+
const QueryRunnerAlreadyReleasedError_1 = require("../../error/QueryRunnerAlreadyReleasedError");
|
|
7
|
+
const TransactionNotStartedError_1 = require("../../error/TransactionNotStartedError");
|
|
8
|
+
const BaseQueryRunner_1 = require("../../query-runner/BaseQueryRunner");
|
|
9
|
+
const QueryResult_1 = require("../../query-runner/QueryResult");
|
|
10
|
+
const Table_1 = require("../../schema-builder/table/Table");
|
|
11
|
+
const TableCheck_1 = require("../../schema-builder/table/TableCheck");
|
|
12
|
+
const TableColumn_1 = require("../../schema-builder/table/TableColumn");
|
|
13
|
+
const TableExclusion_1 = require("../../schema-builder/table/TableExclusion");
|
|
14
|
+
const TableForeignKey_1 = require("../../schema-builder/table/TableForeignKey");
|
|
15
|
+
const TableIndex_1 = require("../../schema-builder/table/TableIndex");
|
|
16
|
+
const TableUnique_1 = require("../../schema-builder/table/TableUnique");
|
|
17
|
+
const View_1 = require("../../schema-builder/view/View");
|
|
18
|
+
const Broadcaster_1 = require("../../subscriber/Broadcaster");
|
|
19
|
+
const InstanceChecker_1 = require("../../util/InstanceChecker");
|
|
20
|
+
const OrmUtils_1 = require("../../util/OrmUtils");
|
|
21
|
+
const VersionUtils_1 = require("../../util/VersionUtils");
|
|
22
|
+
const Query_1 = require("../Query");
|
|
23
|
+
const MetadataTableType_1 = require("../types/MetadataTableType");
|
|
24
|
+
/**
|
|
25
|
+
* Runs queries on a single postgres database connection.
|
|
26
|
+
*/
|
|
27
|
+
class PostgresQueryRunner extends BaseQueryRunner_1.BaseQueryRunner {
|
|
28
|
+
// -------------------------------------------------------------------------
|
|
29
|
+
// Public Implemented Properties
|
|
30
|
+
// -------------------------------------------------------------------------
|
|
31
|
+
/**
|
|
32
|
+
* Database driver used by connection.
|
|
33
|
+
*/
|
|
34
|
+
driver;
|
|
35
|
+
// -------------------------------------------------------------------------
|
|
36
|
+
// Protected Properties
|
|
37
|
+
// -------------------------------------------------------------------------
|
|
38
|
+
/**
|
|
39
|
+
* Promise used to obtain a database connection for a first time.
|
|
40
|
+
*/
|
|
41
|
+
databaseConnectionPromise;
|
|
42
|
+
/**
|
|
43
|
+
* Special callback provided by a driver used to release a created connection.
|
|
44
|
+
*/
|
|
45
|
+
releaseCallback;
|
|
46
|
+
// -------------------------------------------------------------------------
|
|
47
|
+
// Constructor
|
|
48
|
+
// -------------------------------------------------------------------------
|
|
49
|
+
constructor(driver, mode) {
|
|
50
|
+
super();
|
|
51
|
+
this.driver = driver;
|
|
52
|
+
this.connection = driver.connection;
|
|
53
|
+
this.mode = mode;
|
|
54
|
+
this.broadcaster = new Broadcaster_1.Broadcaster(this);
|
|
55
|
+
}
|
|
56
|
+
// -------------------------------------------------------------------------
|
|
57
|
+
// Public Methods
|
|
58
|
+
// -------------------------------------------------------------------------
|
|
59
|
+
/**
|
|
60
|
+
* Creates/uses database connection from the connection pool to perform further operations.
|
|
61
|
+
* Returns obtained database connection.
|
|
62
|
+
*/
|
|
63
|
+
connect() {
|
|
64
|
+
if (this.databaseConnection)
|
|
65
|
+
return Promise.resolve(this.databaseConnection);
|
|
66
|
+
if (this.databaseConnectionPromise)
|
|
67
|
+
return this.databaseConnectionPromise;
|
|
68
|
+
if (this.mode === "slave" && this.driver.isReplicated) {
|
|
69
|
+
this.databaseConnectionPromise = this.driver
|
|
70
|
+
.obtainSlaveConnection()
|
|
71
|
+
.then(([connection, release]) => {
|
|
72
|
+
this.driver.connectedQueryRunners.push(this);
|
|
73
|
+
this.databaseConnection = connection;
|
|
74
|
+
const onErrorCallback = (err) => this.releasePostgresConnection(err);
|
|
75
|
+
this.releaseCallback = (err) => {
|
|
76
|
+
this.databaseConnection.removeListener("error", onErrorCallback);
|
|
77
|
+
release(err);
|
|
78
|
+
};
|
|
79
|
+
this.databaseConnection.on("error", onErrorCallback);
|
|
80
|
+
return this.databaseConnection;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// master
|
|
85
|
+
this.databaseConnectionPromise = this.driver
|
|
86
|
+
.obtainMasterConnection()
|
|
87
|
+
.then(([connection, release]) => {
|
|
88
|
+
this.driver.connectedQueryRunners.push(this);
|
|
89
|
+
this.databaseConnection = connection;
|
|
90
|
+
const onErrorCallback = (err) => this.releasePostgresConnection(err);
|
|
91
|
+
this.releaseCallback = (err) => {
|
|
92
|
+
this.databaseConnection.removeListener("error", onErrorCallback);
|
|
93
|
+
release(err);
|
|
94
|
+
};
|
|
95
|
+
this.databaseConnection.on("error", onErrorCallback);
|
|
96
|
+
return this.databaseConnection;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return this.databaseConnectionPromise;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Release a connection back to the pool, optionally specifying an Error to release with.
|
|
103
|
+
* Per pg-pool documentation this will prevent the pool from re-using the broken connection.
|
|
104
|
+
*/
|
|
105
|
+
async releasePostgresConnection(err) {
|
|
106
|
+
if (this.isReleased) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.isReleased = true;
|
|
110
|
+
if (this.releaseCallback) {
|
|
111
|
+
this.releaseCallback(err);
|
|
112
|
+
this.releaseCallback = undefined;
|
|
113
|
+
}
|
|
114
|
+
const index = this.driver.connectedQueryRunners.indexOf(this);
|
|
115
|
+
if (index !== -1) {
|
|
116
|
+
this.driver.connectedQueryRunners.splice(index, 1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Releases used database connection.
|
|
121
|
+
* You cannot use query runner methods once its released.
|
|
122
|
+
*/
|
|
123
|
+
release() {
|
|
124
|
+
return this.releasePostgresConnection();
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Starts transaction.
|
|
128
|
+
*/
|
|
129
|
+
async startTransaction(isolationLevel) {
|
|
130
|
+
this.isTransactionActive = true;
|
|
131
|
+
try {
|
|
132
|
+
await this.broadcaster.broadcast("BeforeTransactionStart");
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
this.isTransactionActive = false;
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
if (this.transactionDepth === 0) {
|
|
139
|
+
await this.query("START TRANSACTION");
|
|
140
|
+
if (isolationLevel) {
|
|
141
|
+
await this.query("SET TRANSACTION ISOLATION LEVEL " + isolationLevel);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
await this.query(`SAVEPOINT typeorm_${this.transactionDepth}`);
|
|
146
|
+
}
|
|
147
|
+
this.transactionDepth += 1;
|
|
148
|
+
await this.broadcaster.broadcast("AfterTransactionStart");
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Commits transaction.
|
|
152
|
+
* Error will be thrown if transaction was not started.
|
|
153
|
+
*/
|
|
154
|
+
async commitTransaction() {
|
|
155
|
+
if (!this.isTransactionActive)
|
|
156
|
+
throw new TransactionNotStartedError_1.TransactionNotStartedError();
|
|
157
|
+
await this.broadcaster.broadcast("BeforeTransactionCommit");
|
|
158
|
+
if (this.transactionDepth > 1) {
|
|
159
|
+
await this.query(`RELEASE SAVEPOINT typeorm_${this.transactionDepth - 1}`);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
await this.query("COMMIT");
|
|
163
|
+
this.isTransactionActive = false;
|
|
164
|
+
}
|
|
165
|
+
this.transactionDepth -= 1;
|
|
166
|
+
await this.broadcaster.broadcast("AfterTransactionCommit");
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Rollbacks transaction.
|
|
170
|
+
* Error will be thrown if transaction was not started.
|
|
171
|
+
*/
|
|
172
|
+
async rollbackTransaction() {
|
|
173
|
+
if (!this.isTransactionActive)
|
|
174
|
+
throw new TransactionNotStartedError_1.TransactionNotStartedError();
|
|
175
|
+
await this.broadcaster.broadcast("BeforeTransactionRollback");
|
|
176
|
+
if (this.transactionDepth > 1) {
|
|
177
|
+
await this.query(`ROLLBACK TO SAVEPOINT typeorm_${this.transactionDepth - 1}`);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
await this.query("ROLLBACK");
|
|
181
|
+
this.isTransactionActive = false;
|
|
182
|
+
}
|
|
183
|
+
this.transactionDepth -= 1;
|
|
184
|
+
await this.broadcaster.broadcast("AfterTransactionRollback");
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Executes a given SQL query.
|
|
188
|
+
*/
|
|
189
|
+
async query(query, parameters, useStructuredResult = false) {
|
|
190
|
+
if (this.isReleased)
|
|
191
|
+
throw new QueryRunnerAlreadyReleasedError_1.QueryRunnerAlreadyReleasedError();
|
|
192
|
+
const databaseConnection = await this.connect();
|
|
193
|
+
this.driver.connection.logger.logQuery(query, parameters, this);
|
|
194
|
+
try {
|
|
195
|
+
const queryStartTime = +new Date();
|
|
196
|
+
const raw = await databaseConnection.query(query, parameters);
|
|
197
|
+
// log slow queries if maxQueryExecution time is set
|
|
198
|
+
const maxQueryExecutionTime = this.driver.options.maxQueryExecutionTime;
|
|
199
|
+
const queryEndTime = +new Date();
|
|
200
|
+
const queryExecutionTime = queryEndTime - queryStartTime;
|
|
201
|
+
if (maxQueryExecutionTime &&
|
|
202
|
+
queryExecutionTime > maxQueryExecutionTime)
|
|
203
|
+
this.driver.connection.logger.logQuerySlow(queryExecutionTime, query, parameters, this);
|
|
204
|
+
const result = new QueryResult_1.QueryResult();
|
|
205
|
+
if (raw) {
|
|
206
|
+
if (raw.hasOwnProperty("rows")) {
|
|
207
|
+
result.records = raw.rows;
|
|
208
|
+
}
|
|
209
|
+
if (raw.hasOwnProperty("rowCount")) {
|
|
210
|
+
result.affected = raw.rowCount;
|
|
211
|
+
}
|
|
212
|
+
switch (raw.command) {
|
|
213
|
+
case "DELETE":
|
|
214
|
+
case "UPDATE":
|
|
215
|
+
// for UPDATE and DELETE query additionally return number of affected rows
|
|
216
|
+
result.raw = [raw.rows, raw.rowCount];
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
result.raw = raw.rows;
|
|
220
|
+
}
|
|
221
|
+
if (!useStructuredResult) {
|
|
222
|
+
return result.raw;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
this.driver.connection.logger.logQueryError(err, query, parameters, this);
|
|
229
|
+
throw new QueryFailedError_1.QueryFailedError(query, parameters, err);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Returns raw data stream.
|
|
234
|
+
*/
|
|
235
|
+
async stream(query, parameters, onEnd, onError) {
|
|
236
|
+
const QueryStream = this.driver.loadStreamDependency();
|
|
237
|
+
if (this.isReleased)
|
|
238
|
+
throw new QueryRunnerAlreadyReleasedError_1.QueryRunnerAlreadyReleasedError();
|
|
239
|
+
const databaseConnection = await this.connect();
|
|
240
|
+
this.driver.connection.logger.logQuery(query, parameters, this);
|
|
241
|
+
const stream = databaseConnection.query(new QueryStream(query, parameters));
|
|
242
|
+
if (onEnd)
|
|
243
|
+
stream.on("end", onEnd);
|
|
244
|
+
if (onError)
|
|
245
|
+
stream.on("error", onError);
|
|
246
|
+
return stream;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns all available database names including system databases.
|
|
250
|
+
*/
|
|
251
|
+
async getDatabases() {
|
|
252
|
+
return Promise.resolve([]);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Returns all available schema names including system schemas.
|
|
256
|
+
* If database parameter specified, returns schemas of that database.
|
|
257
|
+
*/
|
|
258
|
+
async getSchemas(database) {
|
|
259
|
+
return Promise.resolve([]);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Checks if database with the given name exist.
|
|
263
|
+
*/
|
|
264
|
+
async hasDatabase(database) {
|
|
265
|
+
const result = await this.query(`SELECT * FROM pg_database WHERE datname='${database}';`);
|
|
266
|
+
return result.length ? true : false;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Loads currently using database
|
|
270
|
+
*/
|
|
271
|
+
async getCurrentDatabase() {
|
|
272
|
+
const query = await this.query(`SELECT * FROM current_database()`);
|
|
273
|
+
return query[0]["current_database"];
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Checks if schema with the given name exist.
|
|
277
|
+
*/
|
|
278
|
+
async hasSchema(schema) {
|
|
279
|
+
const result = await this.query(`SELECT * FROM "information_schema"."schemata" WHERE "schema_name" = '${schema}'`);
|
|
280
|
+
return result.length ? true : false;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Loads currently using database schema
|
|
284
|
+
*/
|
|
285
|
+
async getCurrentSchema() {
|
|
286
|
+
const query = await this.query(`SELECT * FROM current_schema()`);
|
|
287
|
+
return query[0]["current_schema"];
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Checks if table with the given name exist in the database.
|
|
291
|
+
*/
|
|
292
|
+
async hasTable(tableOrName) {
|
|
293
|
+
const parsedTableName = this.driver.parseTableName(tableOrName);
|
|
294
|
+
if (!parsedTableName.schema) {
|
|
295
|
+
parsedTableName.schema = await this.getCurrentSchema();
|
|
296
|
+
}
|
|
297
|
+
const sql = `SELECT * FROM "information_schema"."tables" WHERE "table_schema" = '${parsedTableName.schema}' AND "table_name" = '${parsedTableName.tableName}'`;
|
|
298
|
+
const result = await this.query(sql);
|
|
299
|
+
return result.length ? true : false;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Checks if column with the given name exist in the given table.
|
|
303
|
+
*/
|
|
304
|
+
async hasColumn(tableOrName, columnName) {
|
|
305
|
+
const parsedTableName = this.driver.parseTableName(tableOrName);
|
|
306
|
+
if (!parsedTableName.schema) {
|
|
307
|
+
parsedTableName.schema = await this.getCurrentSchema();
|
|
308
|
+
}
|
|
309
|
+
const sql = `SELECT * FROM "information_schema"."columns" WHERE "table_schema" = '${parsedTableName.schema}' AND "table_name" = '${parsedTableName.tableName}' AND "column_name" = '${columnName}'`;
|
|
310
|
+
const result = await this.query(sql);
|
|
311
|
+
return result.length ? true : false;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Creates a new database.
|
|
315
|
+
* Note: Postgres does not support database creation inside a transaction block.
|
|
316
|
+
*/
|
|
317
|
+
async createDatabase(database, ifNotExist) {
|
|
318
|
+
if (ifNotExist) {
|
|
319
|
+
const databaseAlreadyExists = await this.hasDatabase(database);
|
|
320
|
+
if (databaseAlreadyExists)
|
|
321
|
+
return Promise.resolve();
|
|
322
|
+
}
|
|
323
|
+
const up = `CREATE DATABASE "${database}"`;
|
|
324
|
+
const down = `DROP DATABASE "${database}"`;
|
|
325
|
+
await this.executeQueries(new Query_1.Query(up), new Query_1.Query(down));
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Drops database.
|
|
329
|
+
* Note: Postgres does not support database dropping inside a transaction block.
|
|
330
|
+
*/
|
|
331
|
+
async dropDatabase(database, ifExist) {
|
|
332
|
+
const up = ifExist
|
|
333
|
+
? `DROP DATABASE IF EXISTS "${database}"`
|
|
334
|
+
: `DROP DATABASE "${database}"`;
|
|
335
|
+
const down = `CREATE DATABASE "${database}"`;
|
|
336
|
+
await this.executeQueries(new Query_1.Query(up), new Query_1.Query(down));
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Creates a new table schema.
|
|
340
|
+
*/
|
|
341
|
+
async createSchema(schemaPath, ifNotExist) {
|
|
342
|
+
const schema = schemaPath.indexOf(".") === -1
|
|
343
|
+
? schemaPath
|
|
344
|
+
: schemaPath.split(".")[1];
|
|
345
|
+
const up = ifNotExist
|
|
346
|
+
? `CREATE SCHEMA IF NOT EXISTS "${schema}"`
|
|
347
|
+
: `CREATE SCHEMA "${schema}"`;
|
|
348
|
+
const down = `DROP SCHEMA "${schema}" CASCADE`;
|
|
349
|
+
await this.executeQueries(new Query_1.Query(up), new Query_1.Query(down));
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Drops table schema.
|
|
353
|
+
*/
|
|
354
|
+
async dropSchema(schemaPath, ifExist, isCascade) {
|
|
355
|
+
const schema = schemaPath.indexOf(".") === -1
|
|
356
|
+
? schemaPath
|
|
357
|
+
: schemaPath.split(".")[1];
|
|
358
|
+
const up = ifExist
|
|
359
|
+
? `DROP SCHEMA IF EXISTS "${schema}" ${isCascade ? "CASCADE" : ""}`
|
|
360
|
+
: `DROP SCHEMA "${schema}" ${isCascade ? "CASCADE" : ""}`;
|
|
361
|
+
const down = `CREATE SCHEMA "${schema}"`;
|
|
362
|
+
await this.executeQueries(new Query_1.Query(up), new Query_1.Query(down));
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Creates a new table.
|
|
366
|
+
*/
|
|
367
|
+
async createTable(table, ifNotExist = false, createForeignKeys = true, createIndices = true) {
|
|
368
|
+
if (ifNotExist) {
|
|
369
|
+
const isTableExist = await this.hasTable(table);
|
|
370
|
+
if (isTableExist)
|
|
371
|
+
return Promise.resolve();
|
|
372
|
+
}
|
|
373
|
+
const upQueries = [];
|
|
374
|
+
const downQueries = [];
|
|
375
|
+
// if table have column with ENUM type, we must create this type in postgres.
|
|
376
|
+
const enumColumns = table.columns.filter((column) => column.type === "enum" || column.type === "simple-enum");
|
|
377
|
+
const createdEnumTypes = [];
|
|
378
|
+
for (const column of enumColumns) {
|
|
379
|
+
// TODO: Should also check if values of existing type matches expected ones
|
|
380
|
+
const hasEnum = await this.hasEnumType(table, column);
|
|
381
|
+
const enumName = this.buildEnumName(table, column);
|
|
382
|
+
// if enum with the same "enumName" is defined more then once, me must prevent double creation
|
|
383
|
+
if (!hasEnum && createdEnumTypes.indexOf(enumName) === -1) {
|
|
384
|
+
createdEnumTypes.push(enumName);
|
|
385
|
+
upQueries.push(this.createEnumTypeSql(table, column, enumName));
|
|
386
|
+
downQueries.push(this.dropEnumTypeSql(table, column, enumName));
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// if table have column with generated type, we must add the expression to the metadata table
|
|
390
|
+
const generatedColumns = table.columns.filter((column) => column.generatedType === "STORED" && column.asExpression);
|
|
391
|
+
for (const column of generatedColumns) {
|
|
392
|
+
const tableNameWithSchema = (await this.getTableNameWithSchema(table.name)).split(".");
|
|
393
|
+
const tableName = tableNameWithSchema[1];
|
|
394
|
+
const schema = tableNameWithSchema[0];
|
|
395
|
+
const insertQuery = this.insertTypeormMetadataSql({
|
|
396
|
+
database: this.driver.database,
|
|
397
|
+
schema,
|
|
398
|
+
table: tableName,
|
|
399
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
400
|
+
name: column.name,
|
|
401
|
+
value: column.asExpression,
|
|
402
|
+
});
|
|
403
|
+
const deleteQuery = this.deleteTypeormMetadataSql({
|
|
404
|
+
database: this.driver.database,
|
|
405
|
+
schema,
|
|
406
|
+
table: tableName,
|
|
407
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
408
|
+
name: column.name,
|
|
409
|
+
});
|
|
410
|
+
upQueries.push(insertQuery);
|
|
411
|
+
downQueries.push(deleteQuery);
|
|
412
|
+
}
|
|
413
|
+
upQueries.push(this.createTableSql(table, createForeignKeys));
|
|
414
|
+
downQueries.push(this.dropTableSql(table));
|
|
415
|
+
// if createForeignKeys is true, we must drop created foreign keys in down query.
|
|
416
|
+
// createTable does not need separate method to create foreign keys, because it create fk's in the same query with table creation.
|
|
417
|
+
if (createForeignKeys)
|
|
418
|
+
table.foreignKeys.forEach((foreignKey) => downQueries.push(this.dropForeignKeySql(table, foreignKey)));
|
|
419
|
+
if (createIndices) {
|
|
420
|
+
table.indices.forEach((index) => {
|
|
421
|
+
// new index may be passed without name. In this case we generate index name manually.
|
|
422
|
+
if (!index.name)
|
|
423
|
+
index.name = this.connection.namingStrategy.indexName(table, index.columnNames, index.where);
|
|
424
|
+
upQueries.push(this.createIndexSql(table, index));
|
|
425
|
+
downQueries.push(this.dropIndexSql(table, index));
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
await this.executeQueries(upQueries, downQueries);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Drops the table.
|
|
432
|
+
*/
|
|
433
|
+
async dropTable(target, ifExist, dropForeignKeys = true, dropIndices = true) {
|
|
434
|
+
// It needs because if table does not exist and dropForeignKeys or dropIndices is true, we don't need
|
|
435
|
+
// to perform drop queries for foreign keys and indices.
|
|
436
|
+
if (ifExist) {
|
|
437
|
+
const isTableExist = await this.hasTable(target);
|
|
438
|
+
if (!isTableExist)
|
|
439
|
+
return Promise.resolve();
|
|
440
|
+
}
|
|
441
|
+
// if dropTable called with dropForeignKeys = true, we must create foreign keys in down query.
|
|
442
|
+
const createForeignKeys = dropForeignKeys;
|
|
443
|
+
const tablePath = this.getTablePath(target);
|
|
444
|
+
const table = await this.getCachedTable(tablePath);
|
|
445
|
+
const upQueries = [];
|
|
446
|
+
const downQueries = [];
|
|
447
|
+
if (dropIndices) {
|
|
448
|
+
table.indices.forEach((index) => {
|
|
449
|
+
upQueries.push(this.dropIndexSql(table, index));
|
|
450
|
+
downQueries.push(this.createIndexSql(table, index));
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
if (dropForeignKeys)
|
|
454
|
+
table.foreignKeys.forEach((foreignKey) => upQueries.push(this.dropForeignKeySql(table, foreignKey)));
|
|
455
|
+
upQueries.push(this.dropTableSql(table));
|
|
456
|
+
downQueries.push(this.createTableSql(table, createForeignKeys));
|
|
457
|
+
// if table had columns with generated type, we must remove the expression from the metadata table
|
|
458
|
+
const generatedColumns = table.columns.filter((column) => column.generatedType && column.asExpression);
|
|
459
|
+
for (const column of generatedColumns) {
|
|
460
|
+
const tableNameWithSchema = (await this.getTableNameWithSchema(table.name)).split(".");
|
|
461
|
+
const tableName = tableNameWithSchema[1];
|
|
462
|
+
const schema = tableNameWithSchema[0];
|
|
463
|
+
const deleteQuery = this.deleteTypeormMetadataSql({
|
|
464
|
+
database: this.driver.database,
|
|
465
|
+
schema,
|
|
466
|
+
table: tableName,
|
|
467
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
468
|
+
name: column.name,
|
|
469
|
+
});
|
|
470
|
+
const insertQuery = this.insertTypeormMetadataSql({
|
|
471
|
+
database: this.driver.database,
|
|
472
|
+
schema,
|
|
473
|
+
table: tableName,
|
|
474
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
475
|
+
name: column.name,
|
|
476
|
+
value: column.asExpression,
|
|
477
|
+
});
|
|
478
|
+
upQueries.push(deleteQuery);
|
|
479
|
+
downQueries.push(insertQuery);
|
|
480
|
+
}
|
|
481
|
+
await this.executeQueries(upQueries, downQueries);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Creates a new view.
|
|
485
|
+
*/
|
|
486
|
+
async createView(view, syncWithMetadata = false) {
|
|
487
|
+
const upQueries = [];
|
|
488
|
+
const downQueries = [];
|
|
489
|
+
upQueries.push(this.createViewSql(view));
|
|
490
|
+
if (syncWithMetadata)
|
|
491
|
+
upQueries.push(await this.insertViewDefinitionSql(view));
|
|
492
|
+
downQueries.push(this.dropViewSql(view));
|
|
493
|
+
if (syncWithMetadata)
|
|
494
|
+
downQueries.push(await this.deleteViewDefinitionSql(view));
|
|
495
|
+
await this.executeQueries(upQueries, downQueries);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Drops the view.
|
|
499
|
+
*/
|
|
500
|
+
async dropView(target) {
|
|
501
|
+
const viewName = InstanceChecker_1.InstanceChecker.isView(target) ? target.name : target;
|
|
502
|
+
const view = await this.getCachedView(viewName);
|
|
503
|
+
const upQueries = [];
|
|
504
|
+
const downQueries = [];
|
|
505
|
+
upQueries.push(await this.deleteViewDefinitionSql(view));
|
|
506
|
+
upQueries.push(this.dropViewSql(view));
|
|
507
|
+
downQueries.push(await this.insertViewDefinitionSql(view));
|
|
508
|
+
downQueries.push(this.createViewSql(view));
|
|
509
|
+
await this.executeQueries(upQueries, downQueries);
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Renames the given table.
|
|
513
|
+
*/
|
|
514
|
+
async renameTable(oldTableOrName, newTableName) {
|
|
515
|
+
const upQueries = [];
|
|
516
|
+
const downQueries = [];
|
|
517
|
+
const oldTable = InstanceChecker_1.InstanceChecker.isTable(oldTableOrName)
|
|
518
|
+
? oldTableOrName
|
|
519
|
+
: await this.getCachedTable(oldTableOrName);
|
|
520
|
+
const newTable = oldTable.clone();
|
|
521
|
+
const { schema: schemaName, tableName: oldTableName } = this.driver.parseTableName(oldTable);
|
|
522
|
+
newTable.name = schemaName
|
|
523
|
+
? `${schemaName}.${newTableName}`
|
|
524
|
+
: newTableName;
|
|
525
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(oldTable)} RENAME TO "${newTableName}"`));
|
|
526
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(newTable)} RENAME TO "${oldTableName}"`));
|
|
527
|
+
// rename column primary key constraint if it has default constraint name
|
|
528
|
+
if (newTable.primaryColumns.length > 0 &&
|
|
529
|
+
!newTable.primaryColumns[0].primaryKeyConstraintName) {
|
|
530
|
+
const columnNames = newTable.primaryColumns.map((column) => column.name);
|
|
531
|
+
const oldPkName = this.connection.namingStrategy.primaryKeyName(oldTable, columnNames);
|
|
532
|
+
const newPkName = this.connection.namingStrategy.primaryKeyName(newTable, columnNames);
|
|
533
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(newTable)} RENAME CONSTRAINT "${oldPkName}" TO "${newPkName}"`));
|
|
534
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(newTable)} RENAME CONSTRAINT "${newPkName}" TO "${oldPkName}"`));
|
|
535
|
+
}
|
|
536
|
+
// rename sequences
|
|
537
|
+
newTable.columns.map((col) => {
|
|
538
|
+
if (col.isGenerated && col.generationStrategy === "increment") {
|
|
539
|
+
const sequencePath = this.buildSequencePath(oldTable, col.name);
|
|
540
|
+
const sequenceName = this.buildSequenceName(oldTable, col.name);
|
|
541
|
+
const newSequencePath = this.buildSequencePath(newTable, col.name);
|
|
542
|
+
const newSequenceName = this.buildSequenceName(newTable, col.name);
|
|
543
|
+
const up = `ALTER SEQUENCE ${this.escapePath(sequencePath)} RENAME TO "${newSequenceName}"`;
|
|
544
|
+
const down = `ALTER SEQUENCE ${this.escapePath(newSequencePath)} RENAME TO "${sequenceName}"`;
|
|
545
|
+
upQueries.push(new Query_1.Query(up));
|
|
546
|
+
downQueries.push(new Query_1.Query(down));
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
// rename unique constraints
|
|
550
|
+
newTable.uniques.forEach((unique) => {
|
|
551
|
+
const oldUniqueName = this.connection.namingStrategy.uniqueConstraintName(oldTable, unique.columnNames);
|
|
552
|
+
// Skip renaming if Unique has user defined constraint name
|
|
553
|
+
if (unique.name !== oldUniqueName)
|
|
554
|
+
return;
|
|
555
|
+
// build new constraint name
|
|
556
|
+
const newUniqueName = this.connection.namingStrategy.uniqueConstraintName(newTable, unique.columnNames);
|
|
557
|
+
// build queries
|
|
558
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(newTable)} RENAME CONSTRAINT "${unique.name}" TO "${newUniqueName}"`));
|
|
559
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(newTable)} RENAME CONSTRAINT "${newUniqueName}" TO "${unique.name}"`));
|
|
560
|
+
// replace constraint name
|
|
561
|
+
unique.name = newUniqueName;
|
|
562
|
+
});
|
|
563
|
+
// rename index constraints
|
|
564
|
+
newTable.indices.forEach((index) => {
|
|
565
|
+
const oldIndexName = this.connection.namingStrategy.indexName(oldTable, index.columnNames, index.where);
|
|
566
|
+
// Skip renaming if Index has user defined constraint name
|
|
567
|
+
if (index.name !== oldIndexName)
|
|
568
|
+
return;
|
|
569
|
+
// build new constraint name
|
|
570
|
+
const { schema } = this.driver.parseTableName(newTable);
|
|
571
|
+
const newIndexName = this.connection.namingStrategy.indexName(newTable, index.columnNames, index.where);
|
|
572
|
+
// build queries
|
|
573
|
+
const up = schema
|
|
574
|
+
? `ALTER INDEX "${schema}"."${index.name}" RENAME TO "${newIndexName}"`
|
|
575
|
+
: `ALTER INDEX "${index.name}" RENAME TO "${newIndexName}"`;
|
|
576
|
+
const down = schema
|
|
577
|
+
? `ALTER INDEX "${schema}"."${newIndexName}" RENAME TO "${index.name}"`
|
|
578
|
+
: `ALTER INDEX "${newIndexName}" RENAME TO "${index.name}"`;
|
|
579
|
+
upQueries.push(new Query_1.Query(up));
|
|
580
|
+
downQueries.push(new Query_1.Query(down));
|
|
581
|
+
// replace constraint name
|
|
582
|
+
index.name = newIndexName;
|
|
583
|
+
});
|
|
584
|
+
// rename foreign key constraints
|
|
585
|
+
newTable.foreignKeys.forEach((foreignKey) => {
|
|
586
|
+
const oldForeignKeyName = this.connection.namingStrategy.foreignKeyName(oldTable, foreignKey.columnNames, this.getTablePath(foreignKey), foreignKey.referencedColumnNames);
|
|
587
|
+
// Skip renaming if foreign key has user defined constraint name
|
|
588
|
+
if (foreignKey.name !== oldForeignKeyName)
|
|
589
|
+
return;
|
|
590
|
+
// build new constraint name
|
|
591
|
+
const newForeignKeyName = this.connection.namingStrategy.foreignKeyName(newTable, foreignKey.columnNames, this.getTablePath(foreignKey), foreignKey.referencedColumnNames);
|
|
592
|
+
// build queries
|
|
593
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(newTable)} RENAME CONSTRAINT "${foreignKey.name}" TO "${newForeignKeyName}"`));
|
|
594
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(newTable)} RENAME CONSTRAINT "${newForeignKeyName}" TO "${foreignKey.name}"`));
|
|
595
|
+
// replace constraint name
|
|
596
|
+
foreignKey.name = newForeignKeyName;
|
|
597
|
+
});
|
|
598
|
+
// rename ENUM types
|
|
599
|
+
const enumColumns = newTable.columns.filter((column) => column.type === "enum" || column.type === "simple-enum");
|
|
600
|
+
for (let column of enumColumns) {
|
|
601
|
+
// skip renaming for user-defined enum name
|
|
602
|
+
if (column.enumName)
|
|
603
|
+
continue;
|
|
604
|
+
const oldEnumType = await this.getUserDefinedTypeName(oldTable, column);
|
|
605
|
+
upQueries.push(new Query_1.Query(`ALTER TYPE "${oldEnumType.schema}"."${oldEnumType.name}" RENAME TO ${this.buildEnumName(newTable, column, false)}`));
|
|
606
|
+
downQueries.push(new Query_1.Query(`ALTER TYPE ${this.buildEnumName(newTable, column)} RENAME TO "${oldEnumType.name}"`));
|
|
607
|
+
}
|
|
608
|
+
await this.executeQueries(upQueries, downQueries);
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Creates a new column from the column in the table.
|
|
612
|
+
*/
|
|
613
|
+
async addColumn(tableOrName, column) {
|
|
614
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
615
|
+
? tableOrName
|
|
616
|
+
: await this.getCachedTable(tableOrName);
|
|
617
|
+
const clonedTable = table.clone();
|
|
618
|
+
const upQueries = [];
|
|
619
|
+
const downQueries = [];
|
|
620
|
+
if (column.type === "enum" || column.type === "simple-enum") {
|
|
621
|
+
const hasEnum = await this.hasEnumType(table, column);
|
|
622
|
+
if (!hasEnum) {
|
|
623
|
+
upQueries.push(this.createEnumTypeSql(table, column));
|
|
624
|
+
downQueries.push(this.dropEnumTypeSql(table, column));
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD ${this.buildCreateColumnSql(table, column)}`));
|
|
628
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP COLUMN "${column.name}"`));
|
|
629
|
+
// create or update primary key constraint
|
|
630
|
+
if (column.isPrimary) {
|
|
631
|
+
const primaryColumns = clonedTable.primaryColumns;
|
|
632
|
+
// if table already have primary key, me must drop it and recreate again
|
|
633
|
+
if (primaryColumns.length > 0) {
|
|
634
|
+
const pkName = primaryColumns[0].primaryKeyConstraintName
|
|
635
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
636
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map((column) => column.name));
|
|
637
|
+
const columnNames = primaryColumns
|
|
638
|
+
.map((column) => `"${column.name}"`)
|
|
639
|
+
.join(", ");
|
|
640
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${pkName}"`));
|
|
641
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNames})`));
|
|
642
|
+
}
|
|
643
|
+
primaryColumns.push(column);
|
|
644
|
+
const pkName = primaryColumns[0].primaryKeyConstraintName
|
|
645
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
646
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map((column) => column.name));
|
|
647
|
+
const columnNames = primaryColumns
|
|
648
|
+
.map((column) => `"${column.name}"`)
|
|
649
|
+
.join(", ");
|
|
650
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNames})`));
|
|
651
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${pkName}"`));
|
|
652
|
+
}
|
|
653
|
+
// create column index
|
|
654
|
+
const columnIndex = clonedTable.indices.find((index) => index.columnNames.length === 1 &&
|
|
655
|
+
index.columnNames[0] === column.name);
|
|
656
|
+
if (columnIndex) {
|
|
657
|
+
upQueries.push(this.createIndexSql(table, columnIndex));
|
|
658
|
+
downQueries.push(this.dropIndexSql(table, columnIndex));
|
|
659
|
+
}
|
|
660
|
+
// create unique constraint
|
|
661
|
+
if (column.isUnique) {
|
|
662
|
+
const uniqueConstraint = new TableUnique_1.TableUnique({
|
|
663
|
+
name: this.connection.namingStrategy.uniqueConstraintName(table, [column.name]),
|
|
664
|
+
columnNames: [column.name],
|
|
665
|
+
});
|
|
666
|
+
clonedTable.uniques.push(uniqueConstraint);
|
|
667
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${uniqueConstraint.name}" UNIQUE ("${column.name}")`));
|
|
668
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${uniqueConstraint.name}"`));
|
|
669
|
+
}
|
|
670
|
+
if (column.generatedType === "STORED" && column.asExpression) {
|
|
671
|
+
const tableNameWithSchema = (await this.getTableNameWithSchema(table.name)).split(".");
|
|
672
|
+
const tableName = tableNameWithSchema[1];
|
|
673
|
+
const schema = tableNameWithSchema[0];
|
|
674
|
+
const insertQuery = this.insertTypeormMetadataSql({
|
|
675
|
+
database: this.driver.database,
|
|
676
|
+
schema,
|
|
677
|
+
table: tableName,
|
|
678
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
679
|
+
name: column.name,
|
|
680
|
+
value: column.asExpression,
|
|
681
|
+
});
|
|
682
|
+
const deleteQuery = this.deleteTypeormMetadataSql({
|
|
683
|
+
database: this.driver.database,
|
|
684
|
+
schema,
|
|
685
|
+
table: tableName,
|
|
686
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
687
|
+
name: column.name,
|
|
688
|
+
});
|
|
689
|
+
upQueries.push(insertQuery);
|
|
690
|
+
downQueries.push(deleteQuery);
|
|
691
|
+
}
|
|
692
|
+
// create column's comment
|
|
693
|
+
if (column.comment) {
|
|
694
|
+
upQueries.push(new Query_1.Query(`COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}" IS ${this.escapeComment(column.comment)}`));
|
|
695
|
+
downQueries.push(new Query_1.Query(`COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}" IS ${this.escapeComment(column.comment)}`));
|
|
696
|
+
}
|
|
697
|
+
await this.executeQueries(upQueries, downQueries);
|
|
698
|
+
clonedTable.addColumn(column);
|
|
699
|
+
this.replaceCachedTable(table, clonedTable);
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Creates a new columns from the column in the table.
|
|
703
|
+
*/
|
|
704
|
+
async addColumns(tableOrName, columns) {
|
|
705
|
+
for (const column of columns) {
|
|
706
|
+
await this.addColumn(tableOrName, column);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Renames column in the given table.
|
|
711
|
+
*/
|
|
712
|
+
async renameColumn(tableOrName, oldTableColumnOrName, newTableColumnOrName) {
|
|
713
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
714
|
+
? tableOrName
|
|
715
|
+
: await this.getCachedTable(tableOrName);
|
|
716
|
+
const oldColumn = InstanceChecker_1.InstanceChecker.isTableColumn(oldTableColumnOrName)
|
|
717
|
+
? oldTableColumnOrName
|
|
718
|
+
: table.columns.find((c) => c.name === oldTableColumnOrName);
|
|
719
|
+
if (!oldColumn)
|
|
720
|
+
throw new error_1.TypeORMError(`Column "${oldTableColumnOrName}" was not found in the "${table.name}" table.`);
|
|
721
|
+
let newColumn;
|
|
722
|
+
if (InstanceChecker_1.InstanceChecker.isTableColumn(newTableColumnOrName)) {
|
|
723
|
+
newColumn = newTableColumnOrName;
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
newColumn = oldColumn.clone();
|
|
727
|
+
newColumn.name = newTableColumnOrName;
|
|
728
|
+
}
|
|
729
|
+
return this.changeColumn(table, oldColumn, newColumn);
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Changes a column in the table.
|
|
733
|
+
*/
|
|
734
|
+
async changeColumn(tableOrName, oldTableColumnOrName, newColumn) {
|
|
735
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
736
|
+
? tableOrName
|
|
737
|
+
: await this.getCachedTable(tableOrName);
|
|
738
|
+
let clonedTable = table.clone();
|
|
739
|
+
const upQueries = [];
|
|
740
|
+
const downQueries = [];
|
|
741
|
+
let defaultValueChanged = false;
|
|
742
|
+
const oldColumn = InstanceChecker_1.InstanceChecker.isTableColumn(oldTableColumnOrName)
|
|
743
|
+
? oldTableColumnOrName
|
|
744
|
+
: table.columns.find((column) => column.name === oldTableColumnOrName);
|
|
745
|
+
if (!oldColumn)
|
|
746
|
+
throw new error_1.TypeORMError(`Column "${oldTableColumnOrName}" was not found in the "${table.name}" table.`);
|
|
747
|
+
if (oldColumn.type !== newColumn.type ||
|
|
748
|
+
oldColumn.length !== newColumn.length ||
|
|
749
|
+
newColumn.isArray !== oldColumn.isArray ||
|
|
750
|
+
(!oldColumn.generatedType &&
|
|
751
|
+
newColumn.generatedType === "STORED") ||
|
|
752
|
+
(oldColumn.asExpression !== newColumn.asExpression &&
|
|
753
|
+
newColumn.generatedType === "STORED")) {
|
|
754
|
+
// To avoid data conversion, we just recreate column
|
|
755
|
+
await this.dropColumn(table, oldColumn);
|
|
756
|
+
await this.addColumn(table, newColumn);
|
|
757
|
+
// update cloned table
|
|
758
|
+
clonedTable = table.clone();
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
if (oldColumn.name !== newColumn.name) {
|
|
762
|
+
// rename column
|
|
763
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME COLUMN "${oldColumn.name}" TO "${newColumn.name}"`));
|
|
764
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME COLUMN "${newColumn.name}" TO "${oldColumn.name}"`));
|
|
765
|
+
// rename ENUM type
|
|
766
|
+
if (oldColumn.type === "enum" ||
|
|
767
|
+
oldColumn.type === "simple-enum") {
|
|
768
|
+
const oldEnumType = await this.getUserDefinedTypeName(table, oldColumn);
|
|
769
|
+
upQueries.push(new Query_1.Query(`ALTER TYPE "${oldEnumType.schema}"."${oldEnumType.name}" RENAME TO ${this.buildEnumName(table, newColumn, false)}`));
|
|
770
|
+
downQueries.push(new Query_1.Query(`ALTER TYPE ${this.buildEnumName(table, newColumn)} RENAME TO "${oldEnumType.name}"`));
|
|
771
|
+
}
|
|
772
|
+
// rename column primary key constraint
|
|
773
|
+
if (oldColumn.isPrimary === true &&
|
|
774
|
+
!oldColumn.primaryKeyConstraintName) {
|
|
775
|
+
const primaryColumns = clonedTable.primaryColumns;
|
|
776
|
+
// build old primary constraint name
|
|
777
|
+
const columnNames = primaryColumns.map((column) => column.name);
|
|
778
|
+
const oldPkName = this.connection.namingStrategy.primaryKeyName(clonedTable, columnNames);
|
|
779
|
+
// replace old column name with new column name
|
|
780
|
+
columnNames.splice(columnNames.indexOf(oldColumn.name), 1);
|
|
781
|
+
columnNames.push(newColumn.name);
|
|
782
|
+
// build new primary constraint name
|
|
783
|
+
const newPkName = this.connection.namingStrategy.primaryKeyName(clonedTable, columnNames);
|
|
784
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME CONSTRAINT "${oldPkName}" TO "${newPkName}"`));
|
|
785
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME CONSTRAINT "${newPkName}" TO "${oldPkName}"`));
|
|
786
|
+
}
|
|
787
|
+
// rename column sequence
|
|
788
|
+
if (oldColumn.isGenerated === true &&
|
|
789
|
+
newColumn.generationStrategy === "increment") {
|
|
790
|
+
const sequencePath = this.buildSequencePath(table, oldColumn.name);
|
|
791
|
+
const sequenceName = this.buildSequenceName(table, oldColumn.name);
|
|
792
|
+
const newSequencePath = this.buildSequencePath(table, newColumn.name);
|
|
793
|
+
const newSequenceName = this.buildSequenceName(table, newColumn.name);
|
|
794
|
+
const up = `ALTER SEQUENCE ${this.escapePath(sequencePath)} RENAME TO "${newSequenceName}"`;
|
|
795
|
+
const down = `ALTER SEQUENCE ${this.escapePath(newSequencePath)} RENAME TO "${sequenceName}"`;
|
|
796
|
+
upQueries.push(new Query_1.Query(up));
|
|
797
|
+
downQueries.push(new Query_1.Query(down));
|
|
798
|
+
}
|
|
799
|
+
// rename unique constraints
|
|
800
|
+
clonedTable.findColumnUniques(oldColumn).forEach((unique) => {
|
|
801
|
+
const oldUniqueName = this.connection.namingStrategy.uniqueConstraintName(clonedTable, unique.columnNames);
|
|
802
|
+
// Skip renaming if Unique has user defined constraint name
|
|
803
|
+
if (unique.name !== oldUniqueName)
|
|
804
|
+
return;
|
|
805
|
+
// build new constraint name
|
|
806
|
+
unique.columnNames.splice(unique.columnNames.indexOf(oldColumn.name), 1);
|
|
807
|
+
unique.columnNames.push(newColumn.name);
|
|
808
|
+
const newUniqueName = this.connection.namingStrategy.uniqueConstraintName(clonedTable, unique.columnNames);
|
|
809
|
+
// build queries
|
|
810
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME CONSTRAINT "${unique.name}" TO "${newUniqueName}"`));
|
|
811
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME CONSTRAINT "${newUniqueName}" TO "${unique.name}"`));
|
|
812
|
+
// replace constraint name
|
|
813
|
+
unique.name = newUniqueName;
|
|
814
|
+
});
|
|
815
|
+
// rename index constraints
|
|
816
|
+
clonedTable.findColumnIndices(oldColumn).forEach((index) => {
|
|
817
|
+
const oldIndexName = this.connection.namingStrategy.indexName(clonedTable, index.columnNames, index.where);
|
|
818
|
+
// Skip renaming if Index has user defined constraint name
|
|
819
|
+
if (index.name !== oldIndexName)
|
|
820
|
+
return;
|
|
821
|
+
// build new constraint name
|
|
822
|
+
index.columnNames.splice(index.columnNames.indexOf(oldColumn.name), 1);
|
|
823
|
+
index.columnNames.push(newColumn.name);
|
|
824
|
+
const { schema } = this.driver.parseTableName(table);
|
|
825
|
+
const newIndexName = this.connection.namingStrategy.indexName(clonedTable, index.columnNames, index.where);
|
|
826
|
+
// build queries
|
|
827
|
+
const up = schema
|
|
828
|
+
? `ALTER INDEX "${schema}"."${index.name}" RENAME TO "${newIndexName}"`
|
|
829
|
+
: `ALTER INDEX "${index.name}" RENAME TO "${newIndexName}"`;
|
|
830
|
+
const down = schema
|
|
831
|
+
? `ALTER INDEX "${schema}"."${newIndexName}" RENAME TO "${index.name}"`
|
|
832
|
+
: `ALTER INDEX "${newIndexName}" RENAME TO "${index.name}"`;
|
|
833
|
+
upQueries.push(new Query_1.Query(up));
|
|
834
|
+
downQueries.push(new Query_1.Query(down));
|
|
835
|
+
// replace constraint name
|
|
836
|
+
index.name = newIndexName;
|
|
837
|
+
});
|
|
838
|
+
// rename foreign key constraints
|
|
839
|
+
clonedTable
|
|
840
|
+
.findColumnForeignKeys(oldColumn)
|
|
841
|
+
.forEach((foreignKey) => {
|
|
842
|
+
const foreignKeyName = this.connection.namingStrategy.foreignKeyName(clonedTable, foreignKey.columnNames, this.getTablePath(foreignKey), foreignKey.referencedColumnNames);
|
|
843
|
+
// Skip renaming if foreign key has user defined constraint name
|
|
844
|
+
if (foreignKey.name !== foreignKeyName)
|
|
845
|
+
return;
|
|
846
|
+
// build new constraint name
|
|
847
|
+
foreignKey.columnNames.splice(foreignKey.columnNames.indexOf(oldColumn.name), 1);
|
|
848
|
+
foreignKey.columnNames.push(newColumn.name);
|
|
849
|
+
const newForeignKeyName = this.connection.namingStrategy.foreignKeyName(clonedTable, foreignKey.columnNames, this.getTablePath(foreignKey), foreignKey.referencedColumnNames);
|
|
850
|
+
// build queries
|
|
851
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME CONSTRAINT "${foreignKey.name}" TO "${newForeignKeyName}"`));
|
|
852
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME CONSTRAINT "${newForeignKeyName}" TO "${foreignKey.name}"`));
|
|
853
|
+
// replace constraint name
|
|
854
|
+
foreignKey.name = newForeignKeyName;
|
|
855
|
+
});
|
|
856
|
+
// rename old column in the Table object
|
|
857
|
+
const oldTableColumn = clonedTable.columns.find((column) => column.name === oldColumn.name);
|
|
858
|
+
clonedTable.columns[clonedTable.columns.indexOf(oldTableColumn)].name = newColumn.name;
|
|
859
|
+
oldColumn.name = newColumn.name;
|
|
860
|
+
}
|
|
861
|
+
if (newColumn.precision !== oldColumn.precision ||
|
|
862
|
+
newColumn.scale !== oldColumn.scale) {
|
|
863
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" TYPE ${this.driver.createFullType(newColumn)}`));
|
|
864
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" TYPE ${this.driver.createFullType(oldColumn)}`));
|
|
865
|
+
}
|
|
866
|
+
if ((newColumn.type === "enum" ||
|
|
867
|
+
newColumn.type === "simple-enum") &&
|
|
868
|
+
(oldColumn.type === "enum" ||
|
|
869
|
+
oldColumn.type === "simple-enum") &&
|
|
870
|
+
(!OrmUtils_1.OrmUtils.isArraysEqual(newColumn.enum, oldColumn.enum) ||
|
|
871
|
+
newColumn.enumName !== oldColumn.enumName)) {
|
|
872
|
+
const arraySuffix = newColumn.isArray ? "[]" : "";
|
|
873
|
+
// "public"."new_enum"
|
|
874
|
+
const newEnumName = this.buildEnumName(table, newColumn);
|
|
875
|
+
// "public"."old_enum"
|
|
876
|
+
const oldEnumName = this.buildEnumName(table, oldColumn);
|
|
877
|
+
// "old_enum"
|
|
878
|
+
const oldEnumNameWithoutSchema = this.buildEnumName(table, oldColumn, false);
|
|
879
|
+
//"public"."old_enum_old"
|
|
880
|
+
const oldEnumNameWithSchema_old = this.buildEnumName(table, oldColumn, true, false, true);
|
|
881
|
+
//"old_enum_old"
|
|
882
|
+
const oldEnumNameWithoutSchema_old = this.buildEnumName(table, oldColumn, false, false, true);
|
|
883
|
+
// rename old ENUM
|
|
884
|
+
upQueries.push(new Query_1.Query(`ALTER TYPE ${oldEnumName} RENAME TO ${oldEnumNameWithoutSchema_old}`));
|
|
885
|
+
downQueries.push(new Query_1.Query(`ALTER TYPE ${oldEnumNameWithSchema_old} RENAME TO ${oldEnumNameWithoutSchema}`));
|
|
886
|
+
// create new ENUM
|
|
887
|
+
upQueries.push(this.createEnumTypeSql(table, newColumn, newEnumName));
|
|
888
|
+
downQueries.push(this.dropEnumTypeSql(table, newColumn, newEnumName));
|
|
889
|
+
// if column have default value, we must drop it to avoid issues with type casting
|
|
890
|
+
if (oldColumn.default !== null &&
|
|
891
|
+
oldColumn.default !== undefined) {
|
|
892
|
+
// mark default as changed to prevent double update
|
|
893
|
+
defaultValueChanged = true;
|
|
894
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" DROP DEFAULT`));
|
|
895
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" SET DEFAULT ${oldColumn.default}`));
|
|
896
|
+
}
|
|
897
|
+
// build column types
|
|
898
|
+
const upType = `${newEnumName}${arraySuffix} USING "${newColumn.name}"::"text"::${newEnumName}${arraySuffix}`;
|
|
899
|
+
const downType = `${oldEnumNameWithSchema_old}${arraySuffix} USING "${newColumn.name}"::"text"::${oldEnumNameWithSchema_old}${arraySuffix}`;
|
|
900
|
+
// update column to use new type
|
|
901
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" TYPE ${upType}`));
|
|
902
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" TYPE ${downType}`));
|
|
903
|
+
// restore column default or create new one
|
|
904
|
+
if (newColumn.default !== null &&
|
|
905
|
+
newColumn.default !== undefined) {
|
|
906
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT ${newColumn.default}`));
|
|
907
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
908
|
+
}
|
|
909
|
+
// remove old ENUM
|
|
910
|
+
upQueries.push(this.dropEnumTypeSql(table, oldColumn, oldEnumNameWithSchema_old));
|
|
911
|
+
downQueries.push(this.createEnumTypeSql(table, oldColumn, oldEnumNameWithSchema_old));
|
|
912
|
+
}
|
|
913
|
+
if (oldColumn.isNullable !== newColumn.isNullable) {
|
|
914
|
+
if (newColumn.isNullable) {
|
|
915
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" DROP NOT NULL`));
|
|
916
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" SET NOT NULL`));
|
|
917
|
+
}
|
|
918
|
+
else {
|
|
919
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" SET NOT NULL`));
|
|
920
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" DROP NOT NULL`));
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (oldColumn.comment !== newColumn.comment) {
|
|
924
|
+
upQueries.push(new Query_1.Query(`COMMENT ON COLUMN ${this.escapePath(table)}."${oldColumn.name}" IS ${this.escapeComment(newColumn.comment)}`));
|
|
925
|
+
downQueries.push(new Query_1.Query(`COMMENT ON COLUMN ${this.escapePath(table)}."${newColumn.name}" IS ${this.escapeComment(oldColumn.comment)}`));
|
|
926
|
+
}
|
|
927
|
+
if (newColumn.isPrimary !== oldColumn.isPrimary) {
|
|
928
|
+
const primaryColumns = clonedTable.primaryColumns;
|
|
929
|
+
// if primary column state changed, we must always drop existed constraint.
|
|
930
|
+
if (primaryColumns.length > 0) {
|
|
931
|
+
const pkName = primaryColumns[0].primaryKeyConstraintName
|
|
932
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
933
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map((column) => column.name));
|
|
934
|
+
const columnNames = primaryColumns
|
|
935
|
+
.map((column) => `"${column.name}"`)
|
|
936
|
+
.join(", ");
|
|
937
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${pkName}"`));
|
|
938
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNames})`));
|
|
939
|
+
}
|
|
940
|
+
if (newColumn.isPrimary === true) {
|
|
941
|
+
primaryColumns.push(newColumn);
|
|
942
|
+
// update column in table
|
|
943
|
+
const column = clonedTable.columns.find((column) => column.name === newColumn.name);
|
|
944
|
+
column.isPrimary = true;
|
|
945
|
+
const pkName = primaryColumns[0].primaryKeyConstraintName
|
|
946
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
947
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map((column) => column.name));
|
|
948
|
+
const columnNames = primaryColumns
|
|
949
|
+
.map((column) => `"${column.name}"`)
|
|
950
|
+
.join(", ");
|
|
951
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNames})`));
|
|
952
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${pkName}"`));
|
|
953
|
+
}
|
|
954
|
+
else {
|
|
955
|
+
const primaryColumn = primaryColumns.find((c) => c.name === newColumn.name);
|
|
956
|
+
primaryColumns.splice(primaryColumns.indexOf(primaryColumn), 1);
|
|
957
|
+
// update column in table
|
|
958
|
+
const column = clonedTable.columns.find((column) => column.name === newColumn.name);
|
|
959
|
+
column.isPrimary = false;
|
|
960
|
+
// if we have another primary keys, we must recreate constraint.
|
|
961
|
+
if (primaryColumns.length > 0) {
|
|
962
|
+
const pkName = primaryColumns[0]
|
|
963
|
+
.primaryKeyConstraintName
|
|
964
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
965
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map((column) => column.name));
|
|
966
|
+
const columnNames = primaryColumns
|
|
967
|
+
.map((column) => `"${column.name}"`)
|
|
968
|
+
.join(", ");
|
|
969
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNames})`));
|
|
970
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${pkName}"`));
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
if (newColumn.isUnique !== oldColumn.isUnique) {
|
|
975
|
+
if (newColumn.isUnique === true) {
|
|
976
|
+
const uniqueConstraint = new TableUnique_1.TableUnique({
|
|
977
|
+
name: this.connection.namingStrategy.uniqueConstraintName(table, [newColumn.name]),
|
|
978
|
+
columnNames: [newColumn.name],
|
|
979
|
+
});
|
|
980
|
+
clonedTable.uniques.push(uniqueConstraint);
|
|
981
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${uniqueConstraint.name}" UNIQUE ("${newColumn.name}")`));
|
|
982
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${uniqueConstraint.name}"`));
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
const uniqueConstraint = clonedTable.uniques.find((unique) => {
|
|
986
|
+
return (unique.columnNames.length === 1 &&
|
|
987
|
+
!!unique.columnNames.find((columnName) => columnName === newColumn.name));
|
|
988
|
+
});
|
|
989
|
+
clonedTable.uniques.splice(clonedTable.uniques.indexOf(uniqueConstraint), 1);
|
|
990
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${uniqueConstraint.name}"`));
|
|
991
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${uniqueConstraint.name}" UNIQUE ("${newColumn.name}")`));
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if (oldColumn.isGenerated !== newColumn.isGenerated) {
|
|
995
|
+
// if old column was "generated", we should clear defaults
|
|
996
|
+
if (oldColumn.isGenerated) {
|
|
997
|
+
if (oldColumn.generationStrategy === "uuid") {
|
|
998
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" DROP DEFAULT`));
|
|
999
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${oldColumn.name}" SET DEFAULT ${this.driver.uuidGenerator}`));
|
|
1000
|
+
}
|
|
1001
|
+
else if (oldColumn.generationStrategy === "increment") {
|
|
1002
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
1003
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT nextval('${this.escapePath(this.buildSequencePath(table, newColumn))}')`));
|
|
1004
|
+
upQueries.push(new Query_1.Query(`DROP SEQUENCE ${this.escapePath(this.buildSequencePath(table, newColumn))}`));
|
|
1005
|
+
downQueries.push(new Query_1.Query(`CREATE SEQUENCE IF NOT EXISTS ${this.escapePath(this.buildSequencePath(table, newColumn))} OWNED BY ${this.escapePath(table)}."${newColumn.name}"`));
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (newColumn.generationStrategy === "uuid") {
|
|
1009
|
+
if (newColumn.isGenerated === true) {
|
|
1010
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT ${this.driver.uuidGenerator}`));
|
|
1011
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
1015
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT ${this.driver.uuidGenerator}`));
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
else if (newColumn.generationStrategy === "increment") {
|
|
1019
|
+
if (newColumn.isGenerated === true) {
|
|
1020
|
+
upQueries.push(new Query_1.Query(`CREATE SEQUENCE IF NOT EXISTS ${this.escapePath(this.buildSequencePath(table, newColumn))} OWNED BY ${this.escapePath(table)}."${newColumn.name}"`));
|
|
1021
|
+
downQueries.push(new Query_1.Query(`DROP SEQUENCE ${this.escapePath(this.buildSequencePath(table, newColumn))}`));
|
|
1022
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT nextval('${this.escapePath(this.buildSequencePath(table, newColumn))}')`));
|
|
1023
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
1024
|
+
}
|
|
1025
|
+
else {
|
|
1026
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
1027
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT nextval('${this.escapePath(this.buildSequencePath(table, newColumn))}')`));
|
|
1028
|
+
upQueries.push(new Query_1.Query(`DROP SEQUENCE ${this.escapePath(this.buildSequencePath(table, newColumn))}`));
|
|
1029
|
+
downQueries.push(new Query_1.Query(`CREATE SEQUENCE IF NOT EXISTS ${this.escapePath(this.buildSequencePath(table, newColumn))} OWNED BY ${this.escapePath(table)}."${newColumn.name}"`));
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
// the default might have changed when the enum changed
|
|
1034
|
+
if (newColumn.default !== oldColumn.default &&
|
|
1035
|
+
!defaultValueChanged) {
|
|
1036
|
+
if (newColumn.default !== null &&
|
|
1037
|
+
newColumn.default !== undefined) {
|
|
1038
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT ${newColumn.default}`));
|
|
1039
|
+
if (oldColumn.default !== null &&
|
|
1040
|
+
oldColumn.default !== undefined) {
|
|
1041
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT ${oldColumn.default}`));
|
|
1042
|
+
}
|
|
1043
|
+
else {
|
|
1044
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
else if (oldColumn.default !== null &&
|
|
1048
|
+
oldColumn.default !== undefined) {
|
|
1049
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" DROP DEFAULT`));
|
|
1050
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" SET DEFAULT ${oldColumn.default}`));
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
if ((newColumn.spatialFeatureType || "").toLowerCase() !==
|
|
1054
|
+
(oldColumn.spatialFeatureType || "").toLowerCase() ||
|
|
1055
|
+
newColumn.srid !== oldColumn.srid) {
|
|
1056
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" TYPE ${this.driver.createFullType(newColumn)}`));
|
|
1057
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ALTER COLUMN "${newColumn.name}" TYPE ${this.driver.createFullType(oldColumn)}`));
|
|
1058
|
+
}
|
|
1059
|
+
if (newColumn.generatedType !== oldColumn.generatedType) {
|
|
1060
|
+
// Convert generated column data to normal column
|
|
1061
|
+
if (!newColumn.generatedType ||
|
|
1062
|
+
newColumn.generatedType === "VIRTUAL") {
|
|
1063
|
+
// We can copy the generated data to the new column
|
|
1064
|
+
const tableNameWithSchema = (await this.getTableNameWithSchema(table.name)).split(".");
|
|
1065
|
+
const tableName = tableNameWithSchema[1];
|
|
1066
|
+
const schema = tableNameWithSchema[0];
|
|
1067
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} RENAME COLUMN "${oldColumn.name}" TO "TEMP_OLD_${oldColumn.name}"`));
|
|
1068
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD ${this.buildCreateColumnSql(table, newColumn)}`));
|
|
1069
|
+
upQueries.push(new Query_1.Query(`UPDATE ${this.escapePath(table)} SET "${newColumn.name}" = "TEMP_OLD_${oldColumn.name}"`));
|
|
1070
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP COLUMN "TEMP_OLD_${oldColumn.name}"`));
|
|
1071
|
+
upQueries.push(this.deleteTypeormMetadataSql({
|
|
1072
|
+
database: this.driver.database,
|
|
1073
|
+
schema,
|
|
1074
|
+
table: tableName,
|
|
1075
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
1076
|
+
name: oldColumn.name,
|
|
1077
|
+
}));
|
|
1078
|
+
// However, we can't copy it back on downgrade. It needs to regenerate.
|
|
1079
|
+
downQueries.push(this.insertTypeormMetadataSql({
|
|
1080
|
+
database: this.driver.database,
|
|
1081
|
+
schema,
|
|
1082
|
+
table: tableName,
|
|
1083
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
1084
|
+
name: oldColumn.name,
|
|
1085
|
+
value: oldColumn.asExpression,
|
|
1086
|
+
}));
|
|
1087
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD ${this.buildCreateColumnSql(table, oldColumn)}`));
|
|
1088
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP COLUMN "${newColumn.name}"`));
|
|
1089
|
+
// downQueries.push(
|
|
1090
|
+
// this.deleteTypeormMetadataSql({
|
|
1091
|
+
// database: this.driver.database,
|
|
1092
|
+
// schema,
|
|
1093
|
+
// table: tableName,
|
|
1094
|
+
// type: MetadataTableType.GENERATED_COLUMN,
|
|
1095
|
+
// name: newColumn.name,
|
|
1096
|
+
// }),
|
|
1097
|
+
// )
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
await this.executeQueries(upQueries, downQueries);
|
|
1102
|
+
this.replaceCachedTable(table, clonedTable);
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Changes a column in the table.
|
|
1106
|
+
*/
|
|
1107
|
+
async changeColumns(tableOrName, changedColumns) {
|
|
1108
|
+
for (const { oldColumn, newColumn } of changedColumns) {
|
|
1109
|
+
await this.changeColumn(tableOrName, oldColumn, newColumn);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Drops column in the table.
|
|
1114
|
+
*/
|
|
1115
|
+
async dropColumn(tableOrName, columnOrName) {
|
|
1116
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1117
|
+
? tableOrName
|
|
1118
|
+
: await this.getCachedTable(tableOrName);
|
|
1119
|
+
const column = InstanceChecker_1.InstanceChecker.isTableColumn(columnOrName)
|
|
1120
|
+
? columnOrName
|
|
1121
|
+
: table.findColumnByName(columnOrName);
|
|
1122
|
+
if (!column)
|
|
1123
|
+
throw new error_1.TypeORMError(`Column "${columnOrName}" was not found in table "${table.name}"`);
|
|
1124
|
+
const clonedTable = table.clone();
|
|
1125
|
+
const upQueries = [];
|
|
1126
|
+
const downQueries = [];
|
|
1127
|
+
// drop primary key constraint
|
|
1128
|
+
if (column.isPrimary) {
|
|
1129
|
+
const pkName = column.primaryKeyConstraintName
|
|
1130
|
+
? column.primaryKeyConstraintName
|
|
1131
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, clonedTable.primaryColumns.map((column) => column.name));
|
|
1132
|
+
const columnNames = clonedTable.primaryColumns
|
|
1133
|
+
.map((primaryColumn) => `"${primaryColumn.name}"`)
|
|
1134
|
+
.join(", ");
|
|
1135
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(clonedTable)} DROP CONSTRAINT "${pkName}"`));
|
|
1136
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(clonedTable)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNames})`));
|
|
1137
|
+
// update column in table
|
|
1138
|
+
const tableColumn = clonedTable.findColumnByName(column.name);
|
|
1139
|
+
tableColumn.isPrimary = false;
|
|
1140
|
+
// if primary key have multiple columns, we must recreate it without dropped column
|
|
1141
|
+
if (clonedTable.primaryColumns.length > 0) {
|
|
1142
|
+
const pkName = clonedTable.primaryColumns[0]
|
|
1143
|
+
.primaryKeyConstraintName
|
|
1144
|
+
? clonedTable.primaryColumns[0].primaryKeyConstraintName
|
|
1145
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, clonedTable.primaryColumns.map((column) => column.name));
|
|
1146
|
+
const columnNames = clonedTable.primaryColumns
|
|
1147
|
+
.map((primaryColumn) => `"${primaryColumn.name}"`)
|
|
1148
|
+
.join(", ");
|
|
1149
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(clonedTable)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNames})`));
|
|
1150
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(clonedTable)} DROP CONSTRAINT "${pkName}"`));
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
// drop column index
|
|
1154
|
+
const columnIndex = clonedTable.indices.find((index) => index.columnNames.length === 1 &&
|
|
1155
|
+
index.columnNames[0] === column.name);
|
|
1156
|
+
if (columnIndex) {
|
|
1157
|
+
clonedTable.indices.splice(clonedTable.indices.indexOf(columnIndex), 1);
|
|
1158
|
+
upQueries.push(this.dropIndexSql(table, columnIndex));
|
|
1159
|
+
downQueries.push(this.createIndexSql(table, columnIndex));
|
|
1160
|
+
}
|
|
1161
|
+
// drop column check
|
|
1162
|
+
const columnCheck = clonedTable.checks.find((check) => !!check.columnNames &&
|
|
1163
|
+
check.columnNames.length === 1 &&
|
|
1164
|
+
check.columnNames[0] === column.name);
|
|
1165
|
+
if (columnCheck) {
|
|
1166
|
+
clonedTable.checks.splice(clonedTable.checks.indexOf(columnCheck), 1);
|
|
1167
|
+
upQueries.push(this.dropCheckConstraintSql(table, columnCheck));
|
|
1168
|
+
downQueries.push(this.createCheckConstraintSql(table, columnCheck));
|
|
1169
|
+
}
|
|
1170
|
+
// drop column unique
|
|
1171
|
+
const columnUnique = clonedTable.uniques.find((unique) => unique.columnNames.length === 1 &&
|
|
1172
|
+
unique.columnNames[0] === column.name);
|
|
1173
|
+
if (columnUnique) {
|
|
1174
|
+
clonedTable.uniques.splice(clonedTable.uniques.indexOf(columnUnique), 1);
|
|
1175
|
+
upQueries.push(this.dropUniqueConstraintSql(table, columnUnique));
|
|
1176
|
+
downQueries.push(this.createUniqueConstraintSql(table, columnUnique));
|
|
1177
|
+
}
|
|
1178
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP COLUMN "${column.name}"`));
|
|
1179
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD ${this.buildCreateColumnSql(table, column)}`));
|
|
1180
|
+
// drop enum type
|
|
1181
|
+
if (column.type === "enum" || column.type === "simple-enum") {
|
|
1182
|
+
const hasEnum = await this.hasEnumType(table, column);
|
|
1183
|
+
if (hasEnum) {
|
|
1184
|
+
const enumType = await this.getUserDefinedTypeName(table, column);
|
|
1185
|
+
const escapedEnumName = `"${enumType.schema}"."${enumType.name}"`;
|
|
1186
|
+
upQueries.push(this.dropEnumTypeSql(table, column, escapedEnumName));
|
|
1187
|
+
downQueries.push(this.createEnumTypeSql(table, column, escapedEnumName));
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
if (column.generatedType === "STORED") {
|
|
1191
|
+
const tableNameWithSchema = (await this.getTableNameWithSchema(table.name)).split(".");
|
|
1192
|
+
const tableName = tableNameWithSchema[1];
|
|
1193
|
+
const schema = tableNameWithSchema[0];
|
|
1194
|
+
const deleteQuery = this.deleteTypeormMetadataSql({
|
|
1195
|
+
database: this.driver.database,
|
|
1196
|
+
schema,
|
|
1197
|
+
table: tableName,
|
|
1198
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
1199
|
+
name: column.name,
|
|
1200
|
+
});
|
|
1201
|
+
const insertQuery = this.insertTypeormMetadataSql({
|
|
1202
|
+
database: this.driver.database,
|
|
1203
|
+
schema,
|
|
1204
|
+
table: tableName,
|
|
1205
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
1206
|
+
name: column.name,
|
|
1207
|
+
value: column.asExpression,
|
|
1208
|
+
});
|
|
1209
|
+
upQueries.push(deleteQuery);
|
|
1210
|
+
downQueries.push(insertQuery);
|
|
1211
|
+
}
|
|
1212
|
+
await this.executeQueries(upQueries, downQueries);
|
|
1213
|
+
clonedTable.removeColumn(column);
|
|
1214
|
+
this.replaceCachedTable(table, clonedTable);
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Drops the columns in the table.
|
|
1218
|
+
*/
|
|
1219
|
+
async dropColumns(tableOrName, columns) {
|
|
1220
|
+
for (const column of columns) {
|
|
1221
|
+
await this.dropColumn(tableOrName, column);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Creates a new primary key.
|
|
1226
|
+
*/
|
|
1227
|
+
async createPrimaryKey(tableOrName, columnNames, constraintName) {
|
|
1228
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1229
|
+
? tableOrName
|
|
1230
|
+
: await this.getCachedTable(tableOrName);
|
|
1231
|
+
const clonedTable = table.clone();
|
|
1232
|
+
const up = this.createPrimaryKeySql(table, columnNames, constraintName);
|
|
1233
|
+
// mark columns as primary, because dropPrimaryKeySql build constraint name from table primary column names.
|
|
1234
|
+
clonedTable.columns.forEach((column) => {
|
|
1235
|
+
if (columnNames.find((columnName) => columnName === column.name))
|
|
1236
|
+
column.isPrimary = true;
|
|
1237
|
+
});
|
|
1238
|
+
const down = this.dropPrimaryKeySql(clonedTable);
|
|
1239
|
+
await this.executeQueries(up, down);
|
|
1240
|
+
this.replaceCachedTable(table, clonedTable);
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Updates composite primary keys.
|
|
1244
|
+
*/
|
|
1245
|
+
async updatePrimaryKeys(tableOrName, columns) {
|
|
1246
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1247
|
+
? tableOrName
|
|
1248
|
+
: await this.getCachedTable(tableOrName);
|
|
1249
|
+
const clonedTable = table.clone();
|
|
1250
|
+
const columnNames = columns.map((column) => column.name);
|
|
1251
|
+
const upQueries = [];
|
|
1252
|
+
const downQueries = [];
|
|
1253
|
+
// if table already have primary columns, we must drop them.
|
|
1254
|
+
const primaryColumns = clonedTable.primaryColumns;
|
|
1255
|
+
if (primaryColumns.length > 0) {
|
|
1256
|
+
const pkName = primaryColumns[0].primaryKeyConstraintName
|
|
1257
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
1258
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map((column) => column.name));
|
|
1259
|
+
const columnNamesString = primaryColumns
|
|
1260
|
+
.map((column) => `"${column.name}"`)
|
|
1261
|
+
.join(", ");
|
|
1262
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${pkName}"`));
|
|
1263
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNamesString})`));
|
|
1264
|
+
}
|
|
1265
|
+
// update columns in table.
|
|
1266
|
+
clonedTable.columns
|
|
1267
|
+
.filter((column) => columnNames.indexOf(column.name) !== -1)
|
|
1268
|
+
.forEach((column) => (column.isPrimary = true));
|
|
1269
|
+
const pkName = primaryColumns[0].primaryKeyConstraintName
|
|
1270
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
1271
|
+
: this.connection.namingStrategy.primaryKeyName(clonedTable, columnNames);
|
|
1272
|
+
const columnNamesString = columnNames
|
|
1273
|
+
.map((columnName) => `"${columnName}"`)
|
|
1274
|
+
.join(", ");
|
|
1275
|
+
upQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${pkName}" PRIMARY KEY (${columnNamesString})`));
|
|
1276
|
+
downQueries.push(new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${pkName}"`));
|
|
1277
|
+
await this.executeQueries(upQueries, downQueries);
|
|
1278
|
+
this.replaceCachedTable(table, clonedTable);
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Drops a primary key.
|
|
1282
|
+
*/
|
|
1283
|
+
async dropPrimaryKey(tableOrName, constraintName) {
|
|
1284
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1285
|
+
? tableOrName
|
|
1286
|
+
: await this.getCachedTable(tableOrName);
|
|
1287
|
+
const up = this.dropPrimaryKeySql(table);
|
|
1288
|
+
const down = this.createPrimaryKeySql(table, table.primaryColumns.map((column) => column.name), constraintName);
|
|
1289
|
+
await this.executeQueries(up, down);
|
|
1290
|
+
table.primaryColumns.forEach((column) => {
|
|
1291
|
+
column.isPrimary = false;
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Creates new unique constraint.
|
|
1296
|
+
*/
|
|
1297
|
+
async createUniqueConstraint(tableOrName, uniqueConstraint) {
|
|
1298
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1299
|
+
? tableOrName
|
|
1300
|
+
: await this.getCachedTable(tableOrName);
|
|
1301
|
+
// new unique constraint may be passed without name. In this case we generate unique name manually.
|
|
1302
|
+
if (!uniqueConstraint.name)
|
|
1303
|
+
uniqueConstraint.name =
|
|
1304
|
+
this.connection.namingStrategy.uniqueConstraintName(table, uniqueConstraint.columnNames);
|
|
1305
|
+
const up = this.createUniqueConstraintSql(table, uniqueConstraint);
|
|
1306
|
+
const down = this.dropUniqueConstraintSql(table, uniqueConstraint);
|
|
1307
|
+
await this.executeQueries(up, down);
|
|
1308
|
+
table.addUniqueConstraint(uniqueConstraint);
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Creates new unique constraints.
|
|
1312
|
+
*/
|
|
1313
|
+
async createUniqueConstraints(tableOrName, uniqueConstraints) {
|
|
1314
|
+
for (const uniqueConstraint of uniqueConstraints) {
|
|
1315
|
+
await this.createUniqueConstraint(tableOrName, uniqueConstraint);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Drops unique constraint.
|
|
1320
|
+
*/
|
|
1321
|
+
async dropUniqueConstraint(tableOrName, uniqueOrName) {
|
|
1322
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1323
|
+
? tableOrName
|
|
1324
|
+
: await this.getCachedTable(tableOrName);
|
|
1325
|
+
const uniqueConstraint = InstanceChecker_1.InstanceChecker.isTableUnique(uniqueOrName)
|
|
1326
|
+
? uniqueOrName
|
|
1327
|
+
: table.uniques.find((u) => u.name === uniqueOrName);
|
|
1328
|
+
if (!uniqueConstraint)
|
|
1329
|
+
throw new error_1.TypeORMError(`Supplied unique constraint was not found in table ${table.name}`);
|
|
1330
|
+
const up = this.dropUniqueConstraintSql(table, uniqueConstraint);
|
|
1331
|
+
const down = this.createUniqueConstraintSql(table, uniqueConstraint);
|
|
1332
|
+
await this.executeQueries(up, down);
|
|
1333
|
+
table.removeUniqueConstraint(uniqueConstraint);
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Drops unique constraints.
|
|
1337
|
+
*/
|
|
1338
|
+
async dropUniqueConstraints(tableOrName, uniqueConstraints) {
|
|
1339
|
+
for (const uniqueConstraint of uniqueConstraints) {
|
|
1340
|
+
await this.dropUniqueConstraint(tableOrName, uniqueConstraint);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Creates new check constraint.
|
|
1345
|
+
*/
|
|
1346
|
+
async createCheckConstraint(tableOrName, checkConstraint) {
|
|
1347
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1348
|
+
? tableOrName
|
|
1349
|
+
: await this.getCachedTable(tableOrName);
|
|
1350
|
+
// new unique constraint may be passed without name. In this case we generate unique name manually.
|
|
1351
|
+
if (!checkConstraint.name)
|
|
1352
|
+
checkConstraint.name =
|
|
1353
|
+
this.connection.namingStrategy.checkConstraintName(table, checkConstraint.expression);
|
|
1354
|
+
const up = this.createCheckConstraintSql(table, checkConstraint);
|
|
1355
|
+
const down = this.dropCheckConstraintSql(table, checkConstraint);
|
|
1356
|
+
await this.executeQueries(up, down);
|
|
1357
|
+
table.addCheckConstraint(checkConstraint);
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Creates new check constraints.
|
|
1361
|
+
*/
|
|
1362
|
+
async createCheckConstraints(tableOrName, checkConstraints) {
|
|
1363
|
+
const promises = checkConstraints.map((checkConstraint) => this.createCheckConstraint(tableOrName, checkConstraint));
|
|
1364
|
+
await Promise.all(promises);
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Drops check constraint.
|
|
1368
|
+
*/
|
|
1369
|
+
async dropCheckConstraint(tableOrName, checkOrName) {
|
|
1370
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1371
|
+
? tableOrName
|
|
1372
|
+
: await this.getCachedTable(tableOrName);
|
|
1373
|
+
const checkConstraint = InstanceChecker_1.InstanceChecker.isTableCheck(checkOrName)
|
|
1374
|
+
? checkOrName
|
|
1375
|
+
: table.checks.find((c) => c.name === checkOrName);
|
|
1376
|
+
if (!checkConstraint)
|
|
1377
|
+
throw new error_1.TypeORMError(`Supplied check constraint was not found in table ${table.name}`);
|
|
1378
|
+
const up = this.dropCheckConstraintSql(table, checkConstraint);
|
|
1379
|
+
const down = this.createCheckConstraintSql(table, checkConstraint);
|
|
1380
|
+
await this.executeQueries(up, down);
|
|
1381
|
+
table.removeCheckConstraint(checkConstraint);
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Drops check constraints.
|
|
1385
|
+
*/
|
|
1386
|
+
async dropCheckConstraints(tableOrName, checkConstraints) {
|
|
1387
|
+
const promises = checkConstraints.map((checkConstraint) => this.dropCheckConstraint(tableOrName, checkConstraint));
|
|
1388
|
+
await Promise.all(promises);
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Creates new exclusion constraint.
|
|
1392
|
+
*/
|
|
1393
|
+
async createExclusionConstraint(tableOrName, exclusionConstraint) {
|
|
1394
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1395
|
+
? tableOrName
|
|
1396
|
+
: await this.getCachedTable(tableOrName);
|
|
1397
|
+
// new unique constraint may be passed without name. In this case we generate unique name manually.
|
|
1398
|
+
if (!exclusionConstraint.name)
|
|
1399
|
+
exclusionConstraint.name =
|
|
1400
|
+
this.connection.namingStrategy.exclusionConstraintName(table, exclusionConstraint.expression);
|
|
1401
|
+
const up = this.createExclusionConstraintSql(table, exclusionConstraint);
|
|
1402
|
+
const down = this.dropExclusionConstraintSql(table, exclusionConstraint);
|
|
1403
|
+
await this.executeQueries(up, down);
|
|
1404
|
+
table.addExclusionConstraint(exclusionConstraint);
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Creates new exclusion constraints.
|
|
1408
|
+
*/
|
|
1409
|
+
async createExclusionConstraints(tableOrName, exclusionConstraints) {
|
|
1410
|
+
const promises = exclusionConstraints.map((exclusionConstraint) => this.createExclusionConstraint(tableOrName, exclusionConstraint));
|
|
1411
|
+
await Promise.all(promises);
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Drops exclusion constraint.
|
|
1415
|
+
*/
|
|
1416
|
+
async dropExclusionConstraint(tableOrName, exclusionOrName) {
|
|
1417
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1418
|
+
? tableOrName
|
|
1419
|
+
: await this.getCachedTable(tableOrName);
|
|
1420
|
+
const exclusionConstraint = InstanceChecker_1.InstanceChecker.isTableExclusion(exclusionOrName)
|
|
1421
|
+
? exclusionOrName
|
|
1422
|
+
: table.exclusions.find((c) => c.name === exclusionOrName);
|
|
1423
|
+
if (!exclusionConstraint)
|
|
1424
|
+
throw new error_1.TypeORMError(`Supplied exclusion constraint was not found in table ${table.name}`);
|
|
1425
|
+
const up = this.dropExclusionConstraintSql(table, exclusionConstraint);
|
|
1426
|
+
const down = this.createExclusionConstraintSql(table, exclusionConstraint);
|
|
1427
|
+
await this.executeQueries(up, down);
|
|
1428
|
+
table.removeExclusionConstraint(exclusionConstraint);
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Drops exclusion constraints.
|
|
1432
|
+
*/
|
|
1433
|
+
async dropExclusionConstraints(tableOrName, exclusionConstraints) {
|
|
1434
|
+
const promises = exclusionConstraints.map((exclusionConstraint) => this.dropExclusionConstraint(tableOrName, exclusionConstraint));
|
|
1435
|
+
await Promise.all(promises);
|
|
1436
|
+
}
|
|
1437
|
+
/**
|
|
1438
|
+
* Creates a new foreign key.
|
|
1439
|
+
*/
|
|
1440
|
+
async createForeignKey(tableOrName, foreignKey) {
|
|
1441
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1442
|
+
? tableOrName
|
|
1443
|
+
: await this.getCachedTable(tableOrName);
|
|
1444
|
+
// new FK may be passed without name. In this case we generate FK name manually.
|
|
1445
|
+
if (!foreignKey.name)
|
|
1446
|
+
foreignKey.name = this.connection.namingStrategy.foreignKeyName(table, foreignKey.columnNames, this.getTablePath(foreignKey), foreignKey.referencedColumnNames);
|
|
1447
|
+
const up = this.createForeignKeySql(table, foreignKey);
|
|
1448
|
+
const down = this.dropForeignKeySql(table, foreignKey);
|
|
1449
|
+
await this.executeQueries(up, down);
|
|
1450
|
+
table.addForeignKey(foreignKey);
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Creates a new foreign keys.
|
|
1454
|
+
*/
|
|
1455
|
+
async createForeignKeys(tableOrName, foreignKeys) {
|
|
1456
|
+
for (const foreignKey of foreignKeys) {
|
|
1457
|
+
await this.createForeignKey(tableOrName, foreignKey);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Drops a foreign key from the table.
|
|
1462
|
+
*/
|
|
1463
|
+
async dropForeignKey(tableOrName, foreignKeyOrName) {
|
|
1464
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1465
|
+
? tableOrName
|
|
1466
|
+
: await this.getCachedTable(tableOrName);
|
|
1467
|
+
const foreignKey = InstanceChecker_1.InstanceChecker.isTableForeignKey(foreignKeyOrName)
|
|
1468
|
+
? foreignKeyOrName
|
|
1469
|
+
: table.foreignKeys.find((fk) => fk.name === foreignKeyOrName);
|
|
1470
|
+
if (!foreignKey)
|
|
1471
|
+
throw new error_1.TypeORMError(`Supplied foreign key was not found in table ${table.name}`);
|
|
1472
|
+
const up = this.dropForeignKeySql(table, foreignKey);
|
|
1473
|
+
const down = this.createForeignKeySql(table, foreignKey);
|
|
1474
|
+
await this.executeQueries(up, down);
|
|
1475
|
+
table.removeForeignKey(foreignKey);
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Drops a foreign keys from the table.
|
|
1479
|
+
*/
|
|
1480
|
+
async dropForeignKeys(tableOrName, foreignKeys) {
|
|
1481
|
+
for (const foreignKey of foreignKeys) {
|
|
1482
|
+
await this.dropForeignKey(tableOrName, foreignKey);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Creates a new index.
|
|
1487
|
+
*/
|
|
1488
|
+
async createIndex(tableOrName, index) {
|
|
1489
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1490
|
+
? tableOrName
|
|
1491
|
+
: await this.getCachedTable(tableOrName);
|
|
1492
|
+
// new index may be passed without name. In this case we generate index name manually.
|
|
1493
|
+
if (!index.name)
|
|
1494
|
+
index.name = this.generateIndexName(table, index);
|
|
1495
|
+
const up = this.createIndexSql(table, index);
|
|
1496
|
+
const down = this.dropIndexSql(table, index);
|
|
1497
|
+
await this.executeQueries(up, down);
|
|
1498
|
+
table.addIndex(index);
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Creates a new indices
|
|
1502
|
+
*/
|
|
1503
|
+
async createIndices(tableOrName, indices) {
|
|
1504
|
+
for (const index of indices) {
|
|
1505
|
+
await this.createIndex(tableOrName, index);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Drops an index from the table.
|
|
1510
|
+
*/
|
|
1511
|
+
async dropIndex(tableOrName, indexOrName) {
|
|
1512
|
+
const table = InstanceChecker_1.InstanceChecker.isTable(tableOrName)
|
|
1513
|
+
? tableOrName
|
|
1514
|
+
: await this.getCachedTable(tableOrName);
|
|
1515
|
+
const index = InstanceChecker_1.InstanceChecker.isTableIndex(indexOrName)
|
|
1516
|
+
? indexOrName
|
|
1517
|
+
: table.indices.find((i) => i.name === indexOrName);
|
|
1518
|
+
if (!index)
|
|
1519
|
+
throw new error_1.TypeORMError(`Supplied index ${indexOrName} was not found in table ${table.name}`);
|
|
1520
|
+
// old index may be passed without name. In this case we generate index name manually.
|
|
1521
|
+
if (!index.name)
|
|
1522
|
+
index.name = this.generateIndexName(table, index);
|
|
1523
|
+
const up = this.dropIndexSql(table, index);
|
|
1524
|
+
const down = this.createIndexSql(table, index);
|
|
1525
|
+
await this.executeQueries(up, down);
|
|
1526
|
+
table.removeIndex(index);
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Drops an indices from the table.
|
|
1530
|
+
*/
|
|
1531
|
+
async dropIndices(tableOrName, indices) {
|
|
1532
|
+
for (const index of indices) {
|
|
1533
|
+
await this.dropIndex(tableOrName, index);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Clears all table contents.
|
|
1538
|
+
* Note: this operation uses SQL's TRUNCATE query which cannot be reverted in transactions.
|
|
1539
|
+
*/
|
|
1540
|
+
async clearTable(tableName) {
|
|
1541
|
+
await this.query(`TRUNCATE TABLE ${this.escapePath(tableName)}`);
|
|
1542
|
+
}
|
|
1543
|
+
/**
|
|
1544
|
+
* Removes all tables from the currently connected database.
|
|
1545
|
+
*/
|
|
1546
|
+
async clearDatabase() {
|
|
1547
|
+
const schemas = [];
|
|
1548
|
+
this.connection.entityMetadatas
|
|
1549
|
+
.filter((metadata) => metadata.schema)
|
|
1550
|
+
.forEach((metadata) => {
|
|
1551
|
+
const isSchemaExist = !!schemas.find((schema) => schema === metadata.schema);
|
|
1552
|
+
if (!isSchemaExist)
|
|
1553
|
+
schemas.push(metadata.schema);
|
|
1554
|
+
});
|
|
1555
|
+
schemas.push(this.driver.options.schema || "current_schema()");
|
|
1556
|
+
const schemaNamesString = schemas
|
|
1557
|
+
.map((name) => {
|
|
1558
|
+
return name === "current_schema()" ? name : "'" + name + "'";
|
|
1559
|
+
})
|
|
1560
|
+
.join(", ");
|
|
1561
|
+
const isAnotherTransactionActive = this.isTransactionActive;
|
|
1562
|
+
if (!isAnotherTransactionActive)
|
|
1563
|
+
await this.startTransaction();
|
|
1564
|
+
try {
|
|
1565
|
+
const version = await this.getVersion();
|
|
1566
|
+
// drop views
|
|
1567
|
+
const selectViewDropsQuery = `SELECT 'DROP VIEW IF EXISTS "' || schemaname || '"."' || viewname || '" CASCADE;' as "query" ` +
|
|
1568
|
+
`FROM "pg_views" WHERE "schemaname" IN (${schemaNamesString}) AND "viewname" NOT IN ('geography_columns', 'geometry_columns', 'raster_columns', 'raster_overviews')`;
|
|
1569
|
+
const dropViewQueries = await this.query(selectViewDropsQuery);
|
|
1570
|
+
await Promise.all(dropViewQueries.map((q) => this.query(q["query"])));
|
|
1571
|
+
// drop materialized views
|
|
1572
|
+
// Note: materialized views introduced in Postgres 9.3
|
|
1573
|
+
if (VersionUtils_1.VersionUtils.isGreaterOrEqual(version, "9.3")) {
|
|
1574
|
+
const selectMatViewDropsQuery = `SELECT 'DROP MATERIALIZED VIEW IF EXISTS "' || schemaname || '"."' || matviewname || '" CASCADE;' as "query" ` +
|
|
1575
|
+
`FROM "pg_matviews" WHERE "schemaname" IN (${schemaNamesString})`;
|
|
1576
|
+
const dropMatViewQueries = await this.query(selectMatViewDropsQuery);
|
|
1577
|
+
await Promise.all(dropMatViewQueries.map((q) => this.query(q["query"])));
|
|
1578
|
+
}
|
|
1579
|
+
// ignore spatial_ref_sys; it's a special table supporting PostGIS
|
|
1580
|
+
// TODO generalize this as this.driver.ignoreTables
|
|
1581
|
+
// drop tables
|
|
1582
|
+
const selectTableDropsQuery = `SELECT 'DROP TABLE IF EXISTS "' || schemaname || '"."' || tablename || '" CASCADE;' as "query" FROM "pg_tables" WHERE "schemaname" IN (${schemaNamesString}) AND "tablename" NOT IN ('spatial_ref_sys')`;
|
|
1583
|
+
const dropTableQueries = await this.query(selectTableDropsQuery);
|
|
1584
|
+
await Promise.all(dropTableQueries.map((q) => this.query(q["query"])));
|
|
1585
|
+
// drop enum types
|
|
1586
|
+
await this.dropEnumTypes(schemaNamesString);
|
|
1587
|
+
if (!isAnotherTransactionActive) {
|
|
1588
|
+
await this.commitTransaction();
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
catch (error) {
|
|
1592
|
+
try {
|
|
1593
|
+
// we throw original error even if rollback thrown an error
|
|
1594
|
+
if (!isAnotherTransactionActive) {
|
|
1595
|
+
await this.rollbackTransaction();
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
catch (rollbackError) { }
|
|
1599
|
+
throw error;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
// -------------------------------------------------------------------------
|
|
1603
|
+
// Protected Methods
|
|
1604
|
+
// -------------------------------------------------------------------------
|
|
1605
|
+
async loadViews(viewNames) {
|
|
1606
|
+
const hasTable = await this.hasTable(this.getTypeormMetadataTableName());
|
|
1607
|
+
if (!hasTable)
|
|
1608
|
+
return [];
|
|
1609
|
+
if (!viewNames) {
|
|
1610
|
+
viewNames = [];
|
|
1611
|
+
}
|
|
1612
|
+
const currentDatabase = await this.getCurrentDatabase();
|
|
1613
|
+
const currentSchema = await this.getCurrentSchema();
|
|
1614
|
+
const viewsCondition = viewNames.length === 0
|
|
1615
|
+
? "1=1"
|
|
1616
|
+
: viewNames
|
|
1617
|
+
.map((tableName) => this.driver.parseTableName(tableName))
|
|
1618
|
+
.map(({ schema, tableName }) => {
|
|
1619
|
+
if (!schema) {
|
|
1620
|
+
schema =
|
|
1621
|
+
this.driver.options.schema || currentSchema;
|
|
1622
|
+
}
|
|
1623
|
+
return `("t"."schema" = '${schema}' AND "t"."name" = '${tableName}')`;
|
|
1624
|
+
})
|
|
1625
|
+
.join(" OR ");
|
|
1626
|
+
const query = `SELECT "t".* FROM ${this.escapePath(this.getTypeormMetadataTableName())} "t" ` +
|
|
1627
|
+
`INNER JOIN "pg_catalog"."pg_class" "c" ON "c"."relname" = "t"."name" ` +
|
|
1628
|
+
`INNER JOIN "pg_namespace" "n" ON "n"."oid" = "c"."relnamespace" AND "n"."nspname" = "t"."schema" ` +
|
|
1629
|
+
`WHERE "t"."type" IN ('${MetadataTableType_1.MetadataTableType.VIEW}', '${MetadataTableType_1.MetadataTableType.MATERIALIZED_VIEW}') ${viewsCondition ? `AND (${viewsCondition})` : ""}`;
|
|
1630
|
+
const dbViews = await this.query(query);
|
|
1631
|
+
return dbViews.map((dbView) => {
|
|
1632
|
+
const view = new View_1.View();
|
|
1633
|
+
const schema = dbView["schema"] === currentSchema &&
|
|
1634
|
+
!this.driver.options.schema
|
|
1635
|
+
? undefined
|
|
1636
|
+
: dbView["schema"];
|
|
1637
|
+
view.database = currentDatabase;
|
|
1638
|
+
view.schema = dbView["schema"];
|
|
1639
|
+
view.name = this.driver.buildTableName(dbView["name"], schema);
|
|
1640
|
+
view.expression = dbView["value"];
|
|
1641
|
+
view.materialized =
|
|
1642
|
+
dbView["type"] === MetadataTableType_1.MetadataTableType.MATERIALIZED_VIEW;
|
|
1643
|
+
return view;
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* Loads all tables (with given names) from the database and creates a Table from them.
|
|
1648
|
+
*/
|
|
1649
|
+
async loadTables(tableNames) {
|
|
1650
|
+
// if no tables given then no need to proceed
|
|
1651
|
+
if (tableNames && tableNames.length === 0) {
|
|
1652
|
+
return [];
|
|
1653
|
+
}
|
|
1654
|
+
const currentSchema = await this.getCurrentSchema();
|
|
1655
|
+
const currentDatabase = await this.getCurrentDatabase();
|
|
1656
|
+
const dbTables = [];
|
|
1657
|
+
if (!tableNames) {
|
|
1658
|
+
const tablesSql = `SELECT "table_schema", "table_name" FROM "information_schema"."tables"`;
|
|
1659
|
+
dbTables.push(...(await this.query(tablesSql)));
|
|
1660
|
+
}
|
|
1661
|
+
else {
|
|
1662
|
+
const tablesCondition = tableNames
|
|
1663
|
+
.map((tableName) => this.driver.parseTableName(tableName))
|
|
1664
|
+
.map(({ schema, tableName }) => {
|
|
1665
|
+
return `("table_schema" = '${schema || currentSchema}' AND "table_name" = '${tableName}')`;
|
|
1666
|
+
})
|
|
1667
|
+
.join(" OR ");
|
|
1668
|
+
const tablesSql = `SELECT "table_schema", "table_name" FROM "information_schema"."tables" WHERE ` +
|
|
1669
|
+
tablesCondition;
|
|
1670
|
+
dbTables.push(...(await this.query(tablesSql)));
|
|
1671
|
+
}
|
|
1672
|
+
// if tables were not found in the db, no need to proceed
|
|
1673
|
+
if (dbTables.length === 0) {
|
|
1674
|
+
return [];
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Uses standard SQL information_schema.columns table and postgres-specific
|
|
1678
|
+
* pg_catalog.pg_attribute table to get column information.
|
|
1679
|
+
* @see https://stackoverflow.com/a/19541865
|
|
1680
|
+
*/
|
|
1681
|
+
const columnsCondition = dbTables
|
|
1682
|
+
.map(({ table_schema, table_name }) => {
|
|
1683
|
+
return `("table_schema" = '${table_schema}' AND "table_name" = '${table_name}')`;
|
|
1684
|
+
})
|
|
1685
|
+
.join(" OR ");
|
|
1686
|
+
const columnsSql = `SELECT columns.*, pg_catalog.col_description(('"' || table_catalog || '"."' || table_schema || '"."' || table_name || '"')::regclass::oid, ordinal_position) AS description, ` +
|
|
1687
|
+
`('"' || "udt_schema" || '"."' || "udt_name" || '"')::"regtype" AS "regtype", pg_catalog.format_type("col_attr"."atttypid", "col_attr"."atttypmod") AS "format_type" ` +
|
|
1688
|
+
`FROM "information_schema"."columns" ` +
|
|
1689
|
+
`LEFT JOIN "pg_catalog"."pg_attribute" AS "col_attr" ON "col_attr"."attname" = "columns"."column_name" ` +
|
|
1690
|
+
`AND "col_attr"."attrelid" = ( ` +
|
|
1691
|
+
`SELECT "cls"."oid" FROM "pg_catalog"."pg_class" AS "cls" ` +
|
|
1692
|
+
`LEFT JOIN "pg_catalog"."pg_namespace" AS "ns" ON "ns"."oid" = "cls"."relnamespace" ` +
|
|
1693
|
+
`WHERE "cls"."relname" = "columns"."table_name" ` +
|
|
1694
|
+
`AND "ns"."nspname" = "columns"."table_schema" ` +
|
|
1695
|
+
`) ` +
|
|
1696
|
+
`WHERE ` +
|
|
1697
|
+
columnsCondition;
|
|
1698
|
+
const constraintsCondition = dbTables
|
|
1699
|
+
.map(({ table_schema, table_name }) => {
|
|
1700
|
+
return `("ns"."nspname" = '${table_schema}' AND "t"."relname" = '${table_name}')`;
|
|
1701
|
+
})
|
|
1702
|
+
.join(" OR ");
|
|
1703
|
+
const constraintsSql = `SELECT "ns"."nspname" AS "table_schema", "t"."relname" AS "table_name", "cnst"."conname" AS "constraint_name", ` +
|
|
1704
|
+
`pg_get_constraintdef("cnst"."oid") AS "expression", ` +
|
|
1705
|
+
`CASE "cnst"."contype" WHEN 'p' THEN 'PRIMARY' WHEN 'u' THEN 'UNIQUE' WHEN 'c' THEN 'CHECK' WHEN 'x' THEN 'EXCLUDE' END AS "constraint_type", "a"."attname" AS "column_name" ` +
|
|
1706
|
+
`FROM "pg_constraint" "cnst" ` +
|
|
1707
|
+
`INNER JOIN "pg_class" "t" ON "t"."oid" = "cnst"."conrelid" ` +
|
|
1708
|
+
`INNER JOIN "pg_namespace" "ns" ON "ns"."oid" = "cnst"."connamespace" ` +
|
|
1709
|
+
`LEFT JOIN "pg_attribute" "a" ON "a"."attrelid" = "cnst"."conrelid" AND "a"."attnum" = ANY ("cnst"."conkey") ` +
|
|
1710
|
+
`WHERE "t"."relkind" IN ('r', 'p') AND (${constraintsCondition})`;
|
|
1711
|
+
const indicesSql = `SELECT "ns"."nspname" AS "table_schema", "t"."relname" AS "table_name", "i"."relname" AS "constraint_name", "a"."attname" AS "column_name", ` +
|
|
1712
|
+
`CASE "ix"."indisunique" WHEN 't' THEN 'TRUE' ELSE'FALSE' END AS "is_unique", pg_get_expr("ix"."indpred", "ix"."indrelid") AS "condition", ` +
|
|
1713
|
+
`"types"."typname" AS "type_name" ` +
|
|
1714
|
+
`FROM "pg_class" "t" ` +
|
|
1715
|
+
`INNER JOIN "pg_index" "ix" ON "ix"."indrelid" = "t"."oid" ` +
|
|
1716
|
+
`INNER JOIN "pg_attribute" "a" ON "a"."attrelid" = "t"."oid" AND "a"."attnum" = ANY ("ix"."indkey") ` +
|
|
1717
|
+
`INNER JOIN "pg_namespace" "ns" ON "ns"."oid" = "t"."relnamespace" ` +
|
|
1718
|
+
`INNER JOIN "pg_class" "i" ON "i"."oid" = "ix"."indexrelid" ` +
|
|
1719
|
+
`INNER JOIN "pg_type" "types" ON "types"."oid" = "a"."atttypid" ` +
|
|
1720
|
+
`LEFT JOIN "pg_constraint" "cnst" ON "cnst"."conname" = "i"."relname" ` +
|
|
1721
|
+
`WHERE "t"."relkind" IN ('r', 'p') AND "cnst"."contype" IS NULL AND (${constraintsCondition})`;
|
|
1722
|
+
const foreignKeysCondition = dbTables
|
|
1723
|
+
.map(({ table_schema, table_name }) => {
|
|
1724
|
+
return `("ns"."nspname" = '${table_schema}' AND "cl"."relname" = '${table_name}')`;
|
|
1725
|
+
})
|
|
1726
|
+
.join(" OR ");
|
|
1727
|
+
const hasRelispartitionColumn = await this.hasSupportForPartitionedTables();
|
|
1728
|
+
const isPartitionCondition = hasRelispartitionColumn
|
|
1729
|
+
? ` AND "cl"."relispartition" = 'f'`
|
|
1730
|
+
: "";
|
|
1731
|
+
const foreignKeysSql = `SELECT "con"."conname" AS "constraint_name", "con"."nspname" AS "table_schema", "con"."relname" AS "table_name", "att2"."attname" AS "column_name", ` +
|
|
1732
|
+
`"ns"."nspname" AS "referenced_table_schema", "cl"."relname" AS "referenced_table_name", "att"."attname" AS "referenced_column_name", "con"."confdeltype" AS "on_delete", ` +
|
|
1733
|
+
`"con"."confupdtype" AS "on_update", "con"."condeferrable" AS "deferrable", "con"."condeferred" AS "deferred" ` +
|
|
1734
|
+
`FROM ( ` +
|
|
1735
|
+
`SELECT UNNEST ("con1"."conkey") AS "parent", UNNEST ("con1"."confkey") AS "child", "con1"."confrelid", "con1"."conrelid", "con1"."conname", "con1"."contype", "ns"."nspname", ` +
|
|
1736
|
+
`"cl"."relname", "con1"."condeferrable", ` +
|
|
1737
|
+
`CASE WHEN "con1"."condeferred" THEN 'INITIALLY DEFERRED' ELSE 'INITIALLY IMMEDIATE' END as condeferred, ` +
|
|
1738
|
+
`CASE "con1"."confdeltype" WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT' WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END as "confdeltype", ` +
|
|
1739
|
+
`CASE "con1"."confupdtype" WHEN 'a' THEN 'NO ACTION' WHEN 'r' THEN 'RESTRICT' WHEN 'c' THEN 'CASCADE' WHEN 'n' THEN 'SET NULL' WHEN 'd' THEN 'SET DEFAULT' END as "confupdtype" ` +
|
|
1740
|
+
`FROM "pg_class" "cl" ` +
|
|
1741
|
+
`INNER JOIN "pg_namespace" "ns" ON "cl"."relnamespace" = "ns"."oid" ` +
|
|
1742
|
+
`INNER JOIN "pg_constraint" "con1" ON "con1"."conrelid" = "cl"."oid" ` +
|
|
1743
|
+
`WHERE "con1"."contype" = 'f' AND (${foreignKeysCondition}) ` +
|
|
1744
|
+
`) "con" ` +
|
|
1745
|
+
`INNER JOIN "pg_attribute" "att" ON "att"."attrelid" = "con"."confrelid" AND "att"."attnum" = "con"."child" ` +
|
|
1746
|
+
`INNER JOIN "pg_class" "cl" ON "cl"."oid" = "con"."confrelid" ${isPartitionCondition}` +
|
|
1747
|
+
`INNER JOIN "pg_namespace" "ns" ON "cl"."relnamespace" = "ns"."oid" ` +
|
|
1748
|
+
`INNER JOIN "pg_attribute" "att2" ON "att2"."attrelid" = "con"."conrelid" AND "att2"."attnum" = "con"."parent"`;
|
|
1749
|
+
const [dbColumns, dbConstraints, dbIndices, dbForeignKeys,] = await Promise.all([
|
|
1750
|
+
this.query(columnsSql),
|
|
1751
|
+
this.query(constraintsSql),
|
|
1752
|
+
this.query(indicesSql),
|
|
1753
|
+
this.query(foreignKeysSql),
|
|
1754
|
+
]);
|
|
1755
|
+
// create tables for loaded tables
|
|
1756
|
+
return Promise.all(dbTables.map(async (dbTable) => {
|
|
1757
|
+
const table = new Table_1.Table();
|
|
1758
|
+
const getSchemaFromKey = (dbObject, key) => {
|
|
1759
|
+
return dbObject[key] === currentSchema &&
|
|
1760
|
+
(!this.driver.options.schema ||
|
|
1761
|
+
this.driver.options.schema === currentSchema)
|
|
1762
|
+
? undefined
|
|
1763
|
+
: dbObject[key];
|
|
1764
|
+
};
|
|
1765
|
+
// We do not need to join schema name, when database is by default.
|
|
1766
|
+
const schema = getSchemaFromKey(dbTable, "table_schema");
|
|
1767
|
+
table.database = currentDatabase;
|
|
1768
|
+
table.schema = dbTable["table_schema"];
|
|
1769
|
+
table.name = this.driver.buildTableName(dbTable["table_name"], schema);
|
|
1770
|
+
// create columns from the loaded columns
|
|
1771
|
+
table.columns = await Promise.all(dbColumns
|
|
1772
|
+
.filter((dbColumn) => dbColumn["table_name"] ===
|
|
1773
|
+
dbTable["table_name"] &&
|
|
1774
|
+
dbColumn["table_schema"] ===
|
|
1775
|
+
dbTable["table_schema"])
|
|
1776
|
+
.map(async (dbColumn) => {
|
|
1777
|
+
const columnConstraints = dbConstraints.filter((dbConstraint) => {
|
|
1778
|
+
return (dbConstraint["table_name"] ===
|
|
1779
|
+
dbColumn["table_name"] &&
|
|
1780
|
+
dbConstraint["table_schema"] ===
|
|
1781
|
+
dbColumn["table_schema"] &&
|
|
1782
|
+
dbConstraint["column_name"] ===
|
|
1783
|
+
dbColumn["column_name"]);
|
|
1784
|
+
});
|
|
1785
|
+
const tableColumn = new TableColumn_1.TableColumn();
|
|
1786
|
+
tableColumn.name = dbColumn["column_name"];
|
|
1787
|
+
tableColumn.type = dbColumn["regtype"].toLowerCase();
|
|
1788
|
+
if (tableColumn.type === "numeric" ||
|
|
1789
|
+
tableColumn.type === "decimal" ||
|
|
1790
|
+
tableColumn.type === "float") {
|
|
1791
|
+
// If one of these properties was set, and another was not, Postgres sets '0' in to unspecified property
|
|
1792
|
+
// we set 'undefined' in to unspecified property to avoid changing column on sync
|
|
1793
|
+
if (dbColumn["numeric_precision"] !== null &&
|
|
1794
|
+
!this.isDefaultColumnPrecision(table, tableColumn, dbColumn["numeric_precision"])) {
|
|
1795
|
+
tableColumn.precision =
|
|
1796
|
+
dbColumn["numeric_precision"];
|
|
1797
|
+
}
|
|
1798
|
+
else if (dbColumn["numeric_scale"] !== null &&
|
|
1799
|
+
!this.isDefaultColumnScale(table, tableColumn, dbColumn["numeric_scale"])) {
|
|
1800
|
+
tableColumn.precision = undefined;
|
|
1801
|
+
}
|
|
1802
|
+
if (dbColumn["numeric_scale"] !== null &&
|
|
1803
|
+
!this.isDefaultColumnScale(table, tableColumn, dbColumn["numeric_scale"])) {
|
|
1804
|
+
tableColumn.scale =
|
|
1805
|
+
dbColumn["numeric_scale"];
|
|
1806
|
+
}
|
|
1807
|
+
else if (dbColumn["numeric_precision"] !== null &&
|
|
1808
|
+
!this.isDefaultColumnPrecision(table, tableColumn, dbColumn["numeric_precision"])) {
|
|
1809
|
+
tableColumn.scale = undefined;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
if (tableColumn.type === "interval" ||
|
|
1813
|
+
tableColumn.type === "time without time zone" ||
|
|
1814
|
+
tableColumn.type === "time with time zone" ||
|
|
1815
|
+
tableColumn.type ===
|
|
1816
|
+
"timestamp without time zone" ||
|
|
1817
|
+
tableColumn.type === "timestamp with time zone") {
|
|
1818
|
+
tableColumn.precision =
|
|
1819
|
+
!this.isDefaultColumnPrecision(table, tableColumn, dbColumn["datetime_precision"])
|
|
1820
|
+
? dbColumn["datetime_precision"]
|
|
1821
|
+
: undefined;
|
|
1822
|
+
}
|
|
1823
|
+
// check if column has user-defined data type.
|
|
1824
|
+
// NOTE: if ENUM type defined with "array:true" it comes with ARRAY type instead of USER-DEFINED
|
|
1825
|
+
if (dbColumn["data_type"] === "USER-DEFINED" ||
|
|
1826
|
+
dbColumn["data_type"] === "ARRAY") {
|
|
1827
|
+
const { name } = await this.getUserDefinedTypeName(table, tableColumn);
|
|
1828
|
+
// check if `enumName` is specified by user
|
|
1829
|
+
const builtEnumName = this.buildEnumName(table, tableColumn, false, true);
|
|
1830
|
+
const enumName = builtEnumName !== name ? name : undefined;
|
|
1831
|
+
// check if type is ENUM
|
|
1832
|
+
const sql = `SELECT "e"."enumlabel" AS "value" FROM "pg_enum" "e" ` +
|
|
1833
|
+
`INNER JOIN "pg_type" "t" ON "t"."oid" = "e"."enumtypid" ` +
|
|
1834
|
+
`INNER JOIN "pg_namespace" "n" ON "n"."oid" = "t"."typnamespace" ` +
|
|
1835
|
+
`WHERE "n"."nspname" = '${dbTable["table_schema"]}' AND "t"."typname" = '${enumName || name}'`;
|
|
1836
|
+
const results = await this.query(sql);
|
|
1837
|
+
if (results.length) {
|
|
1838
|
+
tableColumn.type = "enum";
|
|
1839
|
+
tableColumn.enum = results.map((result) => result["value"]);
|
|
1840
|
+
tableColumn.enumName = enumName;
|
|
1841
|
+
}
|
|
1842
|
+
if (dbColumn["data_type"] === "ARRAY") {
|
|
1843
|
+
tableColumn.isArray = true;
|
|
1844
|
+
const type = tableColumn.type.replace("[]", "");
|
|
1845
|
+
tableColumn.type =
|
|
1846
|
+
this.connection.driver.normalizeType({
|
|
1847
|
+
type: type,
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
if (tableColumn.type === "geometry") {
|
|
1852
|
+
const geometryColumnSql = `SELECT * FROM (
|
|
1853
|
+
SELECT
|
|
1854
|
+
"f_table_schema" "table_schema",
|
|
1855
|
+
"f_table_name" "table_name",
|
|
1856
|
+
"f_geometry_column" "column_name",
|
|
1857
|
+
"srid",
|
|
1858
|
+
"type"
|
|
1859
|
+
FROM "geometry_columns"
|
|
1860
|
+
) AS _
|
|
1861
|
+
WHERE
|
|
1862
|
+
"column_name" = '${dbColumn["column_name"]}' AND
|
|
1863
|
+
"table_schema" = '${dbColumn["table_schema"]}' AND
|
|
1864
|
+
"table_name" = '${dbColumn["table_name"]}'`;
|
|
1865
|
+
const results = await this.query(geometryColumnSql);
|
|
1866
|
+
if (results.length > 0) {
|
|
1867
|
+
tableColumn.spatialFeatureType =
|
|
1868
|
+
results[0].type;
|
|
1869
|
+
tableColumn.srid = results[0].srid;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
if (tableColumn.type === "geography") {
|
|
1873
|
+
const geographyColumnSql = `SELECT * FROM (
|
|
1874
|
+
SELECT
|
|
1875
|
+
"f_table_schema" "table_schema",
|
|
1876
|
+
"f_table_name" "table_name",
|
|
1877
|
+
"f_geography_column" "column_name",
|
|
1878
|
+
"srid",
|
|
1879
|
+
"type"
|
|
1880
|
+
FROM "geography_columns"
|
|
1881
|
+
) AS _
|
|
1882
|
+
WHERE
|
|
1883
|
+
"column_name" = '${dbColumn["column_name"]}' AND
|
|
1884
|
+
"table_schema" = '${dbColumn["table_schema"]}' AND
|
|
1885
|
+
"table_name" = '${dbColumn["table_name"]}'`;
|
|
1886
|
+
const results = await this.query(geographyColumnSql);
|
|
1887
|
+
if (results.length > 0) {
|
|
1888
|
+
tableColumn.spatialFeatureType =
|
|
1889
|
+
results[0].type;
|
|
1890
|
+
tableColumn.srid = results[0].srid;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
// check only columns that have length property
|
|
1894
|
+
if (this.driver.withLengthColumnTypes.indexOf(tableColumn.type) !== -1) {
|
|
1895
|
+
let length;
|
|
1896
|
+
if (tableColumn.isArray) {
|
|
1897
|
+
const match = /\((\d+)\)/.exec(dbColumn["format_type"]);
|
|
1898
|
+
length = match ? match[1] : undefined;
|
|
1899
|
+
}
|
|
1900
|
+
else if (dbColumn["character_maximum_length"]) {
|
|
1901
|
+
length =
|
|
1902
|
+
dbColumn["character_maximum_length"].toString();
|
|
1903
|
+
}
|
|
1904
|
+
if (length) {
|
|
1905
|
+
tableColumn.length =
|
|
1906
|
+
!this.isDefaultColumnLength(table, tableColumn, length)
|
|
1907
|
+
? length
|
|
1908
|
+
: "";
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
tableColumn.isNullable =
|
|
1912
|
+
dbColumn["is_nullable"] === "YES";
|
|
1913
|
+
const primaryConstraint = columnConstraints.find((constraint) => constraint["constraint_type"] === "PRIMARY");
|
|
1914
|
+
if (primaryConstraint) {
|
|
1915
|
+
tableColumn.isPrimary = true;
|
|
1916
|
+
// find another columns involved in primary key constraint
|
|
1917
|
+
const anotherPrimaryConstraints = dbConstraints.filter((constraint) => constraint["table_name"] ===
|
|
1918
|
+
dbColumn["table_name"] &&
|
|
1919
|
+
constraint["table_schema"] ===
|
|
1920
|
+
dbColumn["table_schema"] &&
|
|
1921
|
+
constraint["column_name"] !==
|
|
1922
|
+
dbColumn["column_name"] &&
|
|
1923
|
+
constraint["constraint_type"] ===
|
|
1924
|
+
"PRIMARY");
|
|
1925
|
+
// collect all column names
|
|
1926
|
+
const columnNames = anotherPrimaryConstraints.map((constraint) => constraint["column_name"]);
|
|
1927
|
+
columnNames.push(dbColumn["column_name"]);
|
|
1928
|
+
// build default primary key constraint name
|
|
1929
|
+
const pkName = this.connection.namingStrategy.primaryKeyName(table, columnNames);
|
|
1930
|
+
// if primary key has user-defined constraint name, write it in table column
|
|
1931
|
+
if (primaryConstraint["constraint_name"] !==
|
|
1932
|
+
pkName) {
|
|
1933
|
+
tableColumn.primaryKeyConstraintName =
|
|
1934
|
+
primaryConstraint["constraint_name"];
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
const uniqueConstraints = columnConstraints.filter((constraint) => constraint["constraint_type"] === "UNIQUE");
|
|
1938
|
+
const isConstraintComposite = uniqueConstraints.every((uniqueConstraint) => {
|
|
1939
|
+
return dbConstraints.some((dbConstraint) => dbConstraint["constraint_type"] ===
|
|
1940
|
+
"UNIQUE" &&
|
|
1941
|
+
dbConstraint["constraint_name"] ===
|
|
1942
|
+
uniqueConstraint["constraint_name"] &&
|
|
1943
|
+
dbConstraint["column_name"] !==
|
|
1944
|
+
dbColumn["column_name"]);
|
|
1945
|
+
});
|
|
1946
|
+
tableColumn.isUnique =
|
|
1947
|
+
uniqueConstraints.length > 0 &&
|
|
1948
|
+
!isConstraintComposite;
|
|
1949
|
+
if (dbColumn.is_identity === "YES") {
|
|
1950
|
+
// Postgres 10+ Identity column
|
|
1951
|
+
tableColumn.isGenerated = true;
|
|
1952
|
+
tableColumn.generationStrategy = "identity";
|
|
1953
|
+
tableColumn.generatedIdentity =
|
|
1954
|
+
dbColumn.identity_generation;
|
|
1955
|
+
}
|
|
1956
|
+
else if (dbColumn["column_default"] !== null &&
|
|
1957
|
+
dbColumn["column_default"] !== undefined) {
|
|
1958
|
+
const serialDefaultName = `nextval('${this.buildSequenceName(table, dbColumn["column_name"])}'::regclass)`;
|
|
1959
|
+
const serialDefaultPath = `nextval('${this.buildSequencePath(table, dbColumn["column_name"])}'::regclass)`;
|
|
1960
|
+
const defaultWithoutQuotes = dbColumn["column_default"].replace(/"/g, "");
|
|
1961
|
+
if (defaultWithoutQuotes ===
|
|
1962
|
+
serialDefaultName ||
|
|
1963
|
+
defaultWithoutQuotes === serialDefaultPath) {
|
|
1964
|
+
tableColumn.isGenerated = true;
|
|
1965
|
+
tableColumn.generationStrategy = "increment";
|
|
1966
|
+
}
|
|
1967
|
+
else if (dbColumn["column_default"] ===
|
|
1968
|
+
"gen_random_uuid()" ||
|
|
1969
|
+
/^uuid_generate_v\d\(\)/.test(dbColumn["column_default"])) {
|
|
1970
|
+
if (tableColumn.type === "uuid") {
|
|
1971
|
+
tableColumn.isGenerated = true;
|
|
1972
|
+
tableColumn.generationStrategy = "uuid";
|
|
1973
|
+
}
|
|
1974
|
+
else {
|
|
1975
|
+
tableColumn.default =
|
|
1976
|
+
dbColumn["column_default"];
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
else if (dbColumn["column_default"] === "now()" ||
|
|
1980
|
+
dbColumn["column_default"].indexOf("'now'::text") !== -1) {
|
|
1981
|
+
tableColumn.default =
|
|
1982
|
+
dbColumn["column_default"];
|
|
1983
|
+
}
|
|
1984
|
+
else {
|
|
1985
|
+
tableColumn.default = dbColumn["column_default"].replace(/::[\w\s\.\[\]\"]+/g, "");
|
|
1986
|
+
tableColumn.default =
|
|
1987
|
+
tableColumn.default.replace(/^(-?\d+)$/, "'$1'");
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
if (dbColumn["is_generated"] === "ALWAYS" &&
|
|
1991
|
+
dbColumn["generation_expression"]) {
|
|
1992
|
+
// In postgres there is no VIRTUAL generated column type
|
|
1993
|
+
tableColumn.generatedType = "STORED";
|
|
1994
|
+
// We cannot relay on information_schema.columns.generation_expression, because it is formatted different.
|
|
1995
|
+
const asExpressionQuery = await this.selectTypeormMetadataSql({
|
|
1996
|
+
database: currentDatabase,
|
|
1997
|
+
schema: dbTable["table_schema"],
|
|
1998
|
+
table: dbTable["table_name"],
|
|
1999
|
+
type: MetadataTableType_1.MetadataTableType.GENERATED_COLUMN,
|
|
2000
|
+
name: tableColumn.name,
|
|
2001
|
+
});
|
|
2002
|
+
const results = await this.query(asExpressionQuery.query, asExpressionQuery.parameters);
|
|
2003
|
+
if (results[0] && results[0].value) {
|
|
2004
|
+
tableColumn.asExpression = results[0].value;
|
|
2005
|
+
}
|
|
2006
|
+
else {
|
|
2007
|
+
tableColumn.asExpression = "";
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
tableColumn.comment = dbColumn["description"]
|
|
2011
|
+
? dbColumn["description"]
|
|
2012
|
+
: undefined;
|
|
2013
|
+
if (dbColumn["character_set_name"])
|
|
2014
|
+
tableColumn.charset =
|
|
2015
|
+
dbColumn["character_set_name"];
|
|
2016
|
+
if (dbColumn["collation_name"])
|
|
2017
|
+
tableColumn.collation =
|
|
2018
|
+
dbColumn["collation_name"];
|
|
2019
|
+
return tableColumn;
|
|
2020
|
+
}));
|
|
2021
|
+
// find unique constraints of table, group them by constraint name and build TableUnique.
|
|
2022
|
+
const tableUniqueConstraints = OrmUtils_1.OrmUtils.uniq(dbConstraints.filter((dbConstraint) => {
|
|
2023
|
+
return (dbConstraint["table_name"] ===
|
|
2024
|
+
dbTable["table_name"] &&
|
|
2025
|
+
dbConstraint["table_schema"] ===
|
|
2026
|
+
dbTable["table_schema"] &&
|
|
2027
|
+
dbConstraint["constraint_type"] === "UNIQUE");
|
|
2028
|
+
}), (dbConstraint) => dbConstraint["constraint_name"]);
|
|
2029
|
+
table.uniques = tableUniqueConstraints.map((constraint) => {
|
|
2030
|
+
const uniques = dbConstraints.filter((dbC) => dbC["constraint_name"] ===
|
|
2031
|
+
constraint["constraint_name"]);
|
|
2032
|
+
return new TableUnique_1.TableUnique({
|
|
2033
|
+
name: constraint["constraint_name"],
|
|
2034
|
+
columnNames: uniques.map((u) => u["column_name"]),
|
|
2035
|
+
deferrable: constraint["deferrable"]
|
|
2036
|
+
? constraint["deferred"]
|
|
2037
|
+
: undefined,
|
|
2038
|
+
});
|
|
2039
|
+
});
|
|
2040
|
+
// find check constraints of table, group them by constraint name and build TableCheck.
|
|
2041
|
+
const tableCheckConstraints = OrmUtils_1.OrmUtils.uniq(dbConstraints.filter((dbConstraint) => {
|
|
2042
|
+
return (dbConstraint["table_name"] ===
|
|
2043
|
+
dbTable["table_name"] &&
|
|
2044
|
+
dbConstraint["table_schema"] ===
|
|
2045
|
+
dbTable["table_schema"] &&
|
|
2046
|
+
dbConstraint["constraint_type"] === "CHECK");
|
|
2047
|
+
}), (dbConstraint) => dbConstraint["constraint_name"]);
|
|
2048
|
+
table.checks = tableCheckConstraints.map((constraint) => {
|
|
2049
|
+
const checks = dbConstraints.filter((dbC) => dbC["constraint_name"] ===
|
|
2050
|
+
constraint["constraint_name"]);
|
|
2051
|
+
return new TableCheck_1.TableCheck({
|
|
2052
|
+
name: constraint["constraint_name"],
|
|
2053
|
+
columnNames: checks.map((c) => c["column_name"]),
|
|
2054
|
+
expression: constraint["expression"].replace(/^\s*CHECK\s*\((.*)\)\s*$/i, "$1"),
|
|
2055
|
+
});
|
|
2056
|
+
});
|
|
2057
|
+
// find exclusion constraints of table, group them by constraint name and build TableExclusion.
|
|
2058
|
+
const tableExclusionConstraints = OrmUtils_1.OrmUtils.uniq(dbConstraints.filter((dbConstraint) => {
|
|
2059
|
+
return (dbConstraint["table_name"] ===
|
|
2060
|
+
dbTable["table_name"] &&
|
|
2061
|
+
dbConstraint["table_schema"] ===
|
|
2062
|
+
dbTable["table_schema"] &&
|
|
2063
|
+
dbConstraint["constraint_type"] === "EXCLUDE");
|
|
2064
|
+
}), (dbConstraint) => dbConstraint["constraint_name"]);
|
|
2065
|
+
table.exclusions = tableExclusionConstraints.map((constraint) => {
|
|
2066
|
+
return new TableExclusion_1.TableExclusion({
|
|
2067
|
+
name: constraint["constraint_name"],
|
|
2068
|
+
expression: constraint["expression"].substring(8), // trim EXCLUDE from start of expression
|
|
2069
|
+
});
|
|
2070
|
+
});
|
|
2071
|
+
// find foreign key constraints of table, group them by constraint name and build TableForeignKey.
|
|
2072
|
+
const tableForeignKeyConstraints = OrmUtils_1.OrmUtils.uniq(dbForeignKeys.filter((dbForeignKey) => {
|
|
2073
|
+
return (dbForeignKey["table_name"] ===
|
|
2074
|
+
dbTable["table_name"] &&
|
|
2075
|
+
dbForeignKey["table_schema"] ===
|
|
2076
|
+
dbTable["table_schema"]);
|
|
2077
|
+
}), (dbForeignKey) => dbForeignKey["constraint_name"]);
|
|
2078
|
+
table.foreignKeys = tableForeignKeyConstraints.map((dbForeignKey) => {
|
|
2079
|
+
const foreignKeys = dbForeignKeys.filter((dbFk) => dbFk["constraint_name"] ===
|
|
2080
|
+
dbForeignKey["constraint_name"]);
|
|
2081
|
+
// if referenced table located in currently used schema, we don't need to concat schema name to table name.
|
|
2082
|
+
const schema = getSchemaFromKey(dbForeignKey, "referenced_table_schema");
|
|
2083
|
+
const referencedTableName = this.driver.buildTableName(dbForeignKey["referenced_table_name"], schema);
|
|
2084
|
+
return new TableForeignKey_1.TableForeignKey({
|
|
2085
|
+
name: dbForeignKey["constraint_name"],
|
|
2086
|
+
columnNames: foreignKeys.map((dbFk) => dbFk["column_name"]),
|
|
2087
|
+
referencedSchema: dbForeignKey["referenced_table_schema"],
|
|
2088
|
+
referencedTableName: referencedTableName,
|
|
2089
|
+
referencedColumnNames: foreignKeys.map((dbFk) => dbFk["referenced_column_name"]),
|
|
2090
|
+
onDelete: dbForeignKey["on_delete"],
|
|
2091
|
+
onUpdate: dbForeignKey["on_update"],
|
|
2092
|
+
deferrable: dbForeignKey["deferrable"]
|
|
2093
|
+
? dbForeignKey["deferred"]
|
|
2094
|
+
: undefined,
|
|
2095
|
+
});
|
|
2096
|
+
});
|
|
2097
|
+
// find index constraints of table, group them by constraint name and build TableIndex.
|
|
2098
|
+
const tableIndexConstraints = OrmUtils_1.OrmUtils.uniq(dbIndices.filter((dbIndex) => {
|
|
2099
|
+
return (dbIndex["table_name"] === dbTable["table_name"] &&
|
|
2100
|
+
dbIndex["table_schema"] === dbTable["table_schema"]);
|
|
2101
|
+
}), (dbIndex) => dbIndex["constraint_name"]);
|
|
2102
|
+
table.indices = tableIndexConstraints.map((constraint) => {
|
|
2103
|
+
const indices = dbIndices.filter((index) => {
|
|
2104
|
+
return (index["table_schema"] ===
|
|
2105
|
+
constraint["table_schema"] &&
|
|
2106
|
+
index["table_name"] === constraint["table_name"] &&
|
|
2107
|
+
index["constraint_name"] ===
|
|
2108
|
+
constraint["constraint_name"]);
|
|
2109
|
+
});
|
|
2110
|
+
return new TableIndex_1.TableIndex({
|
|
2111
|
+
table: table,
|
|
2112
|
+
name: constraint["constraint_name"],
|
|
2113
|
+
columnNames: indices.map((i) => i["column_name"]),
|
|
2114
|
+
isUnique: constraint["is_unique"] === "TRUE",
|
|
2115
|
+
where: constraint["condition"],
|
|
2116
|
+
isSpatial: indices.every((i) => this.driver.spatialTypes.indexOf(i["type_name"]) >= 0),
|
|
2117
|
+
isFulltext: false,
|
|
2118
|
+
});
|
|
2119
|
+
});
|
|
2120
|
+
return table;
|
|
2121
|
+
}));
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Builds create table sql.
|
|
2125
|
+
*/
|
|
2126
|
+
createTableSql(table, createForeignKeys) {
|
|
2127
|
+
const columnDefinitions = table.columns
|
|
2128
|
+
.map((column) => this.buildCreateColumnSql(table, column))
|
|
2129
|
+
.join(", ");
|
|
2130
|
+
let sql = `CREATE TABLE ${this.escapePath(table)} (${columnDefinitions}`;
|
|
2131
|
+
table.columns
|
|
2132
|
+
.filter((column) => column.isUnique)
|
|
2133
|
+
.forEach((column) => {
|
|
2134
|
+
const isUniqueExist = table.uniques.some((unique) => unique.columnNames.length === 1 &&
|
|
2135
|
+
unique.columnNames[0] === column.name);
|
|
2136
|
+
if (!isUniqueExist)
|
|
2137
|
+
table.uniques.push(new TableUnique_1.TableUnique({
|
|
2138
|
+
name: this.connection.namingStrategy.uniqueConstraintName(table, [column.name]),
|
|
2139
|
+
columnNames: [column.name],
|
|
2140
|
+
}));
|
|
2141
|
+
});
|
|
2142
|
+
if (table.uniques.length > 0) {
|
|
2143
|
+
const uniquesSql = table.uniques
|
|
2144
|
+
.map((unique) => {
|
|
2145
|
+
const uniqueName = unique.name
|
|
2146
|
+
? unique.name
|
|
2147
|
+
: this.connection.namingStrategy.uniqueConstraintName(table, unique.columnNames);
|
|
2148
|
+
const columnNames = unique.columnNames
|
|
2149
|
+
.map((columnName) => `"${columnName}"`)
|
|
2150
|
+
.join(", ");
|
|
2151
|
+
let constraint = `CONSTRAINT "${uniqueName}" UNIQUE (${columnNames})`;
|
|
2152
|
+
if (unique.deferrable)
|
|
2153
|
+
constraint += ` DEFERRABLE ${unique.deferrable}`;
|
|
2154
|
+
return constraint;
|
|
2155
|
+
})
|
|
2156
|
+
.join(", ");
|
|
2157
|
+
sql += `, ${uniquesSql}`;
|
|
2158
|
+
}
|
|
2159
|
+
if (table.checks.length > 0) {
|
|
2160
|
+
const checksSql = table.checks
|
|
2161
|
+
.map((check) => {
|
|
2162
|
+
const checkName = check.name
|
|
2163
|
+
? check.name
|
|
2164
|
+
: this.connection.namingStrategy.checkConstraintName(table, check.expression);
|
|
2165
|
+
return `CONSTRAINT "${checkName}" CHECK (${check.expression})`;
|
|
2166
|
+
})
|
|
2167
|
+
.join(", ");
|
|
2168
|
+
sql += `, ${checksSql}`;
|
|
2169
|
+
}
|
|
2170
|
+
if (table.exclusions.length > 0) {
|
|
2171
|
+
const exclusionsSql = table.exclusions
|
|
2172
|
+
.map((exclusion) => {
|
|
2173
|
+
const exclusionName = exclusion.name
|
|
2174
|
+
? exclusion.name
|
|
2175
|
+
: this.connection.namingStrategy.exclusionConstraintName(table, exclusion.expression);
|
|
2176
|
+
return `CONSTRAINT "${exclusionName}" EXCLUDE ${exclusion.expression}`;
|
|
2177
|
+
})
|
|
2178
|
+
.join(", ");
|
|
2179
|
+
sql += `, ${exclusionsSql}`;
|
|
2180
|
+
}
|
|
2181
|
+
if (table.foreignKeys.length > 0 && createForeignKeys) {
|
|
2182
|
+
const foreignKeysSql = table.foreignKeys
|
|
2183
|
+
.map((fk) => {
|
|
2184
|
+
const columnNames = fk.columnNames
|
|
2185
|
+
.map((columnName) => `"${columnName}"`)
|
|
2186
|
+
.join(", ");
|
|
2187
|
+
if (!fk.name)
|
|
2188
|
+
fk.name = this.connection.namingStrategy.foreignKeyName(table, fk.columnNames, this.getTablePath(fk), fk.referencedColumnNames);
|
|
2189
|
+
const referencedColumnNames = fk.referencedColumnNames
|
|
2190
|
+
.map((columnName) => `"${columnName}"`)
|
|
2191
|
+
.join(", ");
|
|
2192
|
+
let constraint = `CONSTRAINT "${fk.name}" FOREIGN KEY (${columnNames}) REFERENCES ${this.escapePath(this.getTablePath(fk))} (${referencedColumnNames})`;
|
|
2193
|
+
if (fk.onDelete)
|
|
2194
|
+
constraint += ` ON DELETE ${fk.onDelete}`;
|
|
2195
|
+
if (fk.onUpdate)
|
|
2196
|
+
constraint += ` ON UPDATE ${fk.onUpdate}`;
|
|
2197
|
+
if (fk.deferrable)
|
|
2198
|
+
constraint += ` DEFERRABLE ${fk.deferrable}`;
|
|
2199
|
+
return constraint;
|
|
2200
|
+
})
|
|
2201
|
+
.join(", ");
|
|
2202
|
+
sql += `, ${foreignKeysSql}`;
|
|
2203
|
+
}
|
|
2204
|
+
const primaryColumns = table.columns.filter((column) => column.isPrimary);
|
|
2205
|
+
if (primaryColumns.length > 0) {
|
|
2206
|
+
const primaryKeyName = primaryColumns[0].primaryKeyConstraintName
|
|
2207
|
+
? primaryColumns[0].primaryKeyConstraintName
|
|
2208
|
+
: this.connection.namingStrategy.primaryKeyName(table, primaryColumns.map((column) => column.name));
|
|
2209
|
+
const columnNames = primaryColumns
|
|
2210
|
+
.map((column) => `"${column.name}"`)
|
|
2211
|
+
.join(", ");
|
|
2212
|
+
sql += `, CONSTRAINT "${primaryKeyName}" PRIMARY KEY (${columnNames})`;
|
|
2213
|
+
}
|
|
2214
|
+
sql += `)`;
|
|
2215
|
+
table.columns
|
|
2216
|
+
.filter((it) => it.comment)
|
|
2217
|
+
.forEach((it) => (sql += `; COMMENT ON COLUMN ${this.escapePath(table)}."${it.name}" IS ${this.escapeComment(it.comment)}`));
|
|
2218
|
+
return new Query_1.Query(sql);
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* Loads Postgres version.
|
|
2222
|
+
*/
|
|
2223
|
+
async getVersion() {
|
|
2224
|
+
const result = await this.query(`SELECT version()`);
|
|
2225
|
+
return result[0]["version"].replace(/^PostgreSQL ([\d\.]+) .*$/, "$1");
|
|
2226
|
+
}
|
|
2227
|
+
/**
|
|
2228
|
+
* Builds drop table sql.
|
|
2229
|
+
*/
|
|
2230
|
+
dropTableSql(tableOrPath) {
|
|
2231
|
+
return new Query_1.Query(`DROP TABLE ${this.escapePath(tableOrPath)}`);
|
|
2232
|
+
}
|
|
2233
|
+
createViewSql(view) {
|
|
2234
|
+
const materializedClause = view.materialized ? "MATERIALIZED " : "";
|
|
2235
|
+
const viewName = this.escapePath(view);
|
|
2236
|
+
if (typeof view.expression === "string") {
|
|
2237
|
+
return new Query_1.Query(`CREATE ${materializedClause}VIEW ${viewName} AS ${view.expression}`);
|
|
2238
|
+
}
|
|
2239
|
+
else {
|
|
2240
|
+
return new Query_1.Query(`CREATE ${materializedClause}VIEW ${viewName} AS ${view
|
|
2241
|
+
.expression(this.connection)
|
|
2242
|
+
.getQuery()}`);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
async insertViewDefinitionSql(view) {
|
|
2246
|
+
const currentSchema = await this.getCurrentSchema();
|
|
2247
|
+
let { schema, tableName: name } = this.driver.parseTableName(view);
|
|
2248
|
+
if (!schema) {
|
|
2249
|
+
schema = currentSchema;
|
|
2250
|
+
}
|
|
2251
|
+
const type = view.materialized
|
|
2252
|
+
? MetadataTableType_1.MetadataTableType.MATERIALIZED_VIEW
|
|
2253
|
+
: MetadataTableType_1.MetadataTableType.VIEW;
|
|
2254
|
+
const expression = typeof view.expression === "string"
|
|
2255
|
+
? view.expression.trim()
|
|
2256
|
+
: view.expression(this.connection).getQuery();
|
|
2257
|
+
return this.insertTypeormMetadataSql({
|
|
2258
|
+
type,
|
|
2259
|
+
schema,
|
|
2260
|
+
name,
|
|
2261
|
+
value: expression,
|
|
2262
|
+
});
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Builds drop view sql.
|
|
2266
|
+
*/
|
|
2267
|
+
dropViewSql(view) {
|
|
2268
|
+
const materializedClause = view.materialized ? "MATERIALIZED " : "";
|
|
2269
|
+
return new Query_1.Query(`DROP ${materializedClause}VIEW ${this.escapePath(view)}`);
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* Builds remove view sql.
|
|
2273
|
+
*/
|
|
2274
|
+
async deleteViewDefinitionSql(view) {
|
|
2275
|
+
const currentSchema = await this.getCurrentSchema();
|
|
2276
|
+
let { schema, tableName: name } = this.driver.parseTableName(view);
|
|
2277
|
+
if (!schema) {
|
|
2278
|
+
schema = currentSchema;
|
|
2279
|
+
}
|
|
2280
|
+
const type = view.materialized
|
|
2281
|
+
? MetadataTableType_1.MetadataTableType.MATERIALIZED_VIEW
|
|
2282
|
+
: MetadataTableType_1.MetadataTableType.VIEW;
|
|
2283
|
+
return this.deleteTypeormMetadataSql({ type, schema, name });
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2286
|
+
* Drops ENUM type from given schemas.
|
|
2287
|
+
*/
|
|
2288
|
+
async dropEnumTypes(schemaNames) {
|
|
2289
|
+
const selectDropsQuery = `SELECT 'DROP TYPE IF EXISTS "' || n.nspname || '"."' || t.typname || '" CASCADE;' as "query" FROM "pg_type" "t" ` +
|
|
2290
|
+
`INNER JOIN "pg_enum" "e" ON "e"."enumtypid" = "t"."oid" ` +
|
|
2291
|
+
`INNER JOIN "pg_namespace" "n" ON "n"."oid" = "t"."typnamespace" ` +
|
|
2292
|
+
`WHERE "n"."nspname" IN (${schemaNames}) GROUP BY "n"."nspname", "t"."typname"`;
|
|
2293
|
+
const dropQueries = await this.query(selectDropsQuery);
|
|
2294
|
+
await Promise.all(dropQueries.map((q) => this.query(q["query"])));
|
|
2295
|
+
}
|
|
2296
|
+
/**
|
|
2297
|
+
* Checks if enum with the given name exist in the database.
|
|
2298
|
+
*/
|
|
2299
|
+
async hasEnumType(table, column) {
|
|
2300
|
+
let { schema } = this.driver.parseTableName(table);
|
|
2301
|
+
if (!schema) {
|
|
2302
|
+
schema = await this.getCurrentSchema();
|
|
2303
|
+
}
|
|
2304
|
+
const enumName = this.buildEnumName(table, column, false, true);
|
|
2305
|
+
const sql = `SELECT "n"."nspname", "t"."typname" FROM "pg_type" "t" ` +
|
|
2306
|
+
`INNER JOIN "pg_namespace" "n" ON "n"."oid" = "t"."typnamespace" ` +
|
|
2307
|
+
`WHERE "n"."nspname" = '${schema}' AND "t"."typname" = '${enumName}'`;
|
|
2308
|
+
const result = await this.query(sql);
|
|
2309
|
+
return result.length ? true : false;
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Builds create ENUM type sql.
|
|
2313
|
+
*/
|
|
2314
|
+
createEnumTypeSql(table, column, enumName) {
|
|
2315
|
+
if (!enumName)
|
|
2316
|
+
enumName = this.buildEnumName(table, column);
|
|
2317
|
+
const enumValues = column
|
|
2318
|
+
.enum.map((value) => `'${value.replace("'", "''")}'`)
|
|
2319
|
+
.join(", ");
|
|
2320
|
+
return new Query_1.Query(`CREATE TYPE ${enumName} AS ENUM(${enumValues})`);
|
|
2321
|
+
}
|
|
2322
|
+
/**
|
|
2323
|
+
* Builds create ENUM type sql.
|
|
2324
|
+
*/
|
|
2325
|
+
dropEnumTypeSql(table, column, enumName) {
|
|
2326
|
+
if (!enumName)
|
|
2327
|
+
enumName = this.buildEnumName(table, column);
|
|
2328
|
+
return new Query_1.Query(`DROP TYPE ${enumName}`);
|
|
2329
|
+
}
|
|
2330
|
+
/**
|
|
2331
|
+
* Builds create index sql.
|
|
2332
|
+
*/
|
|
2333
|
+
createIndexSql(table, index) {
|
|
2334
|
+
const columns = index.columnNames
|
|
2335
|
+
.map((columnName) => `"${columnName}"`)
|
|
2336
|
+
.join(", ");
|
|
2337
|
+
return new Query_1.Query(`CREATE ${index.isUnique ? "UNIQUE " : ""}INDEX "${index.name}" ON ${this.escapePath(table)} ${index.isSpatial ? "USING GiST " : ""}(${columns}) ${index.where ? "WHERE " + index.where : ""}`);
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* Builds drop index sql.
|
|
2341
|
+
*/
|
|
2342
|
+
dropIndexSql(table, indexOrName) {
|
|
2343
|
+
let indexName = InstanceChecker_1.InstanceChecker.isTableIndex(indexOrName)
|
|
2344
|
+
? indexOrName.name
|
|
2345
|
+
: indexOrName;
|
|
2346
|
+
const { schema } = this.driver.parseTableName(table);
|
|
2347
|
+
return schema
|
|
2348
|
+
? new Query_1.Query(`DROP INDEX "${schema}"."${indexName}"`)
|
|
2349
|
+
: new Query_1.Query(`DROP INDEX "${indexName}"`);
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* Builds create primary key sql.
|
|
2353
|
+
*/
|
|
2354
|
+
createPrimaryKeySql(table, columnNames, constraintName) {
|
|
2355
|
+
const primaryKeyName = constraintName
|
|
2356
|
+
? constraintName
|
|
2357
|
+
: this.connection.namingStrategy.primaryKeyName(table, columnNames);
|
|
2358
|
+
const columnNamesString = columnNames
|
|
2359
|
+
.map((columnName) => `"${columnName}"`)
|
|
2360
|
+
.join(", ");
|
|
2361
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${primaryKeyName}" PRIMARY KEY (${columnNamesString})`);
|
|
2362
|
+
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Builds drop primary key sql.
|
|
2365
|
+
*/
|
|
2366
|
+
dropPrimaryKeySql(table) {
|
|
2367
|
+
if (!table.primaryColumns.length)
|
|
2368
|
+
throw new error_1.TypeORMError(`Table ${table} has no primary keys.`);
|
|
2369
|
+
const columnNames = table.primaryColumns.map((column) => column.name);
|
|
2370
|
+
const constraintName = table.primaryColumns[0].primaryKeyConstraintName;
|
|
2371
|
+
const primaryKeyName = constraintName
|
|
2372
|
+
? constraintName
|
|
2373
|
+
: this.connection.namingStrategy.primaryKeyName(table, columnNames);
|
|
2374
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${primaryKeyName}"`);
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Builds create unique constraint sql.
|
|
2378
|
+
*/
|
|
2379
|
+
createUniqueConstraintSql(table, uniqueConstraint) {
|
|
2380
|
+
const columnNames = uniqueConstraint.columnNames
|
|
2381
|
+
.map((column) => `"` + column + `"`)
|
|
2382
|
+
.join(", ");
|
|
2383
|
+
let sql = `ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${uniqueConstraint.name}" UNIQUE (${columnNames})`;
|
|
2384
|
+
if (uniqueConstraint.deferrable)
|
|
2385
|
+
sql += ` DEFERRABLE ${uniqueConstraint.deferrable}`;
|
|
2386
|
+
return new Query_1.Query(sql);
|
|
2387
|
+
}
|
|
2388
|
+
/**
|
|
2389
|
+
* Builds drop unique constraint sql.
|
|
2390
|
+
*/
|
|
2391
|
+
dropUniqueConstraintSql(table, uniqueOrName) {
|
|
2392
|
+
const uniqueName = InstanceChecker_1.InstanceChecker.isTableUnique(uniqueOrName)
|
|
2393
|
+
? uniqueOrName.name
|
|
2394
|
+
: uniqueOrName;
|
|
2395
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${uniqueName}"`);
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Builds create check constraint sql.
|
|
2399
|
+
*/
|
|
2400
|
+
createCheckConstraintSql(table, checkConstraint) {
|
|
2401
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${checkConstraint.name}" CHECK (${checkConstraint.expression})`);
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* Builds drop check constraint sql.
|
|
2405
|
+
*/
|
|
2406
|
+
dropCheckConstraintSql(table, checkOrName) {
|
|
2407
|
+
const checkName = InstanceChecker_1.InstanceChecker.isTableCheck(checkOrName)
|
|
2408
|
+
? checkOrName.name
|
|
2409
|
+
: checkOrName;
|
|
2410
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${checkName}"`);
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Builds create exclusion constraint sql.
|
|
2414
|
+
*/
|
|
2415
|
+
createExclusionConstraintSql(table, exclusionConstraint) {
|
|
2416
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${exclusionConstraint.name}" EXCLUDE ${exclusionConstraint.expression}`);
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2419
|
+
* Builds drop exclusion constraint sql.
|
|
2420
|
+
*/
|
|
2421
|
+
dropExclusionConstraintSql(table, exclusionOrName) {
|
|
2422
|
+
const exclusionName = InstanceChecker_1.InstanceChecker.isTableExclusion(exclusionOrName)
|
|
2423
|
+
? exclusionOrName.name
|
|
2424
|
+
: exclusionOrName;
|
|
2425
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${exclusionName}"`);
|
|
2426
|
+
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Builds create foreign key sql.
|
|
2429
|
+
*/
|
|
2430
|
+
createForeignKeySql(table, foreignKey) {
|
|
2431
|
+
const columnNames = foreignKey.columnNames
|
|
2432
|
+
.map((column) => `"` + column + `"`)
|
|
2433
|
+
.join(", ");
|
|
2434
|
+
const referencedColumnNames = foreignKey.referencedColumnNames
|
|
2435
|
+
.map((column) => `"` + column + `"`)
|
|
2436
|
+
.join(",");
|
|
2437
|
+
let sql = `ALTER TABLE ${this.escapePath(table)} ADD CONSTRAINT "${foreignKey.name}" FOREIGN KEY (${columnNames}) ` +
|
|
2438
|
+
`REFERENCES ${this.escapePath(this.getTablePath(foreignKey))}(${referencedColumnNames})`;
|
|
2439
|
+
if (foreignKey.onDelete)
|
|
2440
|
+
sql += ` ON DELETE ${foreignKey.onDelete}`;
|
|
2441
|
+
if (foreignKey.onUpdate)
|
|
2442
|
+
sql += ` ON UPDATE ${foreignKey.onUpdate}`;
|
|
2443
|
+
if (foreignKey.deferrable)
|
|
2444
|
+
sql += ` DEFERRABLE ${foreignKey.deferrable}`;
|
|
2445
|
+
return new Query_1.Query(sql);
|
|
2446
|
+
}
|
|
2447
|
+
/**
|
|
2448
|
+
* Builds drop foreign key sql.
|
|
2449
|
+
*/
|
|
2450
|
+
dropForeignKeySql(table, foreignKeyOrName) {
|
|
2451
|
+
const foreignKeyName = InstanceChecker_1.InstanceChecker.isTableForeignKey(foreignKeyOrName)
|
|
2452
|
+
? foreignKeyOrName.name
|
|
2453
|
+
: foreignKeyOrName;
|
|
2454
|
+
return new Query_1.Query(`ALTER TABLE ${this.escapePath(table)} DROP CONSTRAINT "${foreignKeyName}"`);
|
|
2455
|
+
}
|
|
2456
|
+
/**
|
|
2457
|
+
* Builds sequence name from given table and column.
|
|
2458
|
+
*/
|
|
2459
|
+
buildSequenceName(table, columnOrName) {
|
|
2460
|
+
const { tableName } = this.driver.parseTableName(table);
|
|
2461
|
+
const columnName = InstanceChecker_1.InstanceChecker.isTableColumn(columnOrName)
|
|
2462
|
+
? columnOrName.name
|
|
2463
|
+
: columnOrName;
|
|
2464
|
+
let seqName = `${tableName}_${columnName}_seq`;
|
|
2465
|
+
if (seqName.length > this.connection.driver.maxAliasLength) {
|
|
2466
|
+
// note doesn't yet handle corner cases where .length differs from number of UTF-8 bytes
|
|
2467
|
+
seqName = `${tableName.substring(0, 29)}_${columnName.substring(0, Math.max(29, 63 - table.name.length - 5))}_seq`;
|
|
2468
|
+
}
|
|
2469
|
+
return seqName;
|
|
2470
|
+
}
|
|
2471
|
+
buildSequencePath(table, columnOrName) {
|
|
2472
|
+
const { schema } = this.driver.parseTableName(table);
|
|
2473
|
+
return schema
|
|
2474
|
+
? `${schema}.${this.buildSequenceName(table, columnOrName)}`
|
|
2475
|
+
: this.buildSequenceName(table, columnOrName);
|
|
2476
|
+
}
|
|
2477
|
+
/**
|
|
2478
|
+
* Builds ENUM type name from given table and column.
|
|
2479
|
+
*/
|
|
2480
|
+
buildEnumName(table, column, withSchema = true, disableEscape, toOld) {
|
|
2481
|
+
const { schema, tableName } = this.driver.parseTableName(table);
|
|
2482
|
+
let enumName = column.enumName
|
|
2483
|
+
? column.enumName
|
|
2484
|
+
: `${tableName}_${column.name.toLowerCase()}_enum`;
|
|
2485
|
+
if (schema && withSchema)
|
|
2486
|
+
enumName = `${schema}.${enumName}`;
|
|
2487
|
+
if (toOld)
|
|
2488
|
+
enumName = enumName + "_old";
|
|
2489
|
+
return enumName
|
|
2490
|
+
.split(".")
|
|
2491
|
+
.map((i) => {
|
|
2492
|
+
return disableEscape ? i : `"${i}"`;
|
|
2493
|
+
})
|
|
2494
|
+
.join(".");
|
|
2495
|
+
}
|
|
2496
|
+
async getUserDefinedTypeName(table, column) {
|
|
2497
|
+
let { schema, tableName: name } = this.driver.parseTableName(table);
|
|
2498
|
+
if (!schema) {
|
|
2499
|
+
schema = await this.getCurrentSchema();
|
|
2500
|
+
}
|
|
2501
|
+
const result = await this.query(`SELECT "udt_schema", "udt_name" ` +
|
|
2502
|
+
`FROM "information_schema"."columns" WHERE "table_schema" = '${schema}' AND "table_name" = '${name}' AND "column_name"='${column.name}'`);
|
|
2503
|
+
// docs: https://www.postgresql.org/docs/current/xtypes.html
|
|
2504
|
+
// When you define a new base type, PostgreSQL automatically provides support for arrays of that type.
|
|
2505
|
+
// The array type typically has the same name as the base type with the underscore character (_) prepended.
|
|
2506
|
+
// ----
|
|
2507
|
+
// so, we must remove this underscore character from enum type name
|
|
2508
|
+
let udtName = result[0]["udt_name"];
|
|
2509
|
+
if (udtName.indexOf("_") === 0) {
|
|
2510
|
+
udtName = udtName.substr(1, udtName.length);
|
|
2511
|
+
}
|
|
2512
|
+
return {
|
|
2513
|
+
schema: result[0]["udt_schema"],
|
|
2514
|
+
name: udtName,
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
/**
|
|
2518
|
+
* Escapes a given comment so it's safe to include in a query.
|
|
2519
|
+
*/
|
|
2520
|
+
escapeComment(comment) {
|
|
2521
|
+
if (!comment || comment.length === 0) {
|
|
2522
|
+
return "NULL";
|
|
2523
|
+
}
|
|
2524
|
+
comment = comment.replace(/'/g, "''").replace(/\u0000/g, ""); // Null bytes aren't allowed in comments
|
|
2525
|
+
return `'${comment}'`;
|
|
2526
|
+
}
|
|
2527
|
+
/**
|
|
2528
|
+
* Escapes given table or view path.
|
|
2529
|
+
*/
|
|
2530
|
+
escapePath(target) {
|
|
2531
|
+
const { schema, tableName } = this.driver.parseTableName(target);
|
|
2532
|
+
if (schema && schema !== this.driver.searchSchema) {
|
|
2533
|
+
return `"${schema}"."${tableName}"`;
|
|
2534
|
+
}
|
|
2535
|
+
return `"${tableName}"`;
|
|
2536
|
+
}
|
|
2537
|
+
/**
|
|
2538
|
+
* Get the table name with table schema
|
|
2539
|
+
* Note: Without ' or "
|
|
2540
|
+
*/
|
|
2541
|
+
async getTableNameWithSchema(target) {
|
|
2542
|
+
const tableName = InstanceChecker_1.InstanceChecker.isTable(target) ? target.name : target;
|
|
2543
|
+
if (tableName.indexOf(".") === -1) {
|
|
2544
|
+
const schemaResult = await this.query(`SELECT current_schema()`);
|
|
2545
|
+
const schema = schemaResult[0]["current_schema"];
|
|
2546
|
+
return `${schema}.${tableName}`;
|
|
2547
|
+
}
|
|
2548
|
+
else {
|
|
2549
|
+
return `${tableName.split(".")[0]}.${tableName.split(".")[1]}`;
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Builds a query for create column.
|
|
2554
|
+
*/
|
|
2555
|
+
buildCreateColumnSql(table, column) {
|
|
2556
|
+
let c = '"' + column.name + '"';
|
|
2557
|
+
if (column.isGenerated === true &&
|
|
2558
|
+
column.generationStrategy !== "uuid") {
|
|
2559
|
+
if (column.generationStrategy === "identity") {
|
|
2560
|
+
// Postgres 10+ Identity generated column
|
|
2561
|
+
const generatedIdentityOrDefault = column.generatedIdentity || "BY DEFAULT";
|
|
2562
|
+
c += ` ${column.type} GENERATED ${generatedIdentityOrDefault} AS IDENTITY`;
|
|
2563
|
+
}
|
|
2564
|
+
else {
|
|
2565
|
+
// classic SERIAL primary column
|
|
2566
|
+
if (column.type === "integer" ||
|
|
2567
|
+
column.type === "int" ||
|
|
2568
|
+
column.type === "int4")
|
|
2569
|
+
c += " SERIAL";
|
|
2570
|
+
if (column.type === "smallint" || column.type === "int2")
|
|
2571
|
+
c += " SMALLSERIAL";
|
|
2572
|
+
if (column.type === "bigint" || column.type === "int8")
|
|
2573
|
+
c += " BIGSERIAL";
|
|
2574
|
+
}
|
|
2575
|
+
}
|
|
2576
|
+
if (column.type === "enum" || column.type === "simple-enum") {
|
|
2577
|
+
c += " " + this.buildEnumName(table, column);
|
|
2578
|
+
if (column.isArray)
|
|
2579
|
+
c += " array";
|
|
2580
|
+
}
|
|
2581
|
+
else if (!column.isGenerated || column.type === "uuid") {
|
|
2582
|
+
c += " " + this.connection.driver.createFullType(column);
|
|
2583
|
+
}
|
|
2584
|
+
// Postgres only supports the stored generated column type
|
|
2585
|
+
if (column.generatedType === "STORED" && column.asExpression) {
|
|
2586
|
+
c += ` GENERATED ALWAYS AS (${column.asExpression}) STORED`;
|
|
2587
|
+
}
|
|
2588
|
+
if (column.charset)
|
|
2589
|
+
c += ' CHARACTER SET "' + column.charset + '"';
|
|
2590
|
+
if (column.collation)
|
|
2591
|
+
c += ' COLLATE "' + column.collation + '"';
|
|
2592
|
+
if (column.isNullable !== true)
|
|
2593
|
+
c += " NOT NULL";
|
|
2594
|
+
if (column.default !== undefined && column.default !== null)
|
|
2595
|
+
c += " DEFAULT " + column.default;
|
|
2596
|
+
if (column.isGenerated &&
|
|
2597
|
+
column.generationStrategy === "uuid" &&
|
|
2598
|
+
!column.default)
|
|
2599
|
+
c += ` DEFAULT ${this.driver.uuidGenerator}`;
|
|
2600
|
+
return c;
|
|
2601
|
+
}
|
|
2602
|
+
/**
|
|
2603
|
+
* Checks if the PostgreSQL server has support for partitioned tables
|
|
2604
|
+
*/
|
|
2605
|
+
async hasSupportForPartitionedTables() {
|
|
2606
|
+
const result = await this.query(`SELECT TRUE FROM information_schema.columns WHERE table_name = 'pg_class' and column_name = 'relispartition'`);
|
|
2607
|
+
return result.length ? true : false;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
exports.PostgresQueryRunner = PostgresQueryRunner;
|
|
2611
|
+
//#endregion
|
|
2612
|
+
//# sourceMappingURL=PostgresQueryRunner.js.map
|