Skip to content

Commit

Permalink
0.0.10
Browse files Browse the repository at this point in the history
Support for no returns version of returns references
  • Loading branch information
ivansglazunov committed Apr 12, 2018
1 parent 39d1489 commit d819072
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/returns-references.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/returns-references.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ancient-babilon",
"version": "0.0.9",
"version": "0.0.10",
"description": "One data query language will rule them all.",
"bugs": "https://github.com/AncientSouls/Babilon/issues",
"repository": "AncientSouls/Babilon",
Expand Down
1 change: 1 addition & 0 deletions src/lib/returns-references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const generateReturnsAs = (asFrom: string = 'from', asId: string = 'id',
export const returnsReferencesSelect = (exp: TExp, createReturns = generateReturnsAs()): TExp[] => {
const i: any = {};
_.each(exp, (exp, e) => e ? i[exp[0]] = e : null);
i.returns = i.returns || exp.length;
const selects = [];
_.each(exp[i.from], (from, f) => {
if (f) {
Expand Down
32 changes: 32 additions & 0 deletions src/tests/returns-references.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,38 @@ import {
} from '../lib/proto-sql';

export default () => {
it('returnsReferences no returns', () => {
const exp = returnsReferences(
['select',
['from',
['alias','x'],
['alias','y','z'],
],
['and',
['gt',['path','z','a'],['data',10]],
['or',
['eq',['path','x','b'],['data',123]],
['eq',['path','x','c'],['data',123]],
],
],
['orders', ['order', ['path', 'z', 'a']], ['order', ['path', 'x', 'b'], false]],
['limit', 10], ['skip', 10],
],
generateReturnsAs(),
);
assert.lengthOf(exp, 3);
assert.deepEqual(exp[1][6], ['returns',
['as', ['data', 'x'], 'from'],
['as', ['path', 'x', 'id'], 'id'],
]);
assert.deepEqual(exp[2][6], ['returns',
['as', ['data', 'y'], 'from'],
['as', ['path', 'y', 'id'], 'id'],
]);
const resolver = createResolver(resolverOptions);
const b = babilon({ resolver, validators, exp });
assert.deepEqual(b.errors, []);
});
it('returnsReferencesAs', () => {
const exp = returnsReferences(
['select',
Expand Down
29 changes: 29 additions & 0 deletions tests/returns-references.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/returns-references.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d819072

Please sign in to comment.