taon-typeorm 18.0.18 → 18.0.20
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/assets/shared/shared_folder_info.txt +1 -1
- package/browser/README.md +24 -24
- package/browser/esm2022/lib/typeorm/driver/cordova/CordovaDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/cordova/CordovaQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/nativescript/NativescriptDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/nativescript/NativescriptQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/react-native/ReactNativeDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/react-native/ReactNativeQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/sqljs/SqljsDriver.mjs +1 -1
- package/browser/esm2022/lib/typeorm/driver/sqljs/SqljsQueryRunner.mjs +1 -1
- package/browser/esm2022/lib/typeorm/index.mjs +1 -3
- package/browser/fesm2022/taon-typeorm.mjs.map +1 -1
- package/client/README.md +24 -24
- package/client/esm2022/lib/typeorm/driver/cordova/CordovaDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/cordova/CordovaQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/nativescript/NativescriptDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/nativescript/NativescriptQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/react-native/ReactNativeDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/react-native/ReactNativeQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/sqljs/SqljsDriver.mjs +1 -1
- package/client/esm2022/lib/typeorm/driver/sqljs/SqljsQueryRunner.mjs +1 -1
- package/client/esm2022/lib/typeorm/index.mjs +1 -3
- package/client/fesm2022/taon-typeorm.mjs.map +1 -1
- package/index.js +15 -2
- package/index.js.map +1 -1
- package/lib/build-info._auto-generated_.js.map +1 -1
- package/lib/index._auto-generated_.d.ts +1 -0
- package/lib/index._auto-generated_.js.map +1 -1
- package/lib/index.js +15 -2
- package/lib/index.js.map +1 -1
- package/lib/typeorm/cache/DbQueryResultCache.js +178 -231
- package/lib/typeorm/cache/DbQueryResultCache.js.map +1 -1
- package/lib/typeorm/cache/QueryResultCache.js.map +1 -1
- package/lib/typeorm/cache/QueryResultCacheFactory.js +11 -11
- package/lib/typeorm/cache/QueryResultCacheFactory.js.map +1 -1
- package/lib/typeorm/cache/QueryResultCacheOptions.js.map +1 -1
- package/lib/typeorm/cache/RedisQueryResultCache.js +121 -149
- package/lib/typeorm/cache/RedisQueryResultCache.js.map +1 -1
- package/lib/typeorm/cli-ts-node-commonjs.js.map +1 -1
- package/lib/typeorm/cli-ts-node-esm.js +7 -5
- package/lib/typeorm/cli-ts-node-esm.js.map +1 -1
- package/lib/typeorm/cli.d.ts +1 -1
- package/lib/typeorm/cli.js +15 -16
- package/lib/typeorm/cli.js.map +1 -1
- package/lib/typeorm/commands/CacheClearCommand.js +37 -65
- package/lib/typeorm/commands/CacheClearCommand.js.map +1 -1
- package/lib/typeorm/commands/CommandUtils.js +57 -112
- package/lib/typeorm/commands/CommandUtils.js.map +1 -1
- package/lib/typeorm/commands/EntityCreateCommand.js +35 -47
- package/lib/typeorm/commands/EntityCreateCommand.js.map +1 -1
- package/lib/typeorm/commands/InitCommand.js +397 -168
- package/lib/typeorm/commands/InitCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationCreateCommand.js +58 -52
- package/lib/typeorm/commands/MigrationCreateCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationGenerateCommand.js +141 -138
- package/lib/typeorm/commands/MigrationGenerateCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationRevertCommand.js +49 -77
- package/lib/typeorm/commands/MigrationRevertCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationRunCommand.js +52 -82
- package/lib/typeorm/commands/MigrationRunCommand.js.map +1 -1
- package/lib/typeorm/commands/MigrationShowCommand.js +32 -60
- package/lib/typeorm/commands/MigrationShowCommand.js.map +1 -1
- package/lib/typeorm/commands/QueryCommand.js +47 -83
- package/lib/typeorm/commands/QueryCommand.js.map +1 -1
- package/lib/typeorm/commands/SchemaDropCommand.js +33 -61
- package/lib/typeorm/commands/SchemaDropCommand.js.map +1 -1
- package/lib/typeorm/commands/SchemaLogCommand.js +57 -81
- package/lib/typeorm/commands/SchemaLogCommand.js.map +1 -1
- package/lib/typeorm/commands/SchemaSyncCommand.js +33 -61
- package/lib/typeorm/commands/SchemaSyncCommand.js.map +1 -1
- package/lib/typeorm/commands/SubscriberCreateCommand.js +35 -47
- package/lib/typeorm/commands/SubscriberCreateCommand.js.map +1 -1
- package/lib/typeorm/commands/VersionCommand.js +38 -54
- package/lib/typeorm/commands/VersionCommand.js.map +1 -1
- package/lib/typeorm/common/DeepPartial.js.map +1 -1
- package/lib/typeorm/common/EntityTarget.js.map +1 -1
- package/lib/typeorm/common/MixedList.js.map +1 -1
- package/lib/typeorm/common/NonNever.js.map +1 -1
- package/lib/typeorm/common/ObjectLiteral.js.map +1 -1
- package/lib/typeorm/common/ObjectType.js.map +1 -1
- package/lib/typeorm/common/RelationType.js.map +1 -1
- package/lib/typeorm/connection/BaseConnectionOptions.js.map +1 -1
- package/lib/typeorm/connection/Connection.js +3 -9
- package/lib/typeorm/connection/Connection.js.map +1 -1
- package/lib/typeorm/connection/ConnectionManager.js +23 -31
- package/lib/typeorm/connection/ConnectionManager.js.map +1 -1
- package/lib/typeorm/connection/ConnectionMetadataBuilder.js +48 -78
- package/lib/typeorm/connection/ConnectionMetadataBuilder.js.map +1 -1
- package/lib/typeorm/connection/ConnectionOptions.js.map +1 -1
- package/lib/typeorm/connection/ConnectionOptionsReader.js +146 -214
- package/lib/typeorm/connection/ConnectionOptionsReader.js.map +1 -1
- package/lib/typeorm/connection/options-reader/ConnectionOptionsEnvReader.js +50 -58
- package/lib/typeorm/connection/options-reader/ConnectionOptionsEnvReader.js.map +1 -1
- package/lib/typeorm/connection/options-reader/ConnectionOptionsXmlReader.js +45 -58
- package/lib/typeorm/connection/options-reader/ConnectionOptionsXmlReader.js.map +1 -1
- package/lib/typeorm/connection/options-reader/ConnectionOptionsYmlReader.js +14 -23
- package/lib/typeorm/connection/options-reader/ConnectionOptionsYmlReader.js.map +1 -1
- package/lib/typeorm/constants.js.map +1 -1
- package/lib/typeorm/container.js +9 -12
- package/lib/typeorm/container.js.map +1 -1
- package/lib/typeorm/data-source/BaseDataSourceOptions.js.map +1 -1
- package/lib/typeorm/data-source/DataSource.js +320 -478
- package/lib/typeorm/data-source/DataSource.js.map +1 -1
- package/lib/typeorm/data-source/DataSourceOptions.js.map +1 -1
- package/lib/typeorm/data-source/index.js +16 -3
- package/lib/typeorm/data-source/index.js.map +1 -1
- package/lib/typeorm/decorator/Check.js +5 -5
- package/lib/typeorm/decorator/Check.js.map +1 -1
- package/lib/typeorm/decorator/EntityRepository.js +1 -1
- package/lib/typeorm/decorator/EntityRepository.js.map +1 -1
- package/lib/typeorm/decorator/Exclusion.js +5 -5
- package/lib/typeorm/decorator/Exclusion.js.map +1 -1
- package/lib/typeorm/decorator/Generated.js +2 -3
- package/lib/typeorm/decorator/Generated.js.map +1 -1
- package/lib/typeorm/decorator/Index.js +5 -5
- package/lib/typeorm/decorator/Index.js.map +1 -1
- package/lib/typeorm/decorator/Unique.js +8 -8
- package/lib/typeorm/decorator/Unique.js.map +1 -1
- package/lib/typeorm/decorator/columns/Column.js +4 -4
- package/lib/typeorm/decorator/columns/Column.js.map +1 -1
- package/lib/typeorm/decorator/columns/CreateDateColumn.js +1 -1
- package/lib/typeorm/decorator/columns/CreateDateColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/DeleteDateColumn.js +1 -1
- package/lib/typeorm/decorator/columns/DeleteDateColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/ObjectIdColumn.js +1 -1
- package/lib/typeorm/decorator/columns/ObjectIdColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/PrimaryColumn.js +5 -5
- package/lib/typeorm/decorator/columns/PrimaryColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/PrimaryGeneratedColumn.js +4 -4
- package/lib/typeorm/decorator/columns/PrimaryGeneratedColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/UpdateDateColumn.js +1 -1
- package/lib/typeorm/decorator/columns/UpdateDateColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/VersionColumn.js +1 -1
- package/lib/typeorm/decorator/columns/VersionColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/ViewColumn.js +1 -1
- package/lib/typeorm/decorator/columns/ViewColumn.js.map +1 -1
- package/lib/typeorm/decorator/columns/VirtualColumn.js +5 -5
- package/lib/typeorm/decorator/columns/VirtualColumn.js.map +1 -1
- package/lib/typeorm/decorator/entity/ChildEntity.js +1 -1
- package/lib/typeorm/decorator/entity/ChildEntity.js.map +1 -1
- package/lib/typeorm/decorator/entity/Entity.js +4 -4
- package/lib/typeorm/decorator/entity/Entity.js.map +1 -1
- package/lib/typeorm/decorator/entity/TableInheritance.js +1 -1
- package/lib/typeorm/decorator/entity/TableInheritance.js.map +1 -1
- package/lib/typeorm/decorator/entity-view/ViewEntity.js +4 -4
- package/lib/typeorm/decorator/entity-view/ViewEntity.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterInsert.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterInsert.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterLoad.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterLoad.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterRecover.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterRecover.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterSoftRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterSoftRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/AfterUpdate.js +2 -2
- package/lib/typeorm/decorator/listeners/AfterUpdate.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeInsert.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeInsert.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeRecover.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeRecover.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeSoftRemove.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeSoftRemove.js.map +1 -1
- package/lib/typeorm/decorator/listeners/BeforeUpdate.js +2 -2
- package/lib/typeorm/decorator/listeners/BeforeUpdate.js.map +1 -1
- package/lib/typeorm/decorator/listeners/EventSubscriber.js +1 -1
- package/lib/typeorm/decorator/listeners/EventSubscriber.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnCommonOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnEmbeddedOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnEnumOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnHstoreOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnNumericOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnWithLengthOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ColumnWithWidthOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/EntityOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/IndexOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/JoinColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/JoinTableMultipleColumnsOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/JoinTableOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/PrimaryGeneratedColumnIdentityOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/PrimaryGeneratedColumnNumericOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/PrimaryGeneratedColumnUUIDOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/RelationOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/SpatialColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/TransactionOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/UniqueOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ValueTransformer.js.map +1 -1
- package/lib/typeorm/decorator/options/ViewColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/ViewEntityOptions.js.map +1 -1
- package/lib/typeorm/decorator/options/VirtualColumnOptions.js.map +1 -1
- package/lib/typeorm/decorator/relations/JoinColumn.js +3 -3
- package/lib/typeorm/decorator/relations/JoinColumn.js.map +1 -1
- package/lib/typeorm/decorator/relations/JoinTable.js +1 -1
- package/lib/typeorm/decorator/relations/JoinTable.js.map +1 -1
- package/lib/typeorm/decorator/relations/ManyToMany.js +5 -5
- package/lib/typeorm/decorator/relations/ManyToMany.js.map +1 -1
- package/lib/typeorm/decorator/relations/ManyToOne.js +5 -5
- package/lib/typeorm/decorator/relations/ManyToOne.js.map +1 -1
- package/lib/typeorm/decorator/relations/OneToMany.js +3 -3
- package/lib/typeorm/decorator/relations/OneToMany.js.map +1 -1
- package/lib/typeorm/decorator/relations/OneToOne.js +5 -5
- package/lib/typeorm/decorator/relations/OneToOne.js.map +1 -1
- package/lib/typeorm/decorator/relations/RelationCount.js +1 -1
- package/lib/typeorm/decorator/relations/RelationCount.js.map +1 -1
- package/lib/typeorm/decorator/relations/RelationId.js +1 -1
- package/lib/typeorm/decorator/relations/RelationId.js.map +1 -1
- package/lib/typeorm/decorator/tree/Tree.js +1 -1
- package/lib/typeorm/decorator/tree/Tree.js.map +1 -1
- package/lib/typeorm/decorator/tree/TreeChildren.js +4 -4
- package/lib/typeorm/decorator/tree/TreeChildren.js.map +1 -1
- package/lib/typeorm/decorator/tree/TreeLevelColumn.js +1 -1
- package/lib/typeorm/decorator/tree/TreeLevelColumn.js.map +1 -1
- package/lib/typeorm/decorator/tree/TreeParent.js +4 -4
- package/lib/typeorm/decorator/tree/TreeParent.js.map +1 -1
- package/lib/typeorm/driver/Driver.js.map +1 -1
- package/lib/typeorm/driver/DriverFactory.js +24 -27
- package/lib/typeorm/driver/DriverFactory.js.map +1 -1
- package/lib/typeorm/driver/DriverUtils.js +78 -126
- package/lib/typeorm/driver/DriverUtils.js.map +1 -1
- package/lib/typeorm/driver/Query.js +6 -5
- package/lib/typeorm/driver/Query.js.map +1 -1
- package/lib/typeorm/driver/SqlInMemory.js +4 -7
- package/lib/typeorm/driver/SqlInMemory.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnection.js +9 -12
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnection.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlDriver.js +392 -399
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlDriver.js.map +1 -1
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.js +1320 -2084
- package/lib/typeorm/driver/aurora-mysql/AuroraMysqlQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresDriver.js +50 -78
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresDriver.js.map +1 -1
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.js +89 -160
- package/lib/typeorm/driver/aurora-postgres/AuroraPostgresQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3ConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3Driver.js +78 -152
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3Driver.js.map +1 -1
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js +96 -155
- package/lib/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js.map +1 -1
- package/lib/typeorm/driver/capacitor/CapacitorConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/capacitor/CapacitorDriver.js +44 -89
- package/lib/typeorm/driver/capacitor/CapacitorDriver.js.map +1 -1
- package/lib/typeorm/driver/capacitor/CapacitorQueryRunner.js +70 -122
- package/lib/typeorm/driver/capacitor/CapacitorQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachDriver.js +368 -404
- package/lib/typeorm/driver/cockroachdb/CockroachDriver.js.map +1 -1
- package/lib/typeorm/driver/cockroachdb/CockroachQueryRunner.js +1752 -2862
- package/lib/typeorm/driver/cockroachdb/CockroachQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/cordova/CordovaConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/cordova/CordovaDriver.js +36 -58
- package/lib/typeorm/driver/cordova/CordovaDriver.js.map +1 -1
- package/lib/typeorm/driver/cordova/CordovaQueryRunner.js +86 -164
- package/lib/typeorm/driver/cordova/CordovaQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/expo/ExpoConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/expo/ExpoDriver.js +34 -44
- package/lib/typeorm/driver/expo/ExpoDriver.js.map +1 -1
- package/lib/typeorm/driver/expo/ExpoQueryRunner.js +114 -204
- package/lib/typeorm/driver/expo/ExpoQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/mongodb/MongoConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/mongodb/MongoDriver.js +269 -243
- package/lib/typeorm/driver/mongodb/MongoDriver.js.map +1 -1
- package/lib/typeorm/driver/mongodb/MongoQueryRunner.js +357 -793
- package/lib/typeorm/driver/mongodb/MongoQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/mongodb/typings.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlDriver.js +475 -480
- package/lib/typeorm/driver/mysql/MysqlDriver.js.map +1 -1
- package/lib/typeorm/driver/mysql/MysqlQueryRunner.js +1692 -2466
- package/lib/typeorm/driver/mysql/MysqlQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/nativescript/NativescriptConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/nativescript/NativescriptDriver.js +46 -50
- package/lib/typeorm/driver/nativescript/NativescriptDriver.js.map +1 -1
- package/lib/typeorm/driver/nativescript/NativescriptQueryRunner.js +62 -101
- package/lib/typeorm/driver/nativescript/NativescriptQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleDriver.js +345 -377
- package/lib/typeorm/driver/oracle/OracleDriver.js.map +1 -1
- package/lib/typeorm/driver/oracle/OracleQueryRunner.js +1484 -2384
- package/lib/typeorm/driver/oracle/OracleQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresDriver.js +574 -690
- package/lib/typeorm/driver/postgres/PostgresDriver.js.map +1 -1
- package/lib/typeorm/driver/postgres/PostgresQueryRunner.js +2153 -3379
- package/lib/typeorm/driver/postgres/PostgresQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/react-native/ReactNativeConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/react-native/ReactNativeDriver.js +34 -44
- package/lib/typeorm/driver/react-native/ReactNativeDriver.js.map +1 -1
- package/lib/typeorm/driver/react-native/ReactNativeQueryRunner.js +60 -94
- package/lib/typeorm/driver/react-native/ReactNativeQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sap/SapConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/sap/SapConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sap/SapDriver.js +310 -305
- package/lib/typeorm/driver/sap/SapDriver.js.map +1 -1
- package/lib/typeorm/driver/sap/SapQueryRunner.js +1635 -2561
- package/lib/typeorm/driver/sap/SapQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerDriver.js +250 -236
- package/lib/typeorm/driver/spanner/SpannerDriver.js.map +1 -1
- package/lib/typeorm/driver/spanner/SpannerQueryRunner.js +1136 -2168
- package/lib/typeorm/driver/spanner/SpannerQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlite/SqliteConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sqlite/SqliteDriver.js +82 -169
- package/lib/typeorm/driver/sqlite/SqliteDriver.js.map +1 -1
- package/lib/typeorm/driver/sqlite/SqliteQueryRunner.js +78 -122
- package/lib/typeorm/driver/sqlite/SqliteQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.js +280 -268
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteDriver.js.map +1 -1
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.js +1158 -1990
- package/lib/typeorm/driver/sqlite-abstract/AbstractSqliteQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqljs/SqljsConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sqljs/SqljsDriver.js +187 -253
- package/lib/typeorm/driver/sqljs/SqljsDriver.js.map +1 -1
- package/lib/typeorm/driver/sqljs/SqljsQueryRunner.js +88 -147
- package/lib/typeorm/driver/sqljs/SqljsQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/MssqlParameter.js +10 -13
- package/lib/typeorm/driver/sqlserver/MssqlParameter.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerDriver.js +352 -372
- package/lib/typeorm/driver/sqlserver/SqlServerDriver.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/SqlServerQueryRunner.js +1979 -3068
- package/lib/typeorm/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryAccessTokenAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiAppServiceAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryMsiVmAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryPasswordAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/AzureActiveDirectoryServicePrincipalSecret.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/DefaultAuthentication.js.map +1 -1
- package/lib/typeorm/driver/sqlserver/authentication/NtlmAuthentication.js.map +1 -1
- package/lib/typeorm/driver/types/ColumnTypes.js.map +1 -1
- package/lib/typeorm/driver/types/CteCapabilities.js.map +1 -1
- package/lib/typeorm/driver/types/DataTypeDefaults.js.map +1 -1
- package/lib/typeorm/driver/types/DatabaseType.js.map +1 -1
- package/lib/typeorm/driver/types/IsolationLevel.js.map +1 -1
- package/lib/typeorm/driver/types/MappedColumnTypes.js.map +1 -1
- package/lib/typeorm/driver/types/MetadataTableType.js.map +1 -1
- package/lib/typeorm/driver/types/ReplicationMode.js.map +1 -1
- package/lib/typeorm/driver/types/UpsertType.js.map +1 -1
- package/lib/typeorm/entity-manager/EntityManager.js +351 -469
- package/lib/typeorm/entity-manager/EntityManager.js.map +1 -1
- package/lib/typeorm/entity-manager/EntityManagerFactory.js +7 -10
- package/lib/typeorm/entity-manager/EntityManagerFactory.js.map +1 -1
- package/lib/typeorm/entity-manager/MongoEntityManager.js +371 -487
- package/lib/typeorm/entity-manager/MongoEntityManager.js.map +1 -1
- package/lib/typeorm/entity-manager/SqljsEntityManager.js +16 -37
- package/lib/typeorm/entity-manager/SqljsEntityManager.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchema.js +5 -5
- package/lib/typeorm/entity-schema/EntitySchema.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaCheckOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.js +17 -5
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedColumnOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedError.js +11 -14
- package/lib/typeorm/entity-schema/EntitySchemaEmbeddedError.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaExclusionOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaIndexOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaOptions.js +82 -5
- package/lib/typeorm/entity-schema/EntitySchemaOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaRelationIdOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaRelationOptions.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaTransformer.js +51 -68
- package/lib/typeorm/entity-schema/EntitySchemaTransformer.js.map +1 -1
- package/lib/typeorm/entity-schema/EntitySchemaUniqueOptions.js.map +1 -1
- package/lib/typeorm/error/AlreadyHasActiveConnectionError.js +6 -9
- package/lib/typeorm/error/AlreadyHasActiveConnectionError.js.map +1 -1
- package/lib/typeorm/error/CannotAttachTreeChildrenEntityError.js +6 -9
- package/lib/typeorm/error/CannotAttachTreeChildrenEntityError.js.map +1 -1
- package/lib/typeorm/error/CannotConnectAlreadyConnectedError.js +5 -8
- package/lib/typeorm/error/CannotConnectAlreadyConnectedError.js.map +1 -1
- package/lib/typeorm/error/CannotCreateEntityIdMapError.js +7 -11
- package/lib/typeorm/error/CannotCreateEntityIdMapError.js.map +1 -1
- package/lib/typeorm/error/CannotDetermineEntityError.js +6 -9
- package/lib/typeorm/error/CannotDetermineEntityError.js.map +1 -1
- package/lib/typeorm/error/CannotExecuteNotConnectedError.js +5 -8
- package/lib/typeorm/error/CannotExecuteNotConnectedError.js.map +1 -1
- package/lib/typeorm/error/CannotGetEntityManagerNotConnectedError.js +5 -8
- package/lib/typeorm/error/CannotGetEntityManagerNotConnectedError.js.map +1 -1
- package/lib/typeorm/error/CannotReflectMethodParameterTypeError.js +7 -10
- package/lib/typeorm/error/CannotReflectMethodParameterTypeError.js.map +1 -1
- package/lib/typeorm/error/CircularRelationsError.js +6 -9
- package/lib/typeorm/error/CircularRelationsError.js.map +1 -1
- package/lib/typeorm/error/ColumnTypeUndefinedError.js +8 -11
- package/lib/typeorm/error/ColumnTypeUndefinedError.js.map +1 -1
- package/lib/typeorm/error/ConnectionIsNotSetError.js +5 -8
- package/lib/typeorm/error/ConnectionIsNotSetError.js.map +1 -1
- package/lib/typeorm/error/ConnectionNotFoundError.js +5 -8
- package/lib/typeorm/error/ConnectionNotFoundError.js.map +1 -1
- package/lib/typeorm/error/CustomRepositoryCannotInheritRepositoryError.js +7 -10
- package/lib/typeorm/error/CustomRepositoryCannotInheritRepositoryError.js.map +1 -1
- package/lib/typeorm/error/CustomRepositoryDoesNotHaveEntityError.js +7 -10
- package/lib/typeorm/error/CustomRepositoryDoesNotHaveEntityError.js.map +1 -1
- package/lib/typeorm/error/CustomRepositoryNotFoundError.js +7 -10
- package/lib/typeorm/error/CustomRepositoryNotFoundError.js.map +1 -1
- package/lib/typeorm/error/DataTypeNotSupportedError.js +7 -11
- package/lib/typeorm/error/DataTypeNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/DriverOptionNotSetError.js +6 -9
- package/lib/typeorm/error/DriverOptionNotSetError.js.map +1 -1
- package/lib/typeorm/error/DriverPackageNotInstalledError.js +6 -9
- package/lib/typeorm/error/DriverPackageNotInstalledError.js.map +1 -1
- package/lib/typeorm/error/EntityMetadataNotFoundError.js +10 -14
- package/lib/typeorm/error/EntityMetadataNotFoundError.js.map +1 -1
- package/lib/typeorm/error/EntityNotFoundError.js +13 -17
- package/lib/typeorm/error/EntityNotFoundError.js.map +1 -1
- package/lib/typeorm/error/EntityPropertyNotFoundError.js +7 -11
- package/lib/typeorm/error/EntityPropertyNotFoundError.js.map +1 -1
- package/lib/typeorm/error/FindRelationsNotFoundError.js +9 -13
- package/lib/typeorm/error/FindRelationsNotFoundError.js.map +1 -1
- package/lib/typeorm/error/ForbiddenTransactionModeOverrideError.js +6 -9
- package/lib/typeorm/error/ForbiddenTransactionModeOverrideError.js.map +1 -1
- package/lib/typeorm/error/InitializedRelationError.js +7 -10
- package/lib/typeorm/error/InitializedRelationError.js.map +1 -1
- package/lib/typeorm/error/InsertValuesMissingError.js +6 -9
- package/lib/typeorm/error/InsertValuesMissingError.js.map +1 -1
- package/lib/typeorm/error/LimitOnUpdateNotSupportedError.js +5 -8
- package/lib/typeorm/error/LimitOnUpdateNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/LockNotSupportedOnGivenDriverError.js +5 -8
- package/lib/typeorm/error/LockNotSupportedOnGivenDriverError.js.map +1 -1
- package/lib/typeorm/error/MetadataAlreadyExistsError.js +6 -9
- package/lib/typeorm/error/MetadataAlreadyExistsError.js.map +1 -1
- package/lib/typeorm/error/MetadataWithSuchNameAlreadyExistsError.js +6 -9
- package/lib/typeorm/error/MetadataWithSuchNameAlreadyExistsError.js.map +1 -1
- package/lib/typeorm/error/MissingDeleteDateColumnError.js +5 -8
- package/lib/typeorm/error/MissingDeleteDateColumnError.js.map +1 -1
- package/lib/typeorm/error/MissingDriverError.js +6 -10
- package/lib/typeorm/error/MissingDriverError.js.map +1 -1
- package/lib/typeorm/error/MissingJoinColumnError.js +12 -16
- package/lib/typeorm/error/MissingJoinColumnError.js.map +1 -1
- package/lib/typeorm/error/MissingJoinTableError.js +12 -16
- package/lib/typeorm/error/MissingJoinTableError.js.map +1 -1
- package/lib/typeorm/error/MissingPrimaryColumnError.js +6 -9
- package/lib/typeorm/error/MissingPrimaryColumnError.js.map +1 -1
- package/lib/typeorm/error/MustBeEntityError.js +5 -8
- package/lib/typeorm/error/MustBeEntityError.js.map +1 -1
- package/lib/typeorm/error/NamingStrategyNotFoundError.js +9 -13
- package/lib/typeorm/error/NamingStrategyNotFoundError.js.map +1 -1
- package/lib/typeorm/error/NestedSetMultipleRootError.js +5 -8
- package/lib/typeorm/error/NestedSetMultipleRootError.js.map +1 -1
- package/lib/typeorm/error/NoConnectionForRepositoryError.js +6 -9
- package/lib/typeorm/error/NoConnectionForRepositoryError.js.map +1 -1
- package/lib/typeorm/error/NoConnectionOptionError.js +6 -9
- package/lib/typeorm/error/NoConnectionOptionError.js.map +1 -1
- package/lib/typeorm/error/NoNeedToReleaseEntityManagerError.js +7 -10
- package/lib/typeorm/error/NoNeedToReleaseEntityManagerError.js.map +1 -1
- package/lib/typeorm/error/NoVersionOrUpdateDateColumnError.js +5 -8
- package/lib/typeorm/error/NoVersionOrUpdateDateColumnError.js.map +1 -1
- package/lib/typeorm/error/OffsetWithoutLimitNotSupportedError.js +7 -10
- package/lib/typeorm/error/OffsetWithoutLimitNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/OptimisticLockCanNotBeUsedError.js +5 -8
- package/lib/typeorm/error/OptimisticLockCanNotBeUsedError.js.map +1 -1
- package/lib/typeorm/error/OptimisticLockVersionMismatchError.js +5 -8
- package/lib/typeorm/error/OptimisticLockVersionMismatchError.js.map +1 -1
- package/lib/typeorm/error/PersistedEntityNotFoundError.js +5 -8
- package/lib/typeorm/error/PersistedEntityNotFoundError.js.map +1 -1
- package/lib/typeorm/error/PessimisticLockTransactionRequiredError.js +5 -8
- package/lib/typeorm/error/PessimisticLockTransactionRequiredError.js.map +1 -1
- package/lib/typeorm/error/PrimaryColumnCannotBeNullableError.js +6 -9
- package/lib/typeorm/error/PrimaryColumnCannotBeNullableError.js.map +1 -1
- package/lib/typeorm/error/QueryFailedError.js +18 -17
- package/lib/typeorm/error/QueryFailedError.js.map +1 -1
- package/lib/typeorm/error/QueryRunnerAlreadyReleasedError.js +5 -8
- package/lib/typeorm/error/QueryRunnerAlreadyReleasedError.js.map +1 -1
- package/lib/typeorm/error/QueryRunnerProviderAlreadyReleasedError.js +6 -9
- package/lib/typeorm/error/QueryRunnerProviderAlreadyReleasedError.js.map +1 -1
- package/lib/typeorm/error/RepositoryNotTreeError.js +9 -13
- package/lib/typeorm/error/RepositoryNotTreeError.js.map +1 -1
- package/lib/typeorm/error/ReturningStatementNotSupportedError.js +5 -8
- package/lib/typeorm/error/ReturningStatementNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/SubjectRemovedAndUpdatedError.js +6 -9
- package/lib/typeorm/error/SubjectRemovedAndUpdatedError.js.map +1 -1
- package/lib/typeorm/error/SubjectWithoutIdentifierError.js +5 -8
- package/lib/typeorm/error/SubjectWithoutIdentifierError.js.map +1 -1
- package/lib/typeorm/error/TransactionAlreadyStartedError.js +5 -8
- package/lib/typeorm/error/TransactionAlreadyStartedError.js.map +1 -1
- package/lib/typeorm/error/TransactionNotStartedError.js +5 -8
- package/lib/typeorm/error/TransactionNotStartedError.js.map +1 -1
- package/lib/typeorm/error/TreeRepositoryNotSupportedError.js +5 -8
- package/lib/typeorm/error/TreeRepositoryNotSupportedError.js.map +1 -1
- package/lib/typeorm/error/TypeORMError.js +9 -18
- package/lib/typeorm/error/TypeORMError.js.map +1 -1
- package/lib/typeorm/error/UpdateValuesMissingError.js +5 -8
- package/lib/typeorm/error/UpdateValuesMissingError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinColumnIsNotAllowedError.js +6 -9
- package/lib/typeorm/error/UsingJoinColumnIsNotAllowedError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.js +7 -10
- package/lib/typeorm/error/UsingJoinColumnOnlyOnOneSideAllowedError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinTableIsNotAllowedError.js +7 -10
- package/lib/typeorm/error/UsingJoinTableIsNotAllowedError.js.map +1 -1
- package/lib/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.js +7 -10
- package/lib/typeorm/error/UsingJoinTableOnlyOnOneSideAllowedError.js.map +1 -1
- package/lib/typeorm/error/index.js +75 -62
- package/lib/typeorm/error/index.js.map +1 -1
- package/lib/typeorm/find-options/EqualOperator.js +6 -10
- package/lib/typeorm/find-options/EqualOperator.js.map +1 -1
- package/lib/typeorm/find-options/FindManyOptions.js.map +1 -1
- package/lib/typeorm/find-options/FindOneOptions.js.map +1 -1
- package/lib/typeorm/find-options/FindOperator.js +90 -94
- package/lib/typeorm/find-options/FindOperator.js.map +1 -1
- package/lib/typeorm/find-options/FindOperatorType.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsOrder.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsRelations.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsSelect.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsUtils.js +56 -87
- package/lib/typeorm/find-options/FindOptionsUtils.js.map +1 -1
- package/lib/typeorm/find-options/FindOptionsWhere.js.map +1 -1
- package/lib/typeorm/find-options/FindTreeOptions.js.map +1 -1
- package/lib/typeorm/find-options/JoinOptions.js.map +1 -1
- package/lib/typeorm/find-options/OrderByCondition.js.map +1 -1
- package/lib/typeorm/find-options/mongodb/MongoFindManyOptions.js.map +1 -1
- package/lib/typeorm/find-options/mongodb/MongoFindOneOptions.js.map +1 -1
- package/lib/typeorm/find-options/operator/And.js +2 -6
- package/lib/typeorm/find-options/operator/And.js.map +1 -1
- package/lib/typeorm/find-options/operator/Any.js +1 -1
- package/lib/typeorm/find-options/operator/Any.js.map +1 -1
- package/lib/typeorm/find-options/operator/ArrayContainedBy.js +1 -1
- package/lib/typeorm/find-options/operator/ArrayContainedBy.js.map +1 -1
- package/lib/typeorm/find-options/operator/ArrayContains.js +1 -1
- package/lib/typeorm/find-options/operator/ArrayContains.js.map +1 -1
- package/lib/typeorm/find-options/operator/ArrayOverlap.js +1 -1
- package/lib/typeorm/find-options/operator/ArrayOverlap.js.map +1 -1
- package/lib/typeorm/find-options/operator/Between.js +1 -1
- package/lib/typeorm/find-options/operator/Between.js.map +1 -1
- package/lib/typeorm/find-options/operator/Equal.js +1 -1
- package/lib/typeorm/find-options/operator/Equal.js.map +1 -1
- package/lib/typeorm/find-options/operator/ILike.js +1 -1
- package/lib/typeorm/find-options/operator/ILike.js.map +1 -1
- package/lib/typeorm/find-options/operator/In.js +1 -1
- package/lib/typeorm/find-options/operator/In.js.map +1 -1
- package/lib/typeorm/find-options/operator/IsNull.js +1 -1
- package/lib/typeorm/find-options/operator/IsNull.js.map +1 -1
- package/lib/typeorm/find-options/operator/LessThan.js +1 -1
- package/lib/typeorm/find-options/operator/LessThan.js.map +1 -1
- package/lib/typeorm/find-options/operator/LessThanOrEqual.js +1 -1
- package/lib/typeorm/find-options/operator/LessThanOrEqual.js.map +1 -1
- package/lib/typeorm/find-options/operator/Like.js +1 -1
- package/lib/typeorm/find-options/operator/Like.js.map +1 -1
- package/lib/typeorm/find-options/operator/MoreThan.js +1 -1
- package/lib/typeorm/find-options/operator/MoreThan.js.map +1 -1
- package/lib/typeorm/find-options/operator/MoreThanOrEqual.js +1 -1
- package/lib/typeorm/find-options/operator/MoreThanOrEqual.js.map +1 -1
- package/lib/typeorm/find-options/operator/Not.js +1 -1
- package/lib/typeorm/find-options/operator/Not.js.map +1 -1
- package/lib/typeorm/find-options/operator/Raw.js +1 -1
- package/lib/typeorm/find-options/operator/Raw.js.map +1 -1
- package/lib/typeorm/globals.js +33 -99
- package/lib/typeorm/globals.js.map +1 -1
- package/lib/typeorm/index.d.ts +0 -1
- package/lib/typeorm/index.js +136 -126
- package/lib/typeorm/index.js.map +1 -1
- package/lib/typeorm/logger/AdvancedConsoleLogger.js +26 -26
- package/lib/typeorm/logger/AdvancedConsoleLogger.js.map +1 -1
- package/lib/typeorm/logger/DebugLogger.js +24 -27
- package/lib/typeorm/logger/DebugLogger.js.map +1 -1
- package/lib/typeorm/logger/FileLogger.js +31 -30
- package/lib/typeorm/logger/FileLogger.js.map +1 -1
- package/lib/typeorm/logger/Logger.js.map +1 -1
- package/lib/typeorm/logger/LoggerFactory.js +9 -12
- package/lib/typeorm/logger/LoggerFactory.js.map +1 -1
- package/lib/typeorm/logger/LoggerOptions.js.map +1 -1
- package/lib/typeorm/logger/SimpleConsoleLogger.js +25 -25
- package/lib/typeorm/logger/SimpleConsoleLogger.js.map +1 -1
- package/lib/typeorm/metadata/CheckMetadata.js +30 -6
- package/lib/typeorm/metadata/CheckMetadata.js.map +1 -1
- package/lib/typeorm/metadata/ColumnMetadata.js +343 -199
- package/lib/typeorm/metadata/ColumnMetadata.js.map +1 -1
- package/lib/typeorm/metadata/EmbeddedMetadata.js +174 -153
- package/lib/typeorm/metadata/EmbeddedMetadata.js.map +1 -1
- package/lib/typeorm/metadata/EntityListenerMetadata.js +35 -15
- package/lib/typeorm/metadata/EntityListenerMetadata.js.map +1 -1
- package/lib/typeorm/metadata/EntityMetadata.js +516 -372
- package/lib/typeorm/metadata/EntityMetadata.js.map +1 -1
- package/lib/typeorm/metadata/ExclusionMetadata.js +30 -6
- package/lib/typeorm/metadata/ExclusionMetadata.js.map +1 -1
- package/lib/typeorm/metadata/ForeignKeyMetadata.js +60 -24
- package/lib/typeorm/metadata/ForeignKeyMetadata.js.map +1 -1
- package/lib/typeorm/metadata/IndexMetadata.js +119 -73
- package/lib/typeorm/metadata/IndexMetadata.js.map +1 -1
- package/lib/typeorm/metadata/RelationCountMetadata.js +40 -10
- package/lib/typeorm/metadata/RelationCountMetadata.js.map +1 -1
- package/lib/typeorm/metadata/RelationIdMetadata.js +47 -18
- package/lib/typeorm/metadata/RelationIdMetadata.js.map +1 -1
- package/lib/typeorm/metadata/RelationMetadata.js +270 -187
- package/lib/typeorm/metadata/RelationMetadata.js.map +1 -1
- package/lib/typeorm/metadata/UniqueMetadata.js +72 -47
- package/lib/typeorm/metadata/UniqueMetadata.js.map +1 -1
- package/lib/typeorm/metadata/types/ClosureTreeOptions.js.map +1 -1
- package/lib/typeorm/metadata/types/DeferrableType.js.map +1 -1
- package/lib/typeorm/metadata/types/EventListenerTypes.js +13 -16
- package/lib/typeorm/metadata/types/EventListenerTypes.js.map +1 -1
- package/lib/typeorm/metadata/types/OnDeleteType.js.map +1 -1
- package/lib/typeorm/metadata/types/OnUpdateType.js.map +1 -1
- package/lib/typeorm/metadata/types/PropertyTypeInFunction.js.map +1 -1
- package/lib/typeorm/metadata/types/RelationTypeInFunction.js.map +1 -1
- package/lib/typeorm/metadata/types/RelationTypes.js.map +1 -1
- package/lib/typeorm/metadata/types/TableTypes.js.map +1 -1
- package/lib/typeorm/metadata/types/TreeTypes.js.map +1 -1
- package/lib/typeorm/metadata-args/CheckMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/ColumnMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/DiscriminatorValueMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EmbeddedMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EntityListenerMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EntityRepositoryMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/EntitySubscriberMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/ExclusionMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/GeneratedMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/IndexMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/InheritanceMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/JoinColumnMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/JoinTableMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/MetadataArgsStorage.js +108 -113
- package/lib/typeorm/metadata-args/MetadataArgsStorage.js.map +1 -1
- package/lib/typeorm/metadata-args/NamingStrategyMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/RelationCountMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/RelationIdMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/RelationMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TableMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TransactionEntityMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TransactionRepositoryMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/TreeMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/UniqueMetadataArgs.js.map +1 -1
- package/lib/typeorm/metadata-args/types/ColumnMode.js.map +1 -1
- package/lib/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.js +14 -15
- package/lib/typeorm/metadata-builder/ClosureJunctionEntityMetadataBuilder.js.map +1 -1
- package/lib/typeorm/metadata-builder/EntityMetadataBuilder.js +291 -347
- package/lib/typeorm/metadata-builder/EntityMetadataBuilder.js.map +1 -1
- package/lib/typeorm/metadata-builder/EntityMetadataValidator.js +63 -77
- package/lib/typeorm/metadata-builder/EntityMetadataValidator.js.map +1 -1
- package/lib/typeorm/metadata-builder/JunctionEntityMetadataBuilder.js +64 -69
- package/lib/typeorm/metadata-builder/JunctionEntityMetadataBuilder.js.map +1 -1
- package/lib/typeorm/metadata-builder/MetadataUtils.js +12 -15
- package/lib/typeorm/metadata-builder/MetadataUtils.js.map +1 -1
- package/lib/typeorm/metadata-builder/RelationJoinColumnBuilder.js +43 -49
- package/lib/typeorm/metadata-builder/RelationJoinColumnBuilder.js.map +1 -1
- package/lib/typeorm/migration/Migration.js +23 -4
- package/lib/typeorm/migration/Migration.js.map +1 -1
- package/lib/typeorm/migration/MigrationExecutor.js +432 -691
- package/lib/typeorm/migration/MigrationExecutor.js.map +1 -1
- package/lib/typeorm/migration/MigrationInterface.js.map +1 -1
- package/lib/typeorm/naming-strategy/DefaultNamingStrategy.js +80 -84
- package/lib/typeorm/naming-strategy/DefaultNamingStrategy.js.map +1 -1
- package/lib/typeorm/naming-strategy/NamingStrategyInterface.js.map +1 -1
- package/lib/typeorm/persistence/EntityPersistExecutor.js +154 -212
- package/lib/typeorm/persistence/EntityPersistExecutor.js.map +1 -1
- package/lib/typeorm/persistence/Subject.js +162 -149
- package/lib/typeorm/persistence/Subject.js.map +1 -1
- package/lib/typeorm/persistence/SubjectChangeMap.js.map +1 -1
- package/lib/typeorm/persistence/SubjectChangedColumnsComputer.js +29 -35
- package/lib/typeorm/persistence/SubjectChangedColumnsComputer.js.map +1 -1
- package/lib/typeorm/persistence/SubjectDatabaseEntityLoader.js +99 -130
- package/lib/typeorm/persistence/SubjectDatabaseEntityLoader.js.map +1 -1
- package/lib/typeorm/persistence/SubjectExecutor.js +635 -879
- package/lib/typeorm/persistence/SubjectExecutor.js.map +1 -1
- package/lib/typeorm/persistence/SubjectTopoligicalSorter.js +62 -58
- package/lib/typeorm/persistence/SubjectTopoligicalSorter.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/CascadesSubjectBuilder.js +16 -19
- package/lib/typeorm/persistence/subject-builder/CascadesSubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.js +50 -53
- package/lib/typeorm/persistence/subject-builder/ManyToManySubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/OneToManySubjectBuilder.js +28 -33
- package/lib/typeorm/persistence/subject-builder/OneToManySubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js +19 -20
- package/lib/typeorm/persistence/subject-builder/OneToOneInverseSideSubjectBuilder.js.map +1 -1
- package/lib/typeorm/persistence/tree/ClosureSubjectExecutor.js +202 -271
- package/lib/typeorm/persistence/tree/ClosureSubjectExecutor.js.map +1 -1
- package/lib/typeorm/persistence/tree/MaterializedPathSubjectExecutor.js +79 -121
- package/lib/typeorm/persistence/tree/MaterializedPathSubjectExecutor.js.map +1 -1
- package/lib/typeorm/persistence/tree/NestedSetSubjectExecutor.js +220 -353
- package/lib/typeorm/persistence/tree/NestedSetSubjectExecutor.js.map +1 -1
- package/lib/typeorm/platform/PlatformTools.js +66 -78
- package/lib/typeorm/platform/PlatformTools.js.map +1 -1
- package/lib/typeorm/query-builder/Alias.js +31 -32
- package/lib/typeorm/query-builder/Alias.js.map +1 -1
- package/lib/typeorm/query-builder/Brackets.js +8 -5
- package/lib/typeorm/query-builder/Brackets.js.map +1 -1
- package/lib/typeorm/query-builder/DeleteQueryBuilder.js +96 -120
- package/lib/typeorm/query-builder/DeleteQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/InsertOrUpdateOptions.js.map +1 -1
- package/lib/typeorm/query-builder/InsertQueryBuilder.js +321 -367
- package/lib/typeorm/query-builder/InsertQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/JoinAttribute.js +175 -206
- package/lib/typeorm/query-builder/JoinAttribute.js.map +1 -1
- package/lib/typeorm/query-builder/JoinOptions.js.map +1 -1
- package/lib/typeorm/query-builder/NotBrackets.js +4 -11
- package/lib/typeorm/query-builder/NotBrackets.js.map +1 -1
- package/lib/typeorm/query-builder/QueryBuilder.js +400 -646
- package/lib/typeorm/query-builder/QueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/QueryBuilderCte.js.map +1 -1
- package/lib/typeorm/query-builder/QueryBuilderUtils.js +5 -9
- package/lib/typeorm/query-builder/QueryBuilderUtils.js.map +1 -1
- package/lib/typeorm/query-builder/QueryExpressionMap.js +304 -233
- package/lib/typeorm/query-builder/QueryExpressionMap.js.map +1 -1
- package/lib/typeorm/query-builder/QueryPartialEntity.js.map +1 -1
- package/lib/typeorm/query-builder/RelationIdLoader.js +166 -189
- package/lib/typeorm/query-builder/RelationIdLoader.js.map +1 -1
- package/lib/typeorm/query-builder/RelationLoader.js +81 -94
- package/lib/typeorm/query-builder/RelationLoader.js.map +1 -1
- package/lib/typeorm/query-builder/RelationQueryBuilder.js +91 -127
- package/lib/typeorm/query-builder/RelationQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/RelationRemover.js +121 -124
- package/lib/typeorm/query-builder/RelationRemover.js.map +1 -1
- package/lib/typeorm/query-builder/RelationUpdater.js +130 -148
- package/lib/typeorm/query-builder/RelationUpdater.js.map +1 -1
- package/lib/typeorm/query-builder/ReturningResultsEntityUpdator.js +131 -159
- package/lib/typeorm/query-builder/ReturningResultsEntityUpdator.js.map +1 -1
- package/lib/typeorm/query-builder/SelectQuery.js.map +1 -1
- package/lib/typeorm/query-builder/SelectQueryBuilder.js +955 -1211
- package/lib/typeorm/query-builder/SelectQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/SelectQueryBuilderOption.js.map +1 -1
- package/lib/typeorm/query-builder/SoftDeleteQueryBuilder.js +155 -194
- package/lib/typeorm/query-builder/SoftDeleteQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/UpdateQueryBuilder.js +204 -246
- package/lib/typeorm/query-builder/UpdateQueryBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/WhereClause.js.map +1 -1
- package/lib/typeorm/query-builder/WhereExpressionBuilder.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountAttribute.js +85 -98
- package/lib/typeorm/query-builder/relation-count/RelationCountAttribute.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountLoadResult.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountLoader.js +153 -172
- package/lib/typeorm/query-builder/relation-count/RelationCountLoader.js.map +1 -1
- package/lib/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.js +16 -17
- package/lib/typeorm/query-builder/relation-count/RelationCountMetadataToAttributeTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdAttribute.js +93 -107
- package/lib/typeorm/query-builder/relation-id/RelationIdAttribute.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdLoadResult.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdLoader.js +259 -267
- package/lib/typeorm/query-builder/relation-id/RelationIdLoader.js.map +1 -1
- package/lib/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.js +16 -17
- package/lib/typeorm/query-builder/relation-id/RelationIdMetadataToAttributeTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/result/DeleteResult.js +14 -8
- package/lib/typeorm/query-builder/result/DeleteResult.js.map +1 -1
- package/lib/typeorm/query-builder/result/InsertResult.js +19 -18
- package/lib/typeorm/query-builder/result/InsertResult.js.map +1 -1
- package/lib/typeorm/query-builder/result/UpdateResult.js +24 -18
- package/lib/typeorm/query-builder/result/UpdateResult.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/DocumentToEntityTransformer.js +24 -26
- package/lib/typeorm/query-builder/transformer/DocumentToEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.js +77 -112
- package/lib/typeorm/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.js +16 -22
- package/lib/typeorm/query-builder/transformer/PlainObjectToNewEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js +117 -132
- package/lib/typeorm/query-builder/transformer/RawSqlResultsToEntityTransformer.js.map +1 -1
- package/lib/typeorm/query-runner/BaseQueryRunner.js +227 -393
- package/lib/typeorm/query-runner/BaseQueryRunner.js.map +1 -1
- package/lib/typeorm/query-runner/QueryLock.js +19 -32
- package/lib/typeorm/query-runner/QueryLock.js.map +1 -1
- package/lib/typeorm/query-runner/QueryResult.js +14 -9
- package/lib/typeorm/query-runner/QueryResult.js.map +1 -1
- package/lib/typeorm/query-runner/QueryRunner.js.map +1 -1
- package/lib/typeorm/repository/AbstractRepository.js +46 -50
- package/lib/typeorm/repository/AbstractRepository.js.map +1 -1
- package/lib/typeorm/repository/BaseEntity.js +106 -123
- package/lib/typeorm/repository/BaseEntity.js.map +1 -1
- package/lib/typeorm/repository/EntityId.js.map +1 -1
- package/lib/typeorm/repository/FindTreesOptions.js.map +1 -1
- package/lib/typeorm/repository/MongoRepository.js +109 -135
- package/lib/typeorm/repository/MongoRepository.js.map +1 -1
- package/lib/typeorm/repository/RemoveOptions.js.map +1 -1
- package/lib/typeorm/repository/Repository.js +108 -140
- package/lib/typeorm/repository/Repository.js.map +1 -1
- package/lib/typeorm/repository/SaveOptions.js.map +1 -1
- package/lib/typeorm/repository/TreeRepository.js +107 -154
- package/lib/typeorm/repository/TreeRepository.js.map +1 -1
- package/lib/typeorm/repository/UpsertOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/MongoSchemaBuilder.js +30 -42
- package/lib/typeorm/schema-builder/MongoSchemaBuilder.js.map +1 -1
- package/lib/typeorm/schema-builder/RdbmsSchemaBuilder.js +727 -1938
- package/lib/typeorm/schema-builder/RdbmsSchemaBuilder.js.map +1 -1
- package/lib/typeorm/schema-builder/SchemaBuilder.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableCheckOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableColumnOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableExclusionOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableForeignKeyOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableIndexOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/TableUniqueOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/options/ViewOptions.js.map +1 -1
- package/lib/typeorm/schema-builder/table/Table.js +160 -157
- package/lib/typeorm/schema-builder/table/Table.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableCheck.js +24 -15
- package/lib/typeorm/schema-builder/table/TableCheck.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableColumn.js +123 -41
- package/lib/typeorm/schema-builder/table/TableColumn.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableExclusion.js +19 -9
- package/lib/typeorm/schema-builder/table/TableExclusion.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableForeignKey.js +52 -20
- package/lib/typeorm/schema-builder/table/TableForeignKey.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableIndex.js +52 -16
- package/lib/typeorm/schema-builder/table/TableIndex.js.map +1 -1
- package/lib/typeorm/schema-builder/table/TableUnique.js +26 -16
- package/lib/typeorm/schema-builder/table/TableUnique.js.map +1 -1
- package/lib/typeorm/schema-builder/util/TableUtils.js +5 -8
- package/lib/typeorm/schema-builder/util/TableUtils.js.map +1 -1
- package/lib/typeorm/schema-builder/util/ViewUtils.js +4 -7
- package/lib/typeorm/schema-builder/util/ViewUtils.js.map +1 -1
- package/lib/typeorm/schema-builder/view/View.js +32 -10
- package/lib/typeorm/schema-builder/view/View.js.map +1 -1
- package/lib/typeorm/subscriber/Broadcaster.js +180 -216
- package/lib/typeorm/subscriber/Broadcaster.js.map +1 -1
- package/lib/typeorm/subscriber/BroadcasterResult.js +16 -29
- package/lib/typeorm/subscriber/BroadcasterResult.js.map +1 -1
- package/lib/typeorm/subscriber/EntitySubscriberInterface.js.map +1 -1
- package/lib/typeorm/subscriber/event/InsertEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/LoadEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/RecoverEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/RemoveEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/SoftRemoveEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/TransactionCommitEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/TransactionRollbackEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/TransactionStartEvent.js.map +1 -1
- package/lib/typeorm/subscriber/event/UpdateEvent.js.map +1 -1
- package/lib/typeorm/util/ApplyValueTransformers.js +9 -12
- package/lib/typeorm/util/ApplyValueTransformers.js.map +1 -1
- package/lib/typeorm/util/DateUtils.js +44 -53
- package/lib/typeorm/util/DateUtils.js.map +1 -1
- package/lib/typeorm/util/DepGraph.js +50 -53
- package/lib/typeorm/util/DepGraph.js.map +1 -1
- package/lib/typeorm/util/DirectoryExportedClassesLoader.js +48 -70
- package/lib/typeorm/util/DirectoryExportedClassesLoader.js.map +1 -1
- package/lib/typeorm/util/ImportUtils.js +43 -65
- package/lib/typeorm/util/ImportUtils.js.map +1 -1
- package/lib/typeorm/util/InstanceChecker.js +64 -67
- package/lib/typeorm/util/InstanceChecker.js.map +1 -1
- package/lib/typeorm/util/ObjectUtils.js +13 -42
- package/lib/typeorm/util/ObjectUtils.js.map +1 -1
- package/lib/typeorm/util/OrmUtils.js +91 -158
- package/lib/typeorm/util/OrmUtils.js.map +1 -1
- package/lib/typeorm/util/PathUtils.js +8 -8
- package/lib/typeorm/util/PathUtils.js.map +1 -1
- package/lib/typeorm/util/RandomGenerator.js +22 -25
- package/lib/typeorm/util/RandomGenerator.js.map +1 -1
- package/lib/typeorm/util/StringUtils.js +17 -21
- package/lib/typeorm/util/StringUtils.js.map +1 -1
- package/lib/typeorm/util/TreeRepositoryUtils.js +27 -30
- package/lib/typeorm/util/TreeRepositoryUtils.js.map +1 -1
- package/lib/typeorm/util/VersionUtils.js +9 -13
- package/lib/typeorm/util/VersionUtils.js.map +1 -1
- package/lib/typeorm/util/escapeRegExp.js +2 -2
- package/lib/typeorm/util/escapeRegExp.js.map +1 -1
- package/migrations/index.js +15 -2
- package/migrations/index.js.map +1 -1
- package/migrations/migrations_index._auto-generated_.d.ts +1 -0
- package/migrations/migrations_index._auto-generated_.js.map +1 -1
- package/package.json +8 -44
- package/src.d.ts +1 -1
- package/taon.jsonc +7 -34
- package/tmp-environment.json +8 -370
- package/websql/README.md +24 -24
- package/websql/esm2022/lib/typeorm/driver/cordova/CordovaDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/cordova/CordovaQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/nativescript/NativescriptDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/nativescript/NativescriptQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/react-native/ReactNativeDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/react-native/ReactNativeQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/sqljs/SqljsDriver.mjs +1 -1
- package/websql/esm2022/lib/typeorm/driver/sqljs/SqljsQueryRunner.mjs +1 -1
- package/websql/esm2022/lib/typeorm/index.mjs +1 -3
- package/websql/fesm2022/taon-typeorm.mjs.map +1 -1
- package/browser/package.json +0 -25
- package/websql/package.json +0 -25
|
@@ -1,211 +1,253 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PostgresDriver = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var InstanceChecker_1 = require("../../util/InstanceChecker");
|
|
4
|
+
const ConnectionIsNotSetError_1 = require("../../error/ConnectionIsNotSetError");
|
|
5
|
+
const DriverPackageNotInstalledError_1 = require("../../error/DriverPackageNotInstalledError");
|
|
6
|
+
const PlatformTools_1 = require("../../platform/PlatformTools");
|
|
7
|
+
const RdbmsSchemaBuilder_1 = require("../../schema-builder/RdbmsSchemaBuilder");
|
|
8
|
+
const ApplyValueTransformers_1 = require("../../util/ApplyValueTransformers");
|
|
9
|
+
const DateUtils_1 = require("../../util/DateUtils");
|
|
10
|
+
const OrmUtils_1 = require("../../util/OrmUtils");
|
|
11
|
+
const VersionUtils_1 = require("../../util/VersionUtils");
|
|
12
|
+
const PostgresQueryRunner_1 = require("./PostgresQueryRunner");
|
|
13
|
+
const DriverUtils_1 = require("../DriverUtils");
|
|
14
|
+
const error_1 = require("../../error");
|
|
15
|
+
const InstanceChecker_1 = require("../../util/InstanceChecker");
|
|
17
16
|
/**
|
|
18
17
|
* Organizes communication with PostgreSQL DBMS.
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
class PostgresDriver {
|
|
20
|
+
// -------------------------------------------------------------------------
|
|
21
|
+
// Public Properties
|
|
22
|
+
// -------------------------------------------------------------------------
|
|
23
|
+
/**
|
|
24
|
+
* Connection used by driver.
|
|
25
|
+
*/
|
|
26
|
+
connection;
|
|
27
|
+
/**
|
|
28
|
+
* Postgres underlying library.
|
|
29
|
+
*/
|
|
30
|
+
postgres;
|
|
31
|
+
/**
|
|
32
|
+
* Pool for master database.
|
|
33
|
+
*/
|
|
34
|
+
master;
|
|
35
|
+
/**
|
|
36
|
+
* Pool for slave databases.
|
|
37
|
+
* Used in replication.
|
|
38
|
+
*/
|
|
39
|
+
slaves = [];
|
|
40
|
+
/**
|
|
41
|
+
* We store all created query runners because we need to release them.
|
|
42
|
+
*/
|
|
43
|
+
connectedQueryRunners = [];
|
|
44
|
+
// -------------------------------------------------------------------------
|
|
45
|
+
// Public Implemented Properties
|
|
46
|
+
// -------------------------------------------------------------------------
|
|
47
|
+
/**
|
|
48
|
+
* Connection options.
|
|
49
|
+
*/
|
|
50
|
+
options;
|
|
51
|
+
/**
|
|
52
|
+
* Version of Postgres. Requires a SQL query to the DB, so it is not always set
|
|
53
|
+
*/
|
|
54
|
+
version;
|
|
55
|
+
/**
|
|
56
|
+
* Database name used to perform all write queries.
|
|
57
|
+
*/
|
|
58
|
+
database;
|
|
59
|
+
/**
|
|
60
|
+
* Schema name used to perform all write queries.
|
|
61
|
+
*/
|
|
62
|
+
schema;
|
|
63
|
+
/**
|
|
64
|
+
* Schema that's used internally by Postgres for object resolution.
|
|
65
|
+
*
|
|
66
|
+
* Because we never set this we have to track it in separately from the `schema` so
|
|
67
|
+
* we know when we have to specify the full schema or not.
|
|
68
|
+
*
|
|
69
|
+
* In most cases this will be `public`.
|
|
70
|
+
*/
|
|
71
|
+
searchSchema;
|
|
72
|
+
/**
|
|
73
|
+
* Indicates if replication is enabled.
|
|
74
|
+
*/
|
|
75
|
+
isReplicated = false;
|
|
76
|
+
/**
|
|
77
|
+
* Indicates if tree tables are supported by this driver.
|
|
78
|
+
*/
|
|
79
|
+
treeSupport = true;
|
|
80
|
+
/**
|
|
81
|
+
* Represent transaction support by this driver
|
|
82
|
+
*/
|
|
83
|
+
transactionSupport = "nested";
|
|
84
|
+
/**
|
|
85
|
+
* Gets list of supported column data types by a driver.
|
|
86
|
+
*
|
|
87
|
+
* @see https://www.tutorialspoint.com/postgresql/postgresql_data_types.htm
|
|
88
|
+
* @see https://www.postgresql.org/docs/9.2/static/datatype.html
|
|
89
|
+
*/
|
|
90
|
+
supportedDataTypes = [
|
|
91
|
+
"int",
|
|
92
|
+
"int2",
|
|
93
|
+
"int4",
|
|
94
|
+
"int8",
|
|
95
|
+
"smallint",
|
|
96
|
+
"integer",
|
|
97
|
+
"bigint",
|
|
98
|
+
"decimal",
|
|
99
|
+
"numeric",
|
|
100
|
+
"real",
|
|
101
|
+
"float",
|
|
102
|
+
"float4",
|
|
103
|
+
"float8",
|
|
104
|
+
"double precision",
|
|
105
|
+
"money",
|
|
106
|
+
"character varying",
|
|
107
|
+
"varchar",
|
|
108
|
+
"character",
|
|
109
|
+
"char",
|
|
110
|
+
"text",
|
|
111
|
+
"citext",
|
|
112
|
+
"hstore",
|
|
113
|
+
"bytea",
|
|
114
|
+
"bit",
|
|
115
|
+
"varbit",
|
|
116
|
+
"bit varying",
|
|
117
|
+
"timetz",
|
|
118
|
+
"timestamptz",
|
|
119
|
+
"timestamp",
|
|
120
|
+
"timestamp without time zone",
|
|
121
|
+
"timestamp with time zone",
|
|
122
|
+
"date",
|
|
123
|
+
"time",
|
|
124
|
+
"time without time zone",
|
|
125
|
+
"time with time zone",
|
|
126
|
+
"interval",
|
|
127
|
+
"bool",
|
|
128
|
+
"boolean",
|
|
129
|
+
"enum",
|
|
130
|
+
"point",
|
|
131
|
+
"line",
|
|
132
|
+
"lseg",
|
|
133
|
+
"box",
|
|
134
|
+
"path",
|
|
135
|
+
"polygon",
|
|
136
|
+
"circle",
|
|
137
|
+
"cidr",
|
|
138
|
+
"inet",
|
|
139
|
+
"macaddr",
|
|
140
|
+
"tsvector",
|
|
141
|
+
"tsquery",
|
|
142
|
+
"uuid",
|
|
143
|
+
"xml",
|
|
144
|
+
"json",
|
|
145
|
+
"jsonb",
|
|
146
|
+
"int4range",
|
|
147
|
+
"int8range",
|
|
148
|
+
"numrange",
|
|
149
|
+
"tsrange",
|
|
150
|
+
"tstzrange",
|
|
151
|
+
"daterange",
|
|
152
|
+
"geometry",
|
|
153
|
+
"geography",
|
|
154
|
+
"cube",
|
|
155
|
+
"ltree",
|
|
156
|
+
];
|
|
157
|
+
/**
|
|
158
|
+
* Returns type of upsert supported by driver if any
|
|
159
|
+
*/
|
|
160
|
+
supportedUpsertType = "on-conflict-do-update";
|
|
161
|
+
/**
|
|
162
|
+
* Gets list of spatial column data types.
|
|
163
|
+
*/
|
|
164
|
+
spatialTypes = ["geometry", "geography"];
|
|
165
|
+
/**
|
|
166
|
+
* Gets list of column data types that support length by a driver.
|
|
167
|
+
*/
|
|
168
|
+
withLengthColumnTypes = [
|
|
169
|
+
"character varying",
|
|
170
|
+
"varchar",
|
|
171
|
+
"character",
|
|
172
|
+
"char",
|
|
173
|
+
"bit",
|
|
174
|
+
"varbit",
|
|
175
|
+
"bit varying",
|
|
176
|
+
];
|
|
177
|
+
/**
|
|
178
|
+
* Gets list of column data types that support precision by a driver.
|
|
179
|
+
*/
|
|
180
|
+
withPrecisionColumnTypes = [
|
|
181
|
+
"numeric",
|
|
182
|
+
"decimal",
|
|
183
|
+
"interval",
|
|
184
|
+
"time without time zone",
|
|
185
|
+
"time with time zone",
|
|
186
|
+
"timestamp without time zone",
|
|
187
|
+
"timestamp with time zone",
|
|
188
|
+
];
|
|
189
|
+
/**
|
|
190
|
+
* Gets list of column data types that support scale by a driver.
|
|
191
|
+
*/
|
|
192
|
+
withScaleColumnTypes = ["numeric", "decimal"];
|
|
193
|
+
/**
|
|
194
|
+
* Orm has special columns and we need to know what database column types should be for those types.
|
|
195
|
+
* Column types are driver dependant.
|
|
196
|
+
*/
|
|
197
|
+
mappedDataTypes = {
|
|
198
|
+
createDate: "timestamp",
|
|
199
|
+
createDateDefault: "now()",
|
|
200
|
+
updateDate: "timestamp",
|
|
201
|
+
updateDateDefault: "now()",
|
|
202
|
+
deleteDate: "timestamp",
|
|
203
|
+
deleteDateNullable: true,
|
|
204
|
+
version: "int4",
|
|
205
|
+
treeLevel: "int4",
|
|
206
|
+
migrationId: "int4",
|
|
207
|
+
migrationName: "varchar",
|
|
208
|
+
migrationTimestamp: "int8",
|
|
209
|
+
cacheId: "int4",
|
|
210
|
+
cacheIdentifier: "varchar",
|
|
211
|
+
cacheTime: "int8",
|
|
212
|
+
cacheDuration: "int4",
|
|
213
|
+
cacheQuery: "text",
|
|
214
|
+
cacheResult: "text",
|
|
215
|
+
metadataType: "varchar",
|
|
216
|
+
metadataDatabase: "varchar",
|
|
217
|
+
metadataSchema: "varchar",
|
|
218
|
+
metadataTable: "varchar",
|
|
219
|
+
metadataName: "varchar",
|
|
220
|
+
metadataValue: "text",
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Default values of length, precision and scale depends on column data type.
|
|
224
|
+
* Used in the cases when length/precision/scale is not specified by user.
|
|
225
|
+
*/
|
|
226
|
+
dataTypeDefaults = {
|
|
227
|
+
character: { length: 1 },
|
|
228
|
+
bit: { length: 1 },
|
|
229
|
+
interval: { precision: 6 },
|
|
230
|
+
"time without time zone": { precision: 6 },
|
|
231
|
+
"time with time zone": { precision: 6 },
|
|
232
|
+
"timestamp without time zone": { precision: 6 },
|
|
233
|
+
"timestamp with time zone": { precision: 6 },
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Max length allowed by Postgres for aliases.
|
|
237
|
+
* @see https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
|
|
238
|
+
*/
|
|
239
|
+
maxAliasLength = 63;
|
|
240
|
+
isGeneratedColumnsSupported = false;
|
|
241
|
+
cteCapabilities = {
|
|
242
|
+
enabled: true,
|
|
243
|
+
writable: true,
|
|
244
|
+
requiresRecursiveHint: true,
|
|
245
|
+
materializedHint: true,
|
|
246
|
+
};
|
|
21
247
|
// -------------------------------------------------------------------------
|
|
22
248
|
// Constructor
|
|
23
249
|
// -------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Pool for slave databases.
|
|
27
|
-
* Used in replication.
|
|
28
|
-
*/
|
|
29
|
-
this.slaves = [];
|
|
30
|
-
/**
|
|
31
|
-
* We store all created query runners because we need to release them.
|
|
32
|
-
*/
|
|
33
|
-
this.connectedQueryRunners = [];
|
|
34
|
-
/**
|
|
35
|
-
* Indicates if replication is enabled.
|
|
36
|
-
*/
|
|
37
|
-
this.isReplicated = false;
|
|
38
|
-
/**
|
|
39
|
-
* Indicates if tree tables are supported by this driver.
|
|
40
|
-
*/
|
|
41
|
-
this.treeSupport = true;
|
|
42
|
-
/**
|
|
43
|
-
* Represent transaction support by this driver
|
|
44
|
-
*/
|
|
45
|
-
this.transactionSupport = "nested";
|
|
46
|
-
/**
|
|
47
|
-
* Gets list of supported column data types by a driver.
|
|
48
|
-
*
|
|
49
|
-
* @see https://www.tutorialspoint.com/postgresql/postgresql_data_types.htm
|
|
50
|
-
* @see https://www.postgresql.org/docs/9.2/static/datatype.html
|
|
51
|
-
*/
|
|
52
|
-
this.supportedDataTypes = [
|
|
53
|
-
"int",
|
|
54
|
-
"int2",
|
|
55
|
-
"int4",
|
|
56
|
-
"int8",
|
|
57
|
-
"smallint",
|
|
58
|
-
"integer",
|
|
59
|
-
"bigint",
|
|
60
|
-
"decimal",
|
|
61
|
-
"numeric",
|
|
62
|
-
"real",
|
|
63
|
-
"float",
|
|
64
|
-
"float4",
|
|
65
|
-
"float8",
|
|
66
|
-
"double precision",
|
|
67
|
-
"money",
|
|
68
|
-
"character varying",
|
|
69
|
-
"varchar",
|
|
70
|
-
"character",
|
|
71
|
-
"char",
|
|
72
|
-
"text",
|
|
73
|
-
"citext",
|
|
74
|
-
"hstore",
|
|
75
|
-
"bytea",
|
|
76
|
-
"bit",
|
|
77
|
-
"varbit",
|
|
78
|
-
"bit varying",
|
|
79
|
-
"timetz",
|
|
80
|
-
"timestamptz",
|
|
81
|
-
"timestamp",
|
|
82
|
-
"timestamp without time zone",
|
|
83
|
-
"timestamp with time zone",
|
|
84
|
-
"date",
|
|
85
|
-
"time",
|
|
86
|
-
"time without time zone",
|
|
87
|
-
"time with time zone",
|
|
88
|
-
"interval",
|
|
89
|
-
"bool",
|
|
90
|
-
"boolean",
|
|
91
|
-
"enum",
|
|
92
|
-
"point",
|
|
93
|
-
"line",
|
|
94
|
-
"lseg",
|
|
95
|
-
"box",
|
|
96
|
-
"path",
|
|
97
|
-
"polygon",
|
|
98
|
-
"circle",
|
|
99
|
-
"cidr",
|
|
100
|
-
"inet",
|
|
101
|
-
"macaddr",
|
|
102
|
-
"tsvector",
|
|
103
|
-
"tsquery",
|
|
104
|
-
"uuid",
|
|
105
|
-
"xml",
|
|
106
|
-
"json",
|
|
107
|
-
"jsonb",
|
|
108
|
-
"int4range",
|
|
109
|
-
"int8range",
|
|
110
|
-
"numrange",
|
|
111
|
-
"tsrange",
|
|
112
|
-
"tstzrange",
|
|
113
|
-
"daterange",
|
|
114
|
-
"geometry",
|
|
115
|
-
"geography",
|
|
116
|
-
"cube",
|
|
117
|
-
"ltree",
|
|
118
|
-
];
|
|
119
|
-
/**
|
|
120
|
-
* Returns type of upsert supported by driver if any
|
|
121
|
-
*/
|
|
122
|
-
this.supportedUpsertType = "on-conflict-do-update";
|
|
123
|
-
/**
|
|
124
|
-
* Gets list of spatial column data types.
|
|
125
|
-
*/
|
|
126
|
-
this.spatialTypes = ["geometry", "geography"];
|
|
127
|
-
/**
|
|
128
|
-
* Gets list of column data types that support length by a driver.
|
|
129
|
-
*/
|
|
130
|
-
this.withLengthColumnTypes = [
|
|
131
|
-
"character varying",
|
|
132
|
-
"varchar",
|
|
133
|
-
"character",
|
|
134
|
-
"char",
|
|
135
|
-
"bit",
|
|
136
|
-
"varbit",
|
|
137
|
-
"bit varying",
|
|
138
|
-
];
|
|
139
|
-
/**
|
|
140
|
-
* Gets list of column data types that support precision by a driver.
|
|
141
|
-
*/
|
|
142
|
-
this.withPrecisionColumnTypes = [
|
|
143
|
-
"numeric",
|
|
144
|
-
"decimal",
|
|
145
|
-
"interval",
|
|
146
|
-
"time without time zone",
|
|
147
|
-
"time with time zone",
|
|
148
|
-
"timestamp without time zone",
|
|
149
|
-
"timestamp with time zone",
|
|
150
|
-
];
|
|
151
|
-
/**
|
|
152
|
-
* Gets list of column data types that support scale by a driver.
|
|
153
|
-
*/
|
|
154
|
-
this.withScaleColumnTypes = ["numeric", "decimal"];
|
|
155
|
-
/**
|
|
156
|
-
* Orm has special columns and we need to know what database column types should be for those types.
|
|
157
|
-
* Column types are driver dependant.
|
|
158
|
-
*/
|
|
159
|
-
this.mappedDataTypes = {
|
|
160
|
-
createDate: "timestamp",
|
|
161
|
-
createDateDefault: "now()",
|
|
162
|
-
updateDate: "timestamp",
|
|
163
|
-
updateDateDefault: "now()",
|
|
164
|
-
deleteDate: "timestamp",
|
|
165
|
-
deleteDateNullable: true,
|
|
166
|
-
version: "int4",
|
|
167
|
-
treeLevel: "int4",
|
|
168
|
-
migrationId: "int4",
|
|
169
|
-
migrationName: "varchar",
|
|
170
|
-
migrationTimestamp: "int8",
|
|
171
|
-
cacheId: "int4",
|
|
172
|
-
cacheIdentifier: "varchar",
|
|
173
|
-
cacheTime: "int8",
|
|
174
|
-
cacheDuration: "int4",
|
|
175
|
-
cacheQuery: "text",
|
|
176
|
-
cacheResult: "text",
|
|
177
|
-
metadataType: "varchar",
|
|
178
|
-
metadataDatabase: "varchar",
|
|
179
|
-
metadataSchema: "varchar",
|
|
180
|
-
metadataTable: "varchar",
|
|
181
|
-
metadataName: "varchar",
|
|
182
|
-
metadataValue: "text",
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Default values of length, precision and scale depends on column data type.
|
|
186
|
-
* Used in the cases when length/precision/scale is not specified by user.
|
|
187
|
-
*/
|
|
188
|
-
this.dataTypeDefaults = {
|
|
189
|
-
character: { length: 1 },
|
|
190
|
-
bit: { length: 1 },
|
|
191
|
-
interval: { precision: 6 },
|
|
192
|
-
"time without time zone": { precision: 6 },
|
|
193
|
-
"time with time zone": { precision: 6 },
|
|
194
|
-
"timestamp without time zone": { precision: 6 },
|
|
195
|
-
"timestamp with time zone": { precision: 6 },
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* Max length allowed by Postgres for aliases.
|
|
199
|
-
* @see https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
|
|
200
|
-
*/
|
|
201
|
-
this.maxAliasLength = 63;
|
|
202
|
-
this.isGeneratedColumnsSupported = false;
|
|
203
|
-
this.cteCapabilities = {
|
|
204
|
-
enabled: true,
|
|
205
|
-
writable: true,
|
|
206
|
-
requiresRecursiveHint: true,
|
|
207
|
-
materializedHint: true,
|
|
208
|
-
};
|
|
250
|
+
constructor(connection) {
|
|
209
251
|
if (!connection) {
|
|
210
252
|
return;
|
|
211
253
|
}
|
|
@@ -239,289 +281,169 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
239
281
|
* Based on pooling options, it can either create connection immediately,
|
|
240
282
|
* either create a pool and create connection when needed.
|
|
241
283
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
_f.label = 5;
|
|
267
|
-
case 5:
|
|
268
|
-
if (!(!this.database || !this.searchSchema)) return [3 /*break*/, 12];
|
|
269
|
-
return [4 /*yield*/, this.createQueryRunner("master")];
|
|
270
|
-
case 6:
|
|
271
|
-
queryRunner = _f.sent();
|
|
272
|
-
if (!!this.database) return [3 /*break*/, 8];
|
|
273
|
-
_d = this;
|
|
274
|
-
return [4 /*yield*/, queryRunner.getCurrentDatabase()];
|
|
275
|
-
case 7:
|
|
276
|
-
_d.database = _f.sent();
|
|
277
|
-
_f.label = 8;
|
|
278
|
-
case 8:
|
|
279
|
-
if (!!this.searchSchema) return [3 /*break*/, 10];
|
|
280
|
-
_e = this;
|
|
281
|
-
return [4 /*yield*/, queryRunner.getCurrentSchema()];
|
|
282
|
-
case 9:
|
|
283
|
-
_e.searchSchema = _f.sent();
|
|
284
|
-
_f.label = 10;
|
|
285
|
-
case 10: return [4 /*yield*/, queryRunner.release()];
|
|
286
|
-
case 11:
|
|
287
|
-
_f.sent();
|
|
288
|
-
_f.label = 12;
|
|
289
|
-
case 12:
|
|
290
|
-
if (!this.schema) {
|
|
291
|
-
this.schema = this.searchSchema;
|
|
292
|
-
}
|
|
293
|
-
return [2 /*return*/];
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
};
|
|
284
|
+
async connect() {
|
|
285
|
+
if (this.options.replication) {
|
|
286
|
+
this.slaves = await Promise.all(this.options.replication.slaves.map((slave) => {
|
|
287
|
+
return this.createPool(this.options, slave);
|
|
288
|
+
}));
|
|
289
|
+
this.master = await this.createPool(this.options, this.options.replication.master);
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
this.master = await this.createPool(this.options, this.options);
|
|
293
|
+
}
|
|
294
|
+
if (!this.database || !this.searchSchema) {
|
|
295
|
+
const queryRunner = await this.createQueryRunner("master");
|
|
296
|
+
if (!this.database) {
|
|
297
|
+
this.database = await queryRunner.getCurrentDatabase();
|
|
298
|
+
}
|
|
299
|
+
if (!this.searchSchema) {
|
|
300
|
+
this.searchSchema = await queryRunner.getCurrentSchema();
|
|
301
|
+
}
|
|
302
|
+
await queryRunner.release();
|
|
303
|
+
}
|
|
304
|
+
if (!this.schema) {
|
|
305
|
+
this.schema = this.searchSchema;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
298
308
|
/**
|
|
299
309
|
* Makes any action after connection (e.g. create extensions in Postgres driver).
|
|
300
310
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
311
|
+
async afterConnect() {
|
|
312
|
+
const extensionsMetadata = await this.checkMetadataForExtensions();
|
|
313
|
+
const [connection, release] = await this.obtainMasterConnection();
|
|
314
|
+
const installExtensions = this.options.installExtensions === undefined ||
|
|
315
|
+
this.options.installExtensions;
|
|
316
|
+
if (installExtensions && extensionsMetadata.hasExtensions) {
|
|
317
|
+
await this.enableExtensions(extensionsMetadata, connection);
|
|
318
|
+
}
|
|
319
|
+
const results = (await this.executeQuery(connection, "SELECT version();"));
|
|
320
|
+
const versionString = results.rows[0].version.replace(/^PostgreSQL ([\d\.]+) .*$/, "$1");
|
|
321
|
+
this.version = versionString;
|
|
322
|
+
this.isGeneratedColumnsSupported = VersionUtils_1.VersionUtils.isGreaterOrEqual(versionString, "12.0");
|
|
323
|
+
await release();
|
|
324
|
+
}
|
|
325
|
+
async enableExtensions(extensionsMetadata, connection) {
|
|
326
|
+
const { logger } = this.connection;
|
|
327
|
+
const { hasUuidColumns, hasCitextColumns, hasHstoreColumns, hasCubeColumns, hasGeometryColumns, hasLtreeColumns, hasExclusionConstraints, } = extensionsMetadata;
|
|
328
|
+
if (hasUuidColumns)
|
|
329
|
+
try {
|
|
330
|
+
await this.executeQuery(connection, `CREATE EXTENSION IF NOT EXISTS "${this.options.uuidExtension || "uuid-ossp"}"`);
|
|
331
|
+
}
|
|
332
|
+
catch (_) {
|
|
333
|
+
logger.log("warn", `At least one of the entities has uuid column, but the '${this.options.uuidExtension || "uuid-ossp"}' extension cannot be installed automatically. Please install it manually using superuser rights, or select another uuid extension.`);
|
|
334
|
+
}
|
|
335
|
+
if (hasCitextColumns)
|
|
336
|
+
try {
|
|
337
|
+
await this.executeQuery(connection, `CREATE EXTENSION IF NOT EXISTS "citext"`);
|
|
338
|
+
}
|
|
339
|
+
catch (_) {
|
|
340
|
+
logger.log("warn", "At least one of the entities has citext column, but the 'citext' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
341
|
+
}
|
|
342
|
+
if (hasHstoreColumns)
|
|
343
|
+
try {
|
|
344
|
+
await this.executeQuery(connection, `CREATE EXTENSION IF NOT EXISTS "hstore"`);
|
|
345
|
+
}
|
|
346
|
+
catch (_) {
|
|
347
|
+
logger.log("warn", "At least one of the entities has hstore column, but the 'hstore' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
348
|
+
}
|
|
349
|
+
if (hasGeometryColumns)
|
|
350
|
+
try {
|
|
351
|
+
await this.executeQuery(connection, `CREATE EXTENSION IF NOT EXISTS "postgis"`);
|
|
352
|
+
}
|
|
353
|
+
catch (_) {
|
|
354
|
+
logger.log("warn", "At least one of the entities has a geometry column, but the 'postgis' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
355
|
+
}
|
|
356
|
+
if (hasCubeColumns)
|
|
357
|
+
try {
|
|
358
|
+
await this.executeQuery(connection, `CREATE EXTENSION IF NOT EXISTS "cube"`);
|
|
359
|
+
}
|
|
360
|
+
catch (_) {
|
|
361
|
+
logger.log("warn", "At least one of the entities has a cube column, but the 'cube' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
362
|
+
}
|
|
363
|
+
if (hasLtreeColumns)
|
|
364
|
+
try {
|
|
365
|
+
await this.executeQuery(connection, `CREATE EXTENSION IF NOT EXISTS "ltree"`);
|
|
366
|
+
}
|
|
367
|
+
catch (_) {
|
|
368
|
+
logger.log("warn", "At least one of the entities has a cube column, but the 'ltree' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
369
|
+
}
|
|
370
|
+
if (hasExclusionConstraints)
|
|
371
|
+
try {
|
|
372
|
+
// The btree_gist extension provides operator support in PostgreSQL exclusion constraints
|
|
373
|
+
await this.executeQuery(connection, `CREATE EXTENSION IF NOT EXISTS "btree_gist"`);
|
|
374
|
+
}
|
|
375
|
+
catch (_) {
|
|
376
|
+
logger.log("warn", "At least one of the entities has an exclusion constraint, but the 'btree_gist' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
async checkMetadataForExtensions() {
|
|
380
|
+
const hasUuidColumns = this.connection.entityMetadatas.some((metadata) => {
|
|
381
|
+
return (metadata.generatedColumns.filter((column) => column.generationStrategy === "uuid").length > 0);
|
|
331
382
|
});
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
335
|
-
var logger, hasUuidColumns, hasCitextColumns, hasHstoreColumns, hasCubeColumns, hasGeometryColumns, hasLtreeColumns, hasExclusionConstraints, _1, _2, _3, _4, _5, _6, _7;
|
|
336
|
-
return tslib_1.__generator(this, function (_a) {
|
|
337
|
-
switch (_a.label) {
|
|
338
|
-
case 0:
|
|
339
|
-
logger = this.connection.logger;
|
|
340
|
-
hasUuidColumns = extensionsMetadata.hasUuidColumns, hasCitextColumns = extensionsMetadata.hasCitextColumns, hasHstoreColumns = extensionsMetadata.hasHstoreColumns, hasCubeColumns = extensionsMetadata.hasCubeColumns, hasGeometryColumns = extensionsMetadata.hasGeometryColumns, hasLtreeColumns = extensionsMetadata.hasLtreeColumns, hasExclusionConstraints = extensionsMetadata.hasExclusionConstraints;
|
|
341
|
-
if (!hasUuidColumns) return [3 /*break*/, 4];
|
|
342
|
-
_a.label = 1;
|
|
343
|
-
case 1:
|
|
344
|
-
_a.trys.push([1, 3, , 4]);
|
|
345
|
-
return [4 /*yield*/, this.executeQuery(connection, "CREATE EXTENSION IF NOT EXISTS \"".concat(this.options.uuidExtension || "uuid-ossp", "\""))];
|
|
346
|
-
case 2:
|
|
347
|
-
_a.sent();
|
|
348
|
-
return [3 /*break*/, 4];
|
|
349
|
-
case 3:
|
|
350
|
-
_1 = _a.sent();
|
|
351
|
-
logger.log("warn", "At least one of the entities has uuid column, but the '".concat(this.options.uuidExtension || "uuid-ossp", "' extension cannot be installed automatically. Please install it manually using superuser rights, or select another uuid extension."));
|
|
352
|
-
return [3 /*break*/, 4];
|
|
353
|
-
case 4:
|
|
354
|
-
if (!hasCitextColumns) return [3 /*break*/, 8];
|
|
355
|
-
_a.label = 5;
|
|
356
|
-
case 5:
|
|
357
|
-
_a.trys.push([5, 7, , 8]);
|
|
358
|
-
return [4 /*yield*/, this.executeQuery(connection, "CREATE EXTENSION IF NOT EXISTS \"citext\"")];
|
|
359
|
-
case 6:
|
|
360
|
-
_a.sent();
|
|
361
|
-
return [3 /*break*/, 8];
|
|
362
|
-
case 7:
|
|
363
|
-
_2 = _a.sent();
|
|
364
|
-
logger.log("warn", "At least one of the entities has citext column, but the 'citext' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
365
|
-
return [3 /*break*/, 8];
|
|
366
|
-
case 8:
|
|
367
|
-
if (!hasHstoreColumns) return [3 /*break*/, 12];
|
|
368
|
-
_a.label = 9;
|
|
369
|
-
case 9:
|
|
370
|
-
_a.trys.push([9, 11, , 12]);
|
|
371
|
-
return [4 /*yield*/, this.executeQuery(connection, "CREATE EXTENSION IF NOT EXISTS \"hstore\"")];
|
|
372
|
-
case 10:
|
|
373
|
-
_a.sent();
|
|
374
|
-
return [3 /*break*/, 12];
|
|
375
|
-
case 11:
|
|
376
|
-
_3 = _a.sent();
|
|
377
|
-
logger.log("warn", "At least one of the entities has hstore column, but the 'hstore' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
378
|
-
return [3 /*break*/, 12];
|
|
379
|
-
case 12:
|
|
380
|
-
if (!hasGeometryColumns) return [3 /*break*/, 16];
|
|
381
|
-
_a.label = 13;
|
|
382
|
-
case 13:
|
|
383
|
-
_a.trys.push([13, 15, , 16]);
|
|
384
|
-
return [4 /*yield*/, this.executeQuery(connection, "CREATE EXTENSION IF NOT EXISTS \"postgis\"")];
|
|
385
|
-
case 14:
|
|
386
|
-
_a.sent();
|
|
387
|
-
return [3 /*break*/, 16];
|
|
388
|
-
case 15:
|
|
389
|
-
_4 = _a.sent();
|
|
390
|
-
logger.log("warn", "At least one of the entities has a geometry column, but the 'postgis' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
391
|
-
return [3 /*break*/, 16];
|
|
392
|
-
case 16:
|
|
393
|
-
if (!hasCubeColumns) return [3 /*break*/, 20];
|
|
394
|
-
_a.label = 17;
|
|
395
|
-
case 17:
|
|
396
|
-
_a.trys.push([17, 19, , 20]);
|
|
397
|
-
return [4 /*yield*/, this.executeQuery(connection, "CREATE EXTENSION IF NOT EXISTS \"cube\"")];
|
|
398
|
-
case 18:
|
|
399
|
-
_a.sent();
|
|
400
|
-
return [3 /*break*/, 20];
|
|
401
|
-
case 19:
|
|
402
|
-
_5 = _a.sent();
|
|
403
|
-
logger.log("warn", "At least one of the entities has a cube column, but the 'cube' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
404
|
-
return [3 /*break*/, 20];
|
|
405
|
-
case 20:
|
|
406
|
-
if (!hasLtreeColumns) return [3 /*break*/, 24];
|
|
407
|
-
_a.label = 21;
|
|
408
|
-
case 21:
|
|
409
|
-
_a.trys.push([21, 23, , 24]);
|
|
410
|
-
return [4 /*yield*/, this.executeQuery(connection, "CREATE EXTENSION IF NOT EXISTS \"ltree\"")];
|
|
411
|
-
case 22:
|
|
412
|
-
_a.sent();
|
|
413
|
-
return [3 /*break*/, 24];
|
|
414
|
-
case 23:
|
|
415
|
-
_6 = _a.sent();
|
|
416
|
-
logger.log("warn", "At least one of the entities has a cube column, but the 'ltree' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
417
|
-
return [3 /*break*/, 24];
|
|
418
|
-
case 24:
|
|
419
|
-
if (!hasExclusionConstraints) return [3 /*break*/, 28];
|
|
420
|
-
_a.label = 25;
|
|
421
|
-
case 25:
|
|
422
|
-
_a.trys.push([25, 27, , 28]);
|
|
423
|
-
// The btree_gist extension provides operator support in PostgreSQL exclusion constraints
|
|
424
|
-
return [4 /*yield*/, this.executeQuery(connection, "CREATE EXTENSION IF NOT EXISTS \"btree_gist\"")];
|
|
425
|
-
case 26:
|
|
426
|
-
// The btree_gist extension provides operator support in PostgreSQL exclusion constraints
|
|
427
|
-
_a.sent();
|
|
428
|
-
return [3 /*break*/, 28];
|
|
429
|
-
case 27:
|
|
430
|
-
_7 = _a.sent();
|
|
431
|
-
logger.log("warn", "At least one of the entities has an exclusion constraint, but the 'btree_gist' extension cannot be installed automatically. Please install it manually using superuser rights");
|
|
432
|
-
return [3 /*break*/, 28];
|
|
433
|
-
case 28: return [2 /*return*/];
|
|
434
|
-
}
|
|
435
|
-
});
|
|
383
|
+
const hasCitextColumns = this.connection.entityMetadatas.some((metadata) => {
|
|
384
|
+
return (metadata.columns.filter((column) => column.type === "citext").length > 0);
|
|
436
385
|
});
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
440
|
-
var hasUuidColumns, hasCitextColumns, hasHstoreColumns, hasCubeColumns, hasGeometryColumns, hasLtreeColumns, hasExclusionConstraints;
|
|
441
|
-
var _this = this;
|
|
442
|
-
return tslib_1.__generator(this, function (_a) {
|
|
443
|
-
hasUuidColumns = this.connection.entityMetadatas.some(function (metadata) {
|
|
444
|
-
return (metadata.generatedColumns.filter(function (column) { return column.generationStrategy === "uuid"; }).length > 0);
|
|
445
|
-
});
|
|
446
|
-
hasCitextColumns = this.connection.entityMetadatas.some(function (metadata) {
|
|
447
|
-
return (metadata.columns.filter(function (column) { return column.type === "citext"; }).length > 0);
|
|
448
|
-
});
|
|
449
|
-
hasHstoreColumns = this.connection.entityMetadatas.some(function (metadata) {
|
|
450
|
-
return (metadata.columns.filter(function (column) { return column.type === "hstore"; }).length > 0);
|
|
451
|
-
});
|
|
452
|
-
hasCubeColumns = this.connection.entityMetadatas.some(function (metadata) {
|
|
453
|
-
return (metadata.columns.filter(function (column) { return column.type === "cube"; })
|
|
454
|
-
.length > 0);
|
|
455
|
-
});
|
|
456
|
-
hasGeometryColumns = this.connection.entityMetadatas.some(function (metadata) {
|
|
457
|
-
return (metadata.columns.filter(function (column) { return _this.spatialTypes.indexOf(column.type) >= 0; }).length > 0);
|
|
458
|
-
});
|
|
459
|
-
hasLtreeColumns = this.connection.entityMetadatas.some(function (metadata) {
|
|
460
|
-
return (metadata.columns.filter(function (column) { return column.type === "ltree"; })
|
|
461
|
-
.length > 0);
|
|
462
|
-
});
|
|
463
|
-
hasExclusionConstraints = this.connection.entityMetadatas.some(function (metadata) {
|
|
464
|
-
return metadata.exclusions.length > 0;
|
|
465
|
-
});
|
|
466
|
-
return [2 /*return*/, {
|
|
467
|
-
hasUuidColumns: hasUuidColumns,
|
|
468
|
-
hasCitextColumns: hasCitextColumns,
|
|
469
|
-
hasHstoreColumns: hasHstoreColumns,
|
|
470
|
-
hasCubeColumns: hasCubeColumns,
|
|
471
|
-
hasGeometryColumns: hasGeometryColumns,
|
|
472
|
-
hasLtreeColumns: hasLtreeColumns,
|
|
473
|
-
hasExclusionConstraints: hasExclusionConstraints,
|
|
474
|
-
hasExtensions: hasUuidColumns ||
|
|
475
|
-
hasCitextColumns ||
|
|
476
|
-
hasHstoreColumns ||
|
|
477
|
-
hasGeometryColumns ||
|
|
478
|
-
hasCubeColumns ||
|
|
479
|
-
hasLtreeColumns ||
|
|
480
|
-
hasExclusionConstraints,
|
|
481
|
-
}];
|
|
482
|
-
});
|
|
386
|
+
const hasHstoreColumns = this.connection.entityMetadatas.some((metadata) => {
|
|
387
|
+
return (metadata.columns.filter((column) => column.type === "hstore").length > 0);
|
|
483
388
|
});
|
|
484
|
-
|
|
389
|
+
const hasCubeColumns = this.connection.entityMetadatas.some((metadata) => {
|
|
390
|
+
return (metadata.columns.filter((column) => column.type === "cube")
|
|
391
|
+
.length > 0);
|
|
392
|
+
});
|
|
393
|
+
const hasGeometryColumns = this.connection.entityMetadatas.some((metadata) => {
|
|
394
|
+
return (metadata.columns.filter((column) => this.spatialTypes.indexOf(column.type) >= 0).length > 0);
|
|
395
|
+
});
|
|
396
|
+
const hasLtreeColumns = this.connection.entityMetadatas.some((metadata) => {
|
|
397
|
+
return (metadata.columns.filter((column) => column.type === "ltree")
|
|
398
|
+
.length > 0);
|
|
399
|
+
});
|
|
400
|
+
const hasExclusionConstraints = this.connection.entityMetadatas.some((metadata) => {
|
|
401
|
+
return metadata.exclusions.length > 0;
|
|
402
|
+
});
|
|
403
|
+
return {
|
|
404
|
+
hasUuidColumns,
|
|
405
|
+
hasCitextColumns,
|
|
406
|
+
hasHstoreColumns,
|
|
407
|
+
hasCubeColumns,
|
|
408
|
+
hasGeometryColumns,
|
|
409
|
+
hasLtreeColumns,
|
|
410
|
+
hasExclusionConstraints,
|
|
411
|
+
hasExtensions: hasUuidColumns ||
|
|
412
|
+
hasCitextColumns ||
|
|
413
|
+
hasHstoreColumns ||
|
|
414
|
+
hasGeometryColumns ||
|
|
415
|
+
hasCubeColumns ||
|
|
416
|
+
hasLtreeColumns ||
|
|
417
|
+
hasExclusionConstraints,
|
|
418
|
+
};
|
|
419
|
+
}
|
|
485
420
|
/**
|
|
486
421
|
* Closes connection with database.
|
|
487
422
|
*/
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
return [4 /*yield*/, this.closePool(this.master)];
|
|
497
|
-
case 1:
|
|
498
|
-
_a.sent();
|
|
499
|
-
return [4 /*yield*/, Promise.all(this.slaves.map(function (slave) { return _this.closePool(slave); }))];
|
|
500
|
-
case 2:
|
|
501
|
-
_a.sent();
|
|
502
|
-
this.master = undefined;
|
|
503
|
-
this.slaves = [];
|
|
504
|
-
return [2 /*return*/];
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
|
-
};
|
|
423
|
+
async disconnect() {
|
|
424
|
+
if (!this.master)
|
|
425
|
+
return Promise.reject(new ConnectionIsNotSetError_1.ConnectionIsNotSetError("postgres"));
|
|
426
|
+
await this.closePool(this.master);
|
|
427
|
+
await Promise.all(this.slaves.map((slave) => this.closePool(slave)));
|
|
428
|
+
this.master = undefined;
|
|
429
|
+
this.slaves = [];
|
|
430
|
+
}
|
|
509
431
|
/**
|
|
510
432
|
* Creates a schema builder used to build and sync a schema.
|
|
511
433
|
*/
|
|
512
|
-
|
|
434
|
+
createSchemaBuilder() {
|
|
513
435
|
return new RdbmsSchemaBuilder_1.RdbmsSchemaBuilder(this.connection);
|
|
514
|
-
}
|
|
436
|
+
}
|
|
515
437
|
/**
|
|
516
438
|
* Creates a query runner used to execute database queries.
|
|
517
439
|
*/
|
|
518
|
-
|
|
440
|
+
createQueryRunner(mode) {
|
|
519
441
|
return new PostgresQueryRunner_1.PostgresQueryRunner(this, mode);
|
|
520
|
-
}
|
|
442
|
+
}
|
|
521
443
|
/**
|
|
522
444
|
* Prepares given value to a value to be persisted, based on its column type and metadata.
|
|
523
445
|
*/
|
|
524
|
-
|
|
446
|
+
preparePersistentValue(value, columnMetadata) {
|
|
525
447
|
if (columnMetadata.transformer)
|
|
526
448
|
value = ApplyValueTransformers_1.ApplyValueTransformers.transformTo(columnMetadata.transformer, value);
|
|
527
449
|
if (value === null || value === undefined)
|
|
@@ -542,7 +464,7 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
542
464
|
columnMetadata.type === "timestamp without time zone") {
|
|
543
465
|
return DateUtils_1.DateUtils.mixedDateToDate(value);
|
|
544
466
|
}
|
|
545
|
-
else if (
|
|
467
|
+
else if (["json", "jsonb", ...this.spatialTypes].indexOf(columnMetadata.type) >= 0) {
|
|
546
468
|
return JSON.stringify(value);
|
|
547
469
|
}
|
|
548
470
|
else if (columnMetadata.type === "hstore") {
|
|
@@ -551,7 +473,7 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
551
473
|
}
|
|
552
474
|
else {
|
|
553
475
|
// https://www.postgresql.org/docs/9.0/hstore.html
|
|
554
|
-
|
|
476
|
+
const quoteString = (value) => {
|
|
555
477
|
// If a string to be quoted is `null` or `undefined`, we return a literal unquoted NULL.
|
|
556
478
|
// This way, NULL values can be stored in the hstore object.
|
|
557
479
|
if (value === null || typeof value === "undefined") {
|
|
@@ -559,12 +481,10 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
559
481
|
}
|
|
560
482
|
// Convert non-null values to string since HStore only stores strings anyway.
|
|
561
483
|
// To include a double quote or a backslash in a key or value, escape it with a backslash.
|
|
562
|
-
return "
|
|
484
|
+
return `"${`${value}`.replace(/(?=["\\])/g, "\\")}"`;
|
|
563
485
|
};
|
|
564
486
|
return Object.keys(value)
|
|
565
|
-
.map(
|
|
566
|
-
return quoteString_1(key) + "=>" + quoteString_1(value[key]);
|
|
567
|
-
})
|
|
487
|
+
.map((key) => quoteString(key) + "=>" + quoteString(value[key]))
|
|
568
488
|
.join(",");
|
|
569
489
|
}
|
|
570
490
|
}
|
|
@@ -576,11 +496,11 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
576
496
|
}
|
|
577
497
|
else if (columnMetadata.type === "cube") {
|
|
578
498
|
if (columnMetadata.isArray) {
|
|
579
|
-
return
|
|
580
|
-
.map(
|
|
581
|
-
.join(",")
|
|
499
|
+
return `{${value
|
|
500
|
+
.map((cube) => `"(${cube.join(",")})"`)
|
|
501
|
+
.join(",")}}`;
|
|
582
502
|
}
|
|
583
|
-
return
|
|
503
|
+
return `(${value.join(",")})`;
|
|
584
504
|
}
|
|
585
505
|
else if (columnMetadata.type === "ltree") {
|
|
586
506
|
return value
|
|
@@ -595,11 +515,11 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
595
515
|
return "" + value;
|
|
596
516
|
}
|
|
597
517
|
return value;
|
|
598
|
-
}
|
|
518
|
+
}
|
|
599
519
|
/**
|
|
600
520
|
* Prepares given value to a value to be persisted, based on its column type or metadata.
|
|
601
521
|
*/
|
|
602
|
-
|
|
522
|
+
prepareHydratedValue(value, columnMetadata) {
|
|
603
523
|
if (value === null || value === undefined)
|
|
604
524
|
return columnMetadata.transformer
|
|
605
525
|
? ApplyValueTransformers_1.ApplyValueTransformers.transformFrom(columnMetadata.transformer, value)
|
|
@@ -622,18 +542,16 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
622
542
|
}
|
|
623
543
|
else if (columnMetadata.type === "hstore") {
|
|
624
544
|
if (columnMetadata.hstoreType === "object") {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
"".concat(value).replace(regexp, function (_, key, nullValue, stringValue) {
|
|
631
|
-
object_1[unescapeString_1(key)] = nullValue
|
|
545
|
+
const unescapeString = (str) => str.replace(/\\./g, (m) => m[1]);
|
|
546
|
+
const regexp = /"([^"\\]*(?:\\.[^"\\]*)*)"=>(?:(NULL)|"([^"\\]*(?:\\.[^"\\]*)*)")(?:,|$)/g;
|
|
547
|
+
const object = {};
|
|
548
|
+
`${value}`.replace(regexp, (_, key, nullValue, stringValue) => {
|
|
549
|
+
object[unescapeString(key)] = nullValue
|
|
632
550
|
? null
|
|
633
|
-
:
|
|
551
|
+
: unescapeString(stringValue);
|
|
634
552
|
return "";
|
|
635
553
|
});
|
|
636
|
-
value =
|
|
554
|
+
value = object;
|
|
637
555
|
}
|
|
638
556
|
}
|
|
639
557
|
else if (columnMetadata.type === "simple-array") {
|
|
@@ -651,10 +569,10 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
651
569
|
* 2. ["", undefined] <- cube of arity 0
|
|
652
570
|
* 3. [undefined, "NULL"] <- NULL
|
|
653
571
|
*/
|
|
654
|
-
|
|
655
|
-
|
|
572
|
+
const regexp = /(?:\"((?:[\d\s\.,])*)\")|(?:(NULL))/g;
|
|
573
|
+
const unparsedArrayString = value;
|
|
656
574
|
value = [];
|
|
657
|
-
|
|
575
|
+
let cube = null;
|
|
658
576
|
// Iterate through all regexp matches for cubes/null in array
|
|
659
577
|
while ((cube = regexp.exec(unparsedArrayString)) !== null) {
|
|
660
578
|
if (cube[1] !== undefined) {
|
|
@@ -678,9 +596,9 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
678
596
|
value = value
|
|
679
597
|
.substr(1, value.length - 2)
|
|
680
598
|
.split(",")
|
|
681
|
-
.map(
|
|
599
|
+
.map((val) => {
|
|
682
600
|
// replace double quotes from the beginning and from the end
|
|
683
|
-
if (val.startsWith("
|
|
601
|
+
if (val.startsWith(`"`) && val.endsWith(`"`))
|
|
684
602
|
val = val.slice(1, -1);
|
|
685
603
|
// replace double escaped backslash to single escaped e.g. \\\\ -> \\
|
|
686
604
|
val = val.replace(/(\\\\)/g, "\\");
|
|
@@ -688,7 +606,7 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
688
606
|
return val.replace(/(\\")/g, '"');
|
|
689
607
|
});
|
|
690
608
|
// convert to number if that exists in possible enum options
|
|
691
|
-
value = value.map(
|
|
609
|
+
value = value.map((val) => {
|
|
692
610
|
return !isNaN(+val) &&
|
|
693
611
|
columnMetadata.enum.indexOf(parseInt(val)) >= 0
|
|
694
612
|
? parseInt(val)
|
|
@@ -711,26 +629,25 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
711
629
|
if (columnMetadata.transformer)
|
|
712
630
|
value = ApplyValueTransformers_1.ApplyValueTransformers.transformFrom(columnMetadata.transformer, value);
|
|
713
631
|
return value;
|
|
714
|
-
}
|
|
632
|
+
}
|
|
715
633
|
/**
|
|
716
634
|
* Replaces parameters in the given sql with special escaping character
|
|
717
635
|
* and an array of parameter names to be passed to a query.
|
|
718
636
|
*/
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
var escapedParameters = Object.keys(nativeParameters).map(function (key) { return nativeParameters[key]; });
|
|
637
|
+
escapeQueryWithParameters(sql, parameters, nativeParameters) {
|
|
638
|
+
const escapedParameters = Object.keys(nativeParameters).map((key) => nativeParameters[key]);
|
|
722
639
|
if (!parameters || !Object.keys(parameters).length)
|
|
723
640
|
return [sql, escapedParameters];
|
|
724
|
-
sql = sql.replace(/:(\.\.\.)?([A-Za-z0-9_.]+)/g,
|
|
641
|
+
sql = sql.replace(/:(\.\.\.)?([A-Za-z0-9_.]+)/g, (full, isArray, key) => {
|
|
725
642
|
if (!parameters.hasOwnProperty(key)) {
|
|
726
643
|
return full;
|
|
727
644
|
}
|
|
728
|
-
|
|
645
|
+
let value = parameters[key];
|
|
729
646
|
if (isArray) {
|
|
730
647
|
return value
|
|
731
|
-
.map(
|
|
648
|
+
.map((v) => {
|
|
732
649
|
escapedParameters.push(v);
|
|
733
|
-
return
|
|
650
|
+
return this.createParameter(key, escapedParameters.length - 1);
|
|
734
651
|
})
|
|
735
652
|
.join(", ");
|
|
736
653
|
}
|
|
@@ -738,35 +655,35 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
738
655
|
return value();
|
|
739
656
|
}
|
|
740
657
|
escapedParameters.push(value);
|
|
741
|
-
return
|
|
658
|
+
return this.createParameter(key, escapedParameters.length - 1);
|
|
742
659
|
}); // todo: make replace only in value statements, otherwise problems
|
|
743
660
|
return [sql, escapedParameters];
|
|
744
|
-
}
|
|
661
|
+
}
|
|
745
662
|
/**
|
|
746
663
|
* Escapes a column name.
|
|
747
664
|
*/
|
|
748
|
-
|
|
665
|
+
escape(columnName) {
|
|
749
666
|
return '"' + columnName + '"';
|
|
750
|
-
}
|
|
667
|
+
}
|
|
751
668
|
/**
|
|
752
669
|
* Build full table name with schema name and table name.
|
|
753
670
|
* E.g. myDB.mySchema.myTable
|
|
754
671
|
*/
|
|
755
|
-
|
|
756
|
-
|
|
672
|
+
buildTableName(tableName, schema) {
|
|
673
|
+
let tablePath = [tableName];
|
|
757
674
|
if (schema) {
|
|
758
675
|
tablePath.unshift(schema);
|
|
759
676
|
}
|
|
760
677
|
return tablePath.join(".");
|
|
761
|
-
}
|
|
678
|
+
}
|
|
762
679
|
/**
|
|
763
680
|
* Parse a target table name or other types and return a normalized table definition.
|
|
764
681
|
*/
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
682
|
+
parseTableName(target) {
|
|
683
|
+
const driverDatabase = this.database;
|
|
684
|
+
const driverSchema = this.schema;
|
|
768
685
|
if (InstanceChecker_1.InstanceChecker.isTable(target) || InstanceChecker_1.InstanceChecker.isView(target)) {
|
|
769
|
-
|
|
686
|
+
const parsed = this.parseTableName(target.name);
|
|
770
687
|
return {
|
|
771
688
|
database: target.database || parsed.database || driverDatabase,
|
|
772
689
|
schema: target.schema || parsed.schema || driverSchema,
|
|
@@ -774,7 +691,7 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
774
691
|
};
|
|
775
692
|
}
|
|
776
693
|
if (InstanceChecker_1.InstanceChecker.isTableForeignKey(target)) {
|
|
777
|
-
|
|
694
|
+
const parsed = this.parseTableName(target.referencedTableName);
|
|
778
695
|
return {
|
|
779
696
|
database: target.referencedDatabase ||
|
|
780
697
|
parsed.database ||
|
|
@@ -791,17 +708,17 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
791
708
|
tableName: target.tableName,
|
|
792
709
|
};
|
|
793
710
|
}
|
|
794
|
-
|
|
711
|
+
const parts = target.split(".");
|
|
795
712
|
return {
|
|
796
713
|
database: driverDatabase,
|
|
797
714
|
schema: (parts.length > 1 ? parts[0] : undefined) || driverSchema,
|
|
798
715
|
tableName: parts.length > 1 ? parts[1] : parts[0],
|
|
799
716
|
};
|
|
800
|
-
}
|
|
717
|
+
}
|
|
801
718
|
/**
|
|
802
719
|
* Creates a database type from a given column metadata.
|
|
803
720
|
*/
|
|
804
|
-
|
|
721
|
+
normalizeType(column) {
|
|
805
722
|
if (column.type === Number ||
|
|
806
723
|
column.type === "int" ||
|
|
807
724
|
column.type === "int4") {
|
|
@@ -858,74 +775,74 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
858
775
|
else {
|
|
859
776
|
return column.type || "";
|
|
860
777
|
}
|
|
861
|
-
}
|
|
778
|
+
}
|
|
862
779
|
/**
|
|
863
780
|
* Normalizes "default" value of the column.
|
|
864
781
|
*/
|
|
865
|
-
|
|
866
|
-
|
|
782
|
+
normalizeDefault(columnMetadata) {
|
|
783
|
+
const defaultValue = columnMetadata.default;
|
|
867
784
|
if (defaultValue === null) {
|
|
868
785
|
return undefined;
|
|
869
786
|
}
|
|
870
787
|
if (columnMetadata.isArray && Array.isArray(defaultValue)) {
|
|
871
|
-
return
|
|
872
|
-
.map(
|
|
873
|
-
.join(",")
|
|
788
|
+
return `'{${defaultValue
|
|
789
|
+
.map((val) => `${val}`)
|
|
790
|
+
.join(",")}}'`;
|
|
874
791
|
}
|
|
875
792
|
if ((columnMetadata.type === "enum" ||
|
|
876
793
|
columnMetadata.type === "simple-enum" ||
|
|
877
794
|
typeof defaultValue === "number" ||
|
|
878
795
|
typeof defaultValue === "string") &&
|
|
879
796
|
defaultValue !== undefined) {
|
|
880
|
-
return
|
|
797
|
+
return `'${defaultValue}'`;
|
|
881
798
|
}
|
|
882
799
|
if (typeof defaultValue === "boolean") {
|
|
883
800
|
return defaultValue ? "true" : "false";
|
|
884
801
|
}
|
|
885
802
|
if (typeof defaultValue === "function") {
|
|
886
|
-
|
|
803
|
+
const value = defaultValue();
|
|
887
804
|
return this.normalizeDatetimeFunction(value);
|
|
888
805
|
}
|
|
889
806
|
if (typeof defaultValue === "object") {
|
|
890
|
-
return
|
|
807
|
+
return `'${JSON.stringify(defaultValue)}'`;
|
|
891
808
|
}
|
|
892
809
|
if (defaultValue === undefined) {
|
|
893
810
|
return undefined;
|
|
894
811
|
}
|
|
895
|
-
return
|
|
896
|
-
}
|
|
812
|
+
return `${defaultValue}`;
|
|
813
|
+
}
|
|
897
814
|
/**
|
|
898
815
|
* Compares "default" value of the column.
|
|
899
816
|
* Postgres sorts json values before it is saved, so in that case a deep comparison has to be performed to see if has changed.
|
|
900
817
|
*/
|
|
901
|
-
|
|
818
|
+
defaultEqual(columnMetadata, tableColumn) {
|
|
902
819
|
if (["json", "jsonb"].includes(columnMetadata.type) &&
|
|
903
820
|
!["function", "undefined"].includes(typeof columnMetadata.default)) {
|
|
904
|
-
|
|
821
|
+
const tableColumnDefault = typeof tableColumn.default === "string"
|
|
905
822
|
? JSON.parse(tableColumn.default.substring(1, tableColumn.default.length - 1))
|
|
906
823
|
: tableColumn.default;
|
|
907
824
|
return OrmUtils_1.OrmUtils.deepCompare(columnMetadata.default, tableColumnDefault);
|
|
908
825
|
}
|
|
909
|
-
|
|
826
|
+
const columnDefault = this.lowerDefaultValueIfNecessary(this.normalizeDefault(columnMetadata));
|
|
910
827
|
return columnDefault === tableColumn.default;
|
|
911
|
-
}
|
|
828
|
+
}
|
|
912
829
|
/**
|
|
913
830
|
* Normalizes "isUnique" value of the column.
|
|
914
831
|
*/
|
|
915
|
-
|
|
916
|
-
return column.entityMetadata.uniques.some(
|
|
917
|
-
}
|
|
832
|
+
normalizeIsUnique(column) {
|
|
833
|
+
return column.entityMetadata.uniques.some((uq) => uq.columns.length === 1 && uq.columns[0] === column);
|
|
834
|
+
}
|
|
918
835
|
/**
|
|
919
836
|
* Returns default column lengths, which is required on column creation.
|
|
920
837
|
*/
|
|
921
|
-
|
|
838
|
+
getColumnLength(column) {
|
|
922
839
|
return column.length ? column.length.toString() : "";
|
|
923
|
-
}
|
|
840
|
+
}
|
|
924
841
|
/**
|
|
925
842
|
* Creates column type definition including length, precision and scale
|
|
926
843
|
*/
|
|
927
|
-
|
|
928
|
-
|
|
844
|
+
createFullType(column) {
|
|
845
|
+
let type = column.type;
|
|
929
846
|
if (column.length) {
|
|
930
847
|
type += "(" + column.length + ")";
|
|
931
848
|
}
|
|
@@ -971,10 +888,10 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
971
888
|
}
|
|
972
889
|
else if (this.spatialTypes.indexOf(column.type) >= 0) {
|
|
973
890
|
if (column.spatialFeatureType != null && column.srid != null) {
|
|
974
|
-
type =
|
|
891
|
+
type = `${column.type}(${column.spatialFeatureType},${column.srid})`;
|
|
975
892
|
}
|
|
976
893
|
else if (column.spatialFeatureType != null) {
|
|
977
|
-
type =
|
|
894
|
+
type = `${column.type}(${column.spatialFeatureType})`;
|
|
978
895
|
}
|
|
979
896
|
else {
|
|
980
897
|
type = column.type;
|
|
@@ -983,95 +900,83 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
983
900
|
if (column.isArray)
|
|
984
901
|
type += " array";
|
|
985
902
|
return type;
|
|
986
|
-
}
|
|
903
|
+
}
|
|
987
904
|
/**
|
|
988
905
|
* Obtains a new database connection to a master server.
|
|
989
906
|
* Used for replication.
|
|
990
907
|
* If replication is not setup then returns default connection's database connection.
|
|
991
908
|
*/
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
return [2 /*return*/, new Promise(function (ok, fail) {
|
|
1000
|
-
_this.master.connect(function (err, connection, release) {
|
|
1001
|
-
err ? fail(err) : ok([connection, release]);
|
|
1002
|
-
});
|
|
1003
|
-
})];
|
|
909
|
+
async obtainMasterConnection() {
|
|
910
|
+
if (!this.master) {
|
|
911
|
+
throw new error_1.TypeORMError("Driver not Connected");
|
|
912
|
+
}
|
|
913
|
+
return new Promise((ok, fail) => {
|
|
914
|
+
this.master.connect((err, connection, release) => {
|
|
915
|
+
err ? fail(err) : ok([connection, release]);
|
|
1004
916
|
});
|
|
1005
917
|
});
|
|
1006
|
-
}
|
|
918
|
+
}
|
|
1007
919
|
/**
|
|
1008
920
|
* Obtains a new database connection to a slave server.
|
|
1009
921
|
* Used for replication.
|
|
1010
922
|
* If replication is not setup then returns master (default) connection's database connection.
|
|
1011
923
|
*/
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
random = Math.floor(Math.random() * this.slaves.length);
|
|
1021
|
-
return [2 /*return*/, new Promise(function (ok, fail) {
|
|
1022
|
-
_this.slaves[random].connect(function (err, connection, release) {
|
|
1023
|
-
err ? fail(err) : ok([connection, release]);
|
|
1024
|
-
});
|
|
1025
|
-
})];
|
|
924
|
+
async obtainSlaveConnection() {
|
|
925
|
+
if (!this.slaves.length) {
|
|
926
|
+
return this.obtainMasterConnection();
|
|
927
|
+
}
|
|
928
|
+
const random = Math.floor(Math.random() * this.slaves.length);
|
|
929
|
+
return new Promise((ok, fail) => {
|
|
930
|
+
this.slaves[random].connect((err, connection, release) => {
|
|
931
|
+
err ? fail(err) : ok([connection, release]);
|
|
1026
932
|
});
|
|
1027
933
|
});
|
|
1028
|
-
}
|
|
934
|
+
}
|
|
1029
935
|
/**
|
|
1030
936
|
* Creates generated map of values generated or returned by database after INSERT query.
|
|
1031
937
|
*
|
|
1032
938
|
* todo: slow. optimize Object.keys(), OrmUtils.mergeDeep and column.createValueMap parts
|
|
1033
939
|
*/
|
|
1034
|
-
|
|
940
|
+
createGeneratedMap(metadata, insertResult) {
|
|
1035
941
|
if (!insertResult)
|
|
1036
942
|
return undefined;
|
|
1037
|
-
return Object.keys(insertResult).reduce(
|
|
1038
|
-
|
|
943
|
+
return Object.keys(insertResult).reduce((map, key) => {
|
|
944
|
+
const column = metadata.findColumnWithDatabaseName(key);
|
|
1039
945
|
if (column) {
|
|
1040
946
|
OrmUtils_1.OrmUtils.mergeDeep(map, column.createValueMap(insertResult[key]));
|
|
1041
947
|
// OrmUtils.mergeDeep(map, column.createValueMap(this.prepareHydratedValue(insertResult[key], column))); // TODO: probably should be like there, but fails on enums, fix later
|
|
1042
948
|
}
|
|
1043
949
|
return map;
|
|
1044
950
|
}, {});
|
|
1045
|
-
}
|
|
951
|
+
}
|
|
1046
952
|
/**
|
|
1047
953
|
* Differentiate columns of this table and columns from the given column metadatas columns
|
|
1048
954
|
* and returns only changed.
|
|
1049
955
|
*/
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
var tableColumn = tableColumns.find(function (c) { return c.name === columnMetadata.databaseName; });
|
|
956
|
+
findChangedColumns(tableColumns, columnMetadatas) {
|
|
957
|
+
return columnMetadatas.filter((columnMetadata) => {
|
|
958
|
+
const tableColumn = tableColumns.find((c) => c.name === columnMetadata.databaseName);
|
|
1054
959
|
if (!tableColumn)
|
|
1055
960
|
return false; // we don't need new columns, we only need exist and changed
|
|
1056
|
-
|
|
1057
|
-
tableColumn.type !==
|
|
961
|
+
const isColumnChanged = tableColumn.name !== columnMetadata.databaseName ||
|
|
962
|
+
tableColumn.type !== this.normalizeType(columnMetadata) ||
|
|
1058
963
|
tableColumn.length !== columnMetadata.length ||
|
|
1059
964
|
tableColumn.isArray !== columnMetadata.isArray ||
|
|
1060
965
|
tableColumn.precision !== columnMetadata.precision ||
|
|
1061
966
|
(columnMetadata.scale !== undefined &&
|
|
1062
967
|
tableColumn.scale !== columnMetadata.scale) ||
|
|
1063
968
|
tableColumn.comment !==
|
|
1064
|
-
|
|
969
|
+
this.escapeComment(columnMetadata.comment) ||
|
|
1065
970
|
(!tableColumn.isGenerated &&
|
|
1066
|
-
!
|
|
971
|
+
!this.defaultEqual(columnMetadata, tableColumn)) || // we included check for generated here, because generated columns already can have default values
|
|
1067
972
|
tableColumn.isPrimary !== columnMetadata.isPrimary ||
|
|
1068
973
|
tableColumn.isNullable !== columnMetadata.isNullable ||
|
|
1069
974
|
tableColumn.isUnique !==
|
|
1070
|
-
|
|
975
|
+
this.normalizeIsUnique(columnMetadata) ||
|
|
1071
976
|
tableColumn.enumName !== columnMetadata.enumName ||
|
|
1072
977
|
(tableColumn.enum &&
|
|
1073
978
|
columnMetadata.enum &&
|
|
1074
|
-
!OrmUtils_1.OrmUtils.isArraysEqual(tableColumn.enum, columnMetadata.enum.map(
|
|
979
|
+
!OrmUtils_1.OrmUtils.isArraysEqual(tableColumn.enum, columnMetadata.enum.map((val) => val + ""))) || // enums in postgres are always strings
|
|
1075
980
|
tableColumn.isGenerated !== columnMetadata.isGenerated ||
|
|
1076
981
|
(tableColumn.spatialFeatureType || "").toLowerCase() !==
|
|
1077
982
|
(columnMetadata.spatialFeatureType || "").toLowerCase() ||
|
|
@@ -1179,79 +1084,75 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
1179
1084
|
// }
|
|
1180
1085
|
return isColumnChanged;
|
|
1181
1086
|
});
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1087
|
+
}
|
|
1088
|
+
lowerDefaultValueIfNecessary(value) {
|
|
1184
1089
|
// Postgres saves function calls in default value as lowercase #2733
|
|
1185
1090
|
if (!value) {
|
|
1186
1091
|
return value;
|
|
1187
1092
|
}
|
|
1188
1093
|
return value
|
|
1189
|
-
.split(
|
|
1190
|
-
.map(
|
|
1094
|
+
.split(`'`)
|
|
1095
|
+
.map((v, i) => {
|
|
1191
1096
|
return i % 2 === 1 ? v : v.toLowerCase();
|
|
1192
1097
|
})
|
|
1193
|
-
.join(
|
|
1194
|
-
}
|
|
1098
|
+
.join(`'`);
|
|
1099
|
+
}
|
|
1195
1100
|
/**
|
|
1196
1101
|
* Returns true if driver supports RETURNING / OUTPUT statement.
|
|
1197
1102
|
*/
|
|
1198
|
-
|
|
1103
|
+
isReturningSqlSupported() {
|
|
1199
1104
|
return true;
|
|
1200
|
-
}
|
|
1105
|
+
}
|
|
1201
1106
|
/**
|
|
1202
1107
|
* Returns true if driver supports uuid values generation on its own.
|
|
1203
1108
|
*/
|
|
1204
|
-
|
|
1109
|
+
isUUIDGenerationSupported() {
|
|
1205
1110
|
return true;
|
|
1206
|
-
}
|
|
1111
|
+
}
|
|
1207
1112
|
/**
|
|
1208
1113
|
* Returns true if driver supports fulltext indices.
|
|
1209
1114
|
*/
|
|
1210
|
-
|
|
1115
|
+
isFullTextColumnTypeSupported() {
|
|
1211
1116
|
return false;
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
},
|
|
1219
|
-
enumerable: false,
|
|
1220
|
-
configurable: true
|
|
1221
|
-
});
|
|
1117
|
+
}
|
|
1118
|
+
get uuidGenerator() {
|
|
1119
|
+
return this.options.uuidExtension === "pgcrypto"
|
|
1120
|
+
? "gen_random_uuid()"
|
|
1121
|
+
: "uuid_generate_v4()";
|
|
1122
|
+
}
|
|
1222
1123
|
/**
|
|
1223
1124
|
* Creates an escaped parameter.
|
|
1224
1125
|
*/
|
|
1225
|
-
|
|
1126
|
+
createParameter(parameterName, index) {
|
|
1226
1127
|
return "$" + (index + 1);
|
|
1227
|
-
}
|
|
1128
|
+
}
|
|
1228
1129
|
// -------------------------------------------------------------------------
|
|
1229
1130
|
// Public Methods
|
|
1230
1131
|
// -------------------------------------------------------------------------
|
|
1231
1132
|
/**
|
|
1232
1133
|
* Loads postgres query stream package.
|
|
1233
1134
|
*/
|
|
1234
|
-
|
|
1135
|
+
loadStreamDependency() {
|
|
1235
1136
|
try {
|
|
1236
1137
|
return PlatformTools_1.PlatformTools.load("pg-query-stream");
|
|
1237
1138
|
}
|
|
1238
1139
|
catch (e) {
|
|
1239
1140
|
// todo: better error for browser env
|
|
1240
|
-
throw new error_1.TypeORMError(
|
|
1141
|
+
throw new error_1.TypeORMError(`To use streams you should install pg-query-stream package. Please run npm i pg-query-stream --save command.`);
|
|
1241
1142
|
}
|
|
1242
|
-
}
|
|
1143
|
+
}
|
|
1243
1144
|
// -------------------------------------------------------------------------
|
|
1244
1145
|
// Protected Methods
|
|
1245
1146
|
// -------------------------------------------------------------------------
|
|
1246
1147
|
/**
|
|
1247
1148
|
* If driver dependency is not given explicitly, then try to load it via "require".
|
|
1248
1149
|
*/
|
|
1249
|
-
|
|
1150
|
+
loadDependencies() {
|
|
1250
1151
|
try {
|
|
1251
|
-
|
|
1152
|
+
const postgres = this.options.driver || PlatformTools_1.PlatformTools.load("pg");
|
|
1252
1153
|
this.postgres = postgres;
|
|
1253
1154
|
try {
|
|
1254
|
-
|
|
1155
|
+
const pgNative = this.options.nativeDriver || PlatformTools_1.PlatformTools.load("pg-native");
|
|
1255
1156
|
if (pgNative && this.postgres.native)
|
|
1256
1157
|
this.postgres = this.postgres.native;
|
|
1257
1158
|
}
|
|
@@ -1261,108 +1162,92 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
1261
1162
|
// todo: better error for browser env
|
|
1262
1163
|
throw new DriverPackageNotInstalledError_1.DriverPackageNotInstalledError("Postgres", "pg");
|
|
1263
1164
|
}
|
|
1264
|
-
}
|
|
1165
|
+
}
|
|
1265
1166
|
/**
|
|
1266
1167
|
* Creates a new connection pool for a given database credentials.
|
|
1267
1168
|
*/
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1169
|
+
async createPool(options, credentials) {
|
|
1170
|
+
credentials = Object.assign({}, credentials);
|
|
1171
|
+
// build connection options for the driver
|
|
1172
|
+
// See: https://github.com/brianc/node-postgres/tree/master/packages/pg-pool#create
|
|
1173
|
+
const connectionOptions = Object.assign({}, {
|
|
1174
|
+
connectionString: credentials.url,
|
|
1175
|
+
host: credentials.host,
|
|
1176
|
+
user: credentials.username,
|
|
1177
|
+
password: credentials.password,
|
|
1178
|
+
database: credentials.database,
|
|
1179
|
+
port: credentials.port,
|
|
1180
|
+
ssl: credentials.ssl,
|
|
1181
|
+
connectionTimeoutMillis: options.connectTimeoutMS,
|
|
1182
|
+
application_name: options.applicationName,
|
|
1183
|
+
max: options.poolSize,
|
|
1184
|
+
}, options.extra || {});
|
|
1185
|
+
// create a connection pool
|
|
1186
|
+
const pool = new this.postgres.Pool(connectionOptions);
|
|
1187
|
+
const { logger } = this.connection;
|
|
1188
|
+
const poolErrorHandler = options.poolErrorHandler ||
|
|
1189
|
+
((error) => logger.log("warn", `Postgres pool raised an error. ${error}`));
|
|
1190
|
+
/*
|
|
1191
|
+
Attaching an error handler to pool errors is essential, as, otherwise, errors raised will go unhandled and
|
|
1192
|
+
cause the hosting app to crash.
|
|
1193
|
+
*/
|
|
1194
|
+
pool.on("error", poolErrorHandler);
|
|
1195
|
+
return new Promise((ok, fail) => {
|
|
1196
|
+
pool.connect((err, connection, release) => {
|
|
1197
|
+
if (err)
|
|
1198
|
+
return fail(err);
|
|
1199
|
+
if (options.logNotifications) {
|
|
1200
|
+
connection.on("notice", (msg) => {
|
|
1201
|
+
msg && this.connection.logger.log("info", msg.message);
|
|
1291
1202
|
});
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
if (err)
|
|
1300
|
-
return fail(err);
|
|
1301
|
-
if (options.logNotifications) {
|
|
1302
|
-
connection.on("notice", function (msg) {
|
|
1303
|
-
msg && _this.connection.logger.log("info", msg.message);
|
|
1304
|
-
});
|
|
1305
|
-
connection.on("notification", function (msg) {
|
|
1306
|
-
msg &&
|
|
1307
|
-
_this.connection.logger.log("info", "Received NOTIFY on channel ".concat(msg.channel, ": ").concat(msg.payload, "."));
|
|
1308
|
-
});
|
|
1309
|
-
}
|
|
1310
|
-
release();
|
|
1311
|
-
ok(pool);
|
|
1312
|
-
});
|
|
1313
|
-
})];
|
|
1203
|
+
connection.on("notification", (msg) => {
|
|
1204
|
+
msg &&
|
|
1205
|
+
this.connection.logger.log("info", `Received NOTIFY on channel ${msg.channel}: ${msg.payload}.`);
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
release();
|
|
1209
|
+
ok(pool);
|
|
1314
1210
|
});
|
|
1315
1211
|
});
|
|
1316
|
-
}
|
|
1212
|
+
}
|
|
1317
1213
|
/**
|
|
1318
1214
|
* Closes connection pool.
|
|
1319
1215
|
*/
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
return [4 /*yield*/, this.connectedQueryRunners[0].release()];
|
|
1327
|
-
case 1:
|
|
1328
|
-
_a.sent();
|
|
1329
|
-
return [3 /*break*/, 0];
|
|
1330
|
-
case 2: return [2 /*return*/, new Promise(function (ok, fail) {
|
|
1331
|
-
pool.end(function (err) { return (err ? fail(err) : ok()); });
|
|
1332
|
-
})];
|
|
1333
|
-
}
|
|
1334
|
-
});
|
|
1216
|
+
async closePool(pool) {
|
|
1217
|
+
while (this.connectedQueryRunners.length) {
|
|
1218
|
+
await this.connectedQueryRunners[0].release();
|
|
1219
|
+
}
|
|
1220
|
+
return new Promise((ok, fail) => {
|
|
1221
|
+
pool.end((err) => (err ? fail(err) : ok()));
|
|
1335
1222
|
});
|
|
1336
|
-
}
|
|
1223
|
+
}
|
|
1337
1224
|
/**
|
|
1338
1225
|
* Executes given query.
|
|
1339
1226
|
*/
|
|
1340
|
-
|
|
1227
|
+
executeQuery(connection, query) {
|
|
1341
1228
|
this.connection.logger.logQuery(query);
|
|
1342
|
-
return new Promise(
|
|
1343
|
-
connection.query(query,
|
|
1344
|
-
return err ? fail(err) : ok(result);
|
|
1345
|
-
});
|
|
1229
|
+
return new Promise((ok, fail) => {
|
|
1230
|
+
connection.query(query, (err, result) => err ? fail(err) : ok(result));
|
|
1346
1231
|
});
|
|
1347
|
-
}
|
|
1232
|
+
}
|
|
1348
1233
|
/**
|
|
1349
1234
|
* If parameter is a datetime function, e.g. "CURRENT_TIMESTAMP", normalizes it.
|
|
1350
1235
|
* Otherwise returns original input.
|
|
1351
1236
|
*/
|
|
1352
|
-
|
|
1237
|
+
normalizeDatetimeFunction(value) {
|
|
1353
1238
|
// check if input is datetime function
|
|
1354
|
-
|
|
1355
|
-
|
|
1239
|
+
const upperCaseValue = value.toUpperCase();
|
|
1240
|
+
const isDatetimeFunction = upperCaseValue.indexOf("CURRENT_TIMESTAMP") !== -1 ||
|
|
1356
1241
|
upperCaseValue.indexOf("CURRENT_DATE") !== -1 ||
|
|
1357
1242
|
upperCaseValue.indexOf("CURRENT_TIME") !== -1 ||
|
|
1358
1243
|
upperCaseValue.indexOf("LOCALTIMESTAMP") !== -1 ||
|
|
1359
1244
|
upperCaseValue.indexOf("LOCALTIME") !== -1;
|
|
1360
1245
|
if (isDatetimeFunction) {
|
|
1361
1246
|
// extract precision, e.g. "(3)"
|
|
1362
|
-
|
|
1247
|
+
const precision = value.match(/\(\d+\)/);
|
|
1363
1248
|
if (upperCaseValue.indexOf("CURRENT_TIMESTAMP") !== -1) {
|
|
1364
1249
|
return precision
|
|
1365
|
-
?
|
|
1250
|
+
? `('now'::text)::timestamp${precision[0]} with time zone`
|
|
1366
1251
|
: "now()";
|
|
1367
1252
|
}
|
|
1368
1253
|
else if (upperCaseValue === "CURRENT_DATE") {
|
|
@@ -1370,33 +1255,32 @@ var PostgresDriver = /** @class */ (function () {
|
|
|
1370
1255
|
}
|
|
1371
1256
|
else if (upperCaseValue.indexOf("CURRENT_TIME") !== -1) {
|
|
1372
1257
|
return precision
|
|
1373
|
-
?
|
|
1258
|
+
? `('now'::text)::time${precision[0]} with time zone`
|
|
1374
1259
|
: "('now'::text)::time with time zone";
|
|
1375
1260
|
}
|
|
1376
1261
|
else if (upperCaseValue.indexOf("LOCALTIMESTAMP") !== -1) {
|
|
1377
1262
|
return precision
|
|
1378
|
-
?
|
|
1263
|
+
? `('now'::text)::timestamp${precision[0]} without time zone`
|
|
1379
1264
|
: "('now'::text)::timestamp without time zone";
|
|
1380
1265
|
}
|
|
1381
1266
|
else if (upperCaseValue.indexOf("LOCALTIME") !== -1) {
|
|
1382
1267
|
return precision
|
|
1383
|
-
?
|
|
1268
|
+
? `('now'::text)::time${precision[0]} without time zone`
|
|
1384
1269
|
: "('now'::text)::time without time zone";
|
|
1385
1270
|
}
|
|
1386
1271
|
}
|
|
1387
1272
|
return value;
|
|
1388
|
-
}
|
|
1273
|
+
}
|
|
1389
1274
|
/**
|
|
1390
1275
|
* Escapes a given comment.
|
|
1391
1276
|
*/
|
|
1392
|
-
|
|
1277
|
+
escapeComment(comment) {
|
|
1393
1278
|
if (!comment)
|
|
1394
1279
|
return comment;
|
|
1395
1280
|
comment = comment.replace(/\u0000/g, ""); // Null bytes aren't allowed in comments
|
|
1396
1281
|
return comment;
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
}());
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1400
1284
|
exports.PostgresDriver = PostgresDriver;
|
|
1401
1285
|
//#endregion
|
|
1402
1286
|
//# sourceMappingURL=PostgresDriver.js.map
|