Skip to content

Latest commit

 

History

History
161 lines (126 loc) · 19.7 KB

driver-sql.mdx

File metadata and controls

161 lines (126 loc) · 19.7 KB
title Driver Sql schema — Data Protocol reference
navTitle Driver Sql
description Driver Sql schemas of the ObjectStack Data Protocol: DataTypeMapping, SQLDialect and 2 more — each property with its type, default and a TypeScript example.

{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}

**Source:** `packages/spec/src/data/driver-sql.zod.ts`

TypeScript Usage

import { DataTypeMappingSchema, SQLDialectSchema, SQLDriverConfigSchema, SSLConfigSchema } from '@objectstack/spec/data';
import type { DataTypeMapping, SQLDialect, SQLDriverConfig, SSLConfig } from '@objectstack/spec/data';

// Validate data
const result = DataTypeMappingSchema.parse(data);

DataTypeMapping

Properties

Property Type Required Description
text string ✅ SQL type for text fields (e.g., VARCHAR, TEXT)
number string ✅ SQL type for number fields (e.g., NUMERIC, DECIMAL, INT)
boolean string ✅ SQL type for boolean fields (e.g., BOOLEAN, BIT)
date string ✅ SQL type for date fields (e.g., DATE)
datetime string ✅ SQL type for datetime fields (e.g., TIMESTAMP, DATETIME)
json string optional SQL type for JSON fields (e.g., JSON, JSONB)
uuid string optional SQL type for UUID fields (e.g., UUID, CHAR(36))
binary string optional SQL type for binary fields (e.g., BLOB, BYTEA)

SQLDialect

Allowed Values

  • postgresql
  • mysql
  • sqlite
  • mssql
  • oracle
  • mariadb

SQLDriverConfig

Properties

Property Type Required Description
name string ✅ Driver instance name
type 'sql' ✅ Driver type must be "sql"
capabilities { queryDateGranularity?: Record<string, boolean>; autonumber?: boolean; batchSchemaSync?: boolean; transactionsUnsupported?: boolean; … } ✅ Driver capability flags
connectionString string optional Database connection string (driver-specific format)
poolConfig { min?: number; max?: number; idleTimeoutMillis?: number; connectionTimeoutMillis?: number } optional Connection pool configuration
dialect Enum<'postgresql' | 'mysql' | 'sqlite' | 'mssql' | 'oracle' | 'mariadb'> ✅ SQL database dialect
dataTypeMapping { text: string; number: string; boolean: string; date: string; … } ✅ SQL data type mapping configuration
ssl boolean optional (default: false) Enable SSL/TLS connection
sslConfig { rejectUnauthorized?: boolean; ca?: string; cert?: string; key?: string } optional SSL/TLS configuration (required when ssl is true)

Nested Shape: SQLDriverConfig.capabilities

