Comparing version 1.8.0 to 1.8.1
{ | ||
"name": "aqb", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"description": "ArangoDB AQL query builder.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -179,2 +179,4 @@ # ArangoDB Query Builder | ||
* `foo1.bar2` | ||
* `` `foo`.bar `` | ||
* `` foo.`bar` `` | ||
@@ -186,3 +188,2 @@ Invalid values: | ||
* `foo bar` | ||
* `foo-bar` | ||
* `foo[bar]` | ||
@@ -189,0 +190,0 @@ |
35
types.js
@@ -55,3 +55,3 @@ /*jshint browserify: true */ | ||
if (obj.constructor && obj.constructor.name === 'ArangoCollection') { | ||
return new Identifier(obj.name()); | ||
return new Identifier(obj); | ||
} | ||
@@ -230,3 +230,9 @@ if (Array.isArray(obj)) { | ||
function Identifier(value) { | ||
if (value && value instanceof Identifier) {value = value.value;} | ||
if (value) { | ||
if (value.constructor && value.constructor.name === 'ArangoCollection') { | ||
value = value.name(); | ||
} else if (value instanceof Identifier) { | ||
value = value.value; | ||
} | ||
} | ||
if (!value || typeof value !== 'string') { | ||
@@ -240,3 +246,3 @@ throw new AqlError('Expected value to be a string: ' + value); | ||
} | ||
Identifier.re = /^[_a-z][-_0-9a-z]*$/i; | ||
Identifier.re = /^[_@a-z][-_@0-9a-z]*$/i; | ||
Identifier.prototype = new Expression(); | ||
@@ -246,10 +252,16 @@ Identifier.prototype.constructor = Identifier; | ||
var value = String(this.value); | ||
if (keywords.indexOf(value.toLowerCase()) === -1 && value.indexOf('-') === -1) { | ||
return value; | ||
if (keywords.indexOf(value.toLowerCase()) !== -1 || value.indexOf('-') !== -1) { | ||
return '`' + value + '`'; | ||
} | ||
return '`' + value + '`'; | ||
return value; | ||
}; | ||
function SimpleReference(value) { | ||
if (value && value instanceof SimpleReference) {value = value.value;} | ||
if (value) { | ||
if (value.constructor && value.constructor.name === 'ArangoCollection') { | ||
value = value.name(); | ||
} else if (value instanceof SimpleReference) { | ||
value = value.value; | ||
} | ||
} | ||
if (!value || typeof value !== 'string') { | ||
@@ -263,3 +275,3 @@ throw new AqlError('Expected value to be a string: ' + value); | ||
} | ||
SimpleReference.re = /^@{0,2}[_a-z][_0-9a-z]*(\.[_a-z][_0-9a-z]*|\[\*\])*$/i; | ||
SimpleReference.re = /^([_@a-z][-_@0-9a-z]*|`[_@a-z][-_@0-9a-z]*`)(\.[_@a-z][-_@0-9a-z]*|\.`[_@a-z][-_@0-9a-z]*`|\[\*\])*$/i; | ||
SimpleReference.prototype = new Expression(); | ||
@@ -269,4 +281,7 @@ SimpleReference.prototype.constructor = SimpleReference; | ||
var value = String(this.value); | ||
var tokens = value.split('.').map(function (token) { | ||
return keywords.indexOf(token) === -1 ? token : '`' + token + '`'; | ||
var tokens = value.split('.').map(function (token, i) { | ||
if (token.charAt(0) !== '`' && (keywords.indexOf(token.toLowerCase()) !== -1 || token.indexOf('-') !== -1)) { | ||
return '`' + token + '`'; | ||
} | ||
return token; | ||
}); | ||
@@ -273,0 +288,0 @@ return tokens.join('.'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64199
991
607