diff --git a/cozo-core/src/lib.rs b/cozo-core/src/lib.rs index b80f5886..b8c48aa0 100644 --- a/cozo-core/src/lib.rs +++ b/cozo-core/src/lib.rs @@ -282,6 +282,9 @@ impl DbInstance { } } /// Import a relation, the data is given as a JSON string, and the returned result is converted into a string + /// + /// Note that triggers are _not_ run for the relations, if any exists. + /// If you need to activate triggers, use queries with parameters. pub fn import_relations_str(&self, data: &str) -> String { match self.import_relations_str_inner(data) { Ok(()) => { @@ -353,6 +356,9 @@ impl DbInstance { } } /// Import relations from an Sqlite backup, with JSON string return value + /// + /// Note that triggers are _not_ run for the relations, if any exists. + /// If you need to activate triggers, use queries with parameters. pub fn import_from_backup_str(&self, payload: &str) -> String { match self.import_from_backup_str_inner(payload) { Ok(_) => json!({"ok": true}).to_string(), diff --git a/cozo-core/src/runtime/db.rs b/cozo-core/src/runtime/db.rs index c9e7f53b..d3db8a0b 100644 --- a/cozo-core/src/runtime/db.rs +++ b/cozo-core/src/runtime/db.rs @@ -195,6 +195,9 @@ impl<'s, S: Storage<'s>> Db { /// Import relations. The argument `data` accepts data in the shape of /// what was returned by [Self::export_relations]. /// The target stored relations must already exist in the database. + /// + /// Note that triggers are _not_ run for the relations, if any exists. + /// If you need to activate triggers, use queries with parameters. pub fn import_relations(&'s self, data: BTreeMap) -> Result<()> { #[derive(Debug, Diagnostic, Error)] #[error("cannot import data for relation '{0}': {1}")] @@ -345,6 +348,9 @@ impl<'s, S: Storage<'s>> Db { } /// Import data from relations in a backup file. /// The target stored relations must already exist in the database. + /// + /// Note that triggers are _not_ run for the relations, if any exists. + /// If you need to activate triggers, use queries with parameters. pub fn import_from_backup(&'s self, in_file: &str, relations: &[String]) -> Result<()> { #[cfg(not(feature = "storage-sqlite"))] bail!("backup requires the 'storage-sqlite' feature to be enabled"); diff --git a/cozo-lib-c/src/lib.rs b/cozo-lib-c/src/lib.rs index 138a6a34..0e75c784 100644 --- a/cozo-lib-c/src/lib.rs +++ b/cozo-lib-c/src/lib.rs @@ -147,6 +147,9 @@ pub unsafe extern "C" fn cozo_run_query( #[no_mangle] /// Import data into relations /// +/// Note that triggers are _not_ run for the relations, if any exists. +/// If you need to activate triggers, use queries with parameters. +/// /// `db_id`: the ID representing the database. /// `json_payload`: a UTF-8 encoded JSON payload, in the same form as returned by exporting relations. /// @@ -275,6 +278,9 @@ pub unsafe extern "C" fn cozo_restore(db_id: i32, in_path: *const c_char) -> *mu #[no_mangle] /// Import data into relations from a backup /// +/// Note that triggers are _not_ run for the relations, if any exists. +/// If you need to activate triggers, use queries with parameters. +/// /// `db_id`: the ID representing the database. /// `json_payload`: a UTF-8 encoded JSON payload: `{"path": ..., "relations": [...]}` /// diff --git a/cozo-lib-nodejs/README.md b/cozo-lib-nodejs/README.md index 686ad630..fa91bec6 100644 --- a/cozo-lib-nodejs/README.md +++ b/cozo-lib-nodejs/README.md @@ -76,7 +76,10 @@ class CozoDb { async exportRelations(relations: Array): object; /** - * Import several relations + * Import several relations. + * + * Note that triggers are _not_ run for the relations, if any exists. + * If you need to activate triggers, use queries with parameters. * * @param data: in the same form as returned by `exportRelations`. The relations * must already exist in the database. @@ -100,6 +103,9 @@ class CozoDb { /** * Import several relations from a backup. The relations must already exist in the database. * + * Note that triggers are _not_ run for the relations, if any exists. + * If you need to activate triggers, use queries with parameters. + * * @param path: path to the backup file. * @param rels: the relations to import. */ diff --git a/cozo-lib-swift/README.md b/cozo-lib-swift/README.md index c4c88849..a0cb340e 100644 --- a/cozo-lib-swift/README.md +++ b/cozo-lib-swift/README.md @@ -110,6 +110,9 @@ public class CozoDB { /** * Import data into relations * + * Note that triggers are _not_ run for the relations, if any exists. + * If you need to activate triggers, use queries with parameters. + * * `data`: the payload, in the same format as returned by `exportRelations`. */ public func importRelations(data: JSON) throws; @@ -129,7 +132,10 @@ public class CozoDB { public func restore(path: String) throws; /** - * Import data into a relation + * Import data into a relation from a backup. + * + * Note that triggers are _not_ run for the relations, if any exists. + * If you need to activate triggers, use queries with parameters. * * `path`: path of the input file. * `relations`: the stored relations to import into. diff --git a/cozo-lib-wasm/README.md b/cozo-lib-wasm/README.md index 8293e396..e2b07296 100644 --- a/cozo-lib-wasm/README.md +++ b/cozo-lib-wasm/README.md @@ -51,6 +51,8 @@ export class CozoDb { export_relations(data: string): string; + // Note that triggers are _not_ run for the relations, if any exists. + // If you need to activate triggers, use queries with parameters. import_relations(data: string): string; } ``` diff --git a/cozoserver/README.md b/cozoserver/README.md index 6cad2b4f..67fe6e07 100644 --- a/cozoserver/README.md +++ b/cozoserver/README.md @@ -74,6 +74,10 @@ and a nicely-formatted diagnostic will be in `"display"` if available. * `GET /`, if you open this in your browser and open your developer tools, you will be able to use a very simple client to query this database. +> For `import` and `import-from-backup`, triggers are _not_ run for the relations, if any exists. +If you need to activate triggers, use queries with parameters. + + ## Building Building `cozo-node` requires a [Rust toolchain](https://rustup.rs). Run