333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
{"version":3,"sources":["../browser/src/driver/Driver.ts"],"names":[],"mappings":"","file":"Driver.js","sourcesContent":["import {QueryRunner} from \"../query-runner/QueryRunner\";\nimport {ColumnMetadata} from \"../metadata/ColumnMetadata\";\nimport {ObjectLiteral} from \"../common/ObjectLiteral\";\nimport {ColumnType} from \"./types/ColumnTypes\";\nimport {MappedColumnTypes} from \"./types/MappedColumnTypes\";\nimport {SchemaBuilder} from \"../schema-builder/SchemaBuilder\";\nimport {DataTypeDefaults} from \"./types/DataTypeDefaults\";\nimport {BaseConnectionOptions} from \"../connection/BaseConnectionOptions\";\nimport {TableColumn} from \"../schema-builder/table/TableColumn\";\nimport {EntityMetadata} from \"../metadata/EntityMetadata\";\n\n/**\n * Driver organizes TypeORM communication with specific database management system.\n */\nexport interface Driver {\n\n    /**\n     * Connection options.\n     */\n    options: BaseConnectionOptions;\n\n    /**\n     * Master database used to perform all write queries.\n     *\n     * todo: probably move into query runner.\n     */\n    database?: string;\n\n    /**\n     * Indicates if replication is enabled.\n     */\n    isReplicated: boolean;\n\n    /**\n     * Indicates if tree tables are supported by this driver.\n     */\n    treeSupport: boolean;\n\n    /**\n     * Gets list of supported column data types by a driver.\n     */\n    supportedDataTypes: ColumnType[];\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\n    /**\n     * Gets list of spatial column data types.\n     */\n    spatialTypes: ColumnType[];\n\n    /**\n     * Gets list of column data types that support length by a driver.\n     */\n    withLengthColumnTypes: ColumnType[];\n\n    /**\n     * Gets list of column data types that support precision by a driver.\n     */\n    withPrecisionColumnTypes: ColumnType[];\n\n    /**\n     * Gets list of column data types that support scale by a driver.\n     */\n    withScaleColumnTypes: ColumnType[];\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\n    /**\n     * Max length allowed by the DBMS for aliases (execution of queries).\n     */\n    maxAliasLength?: number;\n\n    /**\n     * Performs connection to the database.\n     * Depend on driver type it may create a connection pool.\n     */\n    connect(): Promise<void>;\n\n    /**\n     * Makes any action after connection (e.g. create extensions in Postgres driver).\n     */\n    afterConnect(): Promise<void>;\n\n    /**\n     * Closes connection with database and releases all resources.\n     */\n    disconnect(): Promise<void>;\n\n    /**\n     * Synchronizes database schema (creates tables, indices, etc).\n     */\n    createSchemaBuilder(): SchemaBuilder;\n\n    /**\n     * Creates a query runner used for common queries.\n     */\n    createQueryRunner(mode: \"master\"|\"slave\"): QueryRunner;\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(sql: string, parameters: ObjectLiteral, nativeParameters: ObjectLiteral): [string, any[]];\n\n    /**\n     * Escapes a table name, column name or an alias.\n     *\n     * todo: probably escape should be able to handle dots in the names and automatically escape them\n     */\n    escape(name: string): string;\n\n    /**\n     * Build full table name with database name, schema name and table name.\n     * E.g. \"myDB\".\"mySchema\".\"myTable\"\n     */\n    buildTableName(tableName: string, schema?: string, database?: string): string;\n\n    /**\n     * Prepares given value to a value to be persisted, based on its column type and metadata.\n     */\n    preparePersistentValue(value: any, column: ColumnMetadata): any;\n\n    /**\n     * Prepares given value to a value to be persisted, based on its column type.\n     */\n    prepareHydratedValue(value: any, column: ColumnMetadata): any;\n\n    /**\n     * Transforms type of the given column to a database column type.\n     */\n    normalizeType(column: { type?: ColumnType|string, length?: number|string, precision?: number|null, scale?: number, isArray?: boolean }): string;\n\n    /**\n     * Normalizes \"default\" value of the column.\n     */\n    normalizeDefault(columnMetadata: ColumnMetadata): string;\n\n    /**\n     * Normalizes \"isUnique\" value of the column.\n     */\n    normalizeIsUnique(column: ColumnMetadata): boolean;\n\n    /**\n     * Calculates column length taking into account the default length values.\n     */\n    getColumnLength(column: ColumnMetadata): string;\n\n    /**\n     * Normalizes \"default\" value of the column.\n     */\n    createFullType(column: TableColumn): string;\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    obtainMasterConnection(): Promise<any>;\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    obtainSlaveConnection(): Promise<any>;\n\n    /**\n     * Creates generated map of values generated or returned by database after INSERT query.\n     */\n    createGeneratedMap(metadata: EntityMetadata, insertResult: any): ObjectLiteral|undefined;\n\n    /**\n     * Differentiate columns of this table and columns from the given column metadatas columns\n     * and returns only changed.\n     */\n    findChangedColumns(tableColumns: TableColumn[], columnMetadatas: ColumnMetadata[]): ColumnMetadata[];\n\n    /**\n     * Returns true if driver supports RETURNING / OUTPUT statement.\n     */\n    isReturningSqlSupported(): boolean;\n\n    /**\n     * Returns true if driver supports uuid values generation on its own.\n     */\n    isUUIDGenerationSupported(): boolean;\n\n    /**\n     * Creates an escaped parameter.\n     */\n    createParameter(parameterName: string, index: number): string;\n\n}\n"],"sourceRoot":".."}