Skip to content

Commit

Permalink
Do not check for subsets when it is the universal set
Browse files Browse the repository at this point in the history
can-fixture uses the memory store, but its super set is the universal
set. Therefore there isn't a need to check if a query is a subset. Doing
so causes errors when comparisons are made between unknown types.

This is part of canjs/can-query-logic#50
  • Loading branch information
matthewp committed Jul 18, 2019
1 parent 391041d commit 70dc50e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
end_of_line = LF
indent_style = tab
trim_trailing_whitespace = false
insert_final_newline = true
insert_final_newline = true
indent_size = 4

[{*.json,*.yml,*.md}]
indent_style = space
indent_size = 2
19 changes: 19 additions & 0 deletions can-memory-store-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,5 +538,24 @@ QUnit.test("create, update, destroy all return saved data", function(assert) {
});
});

QUnit.test("Does not do subset comparisons when the superset is the universe", function(assert) {
var queryLogic = new QueryLogic({});
queryLogic.isSubset = function() {
throw new Error("CANNOT COMPARE");
};

var store = memoryStore({
queryLogic: queryLogic
});
store.updateQueryDataSync([{ query: {}, startIdentity: "123" }]);

try {
store.getListDataSync({ filter: {a: "b"} });
assert.ok(true, "Able to getListData with a universal superset");
} catch(e) {
assert.ok(false, e);
}
});


// TODO: make sure we get the right count
4 changes: 2 additions & 2 deletions make-simple-store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var canReflect = require("can-reflect");


function getItems(data){
if(Array.isArray(data)) {
return data;
Expand Down Expand Up @@ -80,7 +79,8 @@ function makeSimpleStore(baseConnection) {

for(var i = 0; i < queryData.length; i++) {
var checkSet = queryData[i].query;
if( this.queryLogic.isSubset(query, checkSet) ) {
if( this.queryLogic.isEqual(checkSet, {}) ||
this.queryLogic.isSubset(query, checkSet) ) {
superSetQueryData = queryData[i];
}
}
Expand Down

0 comments on commit 70dc50e

Please sign in to comment.