Skip to main content
Version: Next

SqlitePlatform

Base class for SQL database platforms, providing SQL generation and quoting utilities.

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

inheritedallowsComparingTuples

  • allowsComparingTuples(): boolean
  • Whether the platform supports tuple comparison in WHERE clauses.


    Returns boolean

inheritedcloneEmbeddable

  • cloneEmbeddable<T>(data): T
  • Deep-clones embeddable data and tags it for JSON serialization.


    Parameters

    • data: T

    Returns T

inheritedcompareUuids

  • compareUuids(): string
  • Determines how UUID values are compared in the change set tracking. Return 'string' for inline string comparison (fast), or 'any' for deep comparison via type methods.


    Returns string

inheritedconvertDateToJSValue

  • convertDateToJSValue(value): string
  • Parameters

    • value: string | Date

    Returns string

inheritedconvertIntervalToDatabaseValue

  • convertIntervalToDatabaseValue(value): unknown
  • Parameters

    • value: unknown

    Returns unknown

inheritedconvertIntervalToJSValue

  • convertIntervalToJSValue(value): unknown
  • Parameters

    • value: string

    Returns unknown

inheritedconvertJsonToDatabaseValue

  • convertJsonToDatabaseValue(value, context): unknown
  • Converts a JS value to its JSON database representation (typically JSON.stringify).


    Parameters

    Returns unknown

inheritedconvertJsonToJSValue

  • convertJsonToJSValue(value, context): unknown
  • Converts a database JSON value to its JS representation.


    Parameters

    Returns unknown

convertsJsonAutomatically

  • convertsJsonAutomatically(): boolean
  • Whether the driver automatically parses JSON columns into JS objects.


    Returns boolean

inheritedconvertUuidToDatabaseValue

  • convertUuidToDatabaseValue(value): unknown
  • Parameters

    • value: unknown

    Returns unknown

inheritedconvertUuidToJSValue

  • convertUuidToJSValue(value): unknown
  • Parameters

    • value: unknown

    Returns unknown

convertVersionValue

  • convertVersionValue(value, prop): number | { $in: (string | number)[] }
  • Converts a version field value for comparison in optimistic locking queries.


    Parameters

    Returns number | { $in: (string | number)[] }

