Skip to content

Commit d0a21ef

Browse files
committed
merged
2 parents 50e1099 + 705e501 commit d0a21ef

File tree

9 files changed

+320
-276
lines changed

9 files changed

+320
-276
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
end_of_line = LF
44
indent_style = tab
55
trim_trailing_whitespace = false
6-
insert_final_newline = true
6+
insert_final_newline = true

can-query-logic-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,10 @@ QUnit.test("isPaginated, removePagination", function(assert){
235235
assert.deepEqual( algebra.removePagination({page: {start: 1, end: 2}}), {}, "removePagination page");
236236

237237
});
238+
239+
QUnit.test("Value returned by makeEnum is constructorLike", function(assert){
240+
var Status = QueryLogic.makeEnum(["new", "preparing", "delivery", "delivered"]);
241+
var pass = canReflect.isConstructorLike(Status);
242+
243+
assert.ok(pass, "Status is constructor like");
244+
});

can-query-logic.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var makeBasicQueryConvert = require("./src/serializers/basic-query");
55
var BasicQuery = require("./src/types/basic-query");
66
var valueComparisons = require("./src/types/comparisons");
77
var schemaSymbol = canSymbol.for("can.getSchema");
8+
var newSymbol = canSymbol.for("can.new");
89
var makeEnum = require("./src/types/make-enum");
910

1011

@@ -173,6 +174,7 @@ QueryLogic.UNKNOWABLE = set.UNKNOWABLE;
173174

174175
QueryLogic.makeEnum = function(values){
175176
var Type = function(){};
177+
Type[newSymbol] = function(val) { return val; };
176178
makeEnum(Type, values);
177179
return Type;
178180
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "can-query-logic",
3-
"version": "0.8.9",
3+
"version": "1.0.0",
44
"description": "query data",
55
"homepage": "",
66
"repository": {

src/helpers.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ var helpers = {
8989

9090
return 0;
9191
};
92-
}
92+
},
93+
valueHydrator: function(value){
94+
if(canReflect.isBuiltIn(value)) {
95+
return value;
96+
} else {
97+
throw new Error("can-query-logic doesn't support comparison operator: "+JSON.stringify(value));
98+
}
99+
}
93100
};
94101
module.exports = helpers;

src/serializers/basic-query-test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,25 @@ QUnit.test("gt and lt", function(){
209209

210210
});
211211

212+
QUnit.test("basicquery with no sort", function() {
213+
var query = {};
214+
215+
var converter = makeBasicQueryConvert({
216+
identity: ["id"],
217+
type: "map",
218+
keys: {
219+
id: function(val) { return val; }
220+
}
221+
});
222+
var basicQuery = converter.hydrate(query);
223+
224+
var objs = [{id: 0}, {id: 2}]
225+
var item = {id: 1};
226+
227+
var res = basicQuery.index(item, objs);
228+
QUnit.equal(res, 1, "inserted at 1");
229+
});
230+
212231
/*
213232
QUnit.skip("nested properties within ors", function(){
214233
var query = {

0 commit comments

Comments
 (0)