Skip to main content

SQLiteRelationalDialect

@webda/sqlite


Class: SQLiteRelationalDialect

Defined in: sqlite/src/relational/dialect.ts:46

SQLite syntax of the relational layout: declared column types, inline foreign keys (DEFERRABLE INITIALLY DEFERRED, PRAGMA foreign_keys is set by the store), PRAGMA introspection, JSON1 operations on a named column. One writer at a time: no schema lock.

Extends​

Implements​

  • RelationalDialect

Constructors​

Constructor​

new SQLiteRelationalDialect(): SQLiteRelationalDialect

Returns​

SQLiteRelationalDialect

Inherited from​

SQLiteDialect.constructor

Properties​

binaryCollation​

readonly binaryCollation: "COLLATE BINARY" = "COLLATE BINARY"

Defined in: sqlite/src/dialect.ts:61

Binary collation

Implementation of​

RelationalDialect.binaryCollation

Inherited from​

SQLiteDialect.binaryCollation


inlineForeignKeys​

readonly inlineForeignKeys: true = true

Defined in: sqlite/src/relational/dialect.ts:48

SQLite has no ALTER TABLE ADD CONSTRAINT: foreign keys live in CREATE TABLE

Implementation of​

RelationalDialect.inlineForeignKeys

Methods​

asNumber()​

asNumber(json): string

Defined in: sqlite/src/dialect.ts:113

Parameters​

json​

string

Returns​

string

Implementation of​

RelationalDialect.asNumber

Inherited from​

SQLiteDialect.asNumber


asString()​

asString(json): string

Defined in: sqlite/src/dialect.ts:118

Parameters​

json​

string

Returns​

string

Implementation of​

RelationalDialect.asString

Inherited from​

SQLiteDialect.asString


backfillTypes()​

backfillTypes(table): string

Defined in: sqlite/src/dialect.ts:273

Parameters​

table​

string

Returns​

string

Implementation of​

RelationalDialect.backfillTypes

Inherited from​

SQLiteDialect.backfillTypes


bulkAssign()​

bulkAssign(_table, assignments, args): string

Defined in: sqlite/src/dialect.ts:253

One json_set: parents of dotted targets made objects (read from the stored row: a statement never sets a field and one of its children), then the values. An array index beyond the end of an existing array is not applied (json_set ignores a path past the end).

Parameters​

_table​

string

assignments​

object[]

args​

any[]

Returns​

string

Implementation of​

RelationalDialect.bulkAssign

Inherited from​

SQLiteDialect.bulkAssign


castText()​

castText(expr): string

Defined in: sqlite/src/relational/dialect.ts:209

Parameters​

expr​

string

Returns​

string

Implementation of​

RelationalDialect.castText


checkIndex()​

protected checkIndex(index): number

Defined in: sqlite/src/dialect.ts:310

Check index

Parameters​

index​

number

an array index written inside a JSON path literal

Returns​

number

the index

Inherited from​

SQLiteDialect.checkIndex


checkKey()​

protected checkKey(key): void

Defined in: sqlite/src/dialect.ts:299

Check key

Parameters​

key​

string

a top-level key written inside a JSON path literal

Returns​

void

Inherited from​

SQLiteDialect.checkKey


collectionItemCondition()​

collectionItemCondition(attr, index, field, valueParam): string

Defined in: sqlite/src/dialect.ts:238

Without an index (an append with a condition) the condition never matches, as on the other stores

Parameters​

attr​

string

index​

number | undefined

field​

string

valueParam​

number

Returns​

string

Implementation of​

RelationalDialect.collectionItemCondition

Inherited from​

SQLiteDialect.collectionItemCondition


columnJsonItemCondition()​

columnJsonItemCondition(column, index, field, valueParam): string

Defined in: sqlite/src/relational/dialect.ts:314

Parameters​

column​

string

index​

number

field​

string

valueParam​

number

Returns​

string

Implementation of​

RelationalDialect.columnJsonItemCondition


columnJsonMerge()​

columnJsonMerge(column, patch, args): string

Defined in: sqlite/src/relational/dialect.ts:264

Parameters​

column​

string