inheriteddenormalizePrimaryKey

  • denormalizePrimaryKey(data): IPrimaryKeyValue
  • Converts scalar primary key representation to native driver wrapper (e.g. string to mongodb's ObjectId)


    Parameters

    • data: IPrimaryKeyValue

    Returns IPrimaryKeyValue

escape

  • escape(value): string
  • Parameters

    • value: any

    Returns string

inheritedextractSimpleType

  • extractSimpleType(type): string
  • Extracts the base type name from a full SQL type declaration (e.g. "varchar(255)" -> "varchar").


    Parameters

    • type: string

    Returns string

inheritedformatQuery

  • formatQuery(sql, params): string
  • Replaces ? placeholders in SQL with quoted parameter values.


    Parameters

    • sql: string
    • params: readonly any[]

    Returns string

inheritedgenerateCustomOrder

  • generateCustomOrder(escapedColumn, values): string
  • Generates a custom order by statement given a set of in order values, eg. ORDER BY (CASE WHEN priority = 'low' THEN 1 WHEN priority = 'medium' THEN 2 ELSE NULL END)


    Parameters

    • escapedColumn: string
    • values: unknown[]

    Returns string

inheritedgetArrayDeclarationSQL

  • getArrayDeclarationSQL(): string
  • Returns the SQL type declaration used for array storage.


    Returns string

getBeginTransactionSQL

  • getBeginTransactionSQL(options): string[]
  • Parameters

    Returns string[]

inheritedgetBigIntTypeDeclarationSQL

  • getBigIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

inheritedgetBlobDeclarationSQL

  • getBlobDeclarationSQL(): string
  • Returns string

getBooleanTypeDeclarationSQL

  • getBooleanTypeDeclarationSQL(): string
  • Returns the SQL type declaration for boolean columns.


    Returns string

getCharTypeDeclarationSQL

  • getCharTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

inheritedgetCommitTransactionSQL

  • getCommitTransactionSQL(): string
  • Returns string

inheritedgetConfig

getCurrentTimestampSQL

  • getCurrentTimestampSQL(length): string
  • Returns the SQL specific for the platform to get the current timestamp


    Parameters

    • length: number

    Returns string

getDateTimeTypeDeclarationSQL

  • getDateTimeTypeDeclarationSQL(column): string
  • Returns the SQL type declaration for datetime columns.


    Parameters

    • column: { length: number }
      • length: number

    Returns string

inheritedgetDateTypeDeclarationSQL

  • getDateTypeDeclarationSQL(length): string
  • Returns the SQL type declaration for date columns.


    Parameters

    • optionallength: number

    Returns string

inheritedgetDecimalTypeDeclarationSQL

  • getDecimalTypeDeclarationSQL(column): string
  • Parameters

    • column: { precision?: number; scale?: number }
      • optionalprecision: number
      • optionalscale: number

    Returns string

inheritedgetDefaultCharLength

  • getDefaultCharLength(): number
  • Returns the default length for char columns.


    Returns number

inheritedgetDefaultCharset

  • getDefaultCharset(): string
  • Returns the default character set for this platform.


    Returns string

inheritedgetDefaultClientUrl

  • getDefaultClientUrl(): string
  • Returns default client url for given driver (e.g. mongodb://127.0.0.1:27017 for mongodb)


    Returns string

inheritedgetDefaultDateTimeLength

  • getDefaultDateTimeLength(): number
  • Returns the default fractional seconds precision for datetime columns.


    Returns number

inheritedgetDefaultMappedType

  • getDefaultMappedType(type): Type<unknown, unknown>
  • Returns the default mapped Type for a given type string when no custom mapping is configured.


    Parameters

    • type: string

    Returns Type<unknown, unknown>

inheritedgetDefaultPrimaryName

  • getDefaultPrimaryName(tableName, columns): string
  • Returns the default primary key constraint name.


    Parameters

    • tableName: string
    • columns: string[]

    Returns string

getDefaultSchemaName

  • getDefaultSchemaName(): undefined | string
  • Returns the default schema name for this platform (e.g. "public" for PostgreSQL).


    Returns undefined | string

inheritedgetDefaultVarcharLength

  • getDefaultVarcharLength(): number
  • Returns the default length for varchar columns.


    Returns number

inheritedgetDefaultVersionLength

  • getDefaultVersionLength(): number
  • Returns the default fractional seconds precision for version timestamp columns.


    Returns number

inheritedgetDoubleDeclarationSQL

  • getDoubleDeclarationSQL(): string
  • Returns string

getEnumTypeDeclarationSQL

  • getEnumTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; fieldNames: string[]; items?: unknown[]; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • fieldNames: string[]
      • optionalitems: unknown[]
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

inheritedgetExceptionConverter

  • Returns the exception converter for translating native errors to driver exceptions.


    Returns ExceptionConverter

inheritedgetExtension

  • getExtension<T>(extensionName, extensionKey, moduleName, em): T
  • Retrieves a registered extension (e.g. SchemaGenerator, Migrator), throwing if not found.


    Parameters

    Returns T

getFloatDeclarationSQL

  • getFloatDeclarationSQL(): string
  • Returns string

inheritedgetFullTextIndexExpression

  • getFullTextIndexExpression(indexName, schemaName, tableName, columns): string
  • Parameters

    • indexName: string
    • schemaName: undefined | string
    • tableName: string
    • columns: SimpleColumnMeta[]

    Returns string

getFullTextWhereClause

  • getFullTextWhereClause(): string
  • Returns string

getIndexName

  • getIndexName(tableName, columns, type): string
  • Returns the default name of index for the given columns


    Parameters

    • tableName: string
    • columns: string[]
    • type: primary | index | unique | foreign | sequence

    Returns string

getIntegerTypeDeclarationSQL

  • getIntegerTypeDeclarationSQL(column): string
  • Returns the SQL type declaration for integer columns.


    Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

inheritedgetIntervalTypeDeclarationSQL

  • getIntervalTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

inheritedgetJsonDeclarationSQL

  • getJsonDeclarationSQL(): string
  • Returns string

inheritedgetJsonIndexDefinition

  • getJsonIndexDefinition(index): string[]
  • Parameters

    Returns string[]

inheritedgetMappedType

  • getMappedType(type): Type<unknown, unknown>
  • Returns the mapped Type instance for a given SQL/runtime type string.


    Parameters

    • type: string

    Returns Type<unknown, unknown>

inheritedgetMediumIntTypeDeclarationSQL

  • getMediumIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

inheritedgetNamingStrategy

inheritedgetRegExpOperator

  • getRegExpOperator(val, flags): string
  • Returns the SQL operator used for regular expression matching.


    Parameters

    • optionalval: unknown
    • optionalflags: string

    Returns string

inheritedgetRegExpValue

  • getRegExpValue(val): { $flags?: string; $re: string }
  • Converts a JavaScript RegExp into a platform-specific regex representation.


    Parameters

    • val: RegExp

    Returns { $flags?: string; $re: string }

    • optional$flags?: string
    • $re: string

inheritedgetReleaseSavepointSQL

  • getReleaseSavepointSQL(savepointName): string
  • Parameters

    • savepointName: string

    Returns string

inheritedgetRepositoryClass

  • Returns the default EntityRepository class used by this platform.


    Returns Constructor<EntityRepository<T>>

inheritedgetRollbackToSavepointSQL

  • getRollbackToSavepointSQL(savepointName): string
  • Parameters

    • savepointName: string

    Returns string

inheritedgetRollbackTransactionSQL

  • getRollbackTransactionSQL(): string
  • Returns string

inheritedgetSavepointSQL

  • getSavepointSQL(savepointName): string
  • Parameters

    • savepointName: string

    Returns string

inheritedgetSchemaGenerator

inheritedgetSchemaHelper

  • Returns the schema helper instance for this platform, or undefined if not supported.


    Returns undefined | SchemaHelper

inheritedgetSearchJsonPropertyKey

  • getSearchJsonPropertyKey(path, type, aliased, value): string | RawQueryFragment<string>
  • Parameters

    • path: string[]
    • type: string
    • aliased: boolean
    • optionalvalue: unknown

    Returns string | RawQueryFragment<string>

inheritedgetSearchJsonPropertySQL

  • getSearchJsonPropertySQL(path, type, aliased): string | RawQueryFragment<string>
  • Parameters

    • path: string
    • type: string
    • aliased: boolean

    Returns string | RawQueryFragment<string>

getSmallIntTypeDeclarationSQL

  • getSmallIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

inheritedgetTextTypeDeclarationSQL

  • getTextTypeDeclarationSQL(_column): string
  • Parameters

    • _column: { length?: number }
      • optionallength: number

    Returns string

inheritedgetTimeTypeDeclarationSQL

  • getTimeTypeDeclarationSQL(length): string
  • Returns the SQL type declaration for time columns.


    Parameters

    • optionallength: number

    Returns string

inheritedgetTimezone

  • getTimezone(): undefined | string
  • Returns the configured timezone, or undefined if not set.


    Returns undefined | string

getTinyIntTypeDeclarationSQL

  • getTinyIntTypeDeclarationSQL(column): string
  • Parameters

    • column: { autoincrement?: boolean; length?: number; unsigned?: boolean }
      • optionalautoincrement: boolean
      • optionallength: number
      • optionalunsigned: boolean

    Returns string

inheritedgetUuidTypeDeclarationSQL

  • getUuidTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

getVarcharTypeDeclarationSQL

  • getVarcharTypeDeclarationSQL(column): string
  • Parameters

    • column: { length?: number }
      • optionallength: number

    Returns string

inheritedindexForeignKeys

  • indexForeignKeys(): boolean
  • Whether the platform automatically creates indexes on foreign key columns.


    Returns boolean

inheritedisAllowedTopLevelOperator

  • isAllowedTopLevelOperator(operator): boolean
  • Whether the given operator is allowed at the top level of a query condition.


    Parameters

    • operator: string

    Returns boolean

inheritedisBigIntProperty

  • isBigIntProperty(prop): boolean
  • Whether the given property maps to a bigint database column.


    Parameters

    Returns boolean

inheritedisNumericColumn

  • isNumericColumn(mappedType): boolean
  • Whether the given mapped type represents a numeric column.


    Parameters

    • mappedType: Type<unknown, unknown>

    Returns boolean

inheritedisNumericProperty

  • isNumericProperty(prop, ignoreCustomType): boolean
  • Whether the given property represents a numeric database column.


    Parameters

    Returns boolean

inheritedisPopulated

  • isPopulated<T>(key, populate): boolean
  • Whether the given property key is included in the populate hint.


    Parameters

    Returns boolean

inheritedlookupExtensions

  • lookupExtensions(orm): void

inheritedmapRegExpCondition

  • mapRegExpCondition(mappedKey, value): { params: unknown[]; sql: string }
  • Builds the SQL clause and parameters for a regular expression condition.


    Parameters

    • mappedKey: string
    • value: { $flags?: string; $re: string }
      • optional$flags: string
      • $re: string

    Returns { params: unknown[]; sql: string }

    • params: unknown[]
    • sql: string

inheritedmarshallArray

  • marshallArray(values): string
  • Serializes a string array into its database storage format.


    Parameters

    • values: string[]

    Returns string

normalizeColumnType

  • normalizeColumnType(type, options): string
  • This should be used only to compare types, it can strip some information like the length.


    Parameters

    • type: string
    • options: { length?: number; precision?: number; scale?: number }
      • optionallength: number
      • optionalprecision: number
      • optionalscale: number

    Returns string

inheritednormalizePrimaryKey

  • normalizePrimaryKey<T>(data): T
  • Normalizes primary key wrapper to scalar value (e.g. mongodb's ObjectId to string)


    Parameters

    • data: IPrimaryKeyValue | Primary<T>

    Returns T

inheritedparseDate

  • parseDate(value): Date
  • Parses a string or numeric value into a Date object.


    Parameters

    • value: string | number

    Returns Date

processDateProperty

  • processDateProperty(value): string | number | Date
  • This is used to narrow the value of Date properties as they will be stored as timestamps in sqlite. We use this method to convert Dates to timestamps when computing the changeset, so we have the right data type in the payload as well as in original entity data. Without that, we would end up with diffs including all Date properties, as we would be comparing Date object with timestamp.


    Parameters

    • value: unknown

    Returns string | number | Date

inheritedprocessJsonCondition

  • processJsonCondition<T>(o, value, path, alias): FilterQuery<T>

inheritedquoteIdentifier

  • quoteIdentifier(id, quote): string
  • Wraps a table or column identifier with the platform-specific quote character.


    Parameters

    • id: string | { toString: () => string }
      • toString: () => string
    • quote: string = '`'

    Returns string

quoteValue

  • quoteValue(value): string
  • Quotes a literal value for safe embedding in SQL.


    Parameters

    • value: any

    Returns string

inheritedsetConfig

  • setConfig(config): void

inheritedshouldHaveColumn

  • shouldHaveColumn<T>(prop, populate, exclude, includeFormulas, ignoreInlineEmbeddables): boolean
  • Whether the given property should be included as a column in the SELECT query.


    Parameters

    • prop: EntityProperty<T, any>
    • populate: boolean | readonly PopulateOptions<T>[]
    • optionalexclude: string[]
    • includeFormulas: boolean = true
    • ignoreInlineEmbeddables: boolean = true

    Returns boolean

inheritedsupportsCreatingFullTextIndex

  • supportsCreatingFullTextIndex(): boolean
  • Returns boolean

inheritedsupportsCustomPrimaryKeyNames

  • supportsCustomPrimaryKeyNames(): boolean
  • Whether the platform supports custom names for primary key constraints.


    Returns boolean

supportsDeferredUniqueConstraints

  • supportsDeferredUniqueConstraints(): boolean
  • Whether the platform supports deferred unique constraints.


    Returns boolean

inheritedsupportsDownMigrations

  • supportsDownMigrations(): boolean
  • Whether the platform supports generating down migrations.


    Returns boolean

inheritedsupportsMaterializedViews

  • supportsMaterializedViews(): boolean
  • Whether this platform supports materialized views.


    Returns boolean

inheritedsupportsMultipleCascadePaths

  • supportsMultipleCascadePaths(): boolean
  • Whether the platform supports multiple cascade paths to the same table.


    Returns boolean

inheritedsupportsMultipleStatements

  • supportsMultipleStatements(): boolean
  • Whether the connection supports executing multiple SQL statements in a single call.


    Returns boolean

inheritedsupportsNativeEnums

  • supportsNativeEnums(): boolean
  • for postgres native enums


    Returns boolean

inheritedsupportsOnUpdate

  • supportsOnUpdate(): boolean
  • Returns true if the platform supports ON UPDATE foreign key rules. Oracle doesn't support ON UPDATE rules.


    Returns boolean

supportsSchemas

  • supportsSchemas(): boolean
  • SQLite supports schemas via ATTACH DATABASE. Returns true when there are attached databases configured.


    Returns boolean

inheritedsupportsTransactions

  • supportsTransactions(): boolean
  • Whether this driver supports database transactions.


    Returns boolean

inheritedsupportsUnionWhere

  • supportsUnionWhere(): boolean
  • Whether the platform supports the UNION WHERE optimization for multi-branch queries.


    Returns boolean

inheritedsupportsUnsigned

  • supportsUnsigned(): boolean
  • Whether the platform supports unsigned integer columns.


    Returns boolean

inheritedunmarshallArray

  • unmarshallArray(value): string[]
  • Deserializes a database-stored array string back into a string array.


    Parameters

    • value: string

    Returns string[]

inheritedusesAsKeyword

  • usesAsKeyword(): boolean
  • Returns boolean

inheritedusesBatchInserts

  • usesBatchInserts(): boolean
  • Whether or not the driver supports retuning list of created PKs back when multi-inserting


    Returns boolean

inheritedusesBatchUpdates

  • usesBatchUpdates(): boolean
  • Whether or not the driver supports updating many records at once


    Returns boolean

inheritedusesCascadeStatement

  • usesCascadeStatement(): boolean
  • Whether DELETE statements require explicit CASCADE keyword.


    Returns boolean

usesDefaultKeyword

  • usesDefaultKeyword(): boolean
  • Whether the platform supports the DEFAULT keyword in INSERT statements.


    Returns boolean

usesEnumCheckConstraints

  • usesEnumCheckConstraints(): boolean
  • for postgres text enums (default)


    Returns boolean

inheritedusesImplicitTransactions

  • usesImplicitTransactions(): boolean
  • Whether the driver wraps operations in implicit transactions by default.


    Returns boolean

inheritedusesOutputStatement

  • usesOutputStatement(): boolean
  • Whether the driver supports OUTPUT clause (e.g. MSSQL).


    Returns boolean

inheritedusesPivotTable

  • usesPivotTable(): boolean
  • Whether this driver uses pivot tables for M:N relations (SQL drivers do, MongoDB does not).


    Returns boolean

usesReturningStatement

  • usesReturningStatement(): boolean
  • Whether the driver supports RETURNING clause (e.g. PostgreSQL).


    Returns boolean

inheritedvalidateMetadata

  • validateMetadata(meta): void
  • Platform-specific validation of entity metadata.


    Parameters

    Returns void

Page Options