class
Memo::Dialect::SQLite
- Memo::Dialect::SQLite
- Memo::Dialect::Base
- Reference
- Object
Defined in:
memo/dialect/sqlite.crConstant Summary
-
SCHEMA_SQL =
{{ read_file("/home/trans/Projects/memo/src/memo/dialect/../../../db/schema/memo_schema.sql") }}
Instance Method Summary
-
#db_file_path(db : DB::Database) : String | Nil
Get the database file path from a connection, if applicable.
-
#embedding_rowid_column : String
The column name for embedding row identity used as USearch key.
-
#fts_delete(db : DBHandle, source_id : Int64)
Delete FTS index entry for a source.
-
#fts_join_sql : String
Build FTS JOIN clause for search queries.
-
#fts_upsert(db : DBHandle, source_id : Int64, content : String)
FTS rows are keyed by rowid = source_id.
-
#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.
-
#migrate(db : DB::Database) : Nil
One-time data migrations, run by Database.init after the schema.
-
#migrate_fts_rowids(db : DB::Database) : Nil
Databases from before FTS rows were keyed by source_id: rebuild the FTS table from memo_texts, once.
-
#schema_statements : Array(String)
Get schema DDL statements.
-
#upsert_sql(table : String, columns : String, placeholders : String, conflict_columns : String, update_columns : Array(String)) : String
Build upsert SQL (INSERT OR REPLACE equivalent).
Instance methods inherited from class Memo::Dialect::Base
db_file_path(db : DB::Database) : String | Nil
db_file_path,
embedding_rowid_column : String
embedding_rowid_column,
fts_delete(db : DBHandle, source_id : Int64)
fts_delete,
fts_join_sql : String
fts_join_sql,
fts_upsert(db : DBHandle, source_id : Int64, content : String)
fts_upsert,
fts_where_sql : String
fts_where_sql,
insert_or_ignore_sql(table : String, columns : String, placeholders : String) : String
insert_or_ignore_sql,
insert_returning_id(db : DBHandle, sql : String, *args) : Int64
insert_returning_id,
migrate(db : DB::Database) : Nil
migrate,
schema_statements : Array(String)
schema_statements,
upsert_sql(table : String, columns : String, placeholders : String, conflict_columns : String, update_columns : Array(String)) : String
upsert_sql
Instance Method Detail
Get the database file path from a connection, if applicable.
SQLite: reads pragma_database_list PostgreSQL: returns nil (no local file)
The column name for embedding row identity used as USearch key.
SQLite: "rowid" (implicit) PostgreSQL: "eid" (explicit column)
Delete FTS index entry for a source.
Build FTS JOIN clause for search queries.
FTS rows are keyed by rowid = source_id. An FTS5 table can only look rows up by rowid (or MATCH); filtering on its source_id column scans the whole table, which made each indexed document slower than the last (9 ms per lookup at 150K documents).
Build FTS WHERE clause for match queries.
Build INSERT OR IGNORE SQL.
Execute an INSERT and return the generated ID.
One-time data migrations, run by Database.init after the schema.
Databases from before FTS rows were keyed by source_id: rebuild the FTS table from memo_texts, once. The transaction holds the write lock from the start (BEGIN IMMEDIATE) while it re-checks, so a second process opening the same database waits for the first one's migration (busy_timeout), then skips it.
Get schema DDL statements.
Build upsert SQL (INSERT OR REPLACE equivalent).