Part 5b: rename also/instead to add_intersection and add_alternate.
This commit is contained in:
parent
9e5c735460
commit
74f188df9b
4 changed files with 10 additions and 10 deletions
|
@ -270,11 +270,11 @@ impl ConjoiningClauses {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constrain_column_to_constant(&mut self, table: TableAlias, column: DatomsColumn, constant: TypedValue) {
|
pub fn constrain_column_to_constant(&mut self, table: TableAlias, column: DatomsColumn, constant: TypedValue) {
|
||||||
self.wheres.also(ColumnConstraint::Equals(QualifiedAlias(table, column), QueryValue::TypedValue(constant)))
|
self.wheres.add_intersection(ColumnConstraint::Equals(QualifiedAlias(table, column), QueryValue::TypedValue(constant)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constrain_column_to_entity(&mut self, table: TableAlias, column: DatomsColumn, entity: Entid) {
|
pub fn constrain_column_to_entity(&mut self, table: TableAlias, column: DatomsColumn, entity: Entid) {
|
||||||
self.wheres.also(ColumnConstraint::Equals(QualifiedAlias(table, column), QueryValue::Entid(entity)))
|
self.wheres.add_intersection(ColumnConstraint::Equals(QualifiedAlias(table, column), QueryValue::Entid(entity)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constrain_attribute(&mut self, table: TableAlias, attribute: Entid) {
|
pub fn constrain_attribute(&mut self, table: TableAlias, attribute: Entid) {
|
||||||
|
@ -282,7 +282,7 @@ impl ConjoiningClauses {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn constrain_value_to_numeric(&mut self, table: TableAlias, value: i64) {
|
pub fn constrain_value_to_numeric(&mut self, table: TableAlias, value: i64) {
|
||||||
self.wheres.also(ColumnConstraint::Equals(
|
self.wheres.add_intersection(ColumnConstraint::Equals(
|
||||||
QualifiedAlias(table, DatomsColumn::Value),
|
QualifiedAlias(table, DatomsColumn::Value),
|
||||||
QueryValue::PrimitiveLong(value)))
|
QueryValue::PrimitiveLong(value)))
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ impl ConjoiningClauses {
|
||||||
// TODO: if both primary and secondary are .v, should we make sure
|
// TODO: if both primary and secondary are .v, should we make sure
|
||||||
// the type tag columns also match?
|
// the type tag columns also match?
|
||||||
// We don't do so in the ClojureScript version.
|
// We don't do so in the ClojureScript version.
|
||||||
self.wheres.also(ColumnConstraint::Equals(primary.clone(), QueryValue::Column(secondary.clone())));
|
self.wheres.add_intersection(ColumnConstraint::Equals(primary.clone(), QueryValue::Column(secondary.clone())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ impl ConjoiningClauses {
|
||||||
} else {
|
} else {
|
||||||
// It must be a keyword.
|
// It must be a keyword.
|
||||||
self.constrain_column_to_constant(col.clone(), DatomsColumn::Value, TypedValue::Keyword(kw.clone()));
|
self.constrain_column_to_constant(col.clone(), DatomsColumn::Value, TypedValue::Keyword(kw.clone()));
|
||||||
self.wheres.also(ColumnConstraint::HasType(col.clone(), ValueType::Keyword));
|
self.wheres.add_intersection(ColumnConstraint::HasType(col.clone(), ValueType::Keyword));
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
PatternValuePlace::Constant(ref c) => {
|
PatternValuePlace::Constant(ref c) => {
|
||||||
|
@ -232,7 +232,7 @@ impl ConjoiningClauses {
|
||||||
// Because everything we handle here is unambiguous, we generate a single type
|
// Because everything we handle here is unambiguous, we generate a single type
|
||||||
// restriction from the value type of the typed value.
|
// restriction from the value type of the typed value.
|
||||||
if value_type.is_none() {
|
if value_type.is_none() {
|
||||||
self.wheres.also(ColumnConstraint::HasType(col.clone(), typed_value_type));
|
self.wheres.add_intersection(ColumnConstraint::HasType(col.clone(), typed_value_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -811,4 +811,4 @@ mod testing {
|
||||||
assert_eq!(cc.empty_because.unwrap(),
|
assert_eq!(cc.empty_because.unwrap(),
|
||||||
EmptyBecause::TypeMismatch(x.clone(), unit_type_set(ValueType::Ref), ValueType::Boolean));
|
EmptyBecause::TypeMismatch(x.clone(), unit_type_set(ValueType::Ref), ValueType::Boolean));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl ConjoiningClauses {
|
||||||
left: left,
|
left: left,
|
||||||
right: right,
|
right: right,
|
||||||
};
|
};
|
||||||
self.wheres.also(constraint);
|
self.wheres.add_intersection(constraint);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ impl ColumnIntersection {
|
||||||
self.0.is_empty()
|
self.0.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn also(&mut self, constraint: ColumnConstraint) {
|
pub fn add_intersection(&mut self, constraint: ColumnConstraint) {
|
||||||
self.0.push(ColumnConstraintOrAlternation::Constraint(constraint));
|
self.0.push(ColumnConstraintOrAlternation::Constraint(constraint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ impl IntoIterator for ColumnAlternation {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ColumnAlternation {
|
impl ColumnAlternation {
|
||||||
pub fn instead(&mut self, intersection: ColumnIntersection) {
|
pub fn add_alternate(&mut self, intersection: ColumnIntersection) {
|
||||||
self.0.push(intersection);
|
self.0.push(intersection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue