class

Memo::Dialect::Base

Inherits Reference < Object

Abstract interface for SQL dialect differences between SQLite and PostgreSQL.

Most SQL in Memo is cross-database compatible. This module only abstracts the patterns that differ:

  • Insert-and-return-ID (last_insert_rowid vs RETURNING)
  • Conflict handling (INSERT OR IGNORE, INSERT OR REPLACE)
  • Implicit rowid (SQLite) vs explicit column (PostgreSQL)
  • FTS5 (SQLite) vs tsvector/GIN (PostgreSQL)
  • Schema DDL (AUTOINCREMENT, BLOB, REAL types)
  • DB path discovery (pragma vs connection string)

Instance methods

db_file_path(db : DB::Database) : String | Nil

Get the database file path from a connection, if applicable.

SQLite: reads pragma_database_list PostgreSQL: returns nil (no local file)

Source
drop_legacy_texts(db : DBHandle) : Nil

Drop the tables content-addressed storage replaced (memo_texts and its full-text index).

Source
embedding_rowid_column

The column name for embedding row identity used as USearch key.

SQLite: "rowid" (implicit) PostgreSQL: "eid" (explicit column)

Source
fts_join_sql

Build FTS JOIN clause for search queries (joining a chunk's text).

Source
fts_where_sql

Build FTS WHERE clause for match queries.

Source
insert_or_ignore_sql(table : String, columns : String, placeholders : String) : String

Build INSERT OR IGNORE SQL.

Source
insert_returning_id(db : DBHandle, sql : String, *args) : Int64

Execute an INSERT and return the generated ID.

Source
lock_for_migration(db : DB::Connection) : Nil

Inside a migration's transaction: keep other processes from migrating the same database at the same time.

Source
prepare(db : DB::Database) : Nil

Bring existing tables up to date before the schema runs, where its statements depend on columns older databases lack.

Source
schema_statements

Get schema DDL statements.

Source
table_exists?(db : DBHandle, table : String) : Bool
Source
upsert_sql(table : String, columns : String, placeholders : String, conflict_columns : String, update_columns : Array(String)) : String

Build upsert SQL (INSERT OR REPLACE equivalent).

Source