Files
fastway-plugin-sdk/dbapi_consts.pas
Ken Johnson 7f38e0a426 SDK v0.5.3: Add DBAPI types and updated IFWPluginHost
Refresh of the plugin SDK to match fastway-server v0.5.3. Plugins
that want to use the typed DBAPI (DeclareTable/StoreInsert/etc.)
need dbapi_consts.pas for TDBAColumnType/TDBAOnDeleteAction/etc.
and dbapi_dialect.pas for TDBATableSpec/TDBAColumnSpec/TDBACriterion
and the builder helpers (MakeColumn, MakeFK, MakeUnique, etc.).

fw_plugin_api.pas: latest IFWPluginHost with typed DBAPI methods
(DeclareTable, DeclareColumn, DeclareIndex, StoreInsert, StoreUpdate,
StoreDelete, StoreSelect, StoreUpsert) added under plugin API v1
(still in flux — no version bump during pre-production).

Plugin repos vendor this via 'make pull-sdk' which copies these
files into the plugin's local sdk/ dir and pins the commit hash
in sdk/VERSION. Mirrors the Fimail/fpc-msgbase pattern.
2026-04-18 09:03:08 -07:00

107 lines
2.9 KiB
ObjectPascal

{
dbapi_consts.pas — Core enums and version for the DBAPI framework.
Part of fpc-dbapi: a database abstraction library for Free Pascal
supporting SQLite, MariaDB/MySQL, and PostgreSQL behind a single
dialect interface with declarative schema and structured query ops.
This unit has no dependencies beyond the FPC RTL.
}
unit dbapi_consts;
{$mode objfpc}{$H+}
interface
const
{ Library version. Bumped independently of consumer versions. }
DBAPI_VERSION = '0.1.0';
type
{ Log level passed to TDBALogProc subscribers. }
TDBALogLevel = (
dllDebug,
dllInfo,
dllWarning,
dllError
);
{ Column types supported by the dialect layer. Dialect maps each to
its backend's native type; see IDBADialect.SqlType. }
TDBAColumnType = (
dctText, { Unbounded text: SQLite TEXT / MariaDB TEXT / PG TEXT }
dctVarchar, { Bounded text: VARCHAR(n) on all backends; SQLite stores as TEXT }
dctInteger, { 32-bit signed int }
dctBigInt, { 64-bit signed int }
dctFloat, { 4-byte float }
dctDouble, { 8-byte double }
dctBoolean, { Bool: SQLite INTEGER 0/1, MariaDB TINYINT(1), PG BOOLEAN }
dctBlob, { Binary: BLOB / LONGBLOB / BYTEA }
dctDateTime, { Timestamp with time: UTC assumed }
dctDate, { Calendar date only }
dctTime, { Time of day }
dctJSON, { JSON document: SQLite TEXT, MariaDB LONGTEXT w/ JSON check, PG JSONB }
dctUUID { UUID: stored as CHAR(36) on SQLite/MariaDB, UUID on PG }
);
{ Units for DateAddExpr. }
TDBADateUnit = (
duSecond,
duMinute,
duHour,
duDay,
duWeek,
duMonth,
duYear
);
{ Comparison operators for TDBACriteria. }
TDBACompareOp = (
dcoEq, { column = value }
dcoNeq, { column <> value }
dcoLt, { column < value }
dcoLe, { column <= value }
dcoGt, { column > value }
dcoGe, { column >= value }
dcoLike, { column LIKE value (dialect handles % escaping) }
dcoILike, { case-insensitive LIKE (PG has ILIKE; others use LOWER(col) LIKE LOWER(val)) }
dcoIn, { column IN (values...) }
dcoNotIn, { column NOT IN (values...) }
dcoIsNull, { column IS NULL — value ignored }
dcoIsNotNull { column IS NOT NULL — value ignored }
);
{ Boolean combinator for compound criteria. }
TDBABoolOp = (
dboAnd,
dboOr
);
{ Sort direction for TDBASelectSpec.OrderBy. }
TDBAOrderDir = (
dodAsc,
dodDesc
);
{ Kinds of schema changes fired to TDBASchemaChangeProc subscribers. }
TDBASchemaChangeKind = (
dsckCreateTable,
dsckAddColumn,
dsckModifyColumn,
dsckCreateIndex,
dsckDropIndex
);
{ Which backend a dialect represents. Consumer can query via
IDBADialect.Backend to branch on backend-specific features
(e.g. "only use JSONB on PG"). }
TDBABackend = (
dbSQLite,
dbMariaDB,
dbPostgres
);
implementation
end.