typeorm 0.3.2-dev.ce5973c → 0.3.3-dev.a641c5d

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.
Files changed (57) hide show
  1. package/README.md +470 -525
  2. package/browser/cli-ts-node-commonjs.d.ts +2 -0
  3. package/browser/cli-ts-node-commonjs.js +4 -0
  4. package/browser/cli-ts-node-commonjs.js.map +1 -0
  5. package/browser/cli-ts-node-esm.d.ts +2 -0
  6. package/browser/cli-ts-node-esm.js +4 -0
  7. package/browser/cli-ts-node-esm.js.map +1 -0
  8. package/browser/data-source/DataSource.js +3 -4
  9. package/browser/data-source/DataSource.js.map +1 -1
  10. package/browser/driver/mysql/MysqlConnectionOptions.d.ts +5 -0
  11. package/browser/driver/mysql/MysqlConnectionOptions.js.map +1 -1
  12. package/browser/driver/mysql/MysqlDriver.js +9 -4
  13. package/browser/driver/mysql/MysqlDriver.js.map +1 -1
  14. package/browser/driver/postgres/PostgresDriver.js +1 -1
  15. package/browser/driver/postgres/PostgresDriver.js.map +1 -1
  16. package/browser/repository/BaseEntity.d.ts +2 -2
  17. package/browser/repository/BaseEntity.js.map +1 -1
  18. package/cli-ts-node-commonjs.d.ts +2 -0
  19. package/cli-ts-node-commonjs.js +6 -0
  20. package/cli-ts-node-commonjs.js.map +1 -0
  21. package/cli-ts-node-esm.d.ts +2 -0
  22. package/cli-ts-node-esm.js +6 -0
  23. package/cli-ts-node-esm.js.map +1 -0
  24. package/commands/CacheClearCommand.js +1 -1
  25. package/commands/CacheClearCommand.js.map +1 -1
  26. package/commands/CommandUtils.d.ts +1 -1
  27. package/commands/CommandUtils.js +4 -2
  28. package/commands/CommandUtils.js.map +1 -1
  29. package/commands/InitCommand.js +2 -2
  30. package/commands/InitCommand.js.map +1 -1
  31. package/commands/MigrationGenerateCommand.js +1 -1
  32. package/commands/MigrationGenerateCommand.js.map +1 -1
  33. package/commands/MigrationRevertCommand.js +1 -1
  34. package/commands/MigrationRevertCommand.js.map +1 -1
  35. package/commands/MigrationRunCommand.js +1 -1
  36. package/commands/MigrationRunCommand.js.map +1 -1
  37. package/commands/MigrationShowCommand.js +1 -1
  38. package/commands/MigrationShowCommand.js.map +1 -1
  39. package/commands/QueryCommand.js +1 -1
  40. package/commands/QueryCommand.js.map +1 -1
  41. package/commands/SchemaDropCommand.js +1 -1
  42. package/commands/SchemaDropCommand.js.map +1 -1
  43. package/commands/SchemaLogCommand.js +1 -1
  44. package/commands/SchemaLogCommand.js.map +1 -1
  45. package/commands/SchemaSyncCommand.js +1 -1
  46. package/commands/SchemaSyncCommand.js.map +1 -1
  47. package/data-source/DataSource.js +3 -4
  48. package/data-source/DataSource.js.map +1 -1
  49. package/driver/mysql/MysqlConnectionOptions.d.ts +5 -0
  50. package/driver/mysql/MysqlConnectionOptions.js.map +1 -1
  51. package/driver/mysql/MysqlDriver.js +9 -4
  52. package/driver/mysql/MysqlDriver.js.map +1 -1
  53. package/driver/postgres/PostgresDriver.js +1 -1
  54. package/driver/postgres/PostgresDriver.js.map +1 -1
  55. package/package.json +1 -1
  56. package/repository/BaseEntity.d.ts +2 -2
  57. package/repository/BaseEntity.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/driver/postgres/PostgresDriver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAA;AAG3F,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AAE5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAM9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAGtD,OA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BAA2B,SAAS,CAAC,CAAC,CAAC,oBAAoB;oBAC7D,CAAC,CAAC,4CAA4C,CAAA;aACrD;iBAAM,IAAI,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE;gBACnD,OAAO,SAAS;oBACZ,CAAC,CAAC,sBAAsB,SAAS,CAAC,CAAC,CAAC,oBAAoB;oBACxD,CAAC,CAAC,uCAAuC,CAAA;aAChD;SACJ;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,OAAgB;QACpC,IAAI,CAAC,OAAO;YAAE,OAAO,OAAO,CAAA;QAE5B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA,CAAC,wCAAwC;QAEjF,OAAO,OAAO,CAAA;IAClB,CAAC;CACJ","file":"PostgresDriver.js","sourcesContent":["import { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { ConnectionIsNotSetError } from \"../../error/ConnectionIsNotSetError\"\nimport { DriverPackageNotInstalledError } from \"../../error/DriverPackageNotInstalledError\"\nimport { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { RdbmsSchemaBuilder } from \"../../schema-builder/RdbmsSchemaBuilder\"\nimport { TableColumn } from \"../../schema-builder/table/TableColumn\"\nimport { ApplyValueTransformers } from \"../../util/ApplyValueTransformers\"\nimport { DateUtils } from \"../../util/DateUtils\"\nimport { OrmUtils } from \"../../util/OrmUtils\"\nimport { Driver } from \"../Driver\"\nimport { ColumnType } from \"../types/ColumnTypes\"\nimport { DataTypeDefaults } from \"../types/DataTypeDefaults\"\nimport { MappedColumnTypes } from \"../types/MappedColumnTypes\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { VersionUtils } from \"../../util/VersionUtils\"\nimport { PostgresConnectionCredentialsOptions } from \"./PostgresConnectionCredentialsOptions\"\nimport { PostgresConnectionOptions } from \"./PostgresConnectionOptions\"\nimport { PostgresQueryRunner } from \"./PostgresQueryRunner\"\nimport { DriverUtils } from \"../DriverUtils\"\nimport { TypeORMError } from \"../../error\"\nimport { Table } from \"../../schema-builder/table/Table\"\nimport { View } from \"../../schema-builder/view/View\"\nimport { TableForeignKey } from \"../../schema-builder/table/TableForeignKey\"\nimport { InstanceChecker } from \"../../util/InstanceChecker\"\n\n/**\n * Organizes communication with PostgreSQL DBMS.\n */\nexport class PostgresDriver implements Driver {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by driver.\n */\n connection: DataSource\n\n /**\n * Postgres underlying library.\n */\n postgres: any\n\n /**\n * Pool for master database.\n */\n master: any\n\n /**\n * Pool for slave databases.\n * Used in replication.\n */\n slaves: any[] = []\n\n /**\n * We store all created query runners because we need to release them.\n */\n connectedQueryRunners: QueryRunner[] = []\n\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection options.\n */\n options: PostgresConnectionOptions\n\n /**\n * Database name used to perform all write queries.\n */\n database?: string\n\n /**\n * Schema name used to perform all write queries.\n */\n schema?: string\n\n /**\n * Schema that's used internally by Postgres for object resolution.\n *\n * Because we never set this we have to track it in separately from the `schema` so\n * we know when we have to specify the full schema or not.\n *\n * In most cases this will be `public`.\n */\n searchSchema?: string\n\n /**\n * Indicates if replication is enabled.\n */\n isReplicated: boolean = false\n\n /**\n * Indicates if tree tables are supported by this driver.\n */\n treeSupport = true\n\n /**\n * Represent transaction support by this driver\n */\n transactionSupport = \"nested\" as const\n\n /**\n * Gets list of supported column data types by a driver.\n *\n * @see https://www.tutorialspoint.com/postgresql/postgresql_data_types.htm\n * @see https://www.postgresql.org/docs/9.2/static/datatype.html\n */\n supportedDataTypes: ColumnType[] = [\n \"int\",\n \"int2\",\n \"int4\",\n \"int8\",\n \"smallint\",\n \"integer\",\n \"bigint\",\n \"decimal\",\n \"numeric\",\n \"real\",\n \"float\",\n \"float4\",\n \"float8\",\n \"double precision\",\n \"money\",\n \"character varying\",\n \"varchar\",\n \"character\",\n \"char\",\n \"text\",\n \"citext\",\n \"hstore\",\n \"bytea\",\n \"bit\",\n \"varbit\",\n \"bit varying\",\n \"timetz\",\n \"timestamptz\",\n \"timestamp\",\n \"timestamp without time zone\",\n \"timestamp with time zone\",\n \"date\",\n \"time\",\n \"time without time zone\",\n \"time with time zone\",\n \"interval\",\n \"bool\",\n \"boolean\",\n \"enum\",\n \"point\",\n \"line\",\n \"lseg\",\n \"box\",\n \"path\",\n \"polygon\",\n \"circle\",\n \"cidr\",\n \"inet\",\n \"macaddr\",\n \"tsvector\",\n \"tsquery\",\n \"uuid\",\n \"xml\",\n \"json\",\n \"jsonb\",\n \"int4range\",\n \"int8range\",\n \"numrange\",\n \"tsrange\",\n \"tstzrange\",\n \"daterange\",\n \"geometry\",\n \"geography\",\n \"cube\",\n \"ltree\",\n ]\n\n /**\n * Returns type of upsert supported by driver if any\n */\n readonly supportedUpsertType = \"on-conflict-do-update\"\n\n /**\n * Gets list of spatial column data types.\n */\n spatialTypes: ColumnType[] = [\"geometry\", \"geography\"]\n\n /**\n * Gets list of column data types that support length by a driver.\n */\n withLengthColumnTypes: ColumnType[] = [\n \"character varying\",\n \"varchar\",\n \"character\",\n \"char\",\n \"bit\",\n \"varbit\",\n \"bit varying\",\n ]\n\n /**\n * Gets list of column data types that support precision by a driver.\n */\n withPrecisionColumnTypes: ColumnType[] = [\n \"numeric\",\n \"decimal\",\n \"interval\",\n \"time without time zone\",\n \"time with time zone\",\n \"timestamp without time zone\",\n \"timestamp with time zone\",\n ]\n\n /**\n * Gets list of column data types that support scale by a driver.\n */\n withScaleColumnTypes: ColumnType[] = [\"numeric\", \"decimal\"]\n\n /**\n * Orm has special columns and we need to know what database column types should be for those types.\n * Column types are driver dependant.\n */\n mappedDataTypes: MappedColumnTypes = {\n createDate: \"timestamp\",\n createDateDefault: \"now()\",\n updateDate: \"timestamp\",\n updateDateDefault: \"now()\",\n deleteDate: \"timestamp\",\n deleteDateNullable: true,\n version: \"int4\",\n treeLevel: \"int4\",\n migrationId: \"int4\",\n migrationName: \"varchar\",\n migrationTimestamp: \"int8\",\n cacheId: \"int4\",\n cacheIdentifier: \"varchar\",\n cacheTime: \"int8\",\n cacheDuration: \"int4\",\n cacheQuery: \"text\",\n cacheResult: \"text\",\n metadataType: \"varchar\",\n metadataDatabase: \"varchar\",\n metadataSchema: \"varchar\",\n metadataTable: \"varchar\",\n metadataName: \"varchar\",\n metadataValue: \"text\",\n }\n\n /**\n * Default values of length, precision and scale depends on column data type.\n * Used in the cases when length/precision/scale is not specified by user.\n */\n dataTypeDefaults: DataTypeDefaults = {\n character: { length: 1 },\n bit: { length: 1 },\n interval: { precision: 6 },\n \"time without time zone\": { precision: 6 },\n \"time with time zone\": { precision: 6 },\n \"timestamp without time zone\": { precision: 6 },\n \"timestamp with time zone\": { precision: 6 },\n }\n\n /**\n * Max length allowed by Postgres for aliases.\n * @see https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS\n */\n maxAliasLength = 63\n\n isGeneratedColumnsSupported: boolean = false\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection?: DataSource) {\n if (!connection) {\n return\n }\n\n this.connection = connection\n this.options = connection.options as PostgresConnectionOptions\n this.isReplicated = this.options.replication ? true : false\n if (this.options.useUTC) {\n process.env.PGTZ = \"UTC\"\n }\n // load postgres package\n this.loadDependencies()\n\n this.database = DriverUtils.buildDriverOptions(\n this.options.replication\n ? this.options.replication.master\n : this.options,\n ).database\n this.schema = DriverUtils.buildDriverOptions(this.options).schema\n\n // ObjectUtils.assign(this.options, DriverUtils.buildDriverOptions(connection.options)); // todo: do it better way\n // validate options to make sure everything is set\n // todo: revisit validation with replication in mind\n // if (!this.options.host)\n // throw new DriverOptionNotSetError(\"host\");\n // if (!this.options.username)\n // throw new DriverOptionNotSetError(\"username\");\n // if (!this.options.database)\n // throw new DriverOptionNotSetError(\"database\");\n }\n\n // -------------------------------------------------------------------------\n // Public Implemented Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n * Based on pooling options, it can either create connection immediately,\n * either create a pool and create connection when needed.\n */\n async connect(): Promise<void> {\n if (this.options.replication) {\n this.slaves = await Promise.all(\n this.options.replication.slaves.map((slave) => {\n return this.createPool(this.options, slave)\n }),\n )\n this.master = await this.createPool(\n this.options,\n this.options.replication.master,\n )\n } else {\n this.master = await this.createPool(this.options, this.options)\n }\n\n if (!this.database || !this.searchSchema) {\n const queryRunner = await this.createQueryRunner(\"master\")\n\n if (!this.database) {\n this.database = await queryRunner.getCurrentDatabase()\n }\n\n if (!this.searchSchema) {\n this.searchSchema = await queryRunner.getCurrentSchema()\n }\n\n await queryRunner.release()\n }\n\n if (!this.schema) {\n this.schema = this.searchSchema\n }\n }\n\n /**\n * Makes any action after connection (e.g. create extensions in Postgres driver).\n */\n async afterConnect(): Promise<void> {\n const extensionsMetadata = await this.checkMetadataForExtensions()\n const [connection, release] = await this.obtainMasterConnection()\n\n const installExtensions =\n this.options.installExtensions === undefined ||\n this.options.installExtensions\n if (installExtensions && extensionsMetadata.hasExtensions) {\n await this.enableExtensions(extensionsMetadata, connection)\n }\n\n const results = (await this.executeQuery(\n connection,\n \"SHOW server_version;\",\n )) as {\n rows: {\n server_version: string\n }[]\n }\n const versionString = results.rows[0].server_version\n this.isGeneratedColumnsSupported = VersionUtils.isGreaterOrEqual(\n versionString,\n \"12.0\",\n )\n\n await release()\n }\n\n protected async enableExtensions(extensionsMetadata: any, connection: any) {\n const { logger } = this.connection\n\n const {\n hasUuidColumns,\n hasCitextColumns,\n hasHstoreColumns,\n hasCubeColumns,\n hasGeometryColumns,\n hasLtreeColumns,\n hasExclusionConstraints,\n } = extensionsMetadata\n\n if (hasUuidColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"${\n this.options.uuidExtension || \"uuid-ossp\"\n }\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n `At least one of the entities has uuid column, but the '${\n this.options.uuidExtension || \"uuid-ossp\"\n }' extension cannot be installed automatically. Please install it manually using superuser rights, or select another uuid extension.`,\n )\n }\n if (hasCitextColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"citext\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"At least one of the entities has citext column, but the 'citext' extension cannot be installed automatically. Please install it manually using superuser rights\",\n )\n }\n if (hasHstoreColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"hstore\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"At least one of the entities has hstore column, but the 'hstore' extension cannot be installed automatically. Please install it manually using superuser rights\",\n )\n }\n if (hasGeometryColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"postgis\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n if (hasCubeColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"cube\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n if (hasLtreeColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"ltree\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n if (hasExclusionConstraints)\n try {\n // The btree_gist extension provides operator support in PostgreSQL exclusion constraints\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"btree_gist\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n }\n\n protected async checkMetadataForExtensions() {\n const hasUuidColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.generatedColumns.filter(\n (column) => column.generationStrategy === \"uuid\",\n ).length > 0\n )\n },\n )\n const hasCitextColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter(\n (column) => column.type === \"citext\",\n ).length > 0\n )\n },\n )\n const hasHstoreColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter(\n (column) => column.type === \"hstore\",\n ).length > 0\n )\n },\n )\n const hasCubeColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter((column) => column.type === \"cube\")\n .length > 0\n )\n },\n )\n const hasGeometryColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter(\n (column) => this.spatialTypes.indexOf(column.type) >= 0,\n ).length > 0\n )\n },\n )\n const hasLtreeColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter((column) => column.type === \"ltree\")\n .length > 0\n )\n },\n )\n const hasExclusionConstraints = this.connection.entityMetadatas.some(\n (metadata) => {\n return metadata.exclusions.length > 0\n },\n )\n\n return {\n hasUuidColumns,\n hasCitextColumns,\n hasHstoreColumns,\n hasCubeColumns,\n hasGeometryColumns,\n hasLtreeColumns,\n hasExclusionConstraints,\n hasExtensions:\n hasUuidColumns ||\n hasCitextColumns ||\n hasHstoreColumns ||\n hasGeometryColumns ||\n hasCubeColumns ||\n hasLtreeColumns ||\n hasExclusionConstraints,\n }\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n if (!this.master)\n return Promise.reject(new ConnectionIsNotSetError(\"postgres\"))\n\n await this.closePool(this.master)\n await Promise.all(this.slaves.map((slave) => this.closePool(slave)))\n this.master = undefined\n this.slaves = []\n }\n\n /**\n * Creates a schema builder used to build and sync a schema.\n */\n createSchemaBuilder() {\n return new RdbmsSchemaBuilder(this.connection)\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n return new PostgresQueryRunner(this, mode)\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type and metadata.\n */\n preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any {\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformTo(\n columnMetadata.transformer,\n value,\n )\n\n if (value === null || value === undefined) return value\n\n if (columnMetadata.type === Boolean) {\n return value === true ? 1 : 0\n } else if (columnMetadata.type === \"date\") {\n return DateUtils.mixedDateToDateString(value)\n } else if (columnMetadata.type === \"time\") {\n return DateUtils.mixedDateToTimeString(value)\n } else if (\n columnMetadata.type === \"datetime\" ||\n columnMetadata.type === Date ||\n columnMetadata.type === \"timestamp\" ||\n columnMetadata.type === \"timestamp with time zone\" ||\n columnMetadata.type === \"timestamp without time zone\"\n ) {\n return DateUtils.mixedDateToDate(value)\n } else if (\n [\"json\", \"jsonb\", ...this.spatialTypes].indexOf(\n columnMetadata.type,\n ) >= 0\n ) {\n return value // JSON.stringify()\n } else if (columnMetadata.type === \"hstore\") {\n if (typeof value === \"string\") {\n return value\n } else {\n // https://www.postgresql.org/docs/9.0/hstore.html\n const quoteString = (value: unknown) => {\n // If a string to be quoted is `null` or `undefined`, we return a literal unquoted NULL.\n // This way, NULL values can be stored in the hstore object.\n if (value === null || typeof value === \"undefined\") {\n return \"NULL\"\n }\n // Convert non-null values to string since HStore only stores strings anyway.\n // To include a double quote or a backslash in a key or value, escape it with a backslash.\n return `\"${`${value}`.replace(/(?=[\"\\\\])/g, \"\\\\\")}\"`\n }\n return Object.keys(value)\n .map(\n (key) =>\n quoteString(key) + \"=>\" + quoteString(value[key]),\n )\n .join(\",\")\n }\n } else if (columnMetadata.type === \"simple-array\") {\n return DateUtils.simpleArrayToString(value)\n } else if (columnMetadata.type === \"simple-json\") {\n return DateUtils.simpleJsonToString(value)\n } else if (columnMetadata.type === \"cube\") {\n if (columnMetadata.isArray) {\n return `{${value\n .map((cube: number[]) => `\"(${cube.join(\",\")})\"`)\n .join(\",\")}}`\n }\n return `(${value.join(\",\")})`\n } else if (columnMetadata.type === \"ltree\") {\n return value\n .split(\".\")\n .filter(Boolean)\n .join(\".\")\n .replace(/[\\s]+/g, \"_\")\n } else if (\n (columnMetadata.type === \"enum\" ||\n columnMetadata.type === \"simple-enum\") &&\n !columnMetadata.isArray\n ) {\n return \"\" + value\n }\n\n return value\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type or metadata.\n */\n prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any {\n if (value === null || value === undefined)\n return columnMetadata.transformer\n ? ApplyValueTransformers.transformFrom(\n columnMetadata.transformer,\n value,\n )\n : value\n\n if (columnMetadata.type === Boolean) {\n value = value ? true : false\n } else if (\n columnMetadata.type === \"datetime\" ||\n columnMetadata.type === Date ||\n columnMetadata.type === \"timestamp\" ||\n columnMetadata.type === \"timestamp with time zone\" ||\n columnMetadata.type === \"timestamp without time zone\"\n ) {\n value = DateUtils.normalizeHydratedDate(value)\n } else if (columnMetadata.type === \"date\") {\n value = DateUtils.mixedDateToDateString(value)\n } else if (columnMetadata.type === \"time\") {\n value = DateUtils.mixedTimeToString(value)\n } else if (columnMetadata.type === \"hstore\") {\n if (columnMetadata.hstoreType === \"object\") {\n const unescapeString = (str: string) =>\n str.replace(/\\\\./g, (m) => m[1])\n const regexp =\n /\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"=>(?:(NULL)|\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\")(?:,|$)/g\n const object: ObjectLiteral = {}\n ;`${value}`.replace(\n regexp,\n (_, key, nullValue, stringValue) => {\n object[unescapeString(key)] = nullValue\n ? null\n : unescapeString(stringValue)\n return \"\"\n },\n )\n return object\n } else {\n return value\n }\n } else if (columnMetadata.type === \"simple-array\") {\n value = DateUtils.stringToSimpleArray(value)\n } else if (columnMetadata.type === \"simple-json\") {\n value = DateUtils.stringToSimpleJson(value)\n } else if (columnMetadata.type === \"cube\") {\n value = value.replace(/[\\(\\)\\s]+/g, \"\") // remove whitespace\n if (columnMetadata.isArray) {\n /**\n * Strips these groups from `{\"1,2,3\",\"\",NULL}`:\n * 1. [\"1,2,3\", undefined] <- cube of arity 3\n * 2. [\"\", undefined] <- cube of arity 0\n * 3. [undefined, \"NULL\"] <- NULL\n */\n const regexp = /(?:\\\"((?:[\\d\\s\\.,])*)\\\")|(?:(NULL))/g\n const unparsedArrayString = value\n\n value = []\n let cube: RegExpExecArray | null = null\n // Iterate through all regexp matches for cubes/null in array\n while ((cube = regexp.exec(unparsedArrayString)) !== null) {\n if (cube[1] !== undefined) {\n value.push(\n cube[1].split(\",\").filter(Boolean).map(Number),\n )\n } else {\n value.push(undefined)\n }\n }\n } else {\n value = value.split(\",\").filter(Boolean).map(Number)\n }\n } else if (\n columnMetadata.type === \"enum\" ||\n columnMetadata.type === \"simple-enum\"\n ) {\n if (columnMetadata.isArray) {\n if (value === \"{}\") return []\n\n // manually convert enum array to array of values (pg does not support, see https://github.com/brianc/node-pg-types/issues/56)\n value = (value as string)\n .substr(1, (value as string).length - 2)\n .split(\",\")\n .map((val) => {\n // replace double quotes from the beginning and from the end\n if (val.startsWith(`\"`) && val.endsWith(`\"`))\n val = val.slice(1, -1)\n // replace double escaped backslash to single escaped e.g. \\\\\\\\ -> \\\\\n val = val.replace(/(\\\\\\\\)/g, \"\\\\\")\n // replace escaped double quotes to non-escaped e.g. \\\"asd\\\" -> \"asd\"\n return val.replace(/(\\\\\")/g, '\"')\n })\n\n // convert to number if that exists in possible enum options\n value = value.map((val: string) => {\n return !isNaN(+val) &&\n columnMetadata.enum!.indexOf(parseInt(val)) >= 0\n ? parseInt(val)\n : val\n })\n } else {\n // convert to number if that exists in possible enum options\n value =\n !isNaN(+value) &&\n columnMetadata.enum!.indexOf(parseInt(value)) >= 0\n ? parseInt(value)\n : value\n }\n }\n\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformFrom(\n columnMetadata.transformer,\n value,\n )\n return value\n }\n\n /**\n * Replaces parameters in the given sql with special escaping character\n * and an array of parameter names to be passed to a query.\n */\n escapeQueryWithParameters(\n sql: string,\n parameters: ObjectLiteral,\n nativeParameters: ObjectLiteral,\n ): [string, any[]] {\n const escapedParameters: any[] = Object.keys(nativeParameters).map(\n (key) => nativeParameters[key],\n )\n if (!parameters || !Object.keys(parameters).length)\n return [sql, escapedParameters]\n\n sql = sql.replace(\n /:(\\.\\.\\.)?([A-Za-z0-9_.]+)/g,\n (full, isArray: string, key: string): string => {\n if (!parameters.hasOwnProperty(key)) {\n return full\n }\n\n let value: any = parameters[key]\n\n if (isArray) {\n return value\n .map((v: any) => {\n escapedParameters.push(v)\n return this.createParameter(\n key,\n escapedParameters.length - 1,\n )\n })\n .join(\", \")\n }\n\n if (typeof value === \"function\") {\n return value()\n }\n\n escapedParameters.push(value)\n return this.createParameter(key, escapedParameters.length - 1)\n },\n ) // todo: make replace only in value statements, otherwise problems\n return [sql, escapedParameters]\n }\n\n /**\n * Escapes a column name.\n */\n escape(columnName: string): string {\n return '\"' + columnName + '\"'\n }\n\n /**\n * Build full table name with schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n buildTableName(tableName: string, schema?: string): string {\n let tablePath = [tableName]\n\n if (schema) {\n tablePath.unshift(schema)\n }\n\n return tablePath.join(\".\")\n }\n\n /**\n * Parse a target table name or other types and return a normalized table definition.\n */\n parseTableName(\n target: EntityMetadata | Table | View | TableForeignKey | string,\n ): { database?: string; schema?: string; tableName: string } {\n const driverDatabase = this.database\n const driverSchema = this.schema\n\n if (InstanceChecker.isTable(target) || InstanceChecker.isView(target)) {\n const parsed = this.parseTableName(target.name)\n\n return {\n database: target.database || parsed.database || driverDatabase,\n schema: target.schema || parsed.schema || driverSchema,\n tableName: parsed.tableName,\n }\n }\n\n if (InstanceChecker.isTableForeignKey(target)) {\n const parsed = this.parseTableName(target.referencedTableName)\n\n return {\n database:\n target.referencedDatabase ||\n parsed.database ||\n driverDatabase,\n schema:\n target.referencedSchema || parsed.schema || driverSchema,\n tableName: parsed.tableName,\n }\n }\n\n if (InstanceChecker.isEntityMetadata(target)) {\n // EntityMetadata tableName is never a path\n\n return {\n database: target.database || driverDatabase,\n schema: target.schema || driverSchema,\n tableName: target.tableName,\n }\n }\n\n const parts = target.split(\".\")\n\n return {\n database: driverDatabase,\n schema: (parts.length > 1 ? parts[0] : undefined) || driverSchema,\n tableName: parts.length > 1 ? parts[1] : parts[0],\n }\n }\n\n /**\n * Creates a database type from a given column metadata.\n */\n normalizeType(column: {\n type?: ColumnType\n length?: number | string\n precision?: number | null\n scale?: number\n isArray?: boolean\n }): string {\n if (\n column.type === Number ||\n column.type === \"int\" ||\n column.type === \"int4\"\n ) {\n return \"integer\"\n } else if (column.type === String || column.type === \"varchar\") {\n return \"character varying\"\n } else if (column.type === Date || column.type === \"timestamp\") {\n return \"timestamp without time zone\"\n } else if (column.type === \"timestamptz\") {\n return \"timestamp with time zone\"\n } else if (column.type === \"time\") {\n return \"time without time zone\"\n } else if (column.type === \"timetz\") {\n return \"time with time zone\"\n } else if (column.type === Boolean || column.type === \"bool\") {\n return \"boolean\"\n } else if (column.type === \"simple-array\") {\n return \"text\"\n } else if (column.type === \"simple-json\") {\n return \"text\"\n } else if (column.type === \"simple-enum\") {\n return \"enum\"\n } else if (column.type === \"int2\") {\n return \"smallint\"\n } else if (column.type === \"int8\") {\n return \"bigint\"\n } else if (column.type === \"decimal\") {\n return \"numeric\"\n } else if (column.type === \"float8\" || column.type === \"float\") {\n return \"double precision\"\n } else if (column.type === \"float4\") {\n return \"real\"\n } else if (column.type === \"char\") {\n return \"character\"\n } else if (column.type === \"varbit\") {\n return \"bit varying\"\n } else {\n return (column.type as string) || \"\"\n }\n }\n\n /**\n * Normalizes \"default\" value of the column.\n */\n normalizeDefault(columnMetadata: ColumnMetadata): string | undefined {\n const defaultValue = columnMetadata.default\n\n if (defaultValue === null) {\n return undefined\n }\n\n if (columnMetadata.isArray && Array.isArray(defaultValue)) {\n return `'{${defaultValue\n .map((val: string) => `${val}`)\n .join(\",\")}}'`\n }\n\n if (\n (columnMetadata.type === \"enum\" ||\n columnMetadata.type === \"simple-enum\" ||\n typeof defaultValue === \"number\" ||\n typeof defaultValue === \"string\") &&\n defaultValue !== undefined\n ) {\n return `'${defaultValue}'`\n }\n\n if (typeof defaultValue === \"boolean\") {\n return defaultValue ? \"true\" : \"false\"\n }\n\n if (typeof defaultValue === \"function\") {\n const value = defaultValue()\n\n return this.normalizeDatetimeFunction(value)\n }\n\n if (typeof defaultValue === \"object\") {\n return `'${JSON.stringify(defaultValue)}'`\n }\n\n if (defaultValue === undefined) {\n return undefined\n }\n\n return `${defaultValue}`\n }\n\n /**\n * Compares \"default\" value of the column.\n * Postgres sorts json values before it is saved, so in that case a deep comparison has to be performed to see if has changed.\n */\n private defaultEqual(\n columnMetadata: ColumnMetadata,\n tableColumn: TableColumn,\n ): boolean {\n if (\n [\"json\", \"jsonb\"].includes(columnMetadata.type as string) &&\n ![\"function\", \"undefined\"].includes(typeof columnMetadata.default)\n ) {\n const tableColumnDefault =\n typeof tableColumn.default === \"string\"\n ? JSON.parse(\n tableColumn.default.substring(\n 1,\n tableColumn.default.length - 1,\n ),\n )\n : tableColumn.default\n\n return OrmUtils.deepCompare(\n columnMetadata.default,\n tableColumnDefault,\n )\n }\n\n const columnDefault = this.lowerDefaultValueIfNecessary(\n this.normalizeDefault(columnMetadata),\n )\n return columnDefault === tableColumn.default\n }\n\n /**\n * Normalizes \"isUnique\" value of the column.\n */\n normalizeIsUnique(column: ColumnMetadata): boolean {\n return column.entityMetadata.uniques.some(\n (uq) => uq.columns.length === 1 && uq.columns[0] === column,\n )\n }\n\n /**\n * Returns default column lengths, which is required on column creation.\n */\n getColumnLength(column: ColumnMetadata): string {\n return column.length ? column.length.toString() : \"\"\n }\n\n /**\n * Creates column type definition including length, precision and scale\n */\n createFullType(column: TableColumn): string {\n let type = column.type\n\n if (column.length) {\n type += \"(\" + column.length + \")\"\n } else if (\n column.precision !== null &&\n column.precision !== undefined &&\n column.scale !== null &&\n column.scale !== undefined\n ) {\n type += \"(\" + column.precision + \",\" + column.scale + \")\"\n } else if (\n column.precision !== null &&\n column.precision !== undefined\n ) {\n type += \"(\" + column.precision + \")\"\n }\n\n if (column.type === \"time without time zone\") {\n type =\n \"TIME\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\")\n } else if (column.type === \"time with time zone\") {\n type =\n \"TIME\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\") +\n \" WITH TIME ZONE\"\n } else if (column.type === \"timestamp without time zone\") {\n type =\n \"TIMESTAMP\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\")\n } else if (column.type === \"timestamp with time zone\") {\n type =\n \"TIMESTAMP\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\") +\n \" WITH TIME ZONE\"\n } else if (this.spatialTypes.indexOf(column.type as ColumnType) >= 0) {\n if (column.spatialFeatureType != null && column.srid != null) {\n type = `${column.type}(${column.spatialFeatureType},${column.srid})`\n } else if (column.spatialFeatureType != null) {\n type = `${column.type}(${column.spatialFeatureType})`\n } else {\n type = column.type\n }\n }\n\n if (column.isArray) type += \" array\"\n\n return type\n }\n\n /**\n * Obtains a new database connection to a master server.\n * Used for replication.\n * If replication is not setup then returns default connection's database connection.\n */\n async obtainMasterConnection(): Promise<[any, Function]> {\n if (!this.master) {\n throw new TypeORMError(\"Driver not Connected\")\n }\n\n return new Promise((ok, fail) => {\n this.master.connect((err: any, connection: any, release: any) => {\n err ? fail(err) : ok([connection, release])\n })\n })\n }\n\n /**\n * Obtains a new database connection to a slave server.\n * Used for replication.\n * If replication is not setup then returns master (default) connection's database connection.\n */\n async obtainSlaveConnection(): Promise<[any, Function]> {\n if (!this.slaves.length) {\n return this.obtainMasterConnection()\n }\n\n const random = Math.floor(Math.random() * this.slaves.length)\n\n return new Promise((ok, fail) => {\n this.slaves[random].connect(\n (err: any, connection: any, release: any) => {\n err ? fail(err) : ok([connection, release])\n },\n )\n })\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n *\n * todo: slow. optimize Object.keys(), OrmUtils.mergeDeep and column.createValueMap parts\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: ObjectLiteral) {\n if (!insertResult) return undefined\n\n return Object.keys(insertResult).reduce((map, key) => {\n const column = metadata.findColumnWithDatabaseName(key)\n if (column) {\n OrmUtils.mergeDeep(\n map,\n column.createValueMap(insertResult[key]),\n )\n // OrmUtils.mergeDeep(map, column.createValueMap(this.prepareHydratedValue(insertResult[key], column))); // TODO: probably should be like there, but fails on enums, fix later\n }\n return map\n }, {} as ObjectLiteral)\n }\n\n /**\n * Differentiate columns of this table and columns from the given column metadatas columns\n * and returns only changed.\n */\n findChangedColumns(\n tableColumns: TableColumn[],\n columnMetadatas: ColumnMetadata[],\n ): ColumnMetadata[] {\n return columnMetadatas.filter((columnMetadata) => {\n const tableColumn = tableColumns.find(\n (c) => c.name === columnMetadata.databaseName,\n )\n if (!tableColumn) return false // we don't need new columns, we only need exist and changed\n\n const isColumnChanged =\n tableColumn.name !== columnMetadata.databaseName ||\n tableColumn.type !== this.normalizeType(columnMetadata) ||\n tableColumn.length !== columnMetadata.length ||\n tableColumn.isArray !== columnMetadata.isArray ||\n tableColumn.precision !== columnMetadata.precision ||\n (columnMetadata.scale !== undefined &&\n tableColumn.scale !== columnMetadata.scale) ||\n tableColumn.comment !==\n this.escapeComment(columnMetadata.comment) ||\n (!tableColumn.isGenerated &&\n !this.defaultEqual(columnMetadata, tableColumn)) || // we included check for generated here, because generated columns already can have default values\n tableColumn.isPrimary !== columnMetadata.isPrimary ||\n tableColumn.isNullable !== columnMetadata.isNullable ||\n tableColumn.isUnique !==\n this.normalizeIsUnique(columnMetadata) ||\n tableColumn.enumName !== columnMetadata.enumName ||\n (tableColumn.enum &&\n columnMetadata.enum &&\n !OrmUtils.isArraysEqual(\n tableColumn.enum,\n columnMetadata.enum.map((val) => val + \"\"),\n )) || // enums in postgres are always strings\n tableColumn.isGenerated !== columnMetadata.isGenerated ||\n (tableColumn.spatialFeatureType || \"\").toLowerCase() !==\n (columnMetadata.spatialFeatureType || \"\").toLowerCase() ||\n tableColumn.srid !== columnMetadata.srid ||\n tableColumn.generatedType !== columnMetadata.generatedType ||\n (tableColumn.asExpression || \"\").trim() !==\n (columnMetadata.asExpression || \"\").trim()\n\n // DEBUG SECTION\n // if (isColumnChanged) {\n // console.log(\"table:\", columnMetadata.entityMetadata.tableName);\n // console.log(\"name:\", tableColumn.name, columnMetadata.databaseName);\n // console.log(\"type:\", tableColumn.type, this.normalizeType(columnMetadata));\n // console.log(\"length:\", tableColumn.length, columnMetadata.length);\n // console.log(\"isArray:\", tableColumn.isArray, columnMetadata.isArray);\n // console.log(\"precision:\", tableColumn.precision, columnMetadata.precision);\n // console.log(\"scale:\", tableColumn.scale, columnMetadata.scale);\n // console.log(\"comment:\", tableColumn.comment, this.escapeComment(columnMetadata.comment));\n // console.log(\"enumName:\", tableColumn.enumName, columnMetadata.enumName);\n // console.log(\"enum:\", tableColumn.enum && columnMetadata.enum && !OrmUtils.isArraysEqual(tableColumn.enum, columnMetadata.enum.map(val => val + \"\")));\n // console.log(\"isPrimary:\", tableColumn.isPrimary, columnMetadata.isPrimary);\n // console.log(\"isNullable:\", tableColumn.isNullable, columnMetadata.isNullable);\n // console.log(\"isUnique:\", tableColumn.isUnique, this.normalizeIsUnique(columnMetadata));\n // console.log(\"isGenerated:\", tableColumn.isGenerated, columnMetadata.isGenerated);\n // console.log(\"isGenerated 2:\", !tableColumn.isGenerated && this.lowerDefaultValueIfNecessary(this.normalizeDefault(columnMetadata)) !== tableColumn.default);\n // console.log(\"spatialFeatureType:\", (tableColumn.spatialFeatureType || \"\").toLowerCase(), (columnMetadata.spatialFeatureType || \"\").toLowerCase());\n // console.log(\"srid\", tableColumn.srid, columnMetadata.srid);\n // console.log(\"==========================================\");\n // }\n\n return isColumnChanged\n })\n }\n\n private lowerDefaultValueIfNecessary(value: string | undefined) {\n // Postgres saves function calls in default value as lowercase #2733\n if (!value) {\n return value\n }\n return value\n .split(`'`)\n .map((v, i) => {\n return i % 2 === 1 ? v : v.toLowerCase()\n })\n .join(`'`)\n }\n\n /**\n * Returns true if driver supports RETURNING / OUTPUT statement.\n */\n isReturningSqlSupported(): boolean {\n return true\n }\n\n /**\n * Returns true if driver supports uuid values generation on its own.\n */\n isUUIDGenerationSupported(): boolean {\n return true\n }\n\n /**\n * Returns true if driver supports fulltext indices.\n */\n isFullTextColumnTypeSupported(): boolean {\n return false\n }\n\n get uuidGenerator(): string {\n return this.options.uuidExtension === \"pgcrypto\"\n ? \"gen_random_uuid()\"\n : \"uuid_generate_v4()\"\n }\n\n /**\n * Creates an escaped parameter.\n */\n createParameter(parameterName: string, index: number): string {\n return \"$\" + (index + 1)\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads postgres query stream package.\n */\n loadStreamDependency() {\n try {\n return PlatformTools.load(\"pg-query-stream\")\n } catch (e) {\n // todo: better error for browser env\n throw new TypeORMError(\n `To use streams you should install pg-query-stream package. Please run npm i pg-query-stream --save command.`,\n )\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n try {\n const postgres = this.options.driver || PlatformTools.load(\"pg\")\n this.postgres = postgres\n try {\n const pgNative =\n this.options.nativeDriver || PlatformTools.load(\"pg-native\")\n if (pgNative && this.postgres.native)\n this.postgres = this.postgres.native\n } catch (e) {}\n } catch (e) {\n // todo: better error for browser env\n throw new DriverPackageNotInstalledError(\"Postgres\", \"pg\")\n }\n }\n\n /**\n * Creates a new connection pool for a given database credentials.\n */\n protected async createPool(\n options: PostgresConnectionOptions,\n credentials: PostgresConnectionCredentialsOptions,\n ): Promise<any> {\n credentials = Object.assign({}, credentials)\n\n // build connection options for the driver\n // See: https://github.com/brianc/node-postgres/tree/master/packages/pg-pool#create\n const connectionOptions = Object.assign(\n {},\n {\n connectionString: credentials.url,\n host: credentials.host,\n user: credentials.username,\n password: credentials.password,\n database: credentials.database,\n port: credentials.port,\n ssl: credentials.ssl,\n connectionTimeoutMillis: options.connectTimeoutMS,\n application_name: options.applicationName,\n },\n options.extra || {},\n )\n\n // create a connection pool\n const pool = new this.postgres.Pool(connectionOptions)\n const { logger } = this.connection\n\n const poolErrorHandler =\n options.poolErrorHandler ||\n ((error: any) =>\n logger.log(\"warn\", `Postgres pool raised an error. ${error}`))\n\n /*\n Attaching an error handler to pool errors is essential, as, otherwise, errors raised will go unhandled and\n cause the hosting app to crash.\n */\n pool.on(\"error\", poolErrorHandler)\n\n return new Promise((ok, fail) => {\n pool.connect((err: any, connection: any, release: Function) => {\n if (err) return fail(err)\n\n if (options.logNotifications) {\n connection.on(\"notice\", (msg: any) => {\n msg && this.connection.logger.log(\"info\", msg.message)\n })\n connection.on(\"notification\", (msg: any) => {\n msg &&\n this.connection.logger.log(\n \"info\",\n `Received NOTIFY on channel ${msg.channel}: ${msg.payload}.`,\n )\n })\n }\n release()\n ok(pool)\n })\n })\n }\n\n /**\n * Closes connection pool.\n */\n protected async closePool(pool: any): Promise<void> {\n while (this.connectedQueryRunners.length) {\n await this.connectedQueryRunners[0].release()\n }\n\n return new Promise<void>((ok, fail) => {\n pool.end((err: any) => (err ? fail(err) : ok()))\n })\n }\n\n /**\n * Executes given query.\n */\n protected executeQuery(connection: any, query: string) {\n this.connection.logger.logQuery(query)\n\n return new Promise((ok, fail) => {\n connection.query(query, (err: any, result: any) =>\n err ? fail(err) : ok(result),\n )\n })\n }\n\n /**\n * If parameter is a datetime function, e.g. \"CURRENT_TIMESTAMP\", normalizes it.\n * Otherwise returns original input.\n */\n protected normalizeDatetimeFunction(value: string) {\n // check if input is datetime function\n const upperCaseValue = value.toUpperCase()\n const isDatetimeFunction =\n upperCaseValue.indexOf(\"CURRENT_TIMESTAMP\") !== -1 ||\n upperCaseValue.indexOf(\"CURRENT_DATE\") !== -1 ||\n upperCaseValue.indexOf(\"CURRENT_TIME\") !== -1 ||\n upperCaseValue.indexOf(\"LOCALTIMESTAMP\") !== -1 ||\n upperCaseValue.indexOf(\"LOCALTIME\") !== -1\n\n if (isDatetimeFunction) {\n // extract precision, e.g. \"(3)\"\n const precision = value.match(/\\(\\d+\\)/)\n\n if (upperCaseValue.indexOf(\"CURRENT_TIMESTAMP\") !== -1) {\n return precision\n ? `('now'::text)::timestamp${precision[0]} with time zone`\n : \"now()\"\n } else if (upperCaseValue === \"CURRENT_DATE\") {\n return \"('now'::text)::date\"\n } else if (upperCaseValue.indexOf(\"CURRENT_TIME\") !== -1) {\n return precision\n ? `('now'::text)::time${precision[0]} with time zone`\n : \"('now'::text)::time with time zone\"\n } else if (upperCaseValue.indexOf(\"LOCALTIMESTAMP\") !== -1) {\n return precision\n ? `('now'::text)::timestamp${precision[0]} without time zone`\n : \"('now'::text)::timestamp without time zone\"\n } else if (upperCaseValue.indexOf(\"LOCALTIME\") !== -1) {\n return precision\n ? `('now'::text)::time${precision[0]} without time zone`\n : \"('now'::text)::time without time zone\"\n }\n }\n\n return value\n }\n\n /**\n * Escapes a given comment.\n */\n protected escapeComment(comment?: string) {\n if (!comment) return comment\n\n comment = comment.replace(/\\u0000/g, \"\") // Null bytes aren't allowed in comments\n\n return comment\n }\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/driver/postgres/PostgresDriver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,8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IAAI,cAAc,KAAK,cAAc,EAAE;gBAC1C,OAAO,qBAAqB,CAAA;aAC/B;iBAAM,IAAI,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;gBACtD,OAAO,SAAS;oBACZ,CAAC,CAAC,sBAAsB,SAAS,CAAC,CAAC,CAAC,iBAAiB;oBACrD,CAAC,CAAC,oCAAoC,CAAA;aAC7C;iBAAM,IAAI,cAAc,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE;gBACxD,OAAO,SAAS;oBACZ,CAAC,CAAC,2BAA2B,SAAS,CAAC,CAAC,CAAC,oBAAoB;oBAC7D,CAAC,CAAC,4CAA4C,CAAA;aACrD;iBAAM,IAAI,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE;gBACnD,OAAO,SAAS;oBACZ,CAAC,CAAC,sBAAsB,SAAS,CAAC,CAAC,CAAC,oBAAoB;oBACxD,CAAC,CAAC,uCAAuC,CAAA;aAChD;SACJ;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,OAAgB;QACpC,IAAI,CAAC,OAAO;YAAE,OAAO,OAAO,CAAA;QAE5B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA,CAAC,wCAAwC;QAEjF,OAAO,OAAO,CAAA;IAClB,CAAC;CACJ","file":"PostgresDriver.js","sourcesContent":["import { ObjectLiteral } from \"../../common/ObjectLiteral\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { ConnectionIsNotSetError } from \"../../error/ConnectionIsNotSetError\"\nimport { DriverPackageNotInstalledError } from \"../../error/DriverPackageNotInstalledError\"\nimport { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { RdbmsSchemaBuilder } from \"../../schema-builder/RdbmsSchemaBuilder\"\nimport { TableColumn } from \"../../schema-builder/table/TableColumn\"\nimport { ApplyValueTransformers } from \"../../util/ApplyValueTransformers\"\nimport { DateUtils } from \"../../util/DateUtils\"\nimport { OrmUtils } from \"../../util/OrmUtils\"\nimport { Driver } from \"../Driver\"\nimport { ColumnType } from \"../types/ColumnTypes\"\nimport { DataTypeDefaults } from \"../types/DataTypeDefaults\"\nimport { MappedColumnTypes } from \"../types/MappedColumnTypes\"\nimport { ReplicationMode } from \"../types/ReplicationMode\"\nimport { VersionUtils } from \"../../util/VersionUtils\"\nimport { PostgresConnectionCredentialsOptions } from \"./PostgresConnectionCredentialsOptions\"\nimport { PostgresConnectionOptions } from \"./PostgresConnectionOptions\"\nimport { PostgresQueryRunner } from \"./PostgresQueryRunner\"\nimport { DriverUtils } from \"../DriverUtils\"\nimport { TypeORMError } from \"../../error\"\nimport { Table } from \"../../schema-builder/table/Table\"\nimport { View } from \"../../schema-builder/view/View\"\nimport { TableForeignKey } from \"../../schema-builder/table/TableForeignKey\"\nimport { InstanceChecker } from \"../../util/InstanceChecker\"\n\n/**\n * Organizes communication with PostgreSQL DBMS.\n */\nexport class PostgresDriver implements Driver {\n // -------------------------------------------------------------------------\n // Public Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection used by driver.\n */\n connection: DataSource\n\n /**\n * Postgres underlying library.\n */\n postgres: any\n\n /**\n * Pool for master database.\n */\n master: any\n\n /**\n * Pool for slave databases.\n * Used in replication.\n */\n slaves: any[] = []\n\n /**\n * We store all created query runners because we need to release them.\n */\n connectedQueryRunners: QueryRunner[] = []\n\n // -------------------------------------------------------------------------\n // Public Implemented Properties\n // -------------------------------------------------------------------------\n\n /**\n * Connection options.\n */\n options: PostgresConnectionOptions\n\n /**\n * Database name used to perform all write queries.\n */\n database?: string\n\n /**\n * Schema name used to perform all write queries.\n */\n schema?: string\n\n /**\n * Schema that's used internally by Postgres for object resolution.\n *\n * Because we never set this we have to track it in separately from the `schema` so\n * we know when we have to specify the full schema or not.\n *\n * In most cases this will be `public`.\n */\n searchSchema?: string\n\n /**\n * Indicates if replication is enabled.\n */\n isReplicated: boolean = false\n\n /**\n * Indicates if tree tables are supported by this driver.\n */\n treeSupport = true\n\n /**\n * Represent transaction support by this driver\n */\n transactionSupport = \"nested\" as const\n\n /**\n * Gets list of supported column data types by a driver.\n *\n * @see https://www.tutorialspoint.com/postgresql/postgresql_data_types.htm\n * @see https://www.postgresql.org/docs/9.2/static/datatype.html\n */\n supportedDataTypes: ColumnType[] = [\n \"int\",\n \"int2\",\n \"int4\",\n \"int8\",\n \"smallint\",\n \"integer\",\n \"bigint\",\n \"decimal\",\n \"numeric\",\n \"real\",\n \"float\",\n \"float4\",\n \"float8\",\n \"double precision\",\n \"money\",\n \"character varying\",\n \"varchar\",\n \"character\",\n \"char\",\n \"text\",\n \"citext\",\n \"hstore\",\n \"bytea\",\n \"bit\",\n \"varbit\",\n \"bit varying\",\n \"timetz\",\n \"timestamptz\",\n \"timestamp\",\n \"timestamp without time zone\",\n \"timestamp with time zone\",\n \"date\",\n \"time\",\n \"time without time zone\",\n \"time with time zone\",\n \"interval\",\n \"bool\",\n \"boolean\",\n \"enum\",\n \"point\",\n \"line\",\n \"lseg\",\n \"box\",\n \"path\",\n \"polygon\",\n \"circle\",\n \"cidr\",\n \"inet\",\n \"macaddr\",\n \"tsvector\",\n \"tsquery\",\n \"uuid\",\n \"xml\",\n \"json\",\n \"jsonb\",\n \"int4range\",\n \"int8range\",\n \"numrange\",\n \"tsrange\",\n \"tstzrange\",\n \"daterange\",\n \"geometry\",\n \"geography\",\n \"cube\",\n \"ltree\",\n ]\n\n /**\n * Returns type of upsert supported by driver if any\n */\n readonly supportedUpsertType = \"on-conflict-do-update\"\n\n /**\n * Gets list of spatial column data types.\n */\n spatialTypes: ColumnType[] = [\"geometry\", \"geography\"]\n\n /**\n * Gets list of column data types that support length by a driver.\n */\n withLengthColumnTypes: ColumnType[] = [\n \"character varying\",\n \"varchar\",\n \"character\",\n \"char\",\n \"bit\",\n \"varbit\",\n \"bit varying\",\n ]\n\n /**\n * Gets list of column data types that support precision by a driver.\n */\n withPrecisionColumnTypes: ColumnType[] = [\n \"numeric\",\n \"decimal\",\n \"interval\",\n \"time without time zone\",\n \"time with time zone\",\n \"timestamp without time zone\",\n \"timestamp with time zone\",\n ]\n\n /**\n * Gets list of column data types that support scale by a driver.\n */\n withScaleColumnTypes: ColumnType[] = [\"numeric\", \"decimal\"]\n\n /**\n * Orm has special columns and we need to know what database column types should be for those types.\n * Column types are driver dependant.\n */\n mappedDataTypes: MappedColumnTypes = {\n createDate: \"timestamp\",\n createDateDefault: \"now()\",\n updateDate: \"timestamp\",\n updateDateDefault: \"now()\",\n deleteDate: \"timestamp\",\n deleteDateNullable: true,\n version: \"int4\",\n treeLevel: \"int4\",\n migrationId: \"int4\",\n migrationName: \"varchar\",\n migrationTimestamp: \"int8\",\n cacheId: \"int4\",\n cacheIdentifier: \"varchar\",\n cacheTime: \"int8\",\n cacheDuration: \"int4\",\n cacheQuery: \"text\",\n cacheResult: \"text\",\n metadataType: \"varchar\",\n metadataDatabase: \"varchar\",\n metadataSchema: \"varchar\",\n metadataTable: \"varchar\",\n metadataName: \"varchar\",\n metadataValue: \"text\",\n }\n\n /**\n * Default values of length, precision and scale depends on column data type.\n * Used in the cases when length/precision/scale is not specified by user.\n */\n dataTypeDefaults: DataTypeDefaults = {\n character: { length: 1 },\n bit: { length: 1 },\n interval: { precision: 6 },\n \"time without time zone\": { precision: 6 },\n \"time with time zone\": { precision: 6 },\n \"timestamp without time zone\": { precision: 6 },\n \"timestamp with time zone\": { precision: 6 },\n }\n\n /**\n * Max length allowed by Postgres for aliases.\n * @see https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS\n */\n maxAliasLength = 63\n\n isGeneratedColumnsSupported: boolean = false\n\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(connection?: DataSource) {\n if (!connection) {\n return\n }\n\n this.connection = connection\n this.options = connection.options as PostgresConnectionOptions\n this.isReplicated = this.options.replication ? true : false\n if (this.options.useUTC) {\n process.env.PGTZ = \"UTC\"\n }\n // load postgres package\n this.loadDependencies()\n\n this.database = DriverUtils.buildDriverOptions(\n this.options.replication\n ? this.options.replication.master\n : this.options,\n ).database\n this.schema = DriverUtils.buildDriverOptions(this.options).schema\n\n // ObjectUtils.assign(this.options, DriverUtils.buildDriverOptions(connection.options)); // todo: do it better way\n // validate options to make sure everything is set\n // todo: revisit validation with replication in mind\n // if (!this.options.host)\n // throw new DriverOptionNotSetError(\"host\");\n // if (!this.options.username)\n // throw new DriverOptionNotSetError(\"username\");\n // if (!this.options.database)\n // throw new DriverOptionNotSetError(\"database\");\n }\n\n // -------------------------------------------------------------------------\n // Public Implemented Methods\n // -------------------------------------------------------------------------\n\n /**\n * Performs connection to the database.\n * Based on pooling options, it can either create connection immediately,\n * either create a pool and create connection when needed.\n */\n async connect(): Promise<void> {\n if (this.options.replication) {\n this.slaves = await Promise.all(\n this.options.replication.slaves.map((slave) => {\n return this.createPool(this.options, slave)\n }),\n )\n this.master = await this.createPool(\n this.options,\n this.options.replication.master,\n )\n } else {\n this.master = await this.createPool(this.options, this.options)\n }\n\n if (!this.database || !this.searchSchema) {\n const queryRunner = await this.createQueryRunner(\"master\")\n\n if (!this.database) {\n this.database = await queryRunner.getCurrentDatabase()\n }\n\n if (!this.searchSchema) {\n this.searchSchema = await queryRunner.getCurrentSchema()\n }\n\n await queryRunner.release()\n }\n\n if (!this.schema) {\n this.schema = this.searchSchema\n }\n }\n\n /**\n * Makes any action after connection (e.g. create extensions in Postgres driver).\n */\n async afterConnect(): Promise<void> {\n const extensionsMetadata = await this.checkMetadataForExtensions()\n const [connection, release] = await this.obtainMasterConnection()\n\n const installExtensions =\n this.options.installExtensions === undefined ||\n this.options.installExtensions\n if (installExtensions && extensionsMetadata.hasExtensions) {\n await this.enableExtensions(extensionsMetadata, connection)\n }\n\n const results = (await this.executeQuery(\n connection,\n \"SHOW server_version;\",\n )) as {\n rows: {\n server_version: string\n }[]\n }\n const versionString = results.rows[0].server_version\n this.isGeneratedColumnsSupported = VersionUtils.isGreaterOrEqual(\n versionString,\n \"12.0\",\n )\n\n await release()\n }\n\n protected async enableExtensions(extensionsMetadata: any, connection: any) {\n const { logger } = this.connection\n\n const {\n hasUuidColumns,\n hasCitextColumns,\n hasHstoreColumns,\n hasCubeColumns,\n hasGeometryColumns,\n hasLtreeColumns,\n hasExclusionConstraints,\n } = extensionsMetadata\n\n if (hasUuidColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"${\n this.options.uuidExtension || \"uuid-ossp\"\n }\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n `At least one of the entities has uuid column, but the '${\n this.options.uuidExtension || \"uuid-ossp\"\n }' extension cannot be installed automatically. Please install it manually using superuser rights, or select another uuid extension.`,\n )\n }\n if (hasCitextColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"citext\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"At least one of the entities has citext column, but the 'citext' extension cannot be installed automatically. Please install it manually using superuser rights\",\n )\n }\n if (hasHstoreColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"hstore\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"At least one of the entities has hstore column, but the 'hstore' extension cannot be installed automatically. Please install it manually using superuser rights\",\n )\n }\n if (hasGeometryColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"postgis\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n if (hasCubeColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"cube\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n if (hasLtreeColumns)\n try {\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"ltree\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n if (hasExclusionConstraints)\n try {\n // The btree_gist extension provides operator support in PostgreSQL exclusion constraints\n await this.executeQuery(\n connection,\n `CREATE EXTENSION IF NOT EXISTS \"btree_gist\"`,\n )\n } catch (_) {\n logger.log(\n \"warn\",\n \"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\",\n )\n }\n }\n\n protected async checkMetadataForExtensions() {\n const hasUuidColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.generatedColumns.filter(\n (column) => column.generationStrategy === \"uuid\",\n ).length > 0\n )\n },\n )\n const hasCitextColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter(\n (column) => column.type === \"citext\",\n ).length > 0\n )\n },\n )\n const hasHstoreColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter(\n (column) => column.type === \"hstore\",\n ).length > 0\n )\n },\n )\n const hasCubeColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter((column) => column.type === \"cube\")\n .length > 0\n )\n },\n )\n const hasGeometryColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter(\n (column) => this.spatialTypes.indexOf(column.type) >= 0,\n ).length > 0\n )\n },\n )\n const hasLtreeColumns = this.connection.entityMetadatas.some(\n (metadata) => {\n return (\n metadata.columns.filter((column) => column.type === \"ltree\")\n .length > 0\n )\n },\n )\n const hasExclusionConstraints = this.connection.entityMetadatas.some(\n (metadata) => {\n return metadata.exclusions.length > 0\n },\n )\n\n return {\n hasUuidColumns,\n hasCitextColumns,\n hasHstoreColumns,\n hasCubeColumns,\n hasGeometryColumns,\n hasLtreeColumns,\n hasExclusionConstraints,\n hasExtensions:\n hasUuidColumns ||\n hasCitextColumns ||\n hasHstoreColumns ||\n hasGeometryColumns ||\n hasCubeColumns ||\n hasLtreeColumns ||\n hasExclusionConstraints,\n }\n }\n\n /**\n * Closes connection with database.\n */\n async disconnect(): Promise<void> {\n if (!this.master)\n return Promise.reject(new ConnectionIsNotSetError(\"postgres\"))\n\n await this.closePool(this.master)\n await Promise.all(this.slaves.map((slave) => this.closePool(slave)))\n this.master = undefined\n this.slaves = []\n }\n\n /**\n * Creates a schema builder used to build and sync a schema.\n */\n createSchemaBuilder() {\n return new RdbmsSchemaBuilder(this.connection)\n }\n\n /**\n * Creates a query runner used to execute database queries.\n */\n createQueryRunner(mode: ReplicationMode): QueryRunner {\n return new PostgresQueryRunner(this, mode)\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type and metadata.\n */\n preparePersistentValue(value: any, columnMetadata: ColumnMetadata): any {\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformTo(\n columnMetadata.transformer,\n value,\n )\n\n if (value === null || value === undefined) return value\n\n if (columnMetadata.type === Boolean) {\n return value === true ? 1 : 0\n } else if (columnMetadata.type === \"date\") {\n return DateUtils.mixedDateToDateString(value)\n } else if (columnMetadata.type === \"time\") {\n return DateUtils.mixedDateToTimeString(value)\n } else if (\n columnMetadata.type === \"datetime\" ||\n columnMetadata.type === Date ||\n columnMetadata.type === \"timestamp\" ||\n columnMetadata.type === \"timestamp with time zone\" ||\n columnMetadata.type === \"timestamp without time zone\"\n ) {\n return DateUtils.mixedDateToDate(value)\n } else if (\n [\"json\", \"jsonb\", ...this.spatialTypes].indexOf(\n columnMetadata.type,\n ) >= 0\n ) {\n return JSON.stringify(value)\n } else if (columnMetadata.type === \"hstore\") {\n if (typeof value === \"string\") {\n return value\n } else {\n // https://www.postgresql.org/docs/9.0/hstore.html\n const quoteString = (value: unknown) => {\n // If a string to be quoted is `null` or `undefined`, we return a literal unquoted NULL.\n // This way, NULL values can be stored in the hstore object.\n if (value === null || typeof value === \"undefined\") {\n return \"NULL\"\n }\n // Convert non-null values to string since HStore only stores strings anyway.\n // To include a double quote or a backslash in a key or value, escape it with a backslash.\n return `\"${`${value}`.replace(/(?=[\"\\\\])/g, \"\\\\\")}\"`\n }\n return Object.keys(value)\n .map(\n (key) =>\n quoteString(key) + \"=>\" + quoteString(value[key]),\n )\n .join(\",\")\n }\n } else if (columnMetadata.type === \"simple-array\") {\n return DateUtils.simpleArrayToString(value)\n } else if (columnMetadata.type === \"simple-json\") {\n return DateUtils.simpleJsonToString(value)\n } else if (columnMetadata.type === \"cube\") {\n if (columnMetadata.isArray) {\n return `{${value\n .map((cube: number[]) => `\"(${cube.join(\",\")})\"`)\n .join(\",\")}}`\n }\n return `(${value.join(\",\")})`\n } else if (columnMetadata.type === \"ltree\") {\n return value\n .split(\".\")\n .filter(Boolean)\n .join(\".\")\n .replace(/[\\s]+/g, \"_\")\n } else if (\n (columnMetadata.type === \"enum\" ||\n columnMetadata.type === \"simple-enum\") &&\n !columnMetadata.isArray\n ) {\n return \"\" + value\n }\n\n return value\n }\n\n /**\n * Prepares given value to a value to be persisted, based on its column type or metadata.\n */\n prepareHydratedValue(value: any, columnMetadata: ColumnMetadata): any {\n if (value === null || value === undefined)\n return columnMetadata.transformer\n ? ApplyValueTransformers.transformFrom(\n columnMetadata.transformer,\n value,\n )\n : value\n\n if (columnMetadata.type === Boolean) {\n value = value ? true : false\n } else if (\n columnMetadata.type === \"datetime\" ||\n columnMetadata.type === Date ||\n columnMetadata.type === \"timestamp\" ||\n columnMetadata.type === \"timestamp with time zone\" ||\n columnMetadata.type === \"timestamp without time zone\"\n ) {\n value = DateUtils.normalizeHydratedDate(value)\n } else if (columnMetadata.type === \"date\") {\n value = DateUtils.mixedDateToDateString(value)\n } else if (columnMetadata.type === \"time\") {\n value = DateUtils.mixedTimeToString(value)\n } else if (columnMetadata.type === \"hstore\") {\n if (columnMetadata.hstoreType === \"object\") {\n const unescapeString = (str: string) =>\n str.replace(/\\\\./g, (m) => m[1])\n const regexp =\n /\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"=>(?:(NULL)|\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\")(?:,|$)/g\n const object: ObjectLiteral = {}\n ;`${value}`.replace(\n regexp,\n (_, key, nullValue, stringValue) => {\n object[unescapeString(key)] = nullValue\n ? null\n : unescapeString(stringValue)\n return \"\"\n },\n )\n return object\n } else {\n return value\n }\n } else if (columnMetadata.type === \"simple-array\") {\n value = DateUtils.stringToSimpleArray(value)\n } else if (columnMetadata.type === \"simple-json\") {\n value = DateUtils.stringToSimpleJson(value)\n } else if (columnMetadata.type === \"cube\") {\n value = value.replace(/[\\(\\)\\s]+/g, \"\") // remove whitespace\n if (columnMetadata.isArray) {\n /**\n * Strips these groups from `{\"1,2,3\",\"\",NULL}`:\n * 1. [\"1,2,3\", undefined] <- cube of arity 3\n * 2. [\"\", undefined] <- cube of arity 0\n * 3. [undefined, \"NULL\"] <- NULL\n */\n const regexp = /(?:\\\"((?:[\\d\\s\\.,])*)\\\")|(?:(NULL))/g\n const unparsedArrayString = value\n\n value = []\n let cube: RegExpExecArray | null = null\n // Iterate through all regexp matches for cubes/null in array\n while ((cube = regexp.exec(unparsedArrayString)) !== null) {\n if (cube[1] !== undefined) {\n value.push(\n cube[1].split(\",\").filter(Boolean).map(Number),\n )\n } else {\n value.push(undefined)\n }\n }\n } else {\n value = value.split(\",\").filter(Boolean).map(Number)\n }\n } else if (\n columnMetadata.type === \"enum\" ||\n columnMetadata.type === \"simple-enum\"\n ) {\n if (columnMetadata.isArray) {\n if (value === \"{}\") return []\n\n // manually convert enum array to array of values (pg does not support, see https://github.com/brianc/node-pg-types/issues/56)\n value = (value as string)\n .substr(1, (value as string).length - 2)\n .split(\",\")\n .map((val) => {\n // replace double quotes from the beginning and from the end\n if (val.startsWith(`\"`) && val.endsWith(`\"`))\n val = val.slice(1, -1)\n // replace double escaped backslash to single escaped e.g. \\\\\\\\ -> \\\\\n val = val.replace(/(\\\\\\\\)/g, \"\\\\\")\n // replace escaped double quotes to non-escaped e.g. \\\"asd\\\" -> \"asd\"\n return val.replace(/(\\\\\")/g, '\"')\n })\n\n // convert to number if that exists in possible enum options\n value = value.map((val: string) => {\n return !isNaN(+val) &&\n columnMetadata.enum!.indexOf(parseInt(val)) >= 0\n ? parseInt(val)\n : val\n })\n } else {\n // convert to number if that exists in possible enum options\n value =\n !isNaN(+value) &&\n columnMetadata.enum!.indexOf(parseInt(value)) >= 0\n ? parseInt(value)\n : value\n }\n }\n\n if (columnMetadata.transformer)\n value = ApplyValueTransformers.transformFrom(\n columnMetadata.transformer,\n value,\n )\n return value\n }\n\n /**\n * Replaces parameters in the given sql with special escaping character\n * and an array of parameter names to be passed to a query.\n */\n escapeQueryWithParameters(\n sql: string,\n parameters: ObjectLiteral,\n nativeParameters: ObjectLiteral,\n ): [string, any[]] {\n const escapedParameters: any[] = Object.keys(nativeParameters).map(\n (key) => nativeParameters[key],\n )\n if (!parameters || !Object.keys(parameters).length)\n return [sql, escapedParameters]\n\n sql = sql.replace(\n /:(\\.\\.\\.)?([A-Za-z0-9_.]+)/g,\n (full, isArray: string, key: string): string => {\n if (!parameters.hasOwnProperty(key)) {\n return full\n }\n\n let value: any = parameters[key]\n\n if (isArray) {\n return value\n .map((v: any) => {\n escapedParameters.push(v)\n return this.createParameter(\n key,\n escapedParameters.length - 1,\n )\n })\n .join(\", \")\n }\n\n if (typeof value === \"function\") {\n return value()\n }\n\n escapedParameters.push(value)\n return this.createParameter(key, escapedParameters.length - 1)\n },\n ) // todo: make replace only in value statements, otherwise problems\n return [sql, escapedParameters]\n }\n\n /**\n * Escapes a column name.\n */\n escape(columnName: string): string {\n return '\"' + columnName + '\"'\n }\n\n /**\n * Build full table name with schema name and table name.\n * E.g. myDB.mySchema.myTable\n */\n buildTableName(tableName: string, schema?: string): string {\n let tablePath = [tableName]\n\n if (schema) {\n tablePath.unshift(schema)\n }\n\n return tablePath.join(\".\")\n }\n\n /**\n * Parse a target table name or other types and return a normalized table definition.\n */\n parseTableName(\n target: EntityMetadata | Table | View | TableForeignKey | string,\n ): { database?: string; schema?: string; tableName: string } {\n const driverDatabase = this.database\n const driverSchema = this.schema\n\n if (InstanceChecker.isTable(target) || InstanceChecker.isView(target)) {\n const parsed = this.parseTableName(target.name)\n\n return {\n database: target.database || parsed.database || driverDatabase,\n schema: target.schema || parsed.schema || driverSchema,\n tableName: parsed.tableName,\n }\n }\n\n if (InstanceChecker.isTableForeignKey(target)) {\n const parsed = this.parseTableName(target.referencedTableName)\n\n return {\n database:\n target.referencedDatabase ||\n parsed.database ||\n driverDatabase,\n schema:\n target.referencedSchema || parsed.schema || driverSchema,\n tableName: parsed.tableName,\n }\n }\n\n if (InstanceChecker.isEntityMetadata(target)) {\n // EntityMetadata tableName is never a path\n\n return {\n database: target.database || driverDatabase,\n schema: target.schema || driverSchema,\n tableName: target.tableName,\n }\n }\n\n const parts = target.split(\".\")\n\n return {\n database: driverDatabase,\n schema: (parts.length > 1 ? parts[0] : undefined) || driverSchema,\n tableName: parts.length > 1 ? parts[1] : parts[0],\n }\n }\n\n /**\n * Creates a database type from a given column metadata.\n */\n normalizeType(column: {\n type?: ColumnType\n length?: number | string\n precision?: number | null\n scale?: number\n isArray?: boolean\n }): string {\n if (\n column.type === Number ||\n column.type === \"int\" ||\n column.type === \"int4\"\n ) {\n return \"integer\"\n } else if (column.type === String || column.type === \"varchar\") {\n return \"character varying\"\n } else if (column.type === Date || column.type === \"timestamp\") {\n return \"timestamp without time zone\"\n } else if (column.type === \"timestamptz\") {\n return \"timestamp with time zone\"\n } else if (column.type === \"time\") {\n return \"time without time zone\"\n } else if (column.type === \"timetz\") {\n return \"time with time zone\"\n } else if (column.type === Boolean || column.type === \"bool\") {\n return \"boolean\"\n } else if (column.type === \"simple-array\") {\n return \"text\"\n } else if (column.type === \"simple-json\") {\n return \"text\"\n } else if (column.type === \"simple-enum\") {\n return \"enum\"\n } else if (column.type === \"int2\") {\n return \"smallint\"\n } else if (column.type === \"int8\") {\n return \"bigint\"\n } else if (column.type === \"decimal\") {\n return \"numeric\"\n } else if (column.type === \"float8\" || column.type === \"float\") {\n return \"double precision\"\n } else if (column.type === \"float4\") {\n return \"real\"\n } else if (column.type === \"char\") {\n return \"character\"\n } else if (column.type === \"varbit\") {\n return \"bit varying\"\n } else {\n return (column.type as string) || \"\"\n }\n }\n\n /**\n * Normalizes \"default\" value of the column.\n */\n normalizeDefault(columnMetadata: ColumnMetadata): string | undefined {\n const defaultValue = columnMetadata.default\n\n if (defaultValue === null) {\n return undefined\n }\n\n if (columnMetadata.isArray && Array.isArray(defaultValue)) {\n return `'{${defaultValue\n .map((val: string) => `${val}`)\n .join(\",\")}}'`\n }\n\n if (\n (columnMetadata.type === \"enum\" ||\n columnMetadata.type === \"simple-enum\" ||\n typeof defaultValue === \"number\" ||\n typeof defaultValue === \"string\") &&\n defaultValue !== undefined\n ) {\n return `'${defaultValue}'`\n }\n\n if (typeof defaultValue === \"boolean\") {\n return defaultValue ? \"true\" : \"false\"\n }\n\n if (typeof defaultValue === \"function\") {\n const value = defaultValue()\n\n return this.normalizeDatetimeFunction(value)\n }\n\n if (typeof defaultValue === \"object\") {\n return `'${JSON.stringify(defaultValue)}'`\n }\n\n if (defaultValue === undefined) {\n return undefined\n }\n\n return `${defaultValue}`\n }\n\n /**\n * Compares \"default\" value of the column.\n * Postgres sorts json values before it is saved, so in that case a deep comparison has to be performed to see if has changed.\n */\n private defaultEqual(\n columnMetadata: ColumnMetadata,\n tableColumn: TableColumn,\n ): boolean {\n if (\n [\"json\", \"jsonb\"].includes(columnMetadata.type as string) &&\n ![\"function\", \"undefined\"].includes(typeof columnMetadata.default)\n ) {\n const tableColumnDefault =\n typeof tableColumn.default === \"string\"\n ? JSON.parse(\n tableColumn.default.substring(\n 1,\n tableColumn.default.length - 1,\n ),\n )\n : tableColumn.default\n\n return OrmUtils.deepCompare(\n columnMetadata.default,\n tableColumnDefault,\n )\n }\n\n const columnDefault = this.lowerDefaultValueIfNecessary(\n this.normalizeDefault(columnMetadata),\n )\n return columnDefault === tableColumn.default\n }\n\n /**\n * Normalizes \"isUnique\" value of the column.\n */\n normalizeIsUnique(column: ColumnMetadata): boolean {\n return column.entityMetadata.uniques.some(\n (uq) => uq.columns.length === 1 && uq.columns[0] === column,\n )\n }\n\n /**\n * Returns default column lengths, which is required on column creation.\n */\n getColumnLength(column: ColumnMetadata): string {\n return column.length ? column.length.toString() : \"\"\n }\n\n /**\n * Creates column type definition including length, precision and scale\n */\n createFullType(column: TableColumn): string {\n let type = column.type\n\n if (column.length) {\n type += \"(\" + column.length + \")\"\n } else if (\n column.precision !== null &&\n column.precision !== undefined &&\n column.scale !== null &&\n column.scale !== undefined\n ) {\n type += \"(\" + column.precision + \",\" + column.scale + \")\"\n } else if (\n column.precision !== null &&\n column.precision !== undefined\n ) {\n type += \"(\" + column.precision + \")\"\n }\n\n if (column.type === \"time without time zone\") {\n type =\n \"TIME\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\")\n } else if (column.type === \"time with time zone\") {\n type =\n \"TIME\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\") +\n \" WITH TIME ZONE\"\n } else if (column.type === \"timestamp without time zone\") {\n type =\n \"TIMESTAMP\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\")\n } else if (column.type === \"timestamp with time zone\") {\n type =\n \"TIMESTAMP\" +\n (column.precision !== null && column.precision !== undefined\n ? \"(\" + column.precision + \")\"\n : \"\") +\n \" WITH TIME ZONE\"\n } else if (this.spatialTypes.indexOf(column.type as ColumnType) >= 0) {\n if (column.spatialFeatureType != null && column.srid != null) {\n type = `${column.type}(${column.spatialFeatureType},${column.srid})`\n } else if (column.spatialFeatureType != null) {\n type = `${column.type}(${column.spatialFeatureType})`\n } else {\n type = column.type\n }\n }\n\n if (column.isArray) type += \" array\"\n\n return type\n }\n\n /**\n * Obtains a new database connection to a master server.\n * Used for replication.\n * If replication is not setup then returns default connection's database connection.\n */\n async obtainMasterConnection(): Promise<[any, Function]> {\n if (!this.master) {\n throw new TypeORMError(\"Driver not Connected\")\n }\n\n return new Promise((ok, fail) => {\n this.master.connect((err: any, connection: any, release: any) => {\n err ? fail(err) : ok([connection, release])\n })\n })\n }\n\n /**\n * Obtains a new database connection to a slave server.\n * Used for replication.\n * If replication is not setup then returns master (default) connection's database connection.\n */\n async obtainSlaveConnection(): Promise<[any, Function]> {\n if (!this.slaves.length) {\n return this.obtainMasterConnection()\n }\n\n const random = Math.floor(Math.random() * this.slaves.length)\n\n return new Promise((ok, fail) => {\n this.slaves[random].connect(\n (err: any, connection: any, release: any) => {\n err ? fail(err) : ok([connection, release])\n },\n )\n })\n }\n\n /**\n * Creates generated map of values generated or returned by database after INSERT query.\n *\n * todo: slow. optimize Object.keys(), OrmUtils.mergeDeep and column.createValueMap parts\n */\n createGeneratedMap(metadata: EntityMetadata, insertResult: ObjectLiteral) {\n if (!insertResult) return undefined\n\n return Object.keys(insertResult).reduce((map, key) => {\n const column = metadata.findColumnWithDatabaseName(key)\n if (column) {\n OrmUtils.mergeDeep(\n map,\n column.createValueMap(insertResult[key]),\n )\n // OrmUtils.mergeDeep(map, column.createValueMap(this.prepareHydratedValue(insertResult[key], column))); // TODO: probably should be like there, but fails on enums, fix later\n }\n return map\n }, {} as ObjectLiteral)\n }\n\n /**\n * Differentiate columns of this table and columns from the given column metadatas columns\n * and returns only changed.\n */\n findChangedColumns(\n tableColumns: TableColumn[],\n columnMetadatas: ColumnMetadata[],\n ): ColumnMetadata[] {\n return columnMetadatas.filter((columnMetadata) => {\n const tableColumn = tableColumns.find(\n (c) => c.name === columnMetadata.databaseName,\n )\n if (!tableColumn) return false // we don't need new columns, we only need exist and changed\n\n const isColumnChanged =\n tableColumn.name !== columnMetadata.databaseName ||\n tableColumn.type !== this.normalizeType(columnMetadata) ||\n tableColumn.length !== columnMetadata.length ||\n tableColumn.isArray !== columnMetadata.isArray ||\n tableColumn.precision !== columnMetadata.precision ||\n (columnMetadata.scale !== undefined &&\n tableColumn.scale !== columnMetadata.scale) ||\n tableColumn.comment !==\n this.escapeComment(columnMetadata.comment) ||\n (!tableColumn.isGenerated &&\n !this.defaultEqual(columnMetadata, tableColumn)) || // we included check for generated here, because generated columns already can have default values\n tableColumn.isPrimary !== columnMetadata.isPrimary ||\n tableColumn.isNullable !== columnMetadata.isNullable ||\n tableColumn.isUnique !==\n this.normalizeIsUnique(columnMetadata) ||\n tableColumn.enumName !== columnMetadata.enumName ||\n (tableColumn.enum &&\n columnMetadata.enum &&\n !OrmUtils.isArraysEqual(\n tableColumn.enum,\n columnMetadata.enum.map((val) => val + \"\"),\n )) || // enums in postgres are always strings\n tableColumn.isGenerated !== columnMetadata.isGenerated ||\n (tableColumn.spatialFeatureType || \"\").toLowerCase() !==\n (columnMetadata.spatialFeatureType || \"\").toLowerCase() ||\n tableColumn.srid !== columnMetadata.srid ||\n tableColumn.generatedType !== columnMetadata.generatedType ||\n (tableColumn.asExpression || \"\").trim() !==\n (columnMetadata.asExpression || \"\").trim()\n\n // DEBUG SECTION\n // if (isColumnChanged) {\n // console.log(\"table:\", columnMetadata.entityMetadata.tableName);\n // console.log(\"name:\", tableColumn.name, columnMetadata.databaseName);\n // console.log(\"type:\", tableColumn.type, this.normalizeType(columnMetadata));\n // console.log(\"length:\", tableColumn.length, columnMetadata.length);\n // console.log(\"isArray:\", tableColumn.isArray, columnMetadata.isArray);\n // console.log(\"precision:\", tableColumn.precision, columnMetadata.precision);\n // console.log(\"scale:\", tableColumn.scale, columnMetadata.scale);\n // console.log(\"comment:\", tableColumn.comment, this.escapeComment(columnMetadata.comment));\n // console.log(\"enumName:\", tableColumn.enumName, columnMetadata.enumName);\n // console.log(\"enum:\", tableColumn.enum && columnMetadata.enum && !OrmUtils.isArraysEqual(tableColumn.enum, columnMetadata.enum.map(val => val + \"\")));\n // console.log(\"isPrimary:\", tableColumn.isPrimary, columnMetadata.isPrimary);\n // console.log(\"isNullable:\", tableColumn.isNullable, columnMetadata.isNullable);\n // console.log(\"isUnique:\", tableColumn.isUnique, this.normalizeIsUnique(columnMetadata));\n // console.log(\"isGenerated:\", tableColumn.isGenerated, columnMetadata.isGenerated);\n // console.log(\"isGenerated 2:\", !tableColumn.isGenerated && this.lowerDefaultValueIfNecessary(this.normalizeDefault(columnMetadata)) !== tableColumn.default);\n // console.log(\"spatialFeatureType:\", (tableColumn.spatialFeatureType || \"\").toLowerCase(), (columnMetadata.spatialFeatureType || \"\").toLowerCase());\n // console.log(\"srid\", tableColumn.srid, columnMetadata.srid);\n // console.log(\"==========================================\");\n // }\n\n return isColumnChanged\n })\n }\n\n private lowerDefaultValueIfNecessary(value: string | undefined) {\n // Postgres saves function calls in default value as lowercase #2733\n if (!value) {\n return value\n }\n return value\n .split(`'`)\n .map((v, i) => {\n return i % 2 === 1 ? v : v.toLowerCase()\n })\n .join(`'`)\n }\n\n /**\n * Returns true if driver supports RETURNING / OUTPUT statement.\n */\n isReturningSqlSupported(): boolean {\n return true\n }\n\n /**\n * Returns true if driver supports uuid values generation on its own.\n */\n isUUIDGenerationSupported(): boolean {\n return true\n }\n\n /**\n * Returns true if driver supports fulltext indices.\n */\n isFullTextColumnTypeSupported(): boolean {\n return false\n }\n\n get uuidGenerator(): string {\n return this.options.uuidExtension === \"pgcrypto\"\n ? \"gen_random_uuid()\"\n : \"uuid_generate_v4()\"\n }\n\n /**\n * Creates an escaped parameter.\n */\n createParameter(parameterName: string, index: number): string {\n return \"$\" + (index + 1)\n }\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads postgres query stream package.\n */\n loadStreamDependency() {\n try {\n return PlatformTools.load(\"pg-query-stream\")\n } catch (e) {\n // todo: better error for browser env\n throw new TypeORMError(\n `To use streams you should install pg-query-stream package. Please run npm i pg-query-stream --save command.`,\n )\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * If driver dependency is not given explicitly, then try to load it via \"require\".\n */\n protected loadDependencies(): void {\n try {\n const postgres = this.options.driver || PlatformTools.load(\"pg\")\n this.postgres = postgres\n try {\n const pgNative =\n this.options.nativeDriver || PlatformTools.load(\"pg-native\")\n if (pgNative && this.postgres.native)\n this.postgres = this.postgres.native\n } catch (e) {}\n } catch (e) {\n // todo: better error for browser env\n throw new DriverPackageNotInstalledError(\"Postgres\", \"pg\")\n }\n }\n\n /**\n * Creates a new connection pool for a given database credentials.\n */\n protected async createPool(\n options: PostgresConnectionOptions,\n credentials: PostgresConnectionCredentialsOptions,\n ): Promise<any> {\n credentials = Object.assign({}, credentials)\n\n // build connection options for the driver\n // See: https://github.com/brianc/node-postgres/tree/master/packages/pg-pool#create\n const connectionOptions = Object.assign(\n {},\n {\n connectionString: credentials.url,\n host: credentials.host,\n user: credentials.username,\n password: credentials.password,\n database: credentials.database,\n port: credentials.port,\n ssl: credentials.ssl,\n connectionTimeoutMillis: options.connectTimeoutMS,\n application_name: options.applicationName,\n },\n options.extra || {},\n )\n\n // create a connection pool\n const pool = new this.postgres.Pool(connectionOptions)\n const { logger } = this.connection\n\n const poolErrorHandler =\n options.poolErrorHandler ||\n ((error: any) =>\n logger.log(\"warn\", `Postgres pool raised an error. ${error}`))\n\n /*\n Attaching an error handler to pool errors is essential, as, otherwise, errors raised will go unhandled and\n cause the hosting app to crash.\n */\n pool.on(\"error\", poolErrorHandler)\n\n return new Promise((ok, fail) => {\n pool.connect((err: any, connection: any, release: Function) => {\n if (err) return fail(err)\n\n if (options.logNotifications) {\n connection.on(\"notice\", (msg: any) => {\n msg && this.connection.logger.log(\"info\", msg.message)\n })\n connection.on(\"notification\", (msg: any) => {\n msg &&\n this.connection.logger.log(\n \"info\",\n `Received NOTIFY on channel ${msg.channel}: ${msg.payload}.`,\n )\n })\n }\n release()\n ok(pool)\n })\n })\n }\n\n /**\n * Closes connection pool.\n */\n protected async closePool(pool: any): Promise<void> {\n while (this.connectedQueryRunners.length) {\n await this.connectedQueryRunners[0].release()\n }\n\n return new Promise<void>((ok, fail) => {\n pool.end((err: any) => (err ? fail(err) : ok()))\n })\n }\n\n /**\n * Executes given query.\n */\n protected executeQuery(connection: any, query: string) {\n this.connection.logger.logQuery(query)\n\n return new Promise((ok, fail) => {\n connection.query(query, (err: any, result: any) =>\n err ? fail(err) : ok(result),\n )\n })\n }\n\n /**\n * If parameter is a datetime function, e.g. \"CURRENT_TIMESTAMP\", normalizes it.\n * Otherwise returns original input.\n */\n protected normalizeDatetimeFunction(value: string) {\n // check if input is datetime function\n const upperCaseValue = value.toUpperCase()\n const isDatetimeFunction =\n upperCaseValue.indexOf(\"CURRENT_TIMESTAMP\") !== -1 ||\n upperCaseValue.indexOf(\"CURRENT_DATE\") !== -1 ||\n upperCaseValue.indexOf(\"CURRENT_TIME\") !== -1 ||\n upperCaseValue.indexOf(\"LOCALTIMESTAMP\") !== -1 ||\n upperCaseValue.indexOf(\"LOCALTIME\") !== -1\n\n if (isDatetimeFunction) {\n // extract precision, e.g. \"(3)\"\n const precision = value.match(/\\(\\d+\\)/)\n\n if (upperCaseValue.indexOf(\"CURRENT_TIMESTAMP\") !== -1) {\n return precision\n ? `('now'::text)::timestamp${precision[0]} with time zone`\n : \"now()\"\n } else if (upperCaseValue === \"CURRENT_DATE\") {\n return \"('now'::text)::date\"\n } else if (upperCaseValue.indexOf(\"CURRENT_TIME\") !== -1) {\n return precision\n ? `('now'::text)::time${precision[0]} with time zone`\n : \"('now'::text)::time with time zone\"\n } else if (upperCaseValue.indexOf(\"LOCALTIMESTAMP\") !== -1) {\n return precision\n ? `('now'::text)::timestamp${precision[0]} without time zone`\n : \"('now'::text)::timestamp without time zone\"\n } else if (upperCaseValue.indexOf(\"LOCALTIME\") !== -1) {\n return precision\n ? `('now'::text)::time${precision[0]} without time zone`\n : \"('now'::text)::time without time zone\"\n }\n }\n\n return value\n }\n\n /**\n * Escapes a given comment.\n */\n protected escapeComment(comment?: string) {\n if (!comment) return comment\n\n comment = comment.replace(/\\u0000/g, \"\") // Null bytes aren't allowed in comments\n\n return comment\n }\n}\n"],"sourceRoot":"../.."}
@@ -21,7 +21,7 @@ export declare class BaseEntity {
21
21
  /**
22
22
  * DataSource used in all static methods of the BaseEntity.
23
23
  */
24
- private static dataSource?;
24
+ private static dataSource;
25
25
  /**
26
26
  * Checks if entity has an id.
27
27
  * If entity composite compose ids, it will check them all.
@@ -51,7 +51,7 @@ export declare class BaseEntity {
51
51
  /**
52
52
  * Sets DataSource to be used by entity.
53
53
  */
54
- static useDataSource(dataSource: DataSource): void;
54
+ static useDataSource(dataSource: DataSource | null): void;
55
55
  /**
56
56
  * Gets current entity's Repository.
57
57
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/repository/BaseEntity.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAKjD;;GAEG;AACH,MAAM,OAAO,UAAU;IAWnB,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,KAAK;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACjD,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,OAAqB;QACtB,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACzD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAuB;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD,OAAO,UAA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,UAAU,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QAGR,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,KAAK,EAAE,CAAA;IAC1C,CAAC;CACJ","file":"BaseEntity.js","sourcesContent":["import { Repository } from \"./Repository\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { SaveOptions } from \"./SaveOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { RemoveOptions } from \"./RemoveOptions\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { DataSource } from \"../data-source\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { UpsertOptions } from \"./UpsertOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * DataSource used in all static methods of the BaseEntity.\n */\n // @ts-ignore: Unused variable which is actually used\n private static dataSource?: DataSource\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(): boolean {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().hasId(this)\n }\n\n /**\n * Saves current entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().save(this, options)\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().remove(this, options) as Promise<this>\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().softRemove(this, options)\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().recover(this, options)\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const baseEntity = this.constructor as typeof BaseEntity\n const newestEntity: BaseEntity = await baseEntity\n .getRepository()\n .findOneOrFail(baseEntity.getId(this))\n\n ObjectUtils.assign(this, newestEntity)\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets DataSource to be used by entity.\n */\n static useDataSource(dataSource: DataSource) {\n this.dataSource = dataSource\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Repository<T> {\n const dataSource = (this as typeof BaseEntity).dataSource\n if (!dataSource)\n throw new Error(`DataSource is not set for this entity.`)\n return dataSource.getRepository<T>(this)\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n static get target(): EntityTarget<any> {\n return this.getRepository().target\n }\n\n /**\n * Checks entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n static hasId(entity: BaseEntity): boolean {\n return this.getRepository().hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n static getId<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n ): any {\n return this.getRepository<T>().getId(entity)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n static createQueryBuilder<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n alias?: string,\n ): SelectQueryBuilder<T> {\n return this.getRepository<T>().createQueryBuilder(alias)\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): T\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLikeArray: DeepPartial<T>[],\n ): T[]\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): T\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities?: any,\n ) {\n return this.getRepository<T>().create(entityOrEntities)\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n mergeIntoEntity: T,\n ...entityLikes: DeepPartial<T>[]\n ): T {\n return this.getRepository<T>().merge(\n mergeIntoEntity,\n ...entityLikes,\n ) as T\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n static preload<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): Promise<T | undefined> {\n const thisRepository = this.getRepository() as Repository<T>\n return thisRepository.preload(entityLike)\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: DeepPartial<T>[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: DeepPartial<T>,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: DeepPartial<T> | DeepPartial<T>[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().save(entityOrEntities as any, options)\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: RemoveOptions,\n ): Promise<T[]>\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: RemoveOptions,\n ): Promise<T>\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: RemoveOptions,\n ) {\n return this.getRepository<T>().remove(entityOrEntities as any, options)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().softRemove(\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n static insert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: QueryDeepPartialEntity<T> | QueryDeepPartialEntity<T>[],\n ): Promise<InsertResult> {\n return this.getRepository<T>().insert(entity)\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n static update<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<T>,\n partialEntity: QueryDeepPartialEntity<T>,\n ): Promise<UpdateResult> {\n return this.getRepository<T>().update(criteria, partialEntity)\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n static upsert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities:\n | QueryDeepPartialEntity<T>\n | QueryDeepPartialEntity<T>[],\n conflictPathsOrOptions: string[] | UpsertOptions<T>,\n ): Promise<InsertResult> {\n return this.getRepository<T>().upsert(\n entityOrEntities,\n conflictPathsOrOptions,\n )\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike remove method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n static delete<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<T>,\n ): Promise<DeleteResult> {\n return this.getRepository<T>().delete(criteria)\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<number> {\n return this.getRepository<T>().count(options)\n }\n\n /**\n * Counts entities that match given WHERE conditions.\n */\n static countBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<number> {\n return this.getRepository<T>().countBy(where)\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().find(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n */\n static findBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().findBy(where)\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCount(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCountBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCountBy(where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n static findByIds<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ids: any[],\n ): Promise<T[]> {\n return this.getRepository<T>().findByIds(ids)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOne(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneBy(where)\n }\n\n /**\n * Finds first entity that matches given options.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n static findOneById<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n id: string | number | Date | ObjectID,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneById(id)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneOrFail(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneByOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneByOrFail(where)\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n static query<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n query: string,\n parameters?: any[],\n ): Promise<any> {\n return this.getRepository<T>().query(query, parameters)\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Promise<void> {\n return this.getRepository<T>().clear()\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/repository/BaseEntity.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAKjD;;GAEG;AACH,MAAM,OAAO,UAAU;IAUnB,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;;OAGG;IACH,KAAK;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,WAAgC,CAAA;QACxD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C,aAAa,CAEhB,OAA0B;QAE1B,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IACzD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,eAAe,CAElB,KAA0B;QAE1B,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;IACzD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAER,KAAa,EACb,UAAkB;QAElB,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;IAC3D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QAGR,OAAO,IAAI,CAAC,aAAa,EAAK,CAAC,KAAK,EAAE,CAAA;IAC1C,CAAC;CACJ","file":"BaseEntity.js","sourcesContent":["import { Repository } from \"./Repository\"\nimport { FindOptionsWhere } from \"../find-options/FindOptionsWhere\"\nimport { DeepPartial } from \"../common/DeepPartial\"\nimport { SaveOptions } from \"./SaveOptions\"\nimport { FindOneOptions } from \"../find-options/FindOneOptions\"\nimport { RemoveOptions } from \"./RemoveOptions\"\nimport { FindManyOptions } from \"../find-options/FindManyOptions\"\nimport { DataSource } from \"../data-source\"\nimport { SelectQueryBuilder } from \"../query-builder/SelectQueryBuilder\"\nimport { InsertResult } from \"../query-builder/result/InsertResult\"\nimport { UpdateResult } from \"../query-builder/result/UpdateResult\"\nimport { DeleteResult } from \"../query-builder/result/DeleteResult\"\nimport { ObjectID } from \"../driver/mongodb/typings\"\nimport { ObjectUtils } from \"../util/ObjectUtils\"\nimport { QueryDeepPartialEntity } from \"../query-builder/QueryPartialEntity\"\nimport { UpsertOptions } from \"./UpsertOptions\"\nimport { EntityTarget } from \"../common/EntityTarget\"\n\n/**\n * Base abstract entity for all entities, used in ActiveRecord patterns.\n */\nexport class BaseEntity {\n // -------------------------------------------------------------------------\n // Private Static Properties\n // -------------------------------------------------------------------------\n\n /**\n * DataSource used in all static methods of the BaseEntity.\n */\n private static dataSource: DataSource | null\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Checks if entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n hasId(): boolean {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().hasId(this)\n }\n\n /**\n * Saves current entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n save(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().save(this, options)\n }\n\n /**\n * Removes current entity from the database.\n */\n remove(options?: RemoveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().remove(this, options) as Promise<this>\n }\n\n /**\n * Records the delete date of current entity.\n */\n softRemove(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().softRemove(this, options)\n }\n\n /**\n * Recovers a given entity in the database.\n */\n recover(options?: SaveOptions): Promise<this> {\n const baseEntity = this.constructor as typeof BaseEntity\n return baseEntity.getRepository().recover(this, options)\n }\n\n /**\n * Reloads entity data from the database.\n */\n async reload(): Promise<void> {\n const baseEntity = this.constructor as typeof BaseEntity\n const newestEntity: BaseEntity = await baseEntity\n .getRepository()\n .findOneOrFail(baseEntity.getId(this))\n\n ObjectUtils.assign(this, newestEntity)\n }\n\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Sets DataSource to be used by entity.\n */\n static useDataSource(dataSource: DataSource | null) {\n this.dataSource = dataSource\n }\n\n /**\n * Gets current entity's Repository.\n */\n static getRepository<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Repository<T> {\n const dataSource = (this as typeof BaseEntity).dataSource\n if (!dataSource)\n throw new Error(`DataSource is not set for this entity.`)\n return dataSource.getRepository<T>(this)\n }\n\n /**\n * Returns object that is managed by this repository.\n * If this repository manages entity from schema,\n * then it returns a name of that schema instead.\n */\n static get target(): EntityTarget<any> {\n return this.getRepository().target\n }\n\n /**\n * Checks entity has an id.\n * If entity composite compose ids, it will check them all.\n */\n static hasId(entity: BaseEntity): boolean {\n return this.getRepository().hasId(entity)\n }\n\n /**\n * Gets entity mixed id.\n */\n static getId<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n ): any {\n return this.getRepository<T>().getId(entity)\n }\n\n /**\n * Creates a new query builder that can be used to build a SQL query.\n */\n static createQueryBuilder<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n alias?: string,\n ): SelectQueryBuilder<T> {\n return this.getRepository<T>().createQueryBuilder(alias)\n }\n\n /**\n * Creates a new entity instance.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): T\n\n /**\n * Creates a new entities and copies all entity properties from given objects into their new entities.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLikeArray: DeepPartial<T>[],\n ): T[]\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): T\n\n /**\n * Creates a new entity instance and copies all entity properties from this object into a new entity.\n * Note that it copies only properties that present in entity schema.\n */\n static create<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities?: any,\n ) {\n return this.getRepository<T>().create(entityOrEntities)\n }\n\n /**\n * Merges multiple entities (or entity-like objects) into a given entity.\n */\n static merge<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n mergeIntoEntity: T,\n ...entityLikes: DeepPartial<T>[]\n ): T {\n return this.getRepository<T>().merge(\n mergeIntoEntity,\n ...entityLikes,\n ) as T\n }\n\n /**\n * Creates a new entity from the given plain javascript object. If entity already exist in the database, then\n * it loads it (and everything related to it), replaces all values with the new ones from the given object\n * and returns this new entity. This new entity is actually a loaded from the db entity with all properties\n * replaced from the new object.\n *\n * Note that given entity-like object must have an entity id / primary key to find entity by.\n * Returns undefined if entity with given id was not found.\n */\n static preload<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityLike: DeepPartial<T>,\n ): Promise<T | undefined> {\n const thisRepository = this.getRepository() as Repository<T>\n return thisRepository.preload(entityLike)\n }\n\n /**\n * Saves all given entities in the database.\n * If entities do not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: DeepPartial<T>[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Saves a given entity in the database.\n * If entity does not exist in the database then inserts, otherwise updates.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: DeepPartial<T>,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Saves one or many given entities.\n */\n static save<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: DeepPartial<T> | DeepPartial<T>[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().save(entityOrEntities as any, options)\n }\n\n /**\n * Removes a given entities from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: RemoveOptions,\n ): Promise<T[]>\n\n /**\n * Removes a given entity from the database.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: RemoveOptions,\n ): Promise<T>\n\n /**\n * Removes one or many given entities.\n */\n static remove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: RemoveOptions,\n ) {\n return this.getRepository<T>().remove(entityOrEntities as any, options)\n }\n\n /**\n * Records the delete date of all given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entities: T[],\n options?: SaveOptions,\n ): Promise<T[]>\n\n /**\n * Records the delete date of a given entity.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: T,\n options?: SaveOptions,\n ): Promise<T>\n\n /**\n * Records the delete date of one or many given entities.\n */\n static softRemove<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities: T | T[],\n options?: SaveOptions,\n ) {\n return this.getRepository<T>().softRemove(\n entityOrEntities as any,\n options,\n )\n }\n\n /**\n * Inserts a given entity into the database.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT query.\n * Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.\n */\n static insert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entity: QueryDeepPartialEntity<T> | QueryDeepPartialEntity<T>[],\n ): Promise<InsertResult> {\n return this.getRepository<T>().insert(entity)\n }\n\n /**\n * Updates entity partially. Entity can be found by a given conditions.\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient UPDATE query.\n * Does not check if entity exist in the database.\n */\n static update<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<T>,\n partialEntity: QueryDeepPartialEntity<T>,\n ): Promise<UpdateResult> {\n return this.getRepository<T>().update(criteria, partialEntity)\n }\n\n /**\n * Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity\n * Unlike save method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.\n */\n static upsert<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n entityOrEntities:\n | QueryDeepPartialEntity<T>\n | QueryDeepPartialEntity<T>[],\n conflictPathsOrOptions: string[] | UpsertOptions<T>,\n ): Promise<InsertResult> {\n return this.getRepository<T>().upsert(\n entityOrEntities,\n conflictPathsOrOptions,\n )\n }\n\n /**\n * Deletes entities by a given criteria.\n * Unlike remove method executes a primitive operation without cascades, relations and other operations included.\n * Executes fast and efficient DELETE query.\n * Does not check if entity exist in the database.\n */\n static delete<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n criteria:\n | string\n | string[]\n | number\n | number[]\n | Date\n | Date[]\n | ObjectID\n | ObjectID[]\n | FindOptionsWhere<T>,\n ): Promise<DeleteResult> {\n return this.getRepository<T>().delete(criteria)\n }\n\n /**\n * Counts entities that match given options.\n */\n static count<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<number> {\n return this.getRepository<T>().count(options)\n }\n\n /**\n * Counts entities that match given WHERE conditions.\n */\n static countBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<number> {\n return this.getRepository<T>().countBy(where)\n }\n\n /**\n * Finds entities that match given options.\n */\n static find<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().find(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n */\n static findBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T[]> {\n return this.getRepository<T>().findBy(where)\n }\n\n /**\n * Finds entities that match given find options.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCount<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options?: FindManyOptions<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCount(options)\n }\n\n /**\n * Finds entities that match given WHERE conditions.\n * Also counts all entities that match given conditions,\n * but ignores pagination settings (from and take options).\n */\n static findAndCountBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<[T[], number]> {\n return this.getRepository<T>().findAndCountBy(where)\n }\n\n /**\n * Finds entities by ids.\n * Optionally find options can be applied.\n *\n * @deprecated use `findBy` method instead in conjunction with `In` operator, for example:\n *\n * .findBy({\n * id: In([1, 2, 3])\n * })\n */\n static findByIds<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ids: any[],\n ): Promise<T[]> {\n return this.getRepository<T>().findByIds(ids)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOne<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOne(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneBy<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneBy(where)\n }\n\n /**\n * Finds first entity that matches given options.\n *\n * @deprecated use `findOneBy` method instead in conjunction with `In` operator, for example:\n *\n * .findOneBy({\n * id: 1 // where \"id\" is your primary column name\n * })\n */\n static findOneById<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n id: string | number | Date | ObjectID,\n ): Promise<T | null> {\n return this.getRepository<T>().findOneById(id)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n options: FindOneOptions<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneOrFail(options)\n }\n\n /**\n * Finds first entity that matches given conditions.\n */\n static findOneByOrFail<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n where: FindOptionsWhere<T>,\n ): Promise<T> {\n return this.getRepository<T>().findOneByOrFail(where)\n }\n\n /**\n * Executes a raw SQL query and returns a raw database results.\n * Raw query execution is supported only by relational databases (MongoDB is not supported).\n */\n static query<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n query: string,\n parameters?: any[],\n ): Promise<any> {\n return this.getRepository<T>().query(query, parameters)\n }\n\n /**\n * Clears all the data from the given table/collection (truncates/drops it).\n */\n static clear<T extends BaseEntity>(\n this: { new (): T } & typeof BaseEntity,\n ): Promise<void> {\n return this.getRepository<T>().clear()\n }\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node --require ts-node/register
2
+ import "./cli";
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node --require ts-node/register
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require("./cli");
5
+
6
+ //# sourceMappingURL=cli-ts-node-commonjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cli-ts-node-commonjs.ts"],"names":[],"mappings":";;;AACA,iBAAc","file":"cli-ts-node-commonjs.js","sourcesContent":["#!/usr/bin/env node --require ts-node/register\nimport \"./cli\"\n"],"sourceRoot":"."}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node --loader ts-node/esm --no-warnings
2
+ import "./cli";