abstract class
Memo::Dialect::Base
- Memo::Dialect::Base
- Reference
- Object
Overview
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)
Direct Known Subclasses
Defined in:
memo/dialect/base.crInstance Method Summary
-
#database_name(db : DB::Database) : String | Nil
The database's name on its server, for naming index files.
-
#db_file_path(db : DB::Database) : String | Nil
Get the database file path from a connection, if applicable.
-
#drop_legacy_texts(db : DBHandle) : Nil
Drop the tables content-addressed storage replaced (memo_texts and its full-text index).
-
#embedding_rowid_column : String
The column name for embedding row identity used as USearch key.
-
#fts_join_sql : String
Build FTS JOIN clause for search queries (joining a chunk's text).
-
#fts_where_sql : String
Build FTS WHERE clause for match queries.
-
#insert_or_ignore_sql(table : String, columns : String, placeholders : String) : String
Build INSERT OR IGNORE SQL.
-
#insert_returning_id(db : DBHandle, sql : String, *args) : Int64
Execute an INSERT and return the generated ID.
-
#lock_for_migration(db : DB::Connection) : Nil
Inside a migration's transaction: keep other processes from migrating the same database at the same time.
-
#prepare(db : DB::Database) : Nil
Bring existing tables up to date before the schema runs, where its statements depend on columns older databases lack.
-
#schema_statements : Array(String)
Get schema DDL statements.
- #table_exists?(db : DBHandle, table : String) : Bool
-
#upsert_sql(table : String, columns : String, placeholders : String, conflict_columns : String, update_columns : Array(String)) : String
Build upsert SQL (INSERT OR REPLACE equivalent).
Instance Method Detail
The database's name on its server, for naming index files.
SQLite: nil (the file names it) PostgreSQL: current_database()
Get the database file path from a connection, if applicable.
SQLite: reads pragma_database_list PostgreSQL: returns nil (no local file)
Drop the tables content-addressed storage replaced (memo_texts and its full-text index).
The column name for embedding row identity used as USearch key.
SQLite: "rowid" (implicit) PostgreSQL: "eid" (explicit column)
Build FTS JOIN clause for search queries (joining a chunk's text).
Build INSERT OR IGNORE SQL.
Execute an INSERT and return the generated ID.
Inside a migration's transaction: keep other processes from migrating the same database at the same time.
Bring existing tables up to date before the schema runs, where its statements depend on columns older databases lack.
Build upsert SQL (INSERT OR REPLACE equivalent).