[tx] Don't treat :db/doc as defining a schema attribute. (#784)

This commit is contained in:
Nick Alexander 2018-07-13 14:26:10 -07:00
parent bff24c60b7
commit 9291b2a0b0
3 changed files with 21 additions and 18 deletions

View file

@ -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() {

View file

@ -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,

View file

@ -121,11 +121,8 @@ pub fn update_attribute_map_from_entid_triples<A, R>(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<A, R>(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); },