patch​

Record<string, unknown>

args​

unknown[]

Returns​

string

Implementation of​

RelationalDialect.columnJsonMerge


columnJsonRemoveItem()​

columnJsonRemoveItem(column, index): string

Defined in: sqlite/src/relational/dialect.ts:309

Parameters​

column​

string

index​

number

Returns​

string

Implementation of​

RelationalDialect.columnJsonRemoveItem


columnJsonRemoveKey()​

columnJsonRemoveKey(column, param): string

Defined in: sqlite/src/relational/dialect.ts:277

Parameters​

column​

string

param​

number

Returns​

string

Implementation of​

RelationalDialect.columnJsonRemoveKey


columnJsonSetItem()​

columnJsonSetItem(column, itemParam, index): string

Defined in: sqlite/src/relational/dialect.ts:299

Parameters​

column​

string

itemParam​

number

index​

number | undefined

Returns​

string

Implementation of​

RelationalDialect.columnJsonSetItem


columnJsonSetPath()​

columnJsonSetPath(column, path, valueParam): string

Defined in: sqlite/src/relational/dialect.ts:285

Every parent of the path is made an object when missing (an existing object or array is kept)

Parameters​

column​

string

path​

string[]

valueParam​

number

Returns​

string

Implementation of​

RelationalDialect.columnJsonSetPath


columnJsonText()​

columnJsonText(column, path): string

Defined in: sqlite/src/relational/dialect.ts:247

Booleans read as true / false, everything else as its text; NULL for missing and JSON null

Parameters​

column​

string

path​

string[]

Returns​

string

Implementation of​

RelationalDialect.columnJsonText


columnJsonValue()​

columnJsonValue(column, path): string

Defined in: sqlite/src/relational/dialect.ts:254

Parameters​

column​

string

path​

string[]

Returns​

string

Implementation of​

RelationalDialect.columnJsonValue


columnJsonValueOrNull()​

columnJsonValueOrNull(column, path): string

Defined in: sqlite/src/relational/dialect.ts:259

Parameters​

column​

string

path​

string[]

Returns​

string

Implementation of​

RelationalDialect.columnJsonValueOrNull


columnType()​

columnType(type): string

Defined in: sqlite/src/relational/dialect.ts:56

Parameters​

type​

ColumnType

Returns​

string

Implementation of​

RelationalDialect.columnType


contains()​

contains(json, value): string

Defined in: sqlite/src/dialect.ts:133

Parameters​

json​

string

value​

string | number | boolean

Returns​

string

Implementation of​

RelationalDialect.contains

Inherited from​

SQLiteDialect.contains


countStoredTypes()​

countStoredTypes(table): string

Defined in: sqlite/src/dialect.ts:278

Parameters​

table​

string

Returns​

string

Implementation of​

RelationalDialect.countStoredTypes

Inherited from​

SQLiteDialect.countStoredTypes


createTable()​

createTable(table): string

Defined in: sqlite/src/dialect.ts:151

Parameters​

table​

string

Returns​

string

Implementation of​

RelationalDialect.createTable

Inherited from​

SQLiteDialect.createTable


decode()​

decode(value): any

Defined in: sqlite/src/dialect.ts:291

The data column is JSON text

Parameters​

value​

any

Returns​

any

Implementation of​

RelationalDialect.decode

Inherited from​

SQLiteDialect.decode


describeSchema()​

describeSchema(client, tables): Promise<LiveSchema>

Defined in: sqlite/src/relational/dialect.ts:163

Parameters​

client​

SQLClient

tables​

string[]

Returns​

Promise<LiveSchema>

Implementation of​

RelationalDialect.describeSchema


distinctFrom()​

distinctFrom(left, right): string

Defined in: sqlite/src/dialect.ts:128

Parameters​

left​

string

string

Returns​

string

Implementation of​

RelationalDialect.distinctFrom

Inherited from​

SQLiteDialect.distinctFrom


hasStoredType()​

hasStoredType(): string

Defined in: sqlite/src/dialect.ts:167

Returns​

string

Implementation of​

RelationalDialect.hasStoredType

Inherited from​