Property Type Required Description
queryDateGranularity Record<string, boolean> optional Per-granularity native date bucketing (day/week/month/quarter/year). Missing keys fall back to in-memory bucketing.
autonumber boolean optional Driver natively generates persistent autonumber/sequence values
batchSchemaSync boolean optional Supports batched schema sync to reduce schema DDL round-trips (absence = false)
transactionsUnsupported boolean optional Transport cannot honour transactions even though beginTransaction is inherited (absence = false)
aggregationFilter boolean optional aggregate() evaluates a per-measure aggregations[].filter itself, with the engine's in-memory answer, except that text compares by the backend collation as in where (absence = false: the engine aggregates filtered measures in memory)
create never optional [REMOVED] DriverCapabilities.create was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: create/find/findOne/update/delete are REQUIRED IDataDriver methods and the engine calls them unconditionally. Delete the key.
read never optional [REMOVED] DriverCapabilities.read was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: reads go through the REQUIRED find/findOne/count methods, called unconditionally. Delete the key.
update never optional [REMOVED] DriverCapabilities.update was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: update/upsert are REQUIRED IDataDriver methods, called unconditionally. Delete the key.
delete never optional [REMOVED] DriverCapabilities.delete was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. CRUD is not optional for a driver: delete is a REQUIRED IDataDriver method, called unconditionally. Delete the key.
bulkCreate never optional [REMOVED] DriverCapabilities.bulkCreate was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. The bulk methods (bulkCreate/bulkUpdate/bulkDelete) are REQUIRED IDataDriver methods and the engine calls them directly; wire-level batch capability is advertised by REST discovery as its transactionalBatch bit, derived from the live composition so a client negotiates instead of probing, never from this record. Delete the key.
bulkUpdate never optional [REMOVED] DriverCapabilities.bulkUpdate was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. The bulk methods are REQUIRED IDataDriver methods and the engine calls them directly; wire-level batch capability is advertised by REST discovery as its transactionalBatch bit, derived from the live composition so a client negotiates instead of probing, never from this record. Delete the key.
bulkDelete never optional [REMOVED] DriverCapabilities.bulkDelete was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. The bulk methods are REQUIRED IDataDriver methods and the engine calls them directly; wire-level batch capability is advertised by REST discovery as its transactionalBatch bit, derived from the live composition so a client negotiates instead of probing, never from this record. Delete the key.
transactions never optional [REMOVED] DriverCapabilities.transactions was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Transaction use is gated on the DRIVER'S DECLARATION, no longer on METHOD PRESENCE alone: engine.transaction() asks driverSupportsTransactions(driver) — driver.beginTransaction present AND transactionsUnsupported not set (ADR-0034 ambient transactions, ADR-0119 D1). A driver without the method — or a transport that declares that live bit — gets the non-transactional fallback, whatever this bit claimed. Discovery's transactionalBatch capability is likewise derived from engine.transaction plus the mounted batch route, never from this bit. The live transactionsUnsupported bit is NOT this key restored and is not its opposite spelled differently: this one CLAIMED support nothing checked, that one DENIES support the engine does check, and it is written only by a transport that inherits beginTransaction from a base class it cannot honour. A driver with real transactions declares nothing. Delete the key.
savepoints never optional [REMOVED] DriverCapabilities.savepoints was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. No savepoint code path exists in the engine — a capability bit for a feature the platform does not call is a false affordance, not documentation. Delete the key.
isolationLevels never optional [REMOVED] DriverCapabilities.isolationLevels was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Isolation is requested per transaction via beginTransaction({ isolationLevel }); no planner ever consulted this list to decide anything. Delete the key.
queryFilters never optional [REMOVED] DriverCapabilities.queryFilters was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. find() receives the full QueryAST (where/orderBy/limit/offset) and MUST execute all of it — the "ObjectQL will filter in memory" fallback this bit's description promised was never built. Delete the key.
querySorting never optional [REMOVED] DriverCapabilities.querySorting was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. find() receives the full QueryAST and MUST execute all of it — the "ObjectQL will sort in memory" fallback this bit's description promised was never built. Delete the key.
queryPagination never optional [REMOVED] DriverCapabilities.queryPagination was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. find() receives the full QueryAST and MUST execute all of it — the "ObjectQL will paginate in memory" fallback this bit's description promised was never built. Delete the key.
queryAggregations never optional [REMOVED] DriverCapabilities.queryAggregations was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Aggregate pushdown is decided by typeof driver.aggregate === 'function' plus queryDateGranularity (engine aggregate dispatch) — never by this bit. Delete the key.
queryWindowFunctions never optional [REMOVED] DriverCapabilities.queryWindowFunctions was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. ObjectQL never plans window functions through a driver, so there was nothing for the bit to switch on. Delete the key.
querySubqueries never optional [REMOVED] DriverCapabilities.querySubqueries was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. ObjectQL never plans subqueries through a driver, so there was nothing for the bit to switch on. Delete the key.
queryCTE never optional [REMOVED] DriverCapabilities.queryCTE was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. ObjectQL never plans Common Table Expressions through a driver, so there was nothing for the bit to switch on. Delete the key.
joins never optional [REMOVED] DriverCapabilities.joins was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Related data is resolved by the engine (lookup expansion over find()), not by driver-side JOIN planning — no code consulted the bit. Delete the key.
fullTextSearch never optional [REMOVED] DriverCapabilities.fullTextSearch was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. $search is compiled by the engine into an $or of $icontains predicates over the searchable fields (ADR-0061) and removed from the AST before the driver sees it — no driver-side full-text path exists. The operator is $icontains, NOT $contains: textual search is case-insensitive by ruling, while $contains itself stays case-sensitive. Delete the key.
jsonQuery never optional [REMOVED] DriverCapabilities.jsonQuery was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. No engine path ever branched on driver-side JSON querying. Delete the key.
geospatialQuery never optional [REMOVED] DriverCapabilities.geospatialQuery was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. No geospatial query path exists in the platform — declaring the bit advertised a capability nothing delivers. Delete the key.
streaming never optional [REMOVED] DriverCapabilities.streaming was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, and findStream, the only read this bit could describe, was itself removed in 17.0.0: nothing ever called it, and two of its three implementations materialised the entire result set before yielding. The bit carried the same defect one level up (SqlDriver implemented findStream yet declared streaming: false; InMemoryDriver declared true over a full-table read) — which is what zero readers makes inevitable. Page large reads through find() with limit/offset. Delete the key.
jsonFields never optional [REMOVED] DriverCapabilities.jsonFields was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Field-type handling is negotiated per object at syncSchema time by the driver itself (e.g. SqlDriver's per-object JSON/date column tracking); no engine path consulted the bit. Delete the key.
arrayFields never optional [REMOVED] DriverCapabilities.arrayFields was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Field-type handling is negotiated per object at syncSchema time by the driver itself; no engine path consulted the bit. Delete the key.
vectorSearch never optional [REMOVED] DriverCapabilities.vectorSearch was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. No vector read path routes through IDataDriver. When one exists it should arrive WITH its caller and its capability bit together (the honest order under enforce-or-remove), not as a dangling boolean. Delete the key.
schemaSync never optional [REMOVED] DriverCapabilities.schemaSync was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Schema sync is gated on METHOD PRESENCE — typeof driver.syncSchema === 'function' (engine and ObjectQL plugin init). Delete the key.
migrations never optional [REMOVED] DriverCapabilities.migrations was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. No migration engine ever consulted it. Delete the key.
indexes never optional [REMOVED] DriverCapabilities.indexes was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Declared indexes are materialised by the driver itself during schema sync (SqlDriver.syncDeclaredIndexes); no engine path consulted the bit. Delete the key.
connectionPooling never optional [REMOVED] DriverCapabilities.connectionPooling was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Pooling is configured via poolConfig and owned by the driver; getPoolStats is duck-typed where monitoring wants it. Nothing consulted the bit. Delete the key.
preparedStatements never optional [REMOVED] DriverCapabilities.preparedStatements was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. Parameterised execution is an implementation detail of the driver (execute(command, parameters)); nothing consulted the bit. Delete the key.
queryCache never optional [REMOVED] DriverCapabilities.queryCache was removed in @objectstack/spec 17.0.0 (ADR-0049 enforce-or-remove) — no code in any repository ever read it, so its value never changed which code path ran. No query-cache layer keyed off it exists; DriverOptions.skipCache is a per-call hint to the driver, not a switch on this bit. Delete the key.

Nested Shape: SQLDriverConfig.poolConfig

Property Type Required Description
min number optional (default: 2) Minimum number of connections in pool
max number optional (default: 10) Maximum number of connections in pool
idleTimeoutMillis number optional (default: 30000) Time in ms before idle connection is closed
connectionTimeoutMillis number optional (default: 5000) Time in ms to wait for available connection

Nested Shape: SQLDriverConfig.dataTypeMapping

Property Type Required Description
text string ✅ SQL type for text fields (e.g., VARCHAR, TEXT)
number string ✅ SQL type for number fields (e.g., NUMERIC, DECIMAL, INT)
boolean string ✅ SQL type for boolean fields (e.g., BOOLEAN, BIT)
date string ✅ SQL type for date fields (e.g., DATE)
datetime string ✅ SQL type for datetime fields (e.g., TIMESTAMP, DATETIME)
json string optional SQL type for JSON fields (e.g., JSON, JSONB)
uuid string optional SQL type for UUID fields (e.g., UUID, CHAR(36))
binary string optional SQL type for binary fields (e.g., BLOB, BYTEA)

Nested Shape: SQLDriverConfig.sslConfig

Property Type Required Description
rejectUnauthorized boolean optional (default: true) Reject connections with invalid certificates
ca string optional CA certificate file path or content
cert string optional Client certificate file path or content
key string optional Client private key file path or content

SSLConfig

Properties

Property Type Required Description
rejectUnauthorized boolean optional (default: true) Reject connections with invalid certificates
ca string optional CA certificate file path or content
cert string optional Client certificate file path or content
key string optional Client private key file path or content