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
embedding_rowid_column

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

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

Source
fts_delete(db : DB::Database, source_id : Int64)

Delete FTS index entry for a source.

Source
fts_join_sql

Build FTS JOIN clause for search queries.

Source
fts_upsert(db : DB::Database, source_id : Int64, content : String)

Insert or update FTS index for a source.

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 : DB::Database, sql : String, *args) : Int64

Execute an INSERT and return the generated ID.

Source
schema_statements

Get schema DDL statements.

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