typeorm 0.2.45-dev.96ac8f7 → 0.2.45
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/cache/DbQueryResultCache.js +6 -6
- package/browser/cache/DbQueryResultCache.js.map +1 -1
- package/browser/cache/RedisQueryResultCache.js +2 -2
- package/browser/cache/RedisQueryResultCache.js.map +1 -1
- package/browser/connection/Connection.js +2 -2
- package/browser/connection/Connection.js.map +1 -1
- package/browser/connection/ConnectionOptionsReader.js +2 -2
- package/browser/connection/ConnectionOptionsReader.js.map +1 -1
- package/browser/driver/aurora-data-api/AuroraDataApiDriver.js +10 -10
- package/browser/driver/aurora-data-api/AuroraDataApiDriver.js.map +1 -1
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js +178 -171
- package/browser/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/browser/driver/aurora-data-api-pg/AuroraDataApiPostgresQueryRunner.js +3 -3
- package/browser/driver/aurora-data-api-pg/AuroraDataApiPostgresQueryRunner.js.map +1 -1
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js +4 -4
- package/browser/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/browser/driver/better-sqlite3/BetterSqlite3QueryRunner.js +2 -2
- package/browser/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
- package/browser/driver/capacitor/CapacitorDriver.js +1 -1
- package/browser/driver/capacitor/CapacitorDriver.js.map +1 -1
- package/browser/driver/capacitor/CapacitorQueryRunner.js +1 -1
- package/browser/driver/capacitor/CapacitorQueryRunner.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachDriver.js +6 -6
- package/browser/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/browser/driver/cockroachdb/CockroachQueryRunner.js +172 -166
- package/browser/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/browser/driver/cordova/CordovaQueryRunner.js +1 -1
- package/browser/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/browser/driver/expo/ExpoQueryRunner.js +3 -3
- package/browser/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/browser/driver/mongodb/MongoDriver.js +4 -4
- package/browser/driver/mongodb/MongoDriver.js.map +1 -1
- package/browser/driver/mysql/MysqlDriver.js +11 -11
- package/browser/driver/mysql/MysqlDriver.js.map +1 -1
- package/browser/driver/mysql/MysqlQueryRunner.js +184 -177
- package/browser/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/browser/driver/nativescript/NativescriptQueryRunner.js +1 -1
- package/browser/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
- package/browser/driver/oracle/OracleDriver.js +10 -10
- package/browser/driver/oracle/OracleDriver.js.map +1 -1
- package/browser/driver/oracle/OracleQueryRunner.js +145 -138
- package/browser/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/browser/driver/postgres/PostgresDriver.js +18 -18
- package/browser/driver/postgres/PostgresDriver.js.map +1 -1
- package/browser/driver/postgres/PostgresQueryRunner.js +248 -242
- package/browser/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/browser/driver/react-native/ReactNativeQueryRunner.js +1 -1
- package/browser/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
- package/browser/driver/sap/SapDriver.js +9 -9
- package/browser/driver/sap/SapDriver.js.map +1 -1
- package/browser/driver/sap/SapQueryRunner.js +145 -139
- package/browser/driver/sap/SapQueryRunner.js.map +1 -1
- package/browser/driver/sqlite/SqliteDriver.js +4 -4
- package/browser/driver/sqlite/SqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js +3 -3
- package/browser/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +82 -76
- package/browser/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/browser/driver/sqljs/SqljsDriver.js +3 -3
- package/browser/driver/sqljs/SqljsDriver.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerDriver.js +11 -11
- package/browser/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/browser/driver/sqlserver/SqlServerQueryRunner.js +226 -218
- package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/browser/entity-manager/EntityManager.js +4 -4
- package/browser/entity-manager/EntityManager.js.map +1 -1
- package/browser/entity-manager/MongoEntityManager.js +1 -1
- package/browser/entity-manager/MongoEntityManager.js.map +1 -1
- package/browser/entity-schema/EntitySchemaEmbeddedError.js +2 -2
- package/browser/entity-schema/EntitySchemaEmbeddedError.js.map +1 -1
- package/browser/error/AlreadyHasActiveConnectionError.js +1 -1
- package/browser/error/AlreadyHasActiveConnectionError.js.map +1 -1
- package/browser/error/CannotAttachTreeChildrenEntityError.js +1 -1
- package/browser/error/CannotAttachTreeChildrenEntityError.js.map +1 -1
- package/browser/error/CannotConnectAlreadyConnectedError.js +1 -1
- package/browser/error/CannotConnectAlreadyConnectedError.js.map +1 -1
- package/browser/error/CannotCreateEntityIdMapError.js +1 -1
- package/browser/error/CannotCreateEntityIdMapError.js.map +1 -1
- package/browser/error/CannotDetermineEntityError.js +1 -1
- package/browser/error/CannotDetermineEntityError.js.map +1 -1
- package/browser/error/CannotExecuteNotConnectedError.js +1 -1
- package/browser/error/CannotExecuteNotConnectedError.js.map +1 -1
- package/browser/error/CannotGetEntityManagerNotConnectedError.js +1 -1
- package/browser/error/CannotGetEntityManagerNotConnectedError.js.map +1 -1
- package/browser/error/CannotReflectMethodParameterTypeError.js +1 -1
- package/browser/error/CannotReflectMethodParameterTypeError.js.map +1 -1
- package/browser/error/CircularRelationsError.js +1 -1
- package/browser/error/CircularRelationsError.js.map +1 -1
- package/browser/error/ColumnTypeUndefinedError.js +1 -1
- package/browser/error/ColumnTypeUndefinedError.js.map +1 -1
- package/browser/error/ConnectionIsNotSetError.js +1 -1
- package/browser/error/ConnectionIsNotSetError.js.map +1 -1
- package/browser/error/ConnectionNotFoundError.js +1 -1
- package/browser/error/ConnectionNotFoundError.js.map +1 -1
- package/browser/error/CustomRepositoryCannotInheritRepositoryError.js +1 -1
- package/browser/error/CustomRepositoryCannotInheritRepositoryError.js.map +1 -1
- package/browser/error/CustomRepositoryDoesNotHaveEntityError.js +1 -1
- package/browser/error/CustomRepositoryDoesNotHaveEntityError.js.map +1 -1
- package/browser/error/CustomRepositoryNotFoundError.js +1 -1
- package/browser/error/CustomRepositoryNotFoundError.js.map +1 -1
- package/browser/error/DataTypeNotSupportedError.js +1 -1
- package/browser/error/DataTypeNotSupportedError.js.map +1 -1
- package/browser/error/DriverOptionNotSetError.js +1 -1
- package/browser/error/DriverOptionNotSetError.js.map +1 -1
- package/browser/error/DriverPackageNotInstalledError.js +2 -2
- package/browser/error/DriverPackageNotInstalledError.js.map +1 -1
- package/browser/error/EntityColumnNotFound.js +1 -1
- package/browser/error/EntityColumnNotFound.js.map +1 -1
- package/browser/error/EntityMetadataNotFoundError.js +1 -1
- package/browser/error/EntityMetadataNotFoundError.js.map +1 -1
- package/browser/error/EntityNotFoundError.js +2 -2
- package/browser/error/EntityNotFoundError.js.map +1 -1
- package/browser/error/FindRelationsNotFoundError.js +2 -2
- package/browser/error/FindRelationsNotFoundError.js.map +1 -1
- package/browser/error/InitializedRelationError.js +1 -1
- package/browser/error/InitializedRelationError.js.map +1 -1
- package/browser/error/MissingDeleteDateColumnError.js +1 -1
- package/browser/error/MissingDeleteDateColumnError.js.map +1 -1
- package/browser/error/MissingDriverError.js +2 -2
- package/browser/error/MissingDriverError.js.map +1 -1
- package/browser/error/MissingJoinColumnError.js +3 -3
- package/browser/error/MissingJoinColumnError.js.map +1 -1
- package/browser/error/MissingJoinTableError.js +3 -3
- package/browser/error/MissingJoinTableError.js.map +1 -1
- package/browser/error/MissingPrimaryColumnError.js +1 -1
- package/browser/error/MissingPrimaryColumnError.js.map +1 -1
- package/browser/error/MustBeEntityError.js +1 -1
- package/browser/error/MustBeEntityError.js.map +1 -1
- package/browser/error/NamingStrategyNotFoundError.js +2 -2
- package/browser/error/NamingStrategyNotFoundError.js.map +1 -1
- package/browser/error/NoConnectionForRepositoryError.js +1 -1
- package/browser/error/NoConnectionForRepositoryError.js.map +1 -1
- package/browser/error/NoConnectionOptionError.js +2 -2
- package/browser/error/NoConnectionOptionError.js.map +1 -1
- package/browser/error/NoVersionOrUpdateDateColumnError.js +1 -1
- package/browser/error/NoVersionOrUpdateDateColumnError.js.map +1 -1
- package/browser/error/OptimisticLockVersionMismatchError.js +1 -1
- package/browser/error/OptimisticLockVersionMismatchError.js.map +1 -1
- package/browser/error/PrimaryColumnCannotBeNullableError.js +1 -1
- package/browser/error/PrimaryColumnCannotBeNullableError.js.map +1 -1
- package/browser/error/RepositoryNotFoundError.js +2 -2
- package/browser/error/RepositoryNotFoundError.js.map +1 -1
- package/browser/error/RepositoryNotTreeError.js +1 -1
- package/browser/error/RepositoryNotTreeError.js.map +1 -1
- package/browser/error/SubjectRemovedAndUpdatedError.js +1 -1
- package/browser/error/SubjectRemovedAndUpdatedError.js.map +1 -1
- package/browser/error/SubjectWithoutIdentifierError.js +1 -1
- package/browser/error/SubjectWithoutIdentifierError.js.map +1 -1
- package/browser/error/TreeRepositoryNotSupportedError.js +1 -1
- package/browser/error/TreeRepositoryNotSupportedError.js.map +1 -1
- package/browser/error/UsingJoinColumnIsNotAllowedError.js +1 -1
- package/browser/error/UsingJoinColumnIsNotAllowedError.js.map +1 -1
- package/browser/error/UsingJoinColumnOnlyOnOneSideAllowedError.js +1 -1
- package/browser/error/UsingJoinColumnOnlyOnOneSideAllowedError.js.map +1 -1
- package/browser/error/UsingJoinTableIsNotAllowedError.js +2 -2
- package/browser/error/UsingJoinTableIsNotAllowedError.js.map +1 -1
- package/browser/error/UsingJoinTableOnlyOnOneSideAllowedError.js +1 -1
- package/browser/error/UsingJoinTableOnlyOnOneSideAllowedError.js.map +1 -1
- package/browser/find-options/FindOptionsUtils.js +6 -6
- package/browser/find-options/FindOptionsUtils.js.map +1 -1
- package/browser/logger/FileLogger.js +3 -3
- package/browser/logger/FileLogger.js.map +1 -1
- package/browser/metadata/EmbeddedMetadata.js +1 -1
- package/browser/metadata/EmbeddedMetadata.js.map +1 -1
- package/browser/metadata/IndexMetadata.js +1 -1
- package/browser/metadata/IndexMetadata.js.map +1 -1
- package/browser/metadata/RelationCountMetadata.js +1 -1
- package/browser/metadata/RelationCountMetadata.js.map +1 -1
- package/browser/metadata/RelationIdMetadata.js +1 -1
- package/browser/metadata/RelationIdMetadata.js.map +1 -1
- package/browser/metadata/UniqueMetadata.js +1 -1
- package/browser/metadata/UniqueMetadata.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataBuilder.js +1 -1
- package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/browser/metadata-builder/EntityMetadataValidator.js +9 -9
- package/browser/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/browser/metadata-builder/JunctionEntityMetadataBuilder.js +2 -2
- package/browser/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
- package/browser/metadata-builder/RelationJoinColumnBuilder.js +1 -1
- package/browser/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/browser/migration/MigrationExecutor.js +16 -16
- package/browser/migration/MigrationExecutor.js.map +1 -1
- package/browser/naming-strategy/DefaultNamingStrategy.js +11 -11
- package/browser/naming-strategy/DefaultNamingStrategy.js.map +1 -1
- package/browser/persistence/tree/ClosureSubjectExecutor.js +17 -17
- package/browser/persistence/tree/ClosureSubjectExecutor.js.map +1 -1
- package/browser/persistence/tree/MaterializedPathSubjectExecutor.js +2 -2
- package/browser/persistence/tree/MaterializedPathSubjectExecutor.js.map +1 -1
- package/browser/persistence/tree/NestedSetSubjectExecutor.js +44 -44
- package/browser/persistence/tree/NestedSetSubjectExecutor.js.map +1 -1
- package/browser/platform/BrowserPlatformTools.js +9 -9
- package/browser/platform/BrowserPlatformTools.js.map +1 -1
- package/browser/platform/PlatformTools.js +1 -1
- package/browser/platform/PlatformTools.js.map +1 -1
- package/browser/query-builder/Alias.js +1 -1
- package/browser/query-builder/Alias.js.map +1 -1
- package/browser/query-builder/DeleteQueryBuilder.js +3 -3
- package/browser/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/InsertQueryBuilder.js +22 -22
- package/browser/query-builder/InsertQueryBuilder.js.map +1 -1
- package/browser/query-builder/JoinAttribute.js +1 -1
- package/browser/query-builder/JoinAttribute.js.map +1 -1
- package/browser/query-builder/QueryBuilder.js +39 -39
- package/browser/query-builder/QueryBuilder.js.map +1 -1
- package/browser/query-builder/QueryExpressionMap.js +2 -2
- package/browser/query-builder/QueryExpressionMap.js.map +1 -1
- package/browser/query-builder/RelationLoader.js +7 -7
- package/browser/query-builder/RelationLoader.js.map +1 -1
- package/browser/query-builder/RelationQueryBuilder.js +3 -3
- package/browser/query-builder/RelationQueryBuilder.js.map +1 -1
- package/browser/query-builder/RelationRemover.js +4 -4
- package/browser/query-builder/RelationRemover.js.map +1 -1
- package/browser/query-builder/RelationUpdater.js +1 -1
- package/browser/query-builder/RelationUpdater.js.map +1 -1
- package/browser/query-builder/SelectQueryBuilder.js +23 -23
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/query-builder/SoftDeleteQueryBuilder.js +4 -4
- package/browser/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/browser/query-builder/UpdateQueryBuilder.js +8 -8
- package/browser/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/browser/query-builder/relation-count/RelationCountAttribute.js +1 -1
- package/browser/query-builder/relation-count/RelationCountAttribute.js.map +1 -1
- package/browser/query-builder/relation-id/RelationIdAttribute.js +1 -1
- package/browser/query-builder/relation-id/RelationIdAttribute.js.map +1 -1
- package/browser/query-builder/relation-id/RelationIdLoader.js +4 -4
- package/browser/query-builder/relation-id/RelationIdLoader.js.map +1 -1
- package/browser/query-runner/BaseQueryRunner.js +7 -7
- package/browser/query-runner/BaseQueryRunner.js.map +1 -1
- package/browser/repository/TreeRepository.js +7 -7
- package/browser/repository/TreeRepository.js.map +1 -1
- package/browser/schema-builder/RdbmsSchemaBuilder.js +19 -19
- package/browser/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/browser/subscriber/Broadcaster.js +1 -1
- package/browser/subscriber/Broadcaster.js.map +1 -1
- package/browser/util/DateUtils.js +1 -1
- package/browser/util/DateUtils.js.map +1 -1
- package/browser/util/DepGraph.js +7 -7
- package/browser/util/DepGraph.js.map +1 -1
- package/browser/util/DirectoryExportedClassesLoader.js +2 -2
- package/browser/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/browser/util/PathUtils.js +1 -1
- package/browser/util/PathUtils.js.map +1 -1
- package/cache/DbQueryResultCache.js +6 -6
- package/cache/DbQueryResultCache.js.map +1 -1
- package/cache/RedisQueryResultCache.js +2 -2
- package/cache/RedisQueryResultCache.js.map +1 -1
- package/cli.js +0 -0
- package/commands/CommandUtils.js +1 -1
- package/commands/CommandUtils.js.map +1 -1
- package/commands/EntityCreateCommand.js +3 -3
- package/commands/EntityCreateCommand.js.map +1 -1
- package/commands/InitCommand.js +6 -6
- package/commands/InitCommand.js.map +1 -1
- package/commands/MigrationCreateCommand.js +3 -3
- package/commands/MigrationCreateCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.js +8 -8
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/commands/SchemaLogCommand.js +1 -1
- package/commands/SchemaLogCommand.js.map +1 -1
- package/commands/SubscriberCreateCommand.js +2 -2
- package/commands/SubscriberCreateCommand.js.map +1 -1
- package/connection/Connection.js +2 -2
- package/connection/Connection.js.map +1 -1
- package/connection/ConnectionOptionsReader.js +2 -2
- package/connection/ConnectionOptionsReader.js.map +1 -1
- package/driver/aurora-data-api/AuroraDataApiDriver.js +10 -10
- package/driver/aurora-data-api/AuroraDataApiDriver.js.map +1 -1
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js +178 -171
- package/driver/aurora-data-api/AuroraDataApiQueryRunner.js.map +1 -1
- package/driver/aurora-data-api-pg/AuroraDataApiPostgresQueryRunner.js +3 -3
- package/driver/aurora-data-api-pg/AuroraDataApiPostgresQueryRunner.js.map +1 -1
- package/driver/better-sqlite3/BetterSqlite3Driver.js +4 -4
- package/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/driver/better-sqlite3/BetterSqlite3QueryRunner.js +2 -2
- package/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
- package/driver/capacitor/CapacitorDriver.js +1 -1
- package/driver/capacitor/CapacitorDriver.js.map +1 -1
- package/driver/capacitor/CapacitorQueryRunner.js +1 -1
- package/driver/capacitor/CapacitorQueryRunner.js.map +1 -1
- package/driver/cockroachdb/CockroachDriver.js +6 -6
- package/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/driver/cockroachdb/CockroachQueryRunner.js +172 -166
- package/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/driver/cordova/CordovaQueryRunner.js +1 -1
- package/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/driver/expo/ExpoQueryRunner.js +3 -3
- package/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/driver/mongodb/MongoDriver.js +4 -4
- package/driver/mongodb/MongoDriver.js.map +1 -1
- package/driver/mysql/MysqlDriver.js +11 -11
- package/driver/mysql/MysqlDriver.js.map +1 -1
- package/driver/mysql/MysqlQueryRunner.js +184 -177
- package/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/driver/nativescript/NativescriptQueryRunner.js +1 -1
- package/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
- package/driver/oracle/OracleDriver.js +10 -10
- package/driver/oracle/OracleDriver.js.map +1 -1
- package/driver/oracle/OracleQueryRunner.js +145 -138
- package/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/driver/postgres/PostgresDriver.js +18 -18
- package/driver/postgres/PostgresDriver.js.map +1 -1
- package/driver/postgres/PostgresQueryRunner.js +248 -242
- package/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/driver/react-native/ReactNativeQueryRunner.js +1 -1
- package/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
- package/driver/sap/SapDriver.js +9 -9
- package/driver/sap/SapDriver.js.map +1 -1
- package/driver/sap/SapQueryRunner.js +145 -139
- package/driver/sap/SapQueryRunner.js.map +1 -1
- package/driver/sqlite/SqliteDriver.js +4 -4
- package/driver/sqlite/SqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteDriver.js +3 -3
- package/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +82 -76
- package/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/driver/sqljs/SqljsDriver.js +3 -3
- package/driver/sqljs/SqljsDriver.js.map +1 -1
- package/driver/sqlserver/SqlServerDriver.js +11 -11
- package/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/driver/sqlserver/SqlServerQueryRunner.js +226 -218
- package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/entity-manager/EntityManager.js +4 -4
- package/entity-manager/EntityManager.js.map +1 -1
- package/entity-manager/MongoEntityManager.js +1 -1
- package/entity-manager/MongoEntityManager.js.map +1 -1
- package/entity-schema/EntitySchemaEmbeddedError.js +2 -2
- package/entity-schema/EntitySchemaEmbeddedError.js.map +1 -1
- package/error/AlreadyHasActiveConnectionError.js +1 -1
- package/error/AlreadyHasActiveConnectionError.js.map +1 -1
- package/error/CannotAttachTreeChildrenEntityError.js +1 -1
- package/error/CannotAttachTreeChildrenEntityError.js.map +1 -1
- package/error/CannotConnectAlreadyConnectedError.js +1 -1
- package/error/CannotConnectAlreadyConnectedError.js.map +1 -1
- package/error/CannotCreateEntityIdMapError.js +1 -1
- package/error/CannotCreateEntityIdMapError.js.map +1 -1
- package/error/CannotDetermineEntityError.js +1 -1
- package/error/CannotDetermineEntityError.js.map +1 -1
- package/error/CannotExecuteNotConnectedError.js +1 -1
- package/error/CannotExecuteNotConnectedError.js.map +1 -1
- package/error/CannotGetEntityManagerNotConnectedError.js +1 -1
- package/error/CannotGetEntityManagerNotConnectedError.js.map +1 -1
- package/error/CannotReflectMethodParameterTypeError.js +1 -1
- package/error/CannotReflectMethodParameterTypeError.js.map +1 -1
- package/error/CircularRelationsError.js +1 -1
- package/error/CircularRelationsError.js.map +1 -1
- package/error/ColumnTypeUndefinedError.js +1 -1
- package/error/ColumnTypeUndefinedError.js.map +1 -1
- package/error/ConnectionIsNotSetError.js +1 -1
- package/error/ConnectionIsNotSetError.js.map +1 -1
- package/error/ConnectionNotFoundError.js +1 -1
- package/error/ConnectionNotFoundError.js.map +1 -1
- package/error/CustomRepositoryCannotInheritRepositoryError.js +1 -1
- package/error/CustomRepositoryCannotInheritRepositoryError.js.map +1 -1
- package/error/CustomRepositoryDoesNotHaveEntityError.js +1 -1
- package/error/CustomRepositoryDoesNotHaveEntityError.js.map +1 -1
- package/error/CustomRepositoryNotFoundError.js +1 -1
- package/error/CustomRepositoryNotFoundError.js.map +1 -1
- package/error/DataTypeNotSupportedError.js +1 -1
- package/error/DataTypeNotSupportedError.js.map +1 -1
- package/error/DriverOptionNotSetError.js +1 -1
- package/error/DriverOptionNotSetError.js.map +1 -1
- package/error/DriverPackageNotInstalledError.js +2 -2
- package/error/DriverPackageNotInstalledError.js.map +1 -1
- package/error/EntityColumnNotFound.js +1 -1
- package/error/EntityColumnNotFound.js.map +1 -1
- package/error/EntityMetadataNotFoundError.js +1 -1
- package/error/EntityMetadataNotFoundError.js.map +1 -1
- package/error/EntityNotFoundError.js +2 -2
- package/error/EntityNotFoundError.js.map +1 -1
- package/error/FindRelationsNotFoundError.js +2 -2
- package/error/FindRelationsNotFoundError.js.map +1 -1
- package/error/InitializedRelationError.js +1 -1
- package/error/InitializedRelationError.js.map +1 -1
- package/error/MissingDeleteDateColumnError.js +1 -1
- package/error/MissingDeleteDateColumnError.js.map +1 -1
- package/error/MissingDriverError.js +2 -2
- package/error/MissingDriverError.js.map +1 -1
- package/error/MissingJoinColumnError.js +3 -3
- package/error/MissingJoinColumnError.js.map +1 -1
- package/error/MissingJoinTableError.js +3 -3
- package/error/MissingJoinTableError.js.map +1 -1
- package/error/MissingPrimaryColumnError.js +1 -1
- package/error/MissingPrimaryColumnError.js.map +1 -1
- package/error/MustBeEntityError.js +1 -1
- package/error/MustBeEntityError.js.map +1 -1
- package/error/NamingStrategyNotFoundError.js +2 -2
- package/error/NamingStrategyNotFoundError.js.map +1 -1
- package/error/NoConnectionForRepositoryError.js +1 -1
- package/error/NoConnectionForRepositoryError.js.map +1 -1
- package/error/NoConnectionOptionError.js +2 -2
- package/error/NoConnectionOptionError.js.map +1 -1
- package/error/NoVersionOrUpdateDateColumnError.js +1 -1
- package/error/NoVersionOrUpdateDateColumnError.js.map +1 -1
- package/error/OptimisticLockVersionMismatchError.js +1 -1
- package/error/OptimisticLockVersionMismatchError.js.map +1 -1
- package/error/PrimaryColumnCannotBeNullableError.js +1 -1
- package/error/PrimaryColumnCannotBeNullableError.js.map +1 -1
- package/error/RepositoryNotFoundError.js +2 -2
- package/error/RepositoryNotFoundError.js.map +1 -1
- package/error/RepositoryNotTreeError.js +1 -1
- package/error/RepositoryNotTreeError.js.map +1 -1
- package/error/SubjectRemovedAndUpdatedError.js +1 -1
- package/error/SubjectRemovedAndUpdatedError.js.map +1 -1
- package/error/SubjectWithoutIdentifierError.js +1 -1
- package/error/SubjectWithoutIdentifierError.js.map +1 -1
- package/error/TreeRepositoryNotSupportedError.js +1 -1
- package/error/TreeRepositoryNotSupportedError.js.map +1 -1
- package/error/UsingJoinColumnIsNotAllowedError.js +1 -1
- package/error/UsingJoinColumnIsNotAllowedError.js.map +1 -1
- package/error/UsingJoinColumnOnlyOnOneSideAllowedError.js +1 -1
- package/error/UsingJoinColumnOnlyOnOneSideAllowedError.js.map +1 -1
- package/error/UsingJoinTableIsNotAllowedError.js +2 -2
- package/error/UsingJoinTableIsNotAllowedError.js.map +1 -1
- package/error/UsingJoinTableOnlyOnOneSideAllowedError.js +1 -1
- package/error/UsingJoinTableOnlyOnOneSideAllowedError.js.map +1 -1
- package/find-options/FindOptionsUtils.js +6 -6
- package/find-options/FindOptionsUtils.js.map +1 -1
- package/logger/FileLogger.js +3 -3
- package/logger/FileLogger.js.map +1 -1
- package/metadata/EmbeddedMetadata.js +1 -1
- package/metadata/EmbeddedMetadata.js.map +1 -1
- package/metadata/IndexMetadata.js +1 -1
- package/metadata/IndexMetadata.js.map +1 -1
- package/metadata/RelationCountMetadata.js +1 -1
- package/metadata/RelationCountMetadata.js.map +1 -1
- package/metadata/RelationIdMetadata.js +1 -1
- package/metadata/RelationIdMetadata.js.map +1 -1
- package/metadata/UniqueMetadata.js +1 -1
- package/metadata/UniqueMetadata.js.map +1 -1
- package/metadata-builder/EntityMetadataBuilder.js +1 -1
- package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/metadata-builder/EntityMetadataValidator.js +9 -9
- package/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/metadata-builder/JunctionEntityMetadataBuilder.js +2 -2
- package/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
- package/metadata-builder/RelationJoinColumnBuilder.js +1 -1
- package/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/migration/MigrationExecutor.js +16 -16
- package/migration/MigrationExecutor.js.map +1 -1
- package/naming-strategy/DefaultNamingStrategy.js +11 -11
- package/naming-strategy/DefaultNamingStrategy.js.map +1 -1
- package/package.json +260 -1
- package/persistence/tree/ClosureSubjectExecutor.js +17 -17
- package/persistence/tree/ClosureSubjectExecutor.js.map +1 -1
- package/persistence/tree/MaterializedPathSubjectExecutor.js +2 -2
- package/persistence/tree/MaterializedPathSubjectExecutor.js.map +1 -1
- package/persistence/tree/NestedSetSubjectExecutor.js +44 -44
- package/persistence/tree/NestedSetSubjectExecutor.js.map +1 -1
- package/platform/PlatformTools.js +1 -1
- package/platform/PlatformTools.js.map +1 -1
- package/query-builder/Alias.js +1 -1
- package/query-builder/Alias.js.map +1 -1
- package/query-builder/DeleteQueryBuilder.js +3 -3
- package/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/query-builder/InsertQueryBuilder.js +22 -22
- package/query-builder/InsertQueryBuilder.js.map +1 -1
- package/query-builder/JoinAttribute.js +1 -1
- package/query-builder/JoinAttribute.js.map +1 -1
- package/query-builder/QueryBuilder.js +39 -39
- package/query-builder/QueryBuilder.js.map +1 -1
- package/query-builder/QueryExpressionMap.js +2 -2
- package/query-builder/QueryExpressionMap.js.map +1 -1
- package/query-builder/RelationLoader.js +7 -7
- package/query-builder/RelationLoader.js.map +1 -1
- package/query-builder/RelationQueryBuilder.js +3 -3
- package/query-builder/RelationQueryBuilder.js.map +1 -1
- package/query-builder/RelationRemover.js +4 -4
- package/query-builder/RelationRemover.js.map +1 -1
- package/query-builder/RelationUpdater.js +1 -1
- package/query-builder/RelationUpdater.js.map +1 -1
- package/query-builder/SelectQueryBuilder.js +23 -23
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/query-builder/SoftDeleteQueryBuilder.js +4 -4
- package/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/query-builder/UpdateQueryBuilder.js +8 -8
- package/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/query-builder/relation-count/RelationCountAttribute.js +1 -1
- package/query-builder/relation-count/RelationCountAttribute.js.map +1 -1
- package/query-builder/relation-id/RelationIdAttribute.js +1 -1
- package/query-builder/relation-id/RelationIdAttribute.js.map +1 -1
- package/query-builder/relation-id/RelationIdLoader.js +4 -4
- package/query-builder/relation-id/RelationIdLoader.js.map +1 -1
- package/query-runner/BaseQueryRunner.js +7 -7
- package/query-runner/BaseQueryRunner.js.map +1 -1
- package/repository/TreeRepository.js +7 -7
- package/repository/TreeRepository.js.map +1 -1
- package/schema-builder/RdbmsSchemaBuilder.js +19 -19
- package/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/subscriber/Broadcaster.js +1 -1
- package/subscriber/Broadcaster.js.map +1 -1
- package/util/DateUtils.js +1 -1
- package/util/DateUtils.js.map +1 -1
- package/util/DepGraph.js +7 -7
- package/util/DepGraph.js.map +1 -1
- package/util/DirectoryExportedClassesLoader.js +2 -2
- package/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/util/PathUtils.js +1 -1
- package/util/PathUtils.js.map +1 -1
|
@@ -110,7 +110,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
110
110
|
this.databaseConnection.begin(transactionCallback);
|
|
111
111
|
}
|
|
112
112
|
return [3 /*break*/, 4];
|
|
113
|
-
case 2: return [4 /*yield*/, this.query("SAVE TRANSACTION typeorm_"
|
|
113
|
+
case 2: return [4 /*yield*/, this.query("SAVE TRANSACTION typeorm_".concat(this.transactionDepth))];
|
|
114
114
|
case 3:
|
|
115
115
|
_a.sent();
|
|
116
116
|
ok();
|
|
@@ -194,7 +194,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
194
194
|
case 1:
|
|
195
195
|
_a.sent();
|
|
196
196
|
if (!(this.transactionDepth > 1)) return [3 /*break*/, 3];
|
|
197
|
-
return [4 /*yield*/, this.query("ROLLBACK TRANSACTION typeorm_"
|
|
197
|
+
return [4 /*yield*/, this.query("ROLLBACK TRANSACTION typeorm_".concat(this.transactionDepth - 1))];
|
|
198
198
|
case 2:
|
|
199
199
|
_a.sent();
|
|
200
200
|
this.transactionDepth -= 1;
|
|
@@ -397,7 +397,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
397
397
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
398
398
|
switch (_a.label) {
|
|
399
399
|
case 0:
|
|
400
|
-
query = database ? "SELECT * FROM \""
|
|
400
|
+
query = database ? "SELECT * FROM \"".concat(database, "\".\"sys\".\"schema\"") : "SELECT * FROM \"sys\".\"schemas\"";
|
|
401
401
|
return [4 /*yield*/, this.query(query)];
|
|
402
402
|
case 1:
|
|
403
403
|
results = _a.sent();
|
|
@@ -414,7 +414,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
414
414
|
var result, dbId;
|
|
415
415
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
416
416
|
switch (_a.label) {
|
|
417
|
-
case 0: return [4 /*yield*/, this.query("SELECT DB_ID('"
|
|
417
|
+
case 0: return [4 /*yield*/, this.query("SELECT DB_ID('".concat(database, "') as \"db_id\""))];
|
|
418
418
|
case 1:
|
|
419
419
|
result = _a.sent();
|
|
420
420
|
dbId = result[0]["db_id"];
|
|
@@ -447,7 +447,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
447
447
|
var result, schemaId;
|
|
448
448
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
449
449
|
switch (_a.label) {
|
|
450
|
-
case 0: return [4 /*yield*/, this.query("SELECT SCHEMA_ID('"
|
|
450
|
+
case 0: return [4 /*yield*/, this.query("SELECT SCHEMA_ID('".concat(schema, "') as \"schema_id\""))];
|
|
451
451
|
case 1:
|
|
452
452
|
result = _a.sent();
|
|
453
453
|
schemaId = result[0]["schema_id"];
|
|
@@ -496,7 +496,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
496
496
|
_b.schema = _c.sent();
|
|
497
497
|
_c.label = 4;
|
|
498
498
|
case 4:
|
|
499
|
-
sql = "SELECT * FROM \""
|
|
499
|
+
sql = "SELECT * FROM \"".concat(parsedTableName.database, "\".\"INFORMATION_SCHEMA\".\"TABLES\" WHERE \"TABLE_NAME\" = '").concat(parsedTableName.tableName, "' AND \"TABLE_SCHEMA\" = '").concat(parsedTableName.schema, "'");
|
|
500
500
|
return [4 /*yield*/, this.query(sql)];
|
|
501
501
|
case 5:
|
|
502
502
|
result = _c.sent();
|
|
@@ -529,7 +529,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
529
529
|
_b.schema = _c.sent();
|
|
530
530
|
_c.label = 4;
|
|
531
531
|
case 4:
|
|
532
|
-
sql = "SELECT * FROM \""
|
|
532
|
+
sql = "SELECT * FROM \"".concat(parsedTableName.database, "\".\"INFORMATION_SCHEMA\".\"COLUMNS\" WHERE \"TABLE_NAME\" = '").concat(parsedTableName.tableName, "' AND \"TABLE_SCHEMA\" = '").concat(parsedTableName.schema, "' AND \"COLUMN_NAME\" = '").concat(columnName, "'");
|
|
533
533
|
return [4 /*yield*/, this.query(sql)];
|
|
534
534
|
case 5:
|
|
535
535
|
result = _c.sent();
|
|
@@ -547,8 +547,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
547
547
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
548
548
|
switch (_a.label) {
|
|
549
549
|
case 0:
|
|
550
|
-
up = ifNotExist ? "IF DB_ID('"
|
|
551
|
-
down = "DROP DATABASE \""
|
|
550
|
+
up = ifNotExist ? "IF DB_ID('".concat(database, "') IS NULL CREATE DATABASE \"").concat(database, "\"") : "CREATE DATABASE \"".concat(database, "\"");
|
|
551
|
+
down = "DROP DATABASE \"".concat(database, "\"");
|
|
552
552
|
return [4 /*yield*/, this.executeQueries(new Query_1.Query(up), new Query_1.Query(down))];
|
|
553
553
|
case 1:
|
|
554
554
|
_a.sent();
|
|
@@ -566,8 +566,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
566
566
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
567
567
|
switch (_a.label) {
|
|
568
568
|
case 0:
|
|
569
|
-
up = ifExist ? "IF DB_ID('"
|
|
570
|
-
down = "CREATE DATABASE \""
|
|
569
|
+
up = ifExist ? "IF DB_ID('".concat(database, "') IS NOT NULL DROP DATABASE \"").concat(database, "\"") : "DROP DATABASE \"".concat(database, "\"");
|
|
570
|
+
down = "CREATE DATABASE \"".concat(database, "\"");
|
|
571
571
|
return [4 /*yield*/, this.executeQueries(new Query_1.Query(up), new Query_1.Query(down))];
|
|
572
572
|
case 1:
|
|
573
573
|
_a.sent();
|
|
@@ -589,9 +589,9 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
589
589
|
upQueries = [];
|
|
590
590
|
downQueries = [];
|
|
591
591
|
if (!(schemaPath.indexOf(".") === -1)) return [3 /*break*/, 1];
|
|
592
|
-
upQuery = ifNotExist ? "IF SCHEMA_ID('"
|
|
592
|
+
upQuery = ifNotExist ? "IF SCHEMA_ID('".concat(schemaPath, "') IS NULL BEGIN EXEC ('CREATE SCHEMA \"").concat(schemaPath, "\"') END") : "CREATE SCHEMA \"".concat(schemaPath, "\"");
|
|
593
593
|
upQueries.push(new Query_1.Query(upQuery));
|
|
594
|
-
downQueries.push(new Query_1.Query("DROP SCHEMA \""
|
|
594
|
+
downQueries.push(new Query_1.Query("DROP SCHEMA \"".concat(schemaPath, "\"")));
|
|
595
595
|
return [3 /*break*/, 3];
|
|
596
596
|
case 1:
|
|
597
597
|
dbName = schemaPath.split(".")[0];
|
|
@@ -599,13 +599,13 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
599
599
|
return [4 /*yield*/, this.getCurrentDatabase()];
|
|
600
600
|
case 2:
|
|
601
601
|
currentDB = _a.sent();
|
|
602
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
603
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
604
|
-
upQuery = ifNotExist ? "IF SCHEMA_ID('"
|
|
602
|
+
upQueries.push(new Query_1.Query("USE \"".concat(dbName, "\"")));
|
|
603
|
+
downQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
604
|
+
upQuery = ifNotExist ? "IF SCHEMA_ID('".concat(schema, "') IS NULL BEGIN EXEC ('CREATE SCHEMA \"").concat(schema, "\"') END") : "CREATE SCHEMA \"".concat(schema, "\"");
|
|
605
605
|
upQueries.push(new Query_1.Query(upQuery));
|
|
606
|
-
downQueries.push(new Query_1.Query("DROP SCHEMA \""
|
|
607
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
608
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
606
|
+
downQueries.push(new Query_1.Query("DROP SCHEMA \"".concat(schema, "\"")));
|
|
607
|
+
upQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
608
|
+
downQueries.push(new Query_1.Query("USE \"".concat(dbName, "\"")));
|
|
609
609
|
_a.label = 3;
|
|
610
610
|
case 3: return [4 /*yield*/, this.executeQueries(upQueries, downQueries)];
|
|
611
611
|
case 4:
|
|
@@ -628,9 +628,9 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
628
628
|
upQueries = [];
|
|
629
629
|
downQueries = [];
|
|
630
630
|
if (!(schemaPath.indexOf(".") === -1)) return [3 /*break*/, 1];
|
|
631
|
-
upQuery = ifExist ? "IF SCHEMA_ID('"
|
|
631
|
+
upQuery = ifExist ? "IF SCHEMA_ID('".concat(schemaPath, "') IS NULL BEGIN EXEC ('DROP SCHEMA \"").concat(schemaPath, "\"') END") : "DROP SCHEMA \"".concat(schemaPath, "\"");
|
|
632
632
|
upQueries.push(new Query_1.Query(upQuery));
|
|
633
|
-
downQueries.push(new Query_1.Query("CREATE SCHEMA \""
|
|
633
|
+
downQueries.push(new Query_1.Query("CREATE SCHEMA \"".concat(schemaPath, "\"")));
|
|
634
634
|
return [3 /*break*/, 3];
|
|
635
635
|
case 1:
|
|
636
636
|
dbName = schemaPath.split(".")[0];
|
|
@@ -638,13 +638,13 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
638
638
|
return [4 /*yield*/, this.getCurrentDatabase()];
|
|
639
639
|
case 2:
|
|
640
640
|
currentDB = _a.sent();
|
|
641
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
642
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
643
|
-
upQuery = ifExist ? "IF SCHEMA_ID('"
|
|
641
|
+
upQueries.push(new Query_1.Query("USE \"".concat(dbName, "\"")));
|
|
642
|
+
downQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
643
|
+
upQuery = ifExist ? "IF SCHEMA_ID('".concat(schema, "') IS NULL BEGIN EXEC ('DROP SCHEMA \"").concat(schema, "\"') END") : "DROP SCHEMA \"".concat(schema, "\"");
|
|
644
644
|
upQueries.push(new Query_1.Query(upQuery));
|
|
645
|
-
downQueries.push(new Query_1.Query("CREATE SCHEMA \""
|
|
646
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
647
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
645
|
+
downQueries.push(new Query_1.Query("CREATE SCHEMA \"".concat(schema, "\"")));
|
|
646
|
+
upQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
647
|
+
downQueries.push(new Query_1.Query("USE \"".concat(dbName, "\"")));
|
|
648
648
|
_a.label = 3;
|
|
649
649
|
case 3: return [4 /*yield*/, this.executeQueries(upQueries, downQueries)];
|
|
650
650
|
case 4:
|
|
@@ -857,28 +857,28 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
857
857
|
case 4:
|
|
858
858
|
currentDB = _b.sent();
|
|
859
859
|
if (dbName && dbName !== currentDB) {
|
|
860
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
861
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
860
|
+
upQueries.push(new Query_1.Query("USE \"".concat(dbName, "\"")));
|
|
861
|
+
downQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
862
862
|
}
|
|
863
863
|
// rename table
|
|
864
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
865
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
864
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(oldTable), "\", \"").concat(newTableName, "\"")));
|
|
865
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(newTable), "\", \"").concat(oldTableName, "\"")));
|
|
866
866
|
// rename primary key constraint
|
|
867
867
|
if (newTable.primaryColumns.length > 0) {
|
|
868
868
|
columnNames = newTable.primaryColumns.map(function (column) { return column.name; });
|
|
869
869
|
oldPkName = this.connection.namingStrategy.primaryKeyName(oldTable, columnNames);
|
|
870
870
|
newPkName = this.connection.namingStrategy.primaryKeyName(newTable, columnNames);
|
|
871
871
|
// rename primary constraint
|
|
872
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
873
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
872
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(newTable), ".").concat(oldPkName, "\", \"").concat(newPkName, "\"")));
|
|
873
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(newTable), ".").concat(newPkName, "\", \"").concat(oldPkName, "\"")));
|
|
874
874
|
}
|
|
875
875
|
// rename unique constraints
|
|
876
876
|
newTable.uniques.forEach(function (unique) {
|
|
877
877
|
// build new constraint name
|
|
878
878
|
var newUniqueName = _this.connection.namingStrategy.uniqueConstraintName(newTable, unique.columnNames);
|
|
879
879
|
// build queries
|
|
880
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
881
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
880
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(newTable), ".").concat(unique.name, "\", \"").concat(newUniqueName, "\"")));
|
|
881
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(newTable), ".").concat(newUniqueName, "\", \"").concat(unique.name, "\"")));
|
|
882
882
|
// replace constraint name
|
|
883
883
|
unique.name = newUniqueName;
|
|
884
884
|
});
|
|
@@ -887,8 +887,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
887
887
|
// build new constraint name
|
|
888
888
|
var newIndexName = _this.connection.namingStrategy.indexName(newTable, index.columnNames, index.where);
|
|
889
889
|
// build queries
|
|
890
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
891
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
890
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(newTable), ".").concat(index.name, "\", \"").concat(newIndexName, "\", \"INDEX\"")));
|
|
891
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(newTable), ".").concat(newIndexName, "\", \"").concat(index.name, "\", \"INDEX\"")));
|
|
892
892
|
// replace constraint name
|
|
893
893
|
index.name = newIndexName;
|
|
894
894
|
});
|
|
@@ -897,15 +897,15 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
897
897
|
// build new constraint name
|
|
898
898
|
var newForeignKeyName = _this.connection.namingStrategy.foreignKeyName(newTable, foreignKey.columnNames, _this.getTablePath(foreignKey), foreignKey.referencedColumnNames);
|
|
899
899
|
// build queries
|
|
900
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
901
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
900
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.buildForeignKeyName(foreignKey.name, schemaName, dbName), "\", \"").concat(newForeignKeyName, "\"")));
|
|
901
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.buildForeignKeyName(newForeignKeyName, schemaName, dbName), "\", \"").concat(foreignKey.name, "\"")));
|
|
902
902
|
// replace constraint name
|
|
903
903
|
foreignKey.name = newForeignKeyName;
|
|
904
904
|
});
|
|
905
905
|
// change currently used database back to default db.
|
|
906
906
|
if (dbName && dbName !== currentDB) {
|
|
907
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
908
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
907
|
+
upQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
908
|
+
downQueries.push(new Query_1.Query("USE \"".concat(dbName, "\"")));
|
|
909
909
|
}
|
|
910
910
|
return [4 /*yield*/, this.executeQueries(upQueries, downQueries)];
|
|
911
911
|
case 5:
|
|
@@ -939,23 +939,23 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
939
939
|
clonedTable = table.clone();
|
|
940
940
|
upQueries = [];
|
|
941
941
|
downQueries = [];
|
|
942
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
943
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
942
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD ").concat(this.buildCreateColumnSql(table, column, false, true))));
|
|
943
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP COLUMN \"").concat(column.name, "\"")));
|
|
944
944
|
// create or update primary key constraint
|
|
945
945
|
if (column.isPrimary) {
|
|
946
946
|
primaryColumns = clonedTable.primaryColumns;
|
|
947
947
|
// if table already have primary key, me must drop it and recreate again
|
|
948
948
|
if (primaryColumns.length > 0) {
|
|
949
949
|
pkName_1 = this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map(function (column) { return column.name; }));
|
|
950
|
-
columnNames_1 = primaryColumns.map(function (column) { return "\""
|
|
951
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
952
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
950
|
+
columnNames_1 = primaryColumns.map(function (column) { return "\"".concat(column.name, "\""); }).join(", ");
|
|
951
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(pkName_1, "\"")));
|
|
952
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(pkName_1, "\" PRIMARY KEY (").concat(columnNames_1, ")")));
|
|
953
953
|
}
|
|
954
954
|
primaryColumns.push(column);
|
|
955
955
|
pkName = this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map(function (column) { return column.name; }));
|
|
956
|
-
columnNames = primaryColumns.map(function (column) { return "\""
|
|
957
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
958
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
956
|
+
columnNames = primaryColumns.map(function (column) { return "\"".concat(column.name, "\""); }).join(", ");
|
|
957
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(pkName, "\" PRIMARY KEY (").concat(columnNames, ")")));
|
|
958
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(pkName, "\"")));
|
|
959
959
|
}
|
|
960
960
|
columnIndex = clonedTable.indices.find(function (index) { return index.columnNames.length === 1 && index.columnNames[0] === column.name; });
|
|
961
961
|
if (columnIndex) {
|
|
@@ -969,13 +969,13 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
969
969
|
columnNames: [column.name]
|
|
970
970
|
});
|
|
971
971
|
clonedTable.uniques.push(uniqueConstraint);
|
|
972
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
973
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
972
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(uniqueConstraint.name, "\" UNIQUE (\"").concat(column.name, "\")")));
|
|
973
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(uniqueConstraint.name, "\"")));
|
|
974
974
|
}
|
|
975
975
|
// remove default constraint
|
|
976
976
|
if (column.default !== null && column.default !== undefined) {
|
|
977
977
|
defaultName = this.connection.namingStrategy.defaultConstraintName(table, column.name);
|
|
978
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
978
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(defaultName, "\"")));
|
|
979
979
|
}
|
|
980
980
|
return [4 /*yield*/, this.executeQueries(upQueries, downQueries)];
|
|
981
981
|
case 4:
|
|
@@ -1046,7 +1046,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1046
1046
|
table = _a;
|
|
1047
1047
|
oldColumn = oldTableColumnOrName instanceof TableColumn_1.TableColumn ? oldTableColumnOrName : table.columns.find(function (c) { return c.name === oldTableColumnOrName; });
|
|
1048
1048
|
if (!oldColumn)
|
|
1049
|
-
throw new error_1.TypeORMError("Column \""
|
|
1049
|
+
throw new error_1.TypeORMError("Column \"".concat(oldTableColumnOrName, "\" was not found in the \"").concat(table.name, "\" table."));
|
|
1050
1050
|
newColumn = undefined;
|
|
1051
1051
|
if (newTableColumnOrName instanceof TableColumn_1.TableColumn) {
|
|
1052
1052
|
newColumn = newTableColumnOrName;
|
|
@@ -1089,7 +1089,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1089
1089
|
? oldTableColumnOrName
|
|
1090
1090
|
: table.columns.find(function (column) { return column.name === oldTableColumnOrName; });
|
|
1091
1091
|
if (!oldColumn)
|
|
1092
|
-
throw new error_1.TypeORMError("Column \""
|
|
1092
|
+
throw new error_1.TypeORMError("Column \"".concat(oldTableColumnOrName, "\" was not found in the \"").concat(table.name, "\" table."));
|
|
1093
1093
|
if (!((newColumn.isGenerated !== oldColumn.isGenerated && newColumn.generationStrategy !== "uuid") || newColumn.type !== oldColumn.type || newColumn.length !== oldColumn.length)) return [3 /*break*/, 6];
|
|
1094
1094
|
// SQL Server does not support changing of IDENTITY column, so we must drop column and recreate it again.
|
|
1095
1095
|
// Also, we recreate column if column type changed
|
|
@@ -1121,12 +1121,12 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1121
1121
|
case 7:
|
|
1122
1122
|
currentDB = _b.sent();
|
|
1123
1123
|
if (dbName_1 && dbName_1 !== currentDB) {
|
|
1124
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
1125
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
1124
|
+
upQueries.push(new Query_1.Query("USE \"".concat(dbName_1, "\"")));
|
|
1125
|
+
downQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
1126
1126
|
}
|
|
1127
1127
|
// rename the column
|
|
1128
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1129
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1128
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(table), ".").concat(oldColumn.name, "\", \"").concat(newColumn.name, "\"")));
|
|
1129
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(table), ".").concat(newColumn.name, "\", \"").concat(oldColumn.name, "\"")));
|
|
1130
1130
|
if (oldColumn.isPrimary === true) {
|
|
1131
1131
|
primaryColumns = clonedTable.primaryColumns;
|
|
1132
1132
|
columnNames = primaryColumns.map(function (column) { return column.name; });
|
|
@@ -1136,8 +1136,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1136
1136
|
columnNames.push(newColumn.name);
|
|
1137
1137
|
newPkName = this.connection.namingStrategy.primaryKeyName(clonedTable, columnNames);
|
|
1138
1138
|
// rename primary constraint
|
|
1139
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1140
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1139
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(clonedTable), ".").concat(oldPkName, "\", \"").concat(newPkName, "\"")));
|
|
1140
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(this.getTablePath(clonedTable), ".").concat(newPkName, "\", \"").concat(oldPkName, "\"")));
|
|
1141
1141
|
}
|
|
1142
1142
|
// rename index constraints
|
|
1143
1143
|
clonedTable.findColumnIndices(oldColumn).forEach(function (index) {
|
|
@@ -1146,8 +1146,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1146
1146
|
index.columnNames.push(newColumn.name);
|
|
1147
1147
|
var newIndexName = _this.connection.namingStrategy.indexName(clonedTable, index.columnNames, index.where);
|
|
1148
1148
|
// build queries
|
|
1149
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1150
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1149
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(clonedTable), ".").concat(index.name, "\", \"").concat(newIndexName, "\", \"INDEX\"")));
|
|
1150
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(clonedTable), ".").concat(newIndexName, "\", \"").concat(index.name, "\", \"INDEX\"")));
|
|
1151
1151
|
// replace constraint name
|
|
1152
1152
|
index.name = newIndexName;
|
|
1153
1153
|
});
|
|
@@ -1158,8 +1158,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1158
1158
|
foreignKey.columnNames.push(newColumn.name);
|
|
1159
1159
|
var newForeignKeyName = _this.connection.namingStrategy.foreignKeyName(clonedTable, foreignKey.columnNames, _this.getTablePath(foreignKey), foreignKey.referencedColumnNames);
|
|
1160
1160
|
// build queries
|
|
1161
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1162
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1161
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.buildForeignKeyName(foreignKey.name, schemaName_1, dbName_1), "\", \"").concat(newForeignKeyName, "\"")));
|
|
1162
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.buildForeignKeyName(newForeignKeyName, schemaName_1, dbName_1), "\", \"").concat(foreignKey.name, "\"")));
|
|
1163
1163
|
// replace constraint name
|
|
1164
1164
|
foreignKey.name = newForeignKeyName;
|
|
1165
1165
|
});
|
|
@@ -1170,8 +1170,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1170
1170
|
check.columnNames.push(newColumn.name);
|
|
1171
1171
|
var newCheckName = _this.connection.namingStrategy.checkConstraintName(clonedTable, check.expression);
|
|
1172
1172
|
// build queries
|
|
1173
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1174
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1173
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(clonedTable), ".").concat(check.name, "\", \"").concat(newCheckName, "\"")));
|
|
1174
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(clonedTable), ".").concat(newCheckName, "\", \"").concat(check.name, "\"")));
|
|
1175
1175
|
// replace constraint name
|
|
1176
1176
|
check.name = newCheckName;
|
|
1177
1177
|
});
|
|
@@ -1182,8 +1182,8 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1182
1182
|
unique.columnNames.push(newColumn.name);
|
|
1183
1183
|
var newUniqueName = _this.connection.namingStrategy.uniqueConstraintName(clonedTable, unique.columnNames);
|
|
1184
1184
|
// build queries
|
|
1185
|
-
upQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1186
|
-
downQueries.push(new Query_1.Query("EXEC sp_rename \""
|
|
1185
|
+
upQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(clonedTable), ".").concat(unique.name, "\", \"").concat(newUniqueName, "\"")));
|
|
1186
|
+
downQueries.push(new Query_1.Query("EXEC sp_rename \"".concat(_this.getTablePath(clonedTable), ".").concat(newUniqueName, "\", \"").concat(unique.name, "\"")));
|
|
1187
1187
|
// replace constraint name
|
|
1188
1188
|
unique.name = newUniqueName;
|
|
1189
1189
|
});
|
|
@@ -1191,15 +1191,15 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1191
1191
|
if (oldColumn.default !== null && oldColumn.default !== undefined) {
|
|
1192
1192
|
oldDefaultName = this.connection.namingStrategy.defaultConstraintName(table, oldColumn.name);
|
|
1193
1193
|
newDefaultName = this.connection.namingStrategy.defaultConstraintName(table, newColumn.name);
|
|
1194
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1195
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1196
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1197
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1194
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(oldDefaultName, "\"")));
|
|
1195
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(oldDefaultName, "\" DEFAULT ").concat(oldColumn.default, " FOR \"").concat(newColumn.name, "\"")));
|
|
1196
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(newDefaultName, "\" DEFAULT ").concat(oldColumn.default, " FOR \"").concat(newColumn.name, "\"")));
|
|
1197
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(newDefaultName, "\"")));
|
|
1198
1198
|
}
|
|
1199
1199
|
// change currently used database back to default db.
|
|
1200
1200
|
if (dbName_1 && dbName_1 !== currentDB) {
|
|
1201
|
-
upQueries.push(new Query_1.Query("USE \""
|
|
1202
|
-
downQueries.push(new Query_1.Query("USE \""
|
|
1201
|
+
upQueries.push(new Query_1.Query("USE \"".concat(currentDB, "\"")));
|
|
1202
|
+
downQueries.push(new Query_1.Query("USE \"".concat(dbName_1, "\"")));
|
|
1203
1203
|
}
|
|
1204
1204
|
oldTableColumn = clonedTable.columns.find(function (column) { return column.name === oldColumn.name; });
|
|
1205
1205
|
clonedTable.columns[clonedTable.columns.indexOf(oldTableColumn)].name = newColumn.name;
|
|
@@ -1207,26 +1207,26 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1207
1207
|
_b.label = 8;
|
|
1208
1208
|
case 8:
|
|
1209
1209
|
if (this.isColumnChanged(oldColumn, newColumn, false)) {
|
|
1210
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1211
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1210
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ALTER COLUMN ").concat(this.buildCreateColumnSql(table, newColumn, true, false))));
|
|
1211
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ALTER COLUMN ").concat(this.buildCreateColumnSql(table, oldColumn, true, false))));
|
|
1212
1212
|
}
|
|
1213
1213
|
if (newColumn.isPrimary !== oldColumn.isPrimary) {
|
|
1214
1214
|
primaryColumns = clonedTable.primaryColumns;
|
|
1215
1215
|
// if primary column state changed, we must always drop existed constraint.
|
|
1216
1216
|
if (primaryColumns.length > 0) {
|
|
1217
1217
|
pkName = this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map(function (column) { return column.name; }));
|
|
1218
|
-
columnNames = primaryColumns.map(function (column) { return "\""
|
|
1219
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1220
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1218
|
+
columnNames = primaryColumns.map(function (column) { return "\"".concat(column.name, "\""); }).join(", ");
|
|
1219
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(pkName, "\"")));
|
|
1220
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(pkName, "\" PRIMARY KEY (").concat(columnNames, ")")));
|
|
1221
1221
|
}
|
|
1222
1222
|
if (newColumn.isPrimary === true) {
|
|
1223
1223
|
primaryColumns.push(newColumn);
|
|
1224
1224
|
column = clonedTable.columns.find(function (column) { return column.name === newColumn.name; });
|
|
1225
1225
|
column.isPrimary = true;
|
|
1226
1226
|
pkName = this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map(function (column) { return column.name; }));
|
|
1227
|
-
columnNames = primaryColumns.map(function (column) { return "\""
|
|
1228
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1229
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1227
|
+
columnNames = primaryColumns.map(function (column) { return "\"".concat(column.name, "\""); }).join(", ");
|
|
1228
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(pkName, "\" PRIMARY KEY (").concat(columnNames, ")")));
|
|
1229
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(pkName, "\"")));
|
|
1230
1230
|
}
|
|
1231
1231
|
else {
|
|
1232
1232
|
primaryColumn = primaryColumns.find(function (c) { return c.name === newColumn.name; });
|
|
@@ -1236,9 +1236,9 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1236
1236
|
// if we have another primary keys, we must recreate constraint.
|
|
1237
1237
|
if (primaryColumns.length > 0) {
|
|
1238
1238
|
pkName = this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map(function (column) { return column.name; }));
|
|
1239
|
-
columnNames = primaryColumns.map(function (column) { return "\""
|
|
1240
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1241
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1239
|
+
columnNames = primaryColumns.map(function (column) { return "\"".concat(column.name, "\""); }).join(", ");
|
|
1240
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(pkName, "\" PRIMARY KEY (").concat(columnNames, ")")));
|
|
1241
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(pkName, "\"")));
|
|
1242
1242
|
}
|
|
1243
1243
|
}
|
|
1244
1244
|
}
|
|
@@ -1249,29 +1249,29 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1249
1249
|
columnNames: [newColumn.name]
|
|
1250
1250
|
});
|
|
1251
1251
|
clonedTable.uniques.push(uniqueConstraint);
|
|
1252
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1253
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1252
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(uniqueConstraint.name, "\" UNIQUE (\"").concat(newColumn.name, "\")")));
|
|
1253
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(uniqueConstraint.name, "\"")));
|
|
1254
1254
|
}
|
|
1255
1255
|
else {
|
|
1256
1256
|
uniqueConstraint = clonedTable.uniques.find(function (unique) {
|
|
1257
1257
|
return unique.columnNames.length === 1 && !!unique.columnNames.find(function (columnName) { return columnName === newColumn.name; });
|
|
1258
1258
|
});
|
|
1259
1259
|
clonedTable.uniques.splice(clonedTable.uniques.indexOf(uniqueConstraint), 1);
|
|
1260
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1261
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1260
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(uniqueConstraint.name, "\"")));
|
|
1261
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(uniqueConstraint.name, "\" UNIQUE (\"").concat(newColumn.name, "\")")));
|
|
1262
1262
|
}
|
|
1263
1263
|
}
|
|
1264
1264
|
if (newColumn.default !== oldColumn.default) {
|
|
1265
1265
|
// (note) if there is a previous default, we need to drop its constraint first
|
|
1266
1266
|
if (oldColumn.default !== null && oldColumn.default !== undefined) {
|
|
1267
1267
|
defaultName = this.connection.namingStrategy.defaultConstraintName(table, oldColumn.name);
|
|
1268
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1269
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1268
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(defaultName, "\"")));
|
|
1269
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(defaultName, "\" DEFAULT ").concat(oldColumn.default, " FOR \"").concat(oldColumn.name, "\"")));
|
|
1270
1270
|
}
|
|
1271
1271
|
if (newColumn.default !== null && newColumn.default !== undefined) {
|
|
1272
1272
|
defaultName = this.connection.namingStrategy.defaultConstraintName(table, newColumn.name);
|
|
1273
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1274
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1273
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(defaultName, "\" DEFAULT ").concat(newColumn.default, " FOR \"").concat(newColumn.name, "\"")));
|
|
1274
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(defaultName, "\"")));
|
|
1275
1275
|
}
|
|
1276
1276
|
}
|
|
1277
1277
|
return [4 /*yield*/, this.executeQueries(upQueries, downQueries)];
|
|
@@ -1343,24 +1343,24 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1343
1343
|
table = _a;
|
|
1344
1344
|
column = columnOrName instanceof TableColumn_1.TableColumn ? columnOrName : table.findColumnByName(columnOrName);
|
|
1345
1345
|
if (!column)
|
|
1346
|
-
throw new error_1.TypeORMError("Column \""
|
|
1346
|
+
throw new error_1.TypeORMError("Column \"".concat(columnOrName, "\" was not found in table \"").concat(table.name, "\""));
|
|
1347
1347
|
clonedTable = table.clone();
|
|
1348
1348
|
upQueries = [];
|
|
1349
1349
|
downQueries = [];
|
|
1350
1350
|
// drop primary key constraint
|
|
1351
1351
|
if (column.isPrimary) {
|
|
1352
1352
|
pkName = this.connection.namingStrategy.primaryKeyName(clonedTable, clonedTable.primaryColumns.map(function (column) { return column.name; }));
|
|
1353
|
-
columnNames = clonedTable.primaryColumns.map(function (primaryColumn) { return "\""
|
|
1354
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1355
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1353
|
+
columnNames = clonedTable.primaryColumns.map(function (primaryColumn) { return "\"".concat(primaryColumn.name, "\""); }).join(", ");
|
|
1354
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(clonedTable), " DROP CONSTRAINT \"").concat(pkName, "\"")));
|
|
1355
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(clonedTable), " ADD CONSTRAINT \"").concat(pkName, "\" PRIMARY KEY (").concat(columnNames, ")")));
|
|
1356
1356
|
tableColumn = clonedTable.findColumnByName(column.name);
|
|
1357
1357
|
tableColumn.isPrimary = false;
|
|
1358
1358
|
// if primary key have multiple columns, we must recreate it without dropped column
|
|
1359
1359
|
if (clonedTable.primaryColumns.length > 0) {
|
|
1360
1360
|
pkName_2 = this.connection.namingStrategy.primaryKeyName(clonedTable, clonedTable.primaryColumns.map(function (column) { return column.name; }));
|
|
1361
|
-
columnNames_2 = clonedTable.primaryColumns.map(function (primaryColumn) { return "\""
|
|
1362
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1363
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1361
|
+
columnNames_2 = clonedTable.primaryColumns.map(function (primaryColumn) { return "\"".concat(primaryColumn.name, "\""); }).join(", ");
|
|
1362
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(clonedTable), " ADD CONSTRAINT \"").concat(pkName_2, "\" PRIMARY KEY (").concat(columnNames_2, ")")));
|
|
1363
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(clonedTable), " DROP CONSTRAINT \"").concat(pkName_2, "\"")));
|
|
1364
1364
|
}
|
|
1365
1365
|
}
|
|
1366
1366
|
columnIndex = clonedTable.indices.find(function (index) { return index.columnNames.length === 1 && index.columnNames[0] === column.name; });
|
|
@@ -1384,11 +1384,11 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1384
1384
|
// drop default constraint
|
|
1385
1385
|
if (column.default !== null && column.default !== undefined) {
|
|
1386
1386
|
defaultName = this.connection.namingStrategy.defaultConstraintName(table, column.name);
|
|
1387
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1388
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1387
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(defaultName, "\"")));
|
|
1388
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(defaultName, "\" DEFAULT ").concat(column.default, " FOR \"").concat(column.name, "\"")));
|
|
1389
1389
|
}
|
|
1390
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1391
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1390
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP COLUMN \"").concat(column.name, "\"")));
|
|
1391
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD ").concat(this.buildCreateColumnSql(table, column, false, false))));
|
|
1392
1392
|
return [4 /*yield*/, this.executeQueries(upQueries, downQueries)];
|
|
1393
1393
|
case 4:
|
|
1394
1394
|
_b.sent();
|
|
@@ -1498,18 +1498,18 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1498
1498
|
primaryColumns = clonedTable.primaryColumns;
|
|
1499
1499
|
if (primaryColumns.length > 0) {
|
|
1500
1500
|
pkName_3 = this.connection.namingStrategy.primaryKeyName(clonedTable, primaryColumns.map(function (column) { return column.name; }));
|
|
1501
|
-
columnNamesString_1 = primaryColumns.map(function (column) { return "\""
|
|
1502
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1503
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1501
|
+
columnNamesString_1 = primaryColumns.map(function (column) { return "\"".concat(column.name, "\""); }).join(", ");
|
|
1502
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(pkName_3, "\"")));
|
|
1503
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(pkName_3, "\" PRIMARY KEY (").concat(columnNamesString_1, ")")));
|
|
1504
1504
|
}
|
|
1505
1505
|
// update columns in table.
|
|
1506
1506
|
clonedTable.columns
|
|
1507
1507
|
.filter(function (column) { return columnNames.indexOf(column.name) !== -1; })
|
|
1508
1508
|
.forEach(function (column) { return column.isPrimary = true; });
|
|
1509
1509
|
pkName = this.connection.namingStrategy.primaryKeyName(clonedTable, columnNames);
|
|
1510
|
-
columnNamesString = columnNames.map(function (columnName) { return "\""
|
|
1511
|
-
upQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1512
|
-
downQueries.push(new Query_1.Query("ALTER TABLE "
|
|
1510
|
+
columnNamesString = columnNames.map(function (columnName) { return "\"".concat(columnName, "\""); }).join(", ");
|
|
1511
|
+
upQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(pkName, "\" PRIMARY KEY (").concat(columnNamesString, ")")));
|
|
1512
|
+
downQueries.push(new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(pkName, "\"")));
|
|
1513
1513
|
return [4 /*yield*/, this.executeQueries(upQueries, downQueries)];
|
|
1514
1514
|
case 4:
|
|
1515
1515
|
_b.sent();
|
|
@@ -1621,7 +1621,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1621
1621
|
table = _a;
|
|
1622
1622
|
uniqueConstraint = uniqueOrName instanceof TableUnique_1.TableUnique ? uniqueOrName : table.uniques.find(function (u) { return u.name === uniqueOrName; });
|
|
1623
1623
|
if (!uniqueConstraint)
|
|
1624
|
-
throw new error_1.TypeORMError("Supplied unique constraint was not found in table "
|
|
1624
|
+
throw new error_1.TypeORMError("Supplied unique constraint was not found in table ".concat(table.name));
|
|
1625
1625
|
up = this.dropUniqueConstraintSql(table, uniqueConstraint);
|
|
1626
1626
|
down = this.createUniqueConstraintSql(table, uniqueConstraint);
|
|
1627
1627
|
return [4 /*yield*/, this.executeQueries(up, down)];
|
|
@@ -1723,7 +1723,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1723
1723
|
table = _a;
|
|
1724
1724
|
checkConstraint = checkOrName instanceof TableCheck_1.TableCheck ? checkOrName : table.checks.find(function (c) { return c.name === checkOrName; });
|
|
1725
1725
|
if (!checkConstraint)
|
|
1726
|
-
throw new error_1.TypeORMError("Supplied check constraint was not found in table "
|
|
1726
|
+
throw new error_1.TypeORMError("Supplied check constraint was not found in table ".concat(table.name));
|
|
1727
1727
|
up = this.dropCheckConstraintSql(table, checkConstraint);
|
|
1728
1728
|
down = this.createCheckConstraintSql(table, checkConstraint);
|
|
1729
1729
|
return [4 /*yield*/, this.executeQueries(up, down)];
|
|
@@ -1868,7 +1868,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1868
1868
|
table = _a;
|
|
1869
1869
|
foreignKey = foreignKeyOrName instanceof TableForeignKey_1.TableForeignKey ? foreignKeyOrName : table.foreignKeys.find(function (fk) { return fk.name === foreignKeyOrName; });
|
|
1870
1870
|
if (!foreignKey)
|
|
1871
|
-
throw new error_1.TypeORMError("Supplied foreign key was not found in table "
|
|
1871
|
+
throw new error_1.TypeORMError("Supplied foreign key was not found in table ".concat(table.name));
|
|
1872
1872
|
up = this.dropForeignKeySql(table, foreignKey);
|
|
1873
1873
|
down = this.createForeignKeySql(table, foreignKey);
|
|
1874
1874
|
return [4 /*yield*/, this.executeQueries(up, down)];
|
|
@@ -1970,7 +1970,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
1970
1970
|
table = _a;
|
|
1971
1971
|
index = indexOrName instanceof TableIndex_1.TableIndex ? indexOrName : table.indices.find(function (i) { return i.name === indexOrName; });
|
|
1972
1972
|
if (!index)
|
|
1973
|
-
throw new error_1.TypeORMError("Supplied index was not found in table "
|
|
1973
|
+
throw new error_1.TypeORMError("Supplied index was not found in table ".concat(table.name));
|
|
1974
1974
|
up = this.dropIndexSql(table, index);
|
|
1975
1975
|
down = this.createIndexSql(table, index);
|
|
1976
1976
|
return [4 /*yield*/, this.executeQueries(up, down)];
|
|
@@ -2009,7 +2009,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2009
2009
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
2010
2010
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
2011
2011
|
switch (_a.label) {
|
|
2012
|
-
case 0: return [4 /*yield*/, this.query("TRUNCATE TABLE "
|
|
2012
|
+
case 0: return [4 /*yield*/, this.query("TRUNCATE TABLE ".concat(this.escapePath(tablePath)))];
|
|
2013
2013
|
case 1:
|
|
2014
2014
|
_a.sent();
|
|
2015
2015
|
return [2 /*return*/];
|
|
@@ -2022,7 +2022,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2022
2022
|
*/
|
|
2023
2023
|
SqlServerQueryRunner.prototype.clearDatabase = function (database) {
|
|
2024
2024
|
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
2025
|
-
var isDatabaseExist, allViewsSql, allViewsResults, allTablesSql, allTablesResults, tablesByCatalog, foreignKeysSql, foreignKeys, error_2, rollbackError_1;
|
|
2025
|
+
var isDatabaseExist, isAnotherTransactionActive, allViewsSql, allViewsResults, allTablesSql, allTablesResults, tablesByCatalog, foreignKeysSql, foreignKeys, error_2, rollbackError_1;
|
|
2026
2026
|
var _this = this;
|
|
2027
2027
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
2028
2028
|
switch (_a.label) {
|
|
@@ -2034,27 +2034,30 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2034
2034
|
if (!isDatabaseExist)
|
|
2035
2035
|
return [2 /*return*/, Promise.resolve()];
|
|
2036
2036
|
_a.label = 2;
|
|
2037
|
-
case 2:
|
|
2037
|
+
case 2:
|
|
2038
|
+
isAnotherTransactionActive = this.isTransactionActive;
|
|
2039
|
+
if (!!isAnotherTransactionActive) return [3 /*break*/, 4];
|
|
2040
|
+
return [4 /*yield*/, this.startTransaction()];
|
|
2038
2041
|
case 3:
|
|
2039
2042
|
_a.sent();
|
|
2040
2043
|
_a.label = 4;
|
|
2041
2044
|
case 4:
|
|
2042
|
-
_a.trys.push([4,
|
|
2045
|
+
_a.trys.push([4, 14, , 20]);
|
|
2043
2046
|
allViewsSql = database
|
|
2044
|
-
? "SELECT * FROM \""
|
|
2047
|
+
? "SELECT * FROM \"".concat(database, "\".\"INFORMATION_SCHEMA\".\"VIEWS\"")
|
|
2045
2048
|
: "SELECT * FROM \"INFORMATION_SCHEMA\".\"VIEWS\"";
|
|
2046
2049
|
return [4 /*yield*/, this.query(allViewsSql)];
|
|
2047
2050
|
case 5:
|
|
2048
2051
|
allViewsResults = _a.sent();
|
|
2049
2052
|
return [4 /*yield*/, Promise.all(allViewsResults.map(function (viewResult) {
|
|
2050
2053
|
// 'DROP VIEW' does not allow specifying the database name as a prefix to the object name.
|
|
2051
|
-
var dropTableSql = "DROP VIEW \""
|
|
2054
|
+
var dropTableSql = "DROP VIEW \"".concat(viewResult["TABLE_SCHEMA"], "\".\"").concat(viewResult["TABLE_NAME"], "\"");
|
|
2052
2055
|
return _this.query(dropTableSql);
|
|
2053
2056
|
}))];
|
|
2054
2057
|
case 6:
|
|
2055
2058
|
_a.sent();
|
|
2056
2059
|
allTablesSql = database
|
|
2057
|
-
? "SELECT * FROM \""
|
|
2060
|
+
? "SELECT * FROM \"".concat(database, "\".\"INFORMATION_SCHEMA\".\"TABLES\" WHERE \"TABLE_TYPE\" = 'BASE TABLE'")
|
|
2058
2061
|
: "SELECT * FROM \"INFORMATION_SCHEMA\".\"TABLES\" WHERE \"TABLE_TYPE\" = 'BASE TABLE'";
|
|
2059
2062
|
return [4 /*yield*/, this.query(allTablesSql)];
|
|
2060
2063
|
case 7:
|
|
@@ -2070,9 +2073,9 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2070
2073
|
var _b = (0, tslib_1.__read)(_a, 2), TABLE_CATALOG = _b[0], tables = _b[1];
|
|
2071
2074
|
var conditions = tables.map(function (_a) {
|
|
2072
2075
|
var TABLE_SCHEMA = _a.TABLE_SCHEMA, TABLE_NAME = _a.TABLE_NAME;
|
|
2073
|
-
return "(\"fk\".\"referenced_object_id\" = OBJECT_ID('\""
|
|
2076
|
+
return "(\"fk\".\"referenced_object_id\" = OBJECT_ID('\"".concat(TABLE_CATALOG, "\".\"").concat(TABLE_SCHEMA, "\".\"").concat(TABLE_NAME, "\"'))");
|
|
2074
2077
|
}).join(" OR ");
|
|
2075
|
-
return "\n SELECT DISTINCT '"
|
|
2078
|
+
return "\n SELECT DISTINCT '".concat(TABLE_CATALOG, "' AS \"TABLE_CATALOG\",\n OBJECT_SCHEMA_NAME(\"fk\".\"parent_object_id\",\n DB_ID('").concat(TABLE_CATALOG, "')) AS \"TABLE_SCHEMA\",\n OBJECT_NAME(\"fk\".\"parent_object_id\", DB_ID('").concat(TABLE_CATALOG, "')) AS \"TABLE_NAME\",\n \"fk\".\"name\" AS \"CONSTRAINT_NAME\"\n FROM \"").concat(TABLE_CATALOG, "\".\"sys\".\"foreign_keys\" AS \"fk\"\n WHERE (").concat(conditions, ")\n ");
|
|
2076
2079
|
}).join(" UNION ALL ");
|
|
2077
2080
|
return [4 /*yield*/, this.query(foreignKeysSql)];
|
|
2078
2081
|
case 8:
|
|
@@ -2084,13 +2087,13 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2084
2087
|
switch (_b.label) {
|
|
2085
2088
|
case 0:
|
|
2086
2089
|
// Disable the constraint first.
|
|
2087
|
-
return [4 /*yield*/, this.query("ALTER TABLE \""
|
|
2088
|
-
|
|
2090
|
+
return [4 /*yield*/, this.query("ALTER TABLE \"".concat(TABLE_CATALOG, "\".\"").concat(TABLE_SCHEMA, "\".\"").concat(TABLE_NAME, "\" ") +
|
|
2091
|
+
"NOCHECK CONSTRAINT \"".concat(CONSTRAINT_NAME, "\""))];
|
|
2089
2092
|
case 1:
|
|
2090
2093
|
// Disable the constraint first.
|
|
2091
2094
|
_b.sent();
|
|
2092
|
-
return [4 /*yield*/, this.query("ALTER TABLE \""
|
|
2093
|
-
|
|
2095
|
+
return [4 /*yield*/, this.query("ALTER TABLE \"".concat(TABLE_CATALOG, "\".\"").concat(TABLE_SCHEMA, "\".\"").concat(TABLE_NAME, "\" ") +
|
|
2096
|
+
"DROP CONSTRAINT \"".concat(CONSTRAINT_NAME, "\" -- FROM CLEAR"))];
|
|
2094
2097
|
case 2:
|
|
2095
2098
|
_b.sent();
|
|
2096
2099
|
return [2 /*return*/];
|
|
@@ -2105,30 +2108,35 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2105
2108
|
// don't try to drop temporary tables
|
|
2106
2109
|
return;
|
|
2107
2110
|
}
|
|
2108
|
-
var dropTableSql = "DROP TABLE \""
|
|
2111
|
+
var dropTableSql = "DROP TABLE \"".concat(tablesResult["TABLE_CATALOG"], "\".\"").concat(tablesResult["TABLE_SCHEMA"], "\".\"").concat(tablesResult["TABLE_NAME"], "\"");
|
|
2109
2112
|
return _this.query(dropTableSql);
|
|
2110
2113
|
}))];
|
|
2111
2114
|
case 10:
|
|
2112
2115
|
_a.sent();
|
|
2113
2116
|
_a.label = 11;
|
|
2114
|
-
case 11:
|
|
2117
|
+
case 11:
|
|
2118
|
+
if (!!isAnotherTransactionActive) return [3 /*break*/, 13];
|
|
2119
|
+
return [4 /*yield*/, this.commitTransaction()];
|
|
2115
2120
|
case 12:
|
|
2116
2121
|
_a.sent();
|
|
2117
|
-
|
|
2118
|
-
case 13:
|
|
2119
|
-
error_2 = _a.sent();
|
|
2120
|
-
_a.label = 14;
|
|
2122
|
+
_a.label = 13;
|
|
2123
|
+
case 13: return [3 /*break*/, 20];
|
|
2121
2124
|
case 14:
|
|
2122
|
-
_a.
|
|
2123
|
-
|
|
2125
|
+
error_2 = _a.sent();
|
|
2126
|
+
_a.label = 15;
|
|
2124
2127
|
case 15:
|
|
2125
|
-
_a.
|
|
2126
|
-
return [3 /*break*/, 17];
|
|
2128
|
+
_a.trys.push([15, 18, , 19]);
|
|
2129
|
+
if (!!isAnotherTransactionActive) return [3 /*break*/, 17];
|
|
2130
|
+
return [4 /*yield*/, this.rollbackTransaction()];
|
|
2127
2131
|
case 16:
|
|
2132
|
+
_a.sent();
|
|
2133
|
+
_a.label = 17;
|
|
2134
|
+
case 17: return [3 /*break*/, 19];
|
|
2135
|
+
case 18:
|
|
2128
2136
|
rollbackError_1 = _a.sent();
|
|
2129
|
-
return [3 /*break*/,
|
|
2130
|
-
case
|
|
2131
|
-
case
|
|
2137
|
+
return [3 /*break*/, 19];
|
|
2138
|
+
case 19: throw error_2;
|
|
2139
|
+
case 20: return [2 /*return*/];
|
|
2132
2140
|
}
|
|
2133
2141
|
});
|
|
2134
2142
|
});
|
|
@@ -2167,11 +2175,11 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2167
2175
|
if (!schema) {
|
|
2168
2176
|
schema = currentSchema;
|
|
2169
2177
|
}
|
|
2170
|
-
return "(\"T\".\"SCHEMA\" = '"
|
|
2178
|
+
return "(\"T\".\"SCHEMA\" = '".concat(schema, "' AND \"T\".\"NAME\" = '").concat(name, "')");
|
|
2171
2179
|
}).join(" OR ");
|
|
2172
2180
|
query = dbNames.map(function (dbName) {
|
|
2173
|
-
return "SELECT \"T\".*, \"V\".\"CHECK_OPTION\" FROM "
|
|
2174
|
-
|
|
2181
|
+
return "SELECT \"T\".*, \"V\".\"CHECK_OPTION\" FROM ".concat(_this.escapePath(_this.getTypeormMetadataTableName()), " \"t\" ") +
|
|
2182
|
+
"INNER JOIN \"".concat(dbName, "\".\"INFORMATION_SCHEMA\".\"VIEWS\" \"V\" ON \"V\".\"TABLE_SCHEMA\" = \"T\".\"SCHEMA\" AND \"v\".\"TABLE_NAME\" = \"T\".\"NAME\" WHERE \"T\".\"TYPE\" = '").concat(MetadataTableType_1.MetadataTableType.VIEW, "' ").concat(viewsCondition ? "AND (".concat(viewsCondition, ")") : "");
|
|
2175
2183
|
}).join(" UNION ALL ");
|
|
2176
2184
|
return [4 /*yield*/, this.query(query)];
|
|
2177
2185
|
case 4:
|
|
@@ -2218,7 +2226,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2218
2226
|
dbDatabases = _k.sent();
|
|
2219
2227
|
tablesSql = dbDatabases.map(function (_a) {
|
|
2220
2228
|
var name = _a.name;
|
|
2221
|
-
return "\n SELECT DISTINCT\n \"TABLE_CATALOG\", \"TABLE_SCHEMA\", \"TABLE_NAME\"\n FROM \""
|
|
2229
|
+
return "\n SELECT DISTINCT\n \"TABLE_CATALOG\", \"TABLE_SCHEMA\", \"TABLE_NAME\"\n FROM \"".concat(name, "\".\"INFORMATION_SCHEMA\".\"TABLES\"\n WHERE\n \"TABLE_TYPE\" = 'BASE TABLE'\n AND\n \"TABLE_CATALOG\" = '").concat(name, "'\n AND\n ISNULL(Objectproperty(Object_id(\"TABLE_CATALOG\" + '.' + \"TABLE_SCHEMA\" + '.' + \"TABLE_NAME\"), 'IsMSShipped'), 0) = 0\n ");
|
|
2222
2230
|
}).join(" UNION ALL ");
|
|
2223
2231
|
_b = (_a = dbTables.push).apply;
|
|
2224
2232
|
_c = [dbTables];
|
|
@@ -2245,10 +2253,10 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2245
2253
|
var tablesCondition = tables
|
|
2246
2254
|
.map(function (_a) {
|
|
2247
2255
|
var schema = _a.schema, tableName = _a.tableName;
|
|
2248
|
-
return "(\"TABLE_SCHEMA\" = '"
|
|
2256
|
+
return "(\"TABLE_SCHEMA\" = '".concat(schema, "' AND \"TABLE_NAME\" = '").concat(tableName, "')");
|
|
2249
2257
|
})
|
|
2250
2258
|
.join(" OR ");
|
|
2251
|
-
return "\n SELECT DISTINCT\n \"TABLE_CATALOG\", \"TABLE_SCHEMA\", \"TABLE_NAME\"\n FROM \""
|
|
2259
|
+
return "\n SELECT DISTINCT\n \"TABLE_CATALOG\", \"TABLE_SCHEMA\", \"TABLE_NAME\"\n FROM \"".concat(database, "\".\"INFORMATION_SCHEMA\".\"TABLES\"\n WHERE\n \"TABLE_TYPE\" = 'BASE TABLE' AND\n \"TABLE_CATALOG\" = '").concat(database, "' AND\n ").concat(tablesCondition, "\n ");
|
|
2252
2260
|
}).join(" UNION ALL ");
|
|
2253
2261
|
_f = (_e = dbTables.push).apply;
|
|
2254
2262
|
_g = [dbTables];
|
|
@@ -2272,78 +2280,78 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2272
2280
|
var _b = (0, tslib_1.__read)(_a, 2), TABLE_CATALOG = _b[0], tables = _b[1];
|
|
2273
2281
|
var condition = tables.map(function (_a) {
|
|
2274
2282
|
var TABLE_SCHEMA = _a.TABLE_SCHEMA, TABLE_NAME = _a.TABLE_NAME;
|
|
2275
|
-
return "(\"TABLE_SCHEMA\" = '"
|
|
2283
|
+
return "(\"TABLE_SCHEMA\" = '".concat(TABLE_SCHEMA, "' AND \"TABLE_NAME\" = '").concat(TABLE_NAME, "')");
|
|
2276
2284
|
}).join("OR");
|
|
2277
|
-
return "SELECT * FROM \""
|
|
2285
|
+
return "SELECT * FROM \"".concat(TABLE_CATALOG, "\".\"INFORMATION_SCHEMA\".\"COLUMNS\" WHERE (").concat(condition, ")");
|
|
2278
2286
|
}).join(" UNION ALL ");
|
|
2279
2287
|
constraintsSql = Object.entries(dbTablesByCatalog).map(function (_a) {
|
|
2280
2288
|
var _b = (0, tslib_1.__read)(_a, 2), TABLE_CATALOG = _b[0], tables = _b[1];
|
|
2281
2289
|
var conditions = tables.map(function (_a) {
|
|
2282
2290
|
var TABLE_NAME = _a.TABLE_NAME, TABLE_SCHEMA = _a.TABLE_SCHEMA;
|
|
2283
|
-
return "(\"columnUsages\".\"TABLE_SCHEMA\" = '"
|
|
2291
|
+
return "(\"columnUsages\".\"TABLE_SCHEMA\" = '".concat(TABLE_SCHEMA, "' AND \"columnUsages\".\"TABLE_NAME\" = '").concat(TABLE_NAME, "')");
|
|
2284
2292
|
}).join(" OR ");
|
|
2285
2293
|
return "SELECT \"columnUsages\".*, \"tableConstraints\".\"CONSTRAINT_TYPE\", \"chk\".\"definition\" " +
|
|
2286
|
-
|
|
2287
|
-
|
|
2294
|
+
"FROM \"".concat(TABLE_CATALOG, "\".\"INFORMATION_SCHEMA\".\"CONSTRAINT_COLUMN_USAGE\" \"columnUsages\" ") +
|
|
2295
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"INFORMATION_SCHEMA\".\"TABLE_CONSTRAINTS\" \"tableConstraints\" ") +
|
|
2288
2296
|
"ON " +
|
|
2289
2297
|
"\"tableConstraints\".\"CONSTRAINT_NAME\" = \"columnUsages\".\"CONSTRAINT_NAME\" AND " +
|
|
2290
2298
|
"\"tableConstraints\".\"TABLE_SCHEMA\" = \"columnUsages\".\"TABLE_SCHEMA\" AND " +
|
|
2291
2299
|
"\"tableConstraints\".\"TABLE_NAME\" = \"columnUsages\".\"TABLE_NAME\" " +
|
|
2292
|
-
|
|
2300
|
+
"LEFT JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"check_constraints\" \"chk\" ") +
|
|
2293
2301
|
"ON " +
|
|
2294
2302
|
"\"chk\".\"object_id\" = OBJECT_ID(\"columnUsages\".\"TABLE_CATALOG\" + '.' + \"columnUsages\".\"TABLE_SCHEMA\" + '.' + \"columnUsages\".\"CONSTRAINT_NAME\") " +
|
|
2295
2303
|
"WHERE " +
|
|
2296
|
-
("(
|
|
2304
|
+
"(".concat(conditions, ") AND ") +
|
|
2297
2305
|
"\"tableConstraints\".\"CONSTRAINT_TYPE\" IN ('PRIMARY KEY', 'UNIQUE', 'CHECK')";
|
|
2298
2306
|
}).join(" UNION ALL ");
|
|
2299
2307
|
foreignKeysSql = Object.entries(dbTablesByCatalog).map(function (_a) {
|
|
2300
2308
|
var _b = (0, tslib_1.__read)(_a, 2), TABLE_CATALOG = _b[0], tables = _b[1];
|
|
2301
2309
|
var conditions = tables.map(function (_a) {
|
|
2302
2310
|
var TABLE_NAME = _a.TABLE_NAME, TABLE_SCHEMA = _a.TABLE_SCHEMA;
|
|
2303
|
-
return "(\"s1\".\"name\" = '"
|
|
2311
|
+
return "(\"s1\".\"name\" = '".concat(TABLE_SCHEMA, "' AND \"t1\".\"name\" = '").concat(TABLE_NAME, "')");
|
|
2304
2312
|
}).join(" OR ");
|
|
2305
|
-
return "SELECT \"fk\".\"name\" AS \"FK_NAME\", '"
|
|
2313
|
+
return "SELECT \"fk\".\"name\" AS \"FK_NAME\", '".concat(TABLE_CATALOG, "' AS \"TABLE_CATALOG\", \"s1\".\"name\" AS \"TABLE_SCHEMA\", \"t1\".\"name\" AS \"TABLE_NAME\", ") +
|
|
2306
2314
|
"\"col1\".\"name\" AS \"COLUMN_NAME\", \"s2\".\"name\" AS \"REF_SCHEMA\", \"t2\".\"name\" AS \"REF_TABLE\", \"col2\".\"name\" AS \"REF_COLUMN\", " +
|
|
2307
2315
|
"\"fk\".\"delete_referential_action_desc\" AS \"ON_DELETE\", \"fk\".\"update_referential_action_desc\" AS \"ON_UPDATE\" " +
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2316
|
+
"FROM \"".concat(TABLE_CATALOG, "\".\"sys\".\"foreign_keys\" \"fk\" ") +
|
|
2317
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"foreign_key_columns\" \"fkc\" ON \"fkc\".\"constraint_object_id\" = \"fk\".\"object_id\" ") +
|
|
2318
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"tables\" \"t1\" ON \"t1\".\"object_id\" = \"fk\".\"parent_object_id\" ") +
|
|
2319
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"schemas\" \"s1\" ON \"s1\".\"schema_id\" = \"t1\".\"schema_id\" ") +
|
|
2320
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"tables\" \"t2\" ON \"t2\".\"object_id\" = \"fk\".\"referenced_object_id\" ") +
|
|
2321
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"schemas\" \"s2\" ON \"s2\".\"schema_id\" = \"t2\".\"schema_id\" ") +
|
|
2322
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"columns\" \"col1\" ON \"col1\".\"column_id\" = \"fkc\".\"parent_column_id\" AND \"col1\".\"object_id\" = \"fk\".\"parent_object_id\" ") +
|
|
2323
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"columns\" \"col2\" ON \"col2\".\"column_id\" = \"fkc\".\"referenced_column_id\" AND \"col2\".\"object_id\" = \"fk\".\"referenced_object_id\" ") +
|
|
2324
|
+
"WHERE (".concat(conditions, ")");
|
|
2317
2325
|
}).join(" UNION ALL ");
|
|
2318
2326
|
identityColumnsSql = Object.entries(dbTablesByCatalog).map(function (_a) {
|
|
2319
2327
|
var _b = (0, tslib_1.__read)(_a, 2), TABLE_CATALOG = _b[0], tables = _b[1];
|
|
2320
2328
|
var conditions = tables.map(function (_a) {
|
|
2321
2329
|
var TABLE_NAME = _a.TABLE_NAME, TABLE_SCHEMA = _a.TABLE_SCHEMA;
|
|
2322
|
-
return "(\"TABLE_SCHEMA\" = '"
|
|
2330
|
+
return "(\"TABLE_SCHEMA\" = '".concat(TABLE_SCHEMA, "' AND \"TABLE_NAME\" = '").concat(TABLE_NAME, "')");
|
|
2323
2331
|
}).join(" OR ");
|
|
2324
2332
|
return "SELECT \"TABLE_CATALOG\", \"TABLE_SCHEMA\", \"COLUMN_NAME\", \"TABLE_NAME\" " +
|
|
2325
|
-
|
|
2333
|
+
"FROM \"".concat(TABLE_CATALOG, "\".\"INFORMATION_SCHEMA\".\"COLUMNS\" ") +
|
|
2326
2334
|
"WHERE " +
|
|
2327
|
-
|
|
2328
|
-
("(
|
|
2335
|
+
"EXISTS(SELECT 1 FROM \"".concat(TABLE_CATALOG, "\".\"sys\".\"columns\" \"S\" WHERE OBJECT_ID(\"TABLE_CATALOG\" + '.' + \"TABLE_SCHEMA\" + '.' + \"TABLE_NAME\") = \"S\".\"OBJECT_ID\" AND \"COLUMN_NAME\" = \"S\".\"NAME\" AND \"S\".\"is_identity\" = 1) AND ") +
|
|
2336
|
+
"(".concat(conditions, ")");
|
|
2329
2337
|
}).join(" UNION ALL ");
|
|
2330
2338
|
dbCollationsSql = "SELECT \"NAME\", \"COLLATION_NAME\" FROM \"sys\".\"databases\"";
|
|
2331
2339
|
indicesSql = Object.entries(dbTablesByCatalog).map(function (_a) {
|
|
2332
2340
|
var _b = (0, tslib_1.__read)(_a, 2), TABLE_CATALOG = _b[0], tables = _b[1];
|
|
2333
2341
|
var conditions = tables.map(function (_a) {
|
|
2334
2342
|
var TABLE_NAME = _a.TABLE_NAME, TABLE_SCHEMA = _a.TABLE_SCHEMA;
|
|
2335
|
-
return "(\"s\".\"name\" = '"
|
|
2343
|
+
return "(\"s\".\"name\" = '".concat(TABLE_SCHEMA, "' AND \"t\".\"name\" = '").concat(TABLE_NAME, "')");
|
|
2336
2344
|
}).join(" OR ");
|
|
2337
|
-
return "SELECT '"
|
|
2345
|
+
return "SELECT '".concat(TABLE_CATALOG, "' AS \"TABLE_CATALOG\", \"s\".\"name\" AS \"TABLE_SCHEMA\", \"t\".\"name\" AS \"TABLE_NAME\", ") +
|
|
2338
2346
|
"\"ind\".\"name\" AS \"INDEX_NAME\", \"col\".\"name\" AS \"COLUMN_NAME\", \"ind\".\"is_unique\" AS \"IS_UNIQUE\", \"ind\".\"filter_definition\" as \"CONDITION\" " +
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2347
|
+
"FROM \"".concat(TABLE_CATALOG, "\".\"sys\".\"indexes\" \"ind\" ") +
|
|
2348
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"index_columns\" \"ic\" ON \"ic\".\"object_id\" = \"ind\".\"object_id\" AND \"ic\".\"index_id\" = \"ind\".\"index_id\" ") +
|
|
2349
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"columns\" \"col\" ON \"col\".\"object_id\" = \"ic\".\"object_id\" AND \"col\".\"column_id\" = \"ic\".\"column_id\" ") +
|
|
2350
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"tables\" \"t\" ON \"t\".\"object_id\" = \"ind\".\"object_id\" ") +
|
|
2351
|
+
"INNER JOIN \"".concat(TABLE_CATALOG, "\".\"sys\".\"schemas\" \"s\" ON \"s\".\"schema_id\" = \"t\".\"schema_id\" ") +
|
|
2344
2352
|
"WHERE " +
|
|
2345
2353
|
"\"ind\".\"is_primary_key\" = 0 AND \"ind\".\"is_unique_constraint\" = 0 AND \"t\".\"is_ms_shipped\" = 0 AND " +
|
|
2346
|
-
("(
|
|
2354
|
+
"(".concat(conditions, ")");
|
|
2347
2355
|
}).join(" UNION ALL ");
|
|
2348
2356
|
return [4 /*yield*/, Promise.all([
|
|
2349
2357
|
this.query(columnsSql),
|
|
@@ -2546,7 +2554,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2546
2554
|
SqlServerQueryRunner.prototype.createTableSql = function (table, createForeignKeys) {
|
|
2547
2555
|
var _this = this;
|
|
2548
2556
|
var columnDefinitions = table.columns.map(function (column) { return _this.buildCreateColumnSql(table, column, false, true); }).join(", ");
|
|
2549
|
-
var sql = "CREATE TABLE "
|
|
2557
|
+
var sql = "CREATE TABLE ".concat(this.escapePath(table), " (").concat(columnDefinitions);
|
|
2550
2558
|
table.columns
|
|
2551
2559
|
.filter(function (column) { return column.isUnique; })
|
|
2552
2560
|
.forEach(function (column) {
|
|
@@ -2560,38 +2568,38 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2560
2568
|
if (table.uniques.length > 0) {
|
|
2561
2569
|
var uniquesSql = table.uniques.map(function (unique) {
|
|
2562
2570
|
var uniqueName = unique.name ? unique.name : _this.connection.namingStrategy.uniqueConstraintName(table, unique.columnNames);
|
|
2563
|
-
var columnNames = unique.columnNames.map(function (columnName) { return "\""
|
|
2564
|
-
return "CONSTRAINT \""
|
|
2571
|
+
var columnNames = unique.columnNames.map(function (columnName) { return "\"".concat(columnName, "\""); }).join(", ");
|
|
2572
|
+
return "CONSTRAINT \"".concat(uniqueName, "\" UNIQUE (").concat(columnNames, ")");
|
|
2565
2573
|
}).join(", ");
|
|
2566
|
-
sql += ", "
|
|
2574
|
+
sql += ", ".concat(uniquesSql);
|
|
2567
2575
|
}
|
|
2568
2576
|
if (table.checks.length > 0) {
|
|
2569
2577
|
var checksSql = table.checks.map(function (check) {
|
|
2570
2578
|
var checkName = check.name ? check.name : _this.connection.namingStrategy.checkConstraintName(table, check.expression);
|
|
2571
|
-
return "CONSTRAINT \""
|
|
2579
|
+
return "CONSTRAINT \"".concat(checkName, "\" CHECK (").concat(check.expression, ")");
|
|
2572
2580
|
}).join(", ");
|
|
2573
|
-
sql += ", "
|
|
2581
|
+
sql += ", ".concat(checksSql);
|
|
2574
2582
|
}
|
|
2575
2583
|
if (table.foreignKeys.length > 0 && createForeignKeys) {
|
|
2576
2584
|
var foreignKeysSql = table.foreignKeys.map(function (fk) {
|
|
2577
|
-
var columnNames = fk.columnNames.map(function (columnName) { return "\""
|
|
2585
|
+
var columnNames = fk.columnNames.map(function (columnName) { return "\"".concat(columnName, "\""); }).join(", ");
|
|
2578
2586
|
if (!fk.name)
|
|
2579
2587
|
fk.name = _this.connection.namingStrategy.foreignKeyName(table, fk.columnNames, _this.getTablePath(fk), fk.referencedColumnNames);
|
|
2580
|
-
var referencedColumnNames = fk.referencedColumnNames.map(function (columnName) { return "\""
|
|
2581
|
-
var constraint = "CONSTRAINT \""
|
|
2588
|
+
var referencedColumnNames = fk.referencedColumnNames.map(function (columnName) { return "\"".concat(columnName, "\""); }).join(", ");
|
|
2589
|
+
var constraint = "CONSTRAINT \"".concat(fk.name, "\" FOREIGN KEY (").concat(columnNames, ") REFERENCES ").concat(_this.escapePath(_this.getTablePath(fk)), " (").concat(referencedColumnNames, ")");
|
|
2582
2590
|
if (fk.onDelete)
|
|
2583
|
-
constraint += " ON DELETE "
|
|
2591
|
+
constraint += " ON DELETE ".concat(fk.onDelete);
|
|
2584
2592
|
if (fk.onUpdate)
|
|
2585
|
-
constraint += " ON UPDATE "
|
|
2593
|
+
constraint += " ON UPDATE ".concat(fk.onUpdate);
|
|
2586
2594
|
return constraint;
|
|
2587
2595
|
}).join(", ");
|
|
2588
|
-
sql += ", "
|
|
2596
|
+
sql += ", ".concat(foreignKeysSql);
|
|
2589
2597
|
}
|
|
2590
2598
|
var primaryColumns = table.columns.filter(function (column) { return column.isPrimary; });
|
|
2591
2599
|
if (primaryColumns.length > 0) {
|
|
2592
2600
|
var primaryKeyName = this.connection.namingStrategy.primaryKeyName(table, primaryColumns.map(function (column) { return column.name; }));
|
|
2593
|
-
var columnNames = primaryColumns.map(function (column) { return "\""
|
|
2594
|
-
sql += ", CONSTRAINT \""
|
|
2601
|
+
var columnNames = primaryColumns.map(function (column) { return "\"".concat(column.name, "\""); }).join(", ");
|
|
2602
|
+
sql += ", CONSTRAINT \"".concat(primaryKeyName, "\" PRIMARY KEY (").concat(columnNames, ")");
|
|
2595
2603
|
}
|
|
2596
2604
|
sql += ")";
|
|
2597
2605
|
return new Query_1.Query(sql);
|
|
@@ -2600,18 +2608,18 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2600
2608
|
* Builds drop table sql.
|
|
2601
2609
|
*/
|
|
2602
2610
|
SqlServerQueryRunner.prototype.dropTableSql = function (tableOrName, ifExist) {
|
|
2603
|
-
var query = ifExist ? "DROP TABLE IF EXISTS "
|
|
2611
|
+
var query = ifExist ? "DROP TABLE IF EXISTS ".concat(this.escapePath(tableOrName)) : "DROP TABLE ".concat(this.escapePath(tableOrName));
|
|
2604
2612
|
return new Query_1.Query(query);
|
|
2605
2613
|
};
|
|
2606
2614
|
SqlServerQueryRunner.prototype.createViewSql = function (view) {
|
|
2607
2615
|
var parsedName = this.driver.parseTableName(view);
|
|
2608
2616
|
// Can't use `escapePath` here because `CREATE VIEW` does not accept database names.
|
|
2609
|
-
var viewIdentifier = parsedName.schema ? "\""
|
|
2617
|
+
var viewIdentifier = parsedName.schema ? "\"".concat(parsedName.schema, "\".\"").concat(parsedName.tableName, "\"") : "\"".concat(parsedName.tableName, "\"");
|
|
2610
2618
|
if (typeof view.expression === "string") {
|
|
2611
|
-
return new Query_1.Query("CREATE VIEW "
|
|
2619
|
+
return new Query_1.Query("CREATE VIEW ".concat(viewIdentifier, " AS ").concat(view.expression));
|
|
2612
2620
|
}
|
|
2613
2621
|
else {
|
|
2614
|
-
return new Query_1.Query("CREATE VIEW "
|
|
2622
|
+
return new Query_1.Query("CREATE VIEW ".concat(viewIdentifier, " AS ").concat(view.expression(this.connection).getQuery()));
|
|
2615
2623
|
}
|
|
2616
2624
|
};
|
|
2617
2625
|
SqlServerQueryRunner.prototype.insertViewDefinitionSql = function (view) {
|
|
@@ -2644,7 +2652,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2644
2652
|
* Builds drop view sql.
|
|
2645
2653
|
*/
|
|
2646
2654
|
SqlServerQueryRunner.prototype.dropViewSql = function (viewOrPath) {
|
|
2647
|
-
return new Query_1.Query("DROP VIEW "
|
|
2655
|
+
return new Query_1.Query("DROP VIEW ".concat(this.escapePath(viewOrPath)));
|
|
2648
2656
|
};
|
|
2649
2657
|
/**
|
|
2650
2658
|
* Builds remove view sql.
|
|
@@ -2676,23 +2684,23 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2676
2684
|
* Builds create index sql.
|
|
2677
2685
|
*/
|
|
2678
2686
|
SqlServerQueryRunner.prototype.createIndexSql = function (table, index) {
|
|
2679
|
-
var columns = index.columnNames.map(function (columnName) { return "\""
|
|
2680
|
-
return new Query_1.Query("CREATE "
|
|
2687
|
+
var columns = index.columnNames.map(function (columnName) { return "\"".concat(columnName, "\""); }).join(", ");
|
|
2688
|
+
return new Query_1.Query("CREATE ".concat(index.isUnique ? "UNIQUE " : "", "INDEX \"").concat(index.name, "\" ON ").concat(this.escapePath(table), " (").concat(columns, ") ").concat(index.where ? "WHERE " + index.where : ""));
|
|
2681
2689
|
};
|
|
2682
2690
|
/**
|
|
2683
2691
|
* Builds drop index sql.
|
|
2684
2692
|
*/
|
|
2685
2693
|
SqlServerQueryRunner.prototype.dropIndexSql = function (table, indexOrName) {
|
|
2686
2694
|
var indexName = indexOrName instanceof TableIndex_1.TableIndex ? indexOrName.name : indexOrName;
|
|
2687
|
-
return new Query_1.Query("DROP INDEX \""
|
|
2695
|
+
return new Query_1.Query("DROP INDEX \"".concat(indexName, "\" ON ").concat(this.escapePath(table)));
|
|
2688
2696
|
};
|
|
2689
2697
|
/**
|
|
2690
2698
|
* Builds create primary key sql.
|
|
2691
2699
|
*/
|
|
2692
2700
|
SqlServerQueryRunner.prototype.createPrimaryKeySql = function (table, columnNames) {
|
|
2693
2701
|
var primaryKeyName = this.connection.namingStrategy.primaryKeyName(table, columnNames);
|
|
2694
|
-
var columnNamesString = columnNames.map(function (columnName) { return "\""
|
|
2695
|
-
return new Query_1.Query("ALTER TABLE "
|
|
2702
|
+
var columnNamesString = columnNames.map(function (columnName) { return "\"".concat(columnName, "\""); }).join(", ");
|
|
2703
|
+
return new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(primaryKeyName, "\" PRIMARY KEY (").concat(columnNamesString, ")"));
|
|
2696
2704
|
};
|
|
2697
2705
|
/**
|
|
2698
2706
|
* Builds drop primary key sql.
|
|
@@ -2700,34 +2708,34 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2700
2708
|
SqlServerQueryRunner.prototype.dropPrimaryKeySql = function (table) {
|
|
2701
2709
|
var columnNames = table.primaryColumns.map(function (column) { return column.name; });
|
|
2702
2710
|
var primaryKeyName = this.connection.namingStrategy.primaryKeyName(table, columnNames);
|
|
2703
|
-
return new Query_1.Query("ALTER TABLE "
|
|
2711
|
+
return new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(primaryKeyName, "\""));
|
|
2704
2712
|
};
|
|
2705
2713
|
/**
|
|
2706
2714
|
* Builds create unique constraint sql.
|
|
2707
2715
|
*/
|
|
2708
2716
|
SqlServerQueryRunner.prototype.createUniqueConstraintSql = function (table, uniqueConstraint) {
|
|
2709
2717
|
var columnNames = uniqueConstraint.columnNames.map(function (column) { return "\"" + column + "\""; }).join(", ");
|
|
2710
|
-
return new Query_1.Query("ALTER TABLE "
|
|
2718
|
+
return new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(uniqueConstraint.name, "\" UNIQUE (").concat(columnNames, ")"));
|
|
2711
2719
|
};
|
|
2712
2720
|
/**
|
|
2713
2721
|
* Builds drop unique constraint sql.
|
|
2714
2722
|
*/
|
|
2715
2723
|
SqlServerQueryRunner.prototype.dropUniqueConstraintSql = function (table, uniqueOrName) {
|
|
2716
2724
|
var uniqueName = uniqueOrName instanceof TableUnique_1.TableUnique ? uniqueOrName.name : uniqueOrName;
|
|
2717
|
-
return new Query_1.Query("ALTER TABLE "
|
|
2725
|
+
return new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(uniqueName, "\""));
|
|
2718
2726
|
};
|
|
2719
2727
|
/**
|
|
2720
2728
|
* Builds create check constraint sql.
|
|
2721
2729
|
*/
|
|
2722
2730
|
SqlServerQueryRunner.prototype.createCheckConstraintSql = function (table, checkConstraint) {
|
|
2723
|
-
return new Query_1.Query("ALTER TABLE "
|
|
2731
|
+
return new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(checkConstraint.name, "\" CHECK (").concat(checkConstraint.expression, ")"));
|
|
2724
2732
|
};
|
|
2725
2733
|
/**
|
|
2726
2734
|
* Builds drop check constraint sql.
|
|
2727
2735
|
*/
|
|
2728
2736
|
SqlServerQueryRunner.prototype.dropCheckConstraintSql = function (table, checkOrName) {
|
|
2729
2737
|
var checkName = checkOrName instanceof TableCheck_1.TableCheck ? checkOrName.name : checkOrName;
|
|
2730
|
-
return new Query_1.Query("ALTER TABLE "
|
|
2738
|
+
return new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(checkName, "\""));
|
|
2731
2739
|
};
|
|
2732
2740
|
/**
|
|
2733
2741
|
* Builds create foreign key sql.
|
|
@@ -2735,12 +2743,12 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2735
2743
|
SqlServerQueryRunner.prototype.createForeignKeySql = function (table, foreignKey) {
|
|
2736
2744
|
var columnNames = foreignKey.columnNames.map(function (column) { return "\"" + column + "\""; }).join(", ");
|
|
2737
2745
|
var referencedColumnNames = foreignKey.referencedColumnNames.map(function (column) { return "\"" + column + "\""; }).join(",");
|
|
2738
|
-
var sql = "ALTER TABLE "
|
|
2739
|
-
|
|
2746
|
+
var sql = "ALTER TABLE ".concat(this.escapePath(table), " ADD CONSTRAINT \"").concat(foreignKey.name, "\" FOREIGN KEY (").concat(columnNames, ") ") +
|
|
2747
|
+
"REFERENCES ".concat(this.escapePath(this.getTablePath(foreignKey)), "(").concat(referencedColumnNames, ")");
|
|
2740
2748
|
if (foreignKey.onDelete)
|
|
2741
|
-
sql += " ON DELETE "
|
|
2749
|
+
sql += " ON DELETE ".concat(foreignKey.onDelete);
|
|
2742
2750
|
if (foreignKey.onUpdate)
|
|
2743
|
-
sql += " ON UPDATE "
|
|
2751
|
+
sql += " ON UPDATE ".concat(foreignKey.onUpdate);
|
|
2744
2752
|
return new Query_1.Query(sql);
|
|
2745
2753
|
};
|
|
2746
2754
|
/**
|
|
@@ -2748,7 +2756,7 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2748
2756
|
*/
|
|
2749
2757
|
SqlServerQueryRunner.prototype.dropForeignKeySql = function (table, foreignKeyOrName) {
|
|
2750
2758
|
var foreignKeyName = foreignKeyOrName instanceof TableForeignKey_1.TableForeignKey ? foreignKeyOrName.name : foreignKeyOrName;
|
|
2751
|
-
return new Query_1.Query("ALTER TABLE "
|
|
2759
|
+
return new Query_1.Query("ALTER TABLE ".concat(this.escapePath(table), " DROP CONSTRAINT \"").concat(foreignKeyName, "\""));
|
|
2752
2760
|
};
|
|
2753
2761
|
/**
|
|
2754
2762
|
* Escapes given table or View path.
|
|
@@ -2757,14 +2765,14 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2757
2765
|
var _a = this.driver.parseTableName(target), database = _a.database, schema = _a.schema, tableName = _a.tableName;
|
|
2758
2766
|
if (database && database !== this.driver.database) {
|
|
2759
2767
|
if (schema && schema !== this.driver.searchSchema) {
|
|
2760
|
-
return "\""
|
|
2768
|
+
return "\"".concat(database, "\".\"").concat(schema, "\".\"").concat(tableName, "\"");
|
|
2761
2769
|
}
|
|
2762
|
-
return "\""
|
|
2770
|
+
return "\"".concat(database, "\"..\"").concat(tableName, "\"");
|
|
2763
2771
|
}
|
|
2764
2772
|
if (schema && schema !== this.driver.searchSchema) {
|
|
2765
|
-
return "\""
|
|
2773
|
+
return "\"".concat(schema, "\".\"").concat(tableName, "\"");
|
|
2766
2774
|
}
|
|
2767
|
-
return "\""
|
|
2775
|
+
return "\"".concat(tableName, "\"");
|
|
2768
2776
|
};
|
|
2769
2777
|
/**
|
|
2770
2778
|
* Concat database name and schema name to the foreign key name.
|
|
@@ -2795,11 +2803,11 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2795
2803
|
* Builds a query for create column.
|
|
2796
2804
|
*/
|
|
2797
2805
|
SqlServerQueryRunner.prototype.buildCreateColumnSql = function (table, column, skipIdentity, createDefault) {
|
|
2798
|
-
var c = "\""
|
|
2806
|
+
var c = "\"".concat(column.name, "\" ").concat(this.connection.driver.createFullType(column));
|
|
2799
2807
|
if (column.enum) {
|
|
2800
2808
|
var expression = column.name + " IN (" + column.enum.map(function (val) { return "'" + val + "'"; }).join(",") + ")";
|
|
2801
2809
|
var checkName = this.connection.namingStrategy.checkConstraintName(table, expression, true);
|
|
2802
|
-
c += " CONSTRAINT "
|
|
2810
|
+
c += " CONSTRAINT ".concat(checkName, " CHECK(").concat(expression, ")");
|
|
2803
2811
|
}
|
|
2804
2812
|
if (column.collation)
|
|
2805
2813
|
c += " COLLATE " + column.collation;
|
|
@@ -2810,12 +2818,12 @@ var SqlServerQueryRunner = /** @class */ (function (_super) {
|
|
|
2810
2818
|
if (column.default !== undefined && column.default !== null && createDefault) {
|
|
2811
2819
|
// we create named constraint to be able to delete this constraint when column been dropped
|
|
2812
2820
|
var defaultName = this.connection.namingStrategy.defaultConstraintName(table, column.name);
|
|
2813
|
-
c += " CONSTRAINT \""
|
|
2821
|
+
c += " CONSTRAINT \"".concat(defaultName, "\" DEFAULT ").concat(column.default);
|
|
2814
2822
|
}
|
|
2815
2823
|
if (column.isGenerated && column.generationStrategy === "uuid" && !column.default) {
|
|
2816
2824
|
// we create named constraint to be able to delete this constraint when column been dropped
|
|
2817
2825
|
var defaultName = this.connection.namingStrategy.defaultConstraintName(table, column.name);
|
|
2818
|
-
c += " CONSTRAINT \""
|
|
2826
|
+
c += " CONSTRAINT \"".concat(defaultName, "\" DEFAULT NEWSEQUENTIALID()");
|
|
2819
2827
|
}
|
|
2820
2828
|
return c;
|
|
2821
2829
|
};
|