-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
In the feature/v2 branch, the has_fields method et al. looks like:
def has_fields(self, *fields):
self.terms.append(['$has_fields', fields])
return self._clone()
def _clone(self):
query = type(self)(self.schema)
query.terms.extend(copy.deepcopy(self.terms))
return queryhas_fields() Reference
_clone() Reference
I'm assuming self isn't being returned directly because Query objects are intended to be immutable.
getAllQuery = montage.Query('movies');
hasFieldsQuery = getAllQuery.hasFields('field');
limitQuery = getAllQuery.limit(1);
Unless I'm missing something, getAllQuery, hasFieldsQuery, and limitQuery would have different references but their terms would overlap because terms.append() happens before the copy.deepcopy().
More specifically, getAllQuery would get the terms from the .hasFields() call and hasFieldsQuery and limitQuery would have identical terms.
- Are my observations above correct?
- Should Query instances be immutable? (so I can duplicate this behavior in the
javascript-montagewrapper).
Reactions are currently unavailable