SQLiteDialect.hasStoredType


increment()​

increment(entries, updateDate, args): string

Defined in: sqlite/src/dialect.ts:204

Parameters​

entries​

object[]

updateDate​

string

args​

any[]

Returns​

string

Implementation of​

RelationalDialect.increment

Inherited from​

SQLiteDialect.increment


isForeignKeyViolation()​

isForeignKeyViolation(err): { constraint?: string; } | undefined

Defined in: sqlite/src/relational/dialect.ts:323

SQLITE_CONSTRAINT_FOREIGNKEY (787); SQLite names no constraint

Parameters​

err​

unknown

Returns​

{ constraint?: string; } | undefined

Implementation of​

RelationalDialect.isForeignKeyViolation


isObjectRow()​

isObjectRow(): string

Defined in: sqlite/src/dialect.ts:283

Returns​

string

Implementation of​

RelationalDialect.isObjectRow

Inherited from​

SQLiteDialect.isObjectRow


isType()​

isType(json, type): string

Defined in: sqlite/src/dialect.ts:99

Parameters​

json​

string

type​

JSONType

Returns​

string

Implementation of​

RelationalDialect.isType

Inherited from​

SQLiteDialect.isType


isUniqueViolation()​

isUniqueViolation(err): boolean

Defined in: sqlite/src/dialect.ts:159

SQLITE_CONSTRAINT_PRIMARYKEY (1555) or SQLITE_CONSTRAINT_UNIQUE (2067)

Parameters​

err​

unknown

Returns​

boolean

Implementation of​

RelationalDialect.isUniqueViolation

Inherited from​

SQLiteDialect.isUniqueViolation


jsonParam()​

jsonParam(i): string

Defined in: sqlite/src/dialect.ts:69

Parameters​

i​

number

Returns​

string

Implementation of​

RelationalDialect.jsonParam

Inherited from​

SQLiteDialect.jsonParam


jsonText()​

jsonText(path): string

Defined in: sqlite/src/dialect.ts:77

Booleans read as true / false (not 0 / 1), everything else as its text; NULL for missing and JSON null

Parameters​

path​

string[]

Returns​

string

Implementation of​

RelationalDialect.jsonText

Inherited from​

SQLiteDialect.jsonText


jsonValue()​

jsonValue(path): string

Defined in: sqlite/src/dialect.ts:83

Parameters​

path​

string[]

Returns​

string

Implementation of​

RelationalDialect.jsonValue

Inherited from​

SQLiteDialect.jsonValue


jsonValueOrNull()​

jsonValueOrNull(path): string

Defined in: sqlite/src/dialect.ts:88

Parameters​

path​

string[]

Returns​

string

Implementation of​

RelationalDialect.jsonValueOrNull

Inherited from​

SQLiteDialect.jsonValueOrNull


keptType()​

keptType(mapParam): string

Defined in: sqlite/src/dialect.ts:172

Parameters​

mapParam​

number

Returns​

string

Implementation of​

RelationalDialect.keptType

Inherited from​

SQLiteDialect.keptType


keyText()​

keyText(key): string

Defined in: sqlite/src/dialect.ts:93

Parameters​

key​

string

Returns​

string

Implementation of​

RelationalDialect.keyText

Inherited from​

SQLiteDialect.keyText


like()​

like(text, pattern): string

Defined in: sqlite/src/dialect.ts:146

Parameters​

text​

string

pattern​

string

Returns​

string

Implementation of​

RelationalDialect.like

Inherited from​

SQLiteDialect.like


liveType()​

liveType(declared): ColumnType | undefined

Defined in: sqlite/src/relational/dialect.ts:65

Return the plan type, undefined for an unknown declaration

Parameters​

declared​

string

the declared type of a column, as PRAGMA table_info gives it

Returns​

ColumnType | undefined

the plan type, undefined for an unknown declaration


placeholder()​

placeholder(i): string

Defined in: sqlite/src/dialect.ts:64

Parameters​

i​

number

Returns​

string

Implementation of​

RelationalDialect.placeholder

Inherited from​

SQLiteDialect.placeholder


quote()​

quote(identifier): string

Defined in: sqlite/src/relational/dialect.ts:51

Parameters​

identifier​

string

Returns​

string

Implementation of​

RelationalDialect.quote


removeCollectionItem()​

removeCollectionItem(attr, index, updateDate): string

Defined in: sqlite/src/dialect.ts:229

Parameters​

attr​

string

index​

number

updateDate​

string

Returns​

string

Implementation of​

RelationalDialect.removeCollectionItem

Inherited from​

SQLiteDialect.removeCollectionItem


removeKey()​

removeKey(attribute, args): string

Defined in: sqlite/src/dialect.ts:197

Parameters​

attribute​

string

args​

any[]

Returns​

string

Implementation of​

RelationalDialect.removeKey

Inherited from​

SQLiteDialect.removeKey


renderContractStep()​

renderContractStep(step): string[]

Defined in: sqlite/src/relational/dialect.ts:109

SQLite drops columns and tables; it cannot set NOT NULL on an existing column (reported, not applied) and has no constraint validation (foreign keys are declared inline)

Parameters​

step​

ContractStep

Returns​

string[]

Implementation of​

RelationalDialect.renderContractStep


renderStep()​

renderStep(step): string[]

Defined in: sqlite/src/relational/dialect.ts:86

Parameters​

step​

SchemaStep

Returns​

string[]

Implementation of​

RelationalDialect.renderStep


schemaLock()​

schemaLock(_name): string | undefined

Defined in: sqlite/src/relational/dialect.ts:204

One writer at a time: no lock needed

Parameters​

_name​

string

Returns​

string | undefined

Implementation of​

RelationalDialect.schemaLock


setCollectionItem()​

setCollectionItem(attr, itemParam, index, updateDate): string

Defined in: sqlite/src/dialect.ts:217

An index at or beyond the end appends (json_set ignores a path past the end), as PostgreSQL jsonb_set does

Parameters​

attr​

string

itemParam​

number

index​

number | undefined

updateDate​

string

Returns​

string

Implementation of​

RelationalDialect.setCollectionItem

Inherited from​

SQLiteDialect.setCollectionItem


shallowMerge()​

shallowMerge(json, patch, args): string

Defined in: sqlite/src/dialect.ts:185

One json_set pair per top-level key (json_patch would drop null values and merge nested objects)

Parameters​

json​

string

patch​

Record<string, any>

args​

any[]

Returns​

string

Implementation of​

RelationalDialect.shallowMerge

Inherited from​

SQLiteDialect.shallowMerge


timeText()​

timeText(expr, _type): string

Defined in: sqlite/src/relational/dialect.ts:217

Time columns hold their ISO text already

Parameters​

expr​

string

_type​

ColumnType

Returns​

string

Implementation of​

RelationalDialect.timeText


toJson()​

toJson(expr, type): string

Defined in: sqlite/src/relational/dialect.ts:225

Booleans are stored as 0/1: rendered as JSON booleans for the aggregations

Parameters​

expr​

string

type​

ColumnType

Returns​

string

Implementation of​

RelationalDialect.toJson


typedAttribute()​

typedAttribute(_text, json, type): string

Defined in: sqlite/src/dialect.ts:123

Parameters​

_text​

string

json​

string

type​

"number" | "boolean"

Returns​

string

Implementation of​

RelationalDialect.typedAttribute

Inherited from​

SQLiteDialect.typedAttribute


uniqueViolation()​

uniqueViolation(err): UniqueViolation | undefined

Defined in: sqlite/src/relational/dialect.ts:333

SQLITE_CONSTRAINT_PRIMARYKEY (1555) or SQLITE_CONSTRAINT_UNIQUE (2067); the message names the columns (UNIQUE constraint failed: t.a, t.b), never the index

Parameters​

err​

unknown

Returns​

UniqueViolation | undefined

Implementation of​

RelationalDialect.uniqueViolation


withStoredType()​

withStoredType(json, type): string

Defined in: sqlite/src/dialect.ts:177

Parameters​

json​

string

type​

string

Returns​

string

Implementation of​

RelationalDialect.withStoredType

Inherited from​

SQLiteDialect.withStoredType