From 9291b2a0b0ad5cfad35657759fc15b2b9959efe9 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Fri, 13 Jul 2018 14:26:10 -0700 Subject: [PATCH] [tx] Don't treat :db/doc as defining a schema attribute. (#784) --- db/src/db.rs | 16 ++++++++++++++++ db/src/entids.rs | 9 +++------ db/src/metadata.rs | 14 ++------------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/db/src/db.rs b/db/src/db.rs index be350905..2bd82766 100644 --- a/db/src/db.rs +++ b/db/src/db.rs @@ -1498,6 +1498,22 @@ mod tests { [200 :db.schema/attribute 101]]"); } + #[test] + fn test_db_doc_is_not_schema() { + let mut conn = TestConn::default(); + + // Neither transaction below is defining a new attribute. That is, it's fine to use :db/doc + // to describe any entity in the system, not just attributes. And in particular, including + // :db/doc shouldn't make the transactor consider the entity a schema attribute. + assert_transact!(conn, r#" + [{:db/doc "test"}] + "#); + + assert_transact!(conn, r#" + [{:db/ident :test/id :db/doc "test"}] + "#); + } + // Unique is required! #[test] fn test_upsert_issue_538() { diff --git a/db/src/entids.rs b/db/src/entids.rs index 5eaaa5ff..2c2e0bb4 100644 --- a/db/src/entids.rs +++ b/db/src/entids.rs @@ -61,7 +61,7 @@ pub const DB_SCHEMA_CORE: Entid = 40; /// Return `false` if the given attribute will not change the metadata: recognized idents, schema, /// partitions in the partition map. pub fn might_update_metadata(attribute: Entid) -> bool { - if attribute > DB_DOC { + if attribute >= DB_DOC { return false } match attribute { @@ -69,7 +69,6 @@ pub fn might_update_metadata(attribute: Entid) -> bool { DB_IDENT | // Schema. DB_CARDINALITY | - DB_DOC | DB_FULLTEXT | DB_INDEX | DB_IS_COMPONENT | @@ -89,9 +88,8 @@ lazy_static! { /// Attributes that are "schema related". These might change the "schema" materialized view. pub static ref SCHEMA_SQL_LIST: String = { - format!("({}, {}, {}, {}, {}, {}, {})", + format!("({}, {}, {}, {}, {}, {})", DB_CARDINALITY, - DB_DOC, DB_FULLTEXT, DB_INDEX, DB_IS_COMPONENT, @@ -101,9 +99,8 @@ lazy_static! { /// Attributes that are "metadata" related. These might change one of the materialized views. pub static ref METADATA_SQL_LIST: String = { - format!("({}, {}, {}, {}, {}, {}, {}, {})", + format!("({}, {}, {}, {}, {}, {}, {})", DB_CARDINALITY, - DB_DOC, DB_FULLTEXT, DB_IDENT, DB_INDEX, diff --git a/db/src/metadata.rs b/db/src/metadata.rs index 651c5054..2e9a66c7 100644 --- a/db/src/metadata.rs +++ b/db/src/metadata.rs @@ -121,11 +121,8 @@ pub fn update_attribute_map_from_entid_triples(attribute_map: &mut Attribu for (entid, attr, ref value) in retractions.into_iter() { let builder = builders.entry(entid).or_insert_with(|| attribute_builder_to_modify(entid, attribute_map)); match attr { - // You can only retract :db/unique, :db/doc, :db/isComponent; all others - // must be altered instead of retracted, or are not allowed to change. - entids::DB_DOC => { - // Nothing to do here; we don't keep docstrings inside `Attribute`s. - }, + // You can only retract :db/unique, :db/isComponent; all others must be altered instead + // of retracted, or are not allowed to change. entids::DB_IS_COMPONENT => { match value { &TypedValue::Boolean(v) if builder.component == Some(v) => { @@ -166,13 +163,6 @@ pub fn update_attribute_map_from_entid_triples(attribute_map: &mut Attribu // TODO: improve error messages throughout. match attr { - entids::DB_DOC => { - match *value { - TypedValue::String(_) => {}, - _ => bail!(DbErrorKind::BadSchemaAssertion(format!("Expected [... :db/doc \"string value\"] but got [... :db/doc {:?}] for entid {} and attribute {}", value, entid, attr))) - } - }, - entids::DB_VALUE_TYPE => { match *value { TypedValue::Ref(entids::DB_TYPE_BOOLEAN) => { builder.value_type(ValueType::Boolean); },