abstract class Memo::Dialect::Base

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:

Direct Known Subclasses

Defined in:

memo/dialect/base.cr

Instance Method Summary

Instance Method Detail

abstract def database_name(db : DB::Database) : String | Nil #

The database's name on its server, for naming index files.

SQLite: nil (the file names it) PostgreSQL: current_database()


[View source]
abstract def 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)


[View source]
abstract def drop_legacy_texts(db : DBHandle) : Nil #

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


[View source]
abstract def embedding_rowid_column : String #

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

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


[View source]
abstract def fts_join_sql : String #

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


[View source]
abstract def fts_where_sql : String #

Build FTS WHERE clause for match queries.


[View source]
abstract def insert_or_ignore_sql(table : String, columns : String, placeholders : String) : String #

Build INSERT OR IGNORE SQL.


[View source]
abstract def insert_returning_id(db : DBHandle, sql : String, *args) : Int64 #

Execute an INSERT and return the generated ID.


[View source]
abstract def lock_for_migration(db : DB::Connection) : Nil #

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


[View source]
def prepare(db : DB::Database) : Nil #

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


[View source]
abstract def schema_statements : Array(String) #

Get schema DDL statements.


[View source]
abstract def table_exists?(db : DBHandle, table : String) : Bool #

[View source]
abstract def upsert_sql(table : String, columns : String, placeholders : String, conflict_columns : String, update_columns : Array(String)) : String #

Build upsert SQL (INSERT OR REPLACE equivalent).


[View source]