Skip to content

Commit

Permalink
Fix concat formatter for open data query (#82)
Browse files Browse the repository at this point in the history
* fconcat formatter for open data query

* 2.11.2

* add missing babel dependency
  • Loading branch information
kbarbounakis authored Dec 5, 2023
1 parent 64332b5 commit 11c2084
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 51 deletions.
183 changes: 134 additions & 49 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@themost/query",
"version": "2.11.1",
"version": "2.11.2",
"description": "MOST Web Framework Codename ZeroGravity - Query Module",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
Expand Down Expand Up @@ -32,6 +32,7 @@
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-transform-runtime": "^7.23.4",
"@babel/preset-env": "^7.20.2",
"@babel/register": "^7.18.9",
"@rollup/plugin-babel": "^5.3.1",
Expand Down
17 changes: 17 additions & 0 deletions spec/OpenDataQuery.select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,21 @@ describe('OpenDataQuery.select', () => {
expect(result.$top).toEqual(25);
});

it('should format $concat', () => {
let query = new OpenDataQuery()
.select((x) => {
return {
id: x.id,
familyName: x.familyName,
givenName: x.givenName,
name: x.givenName.concat(' ', x.familyName),
};
})
.from('People');
expect(query).toBeTruthy();
const formatter = new OpenDataQueryFormatter();
let result = formatter.formatSelect(query);
expect(result.$select).toEqual('id,familyName,givenName,concat(concat(givenName,\' \'),familyName) as name');
});

});
2 changes: 1 addition & 1 deletion src/open-data-query.formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class OpenDataQueryFormatter extends SqlFormatter {
const s1 = args[index];
str = sprintf('concat(%s,%s)', self.escape(s0), self.escape(s1));
} else {
str = sprintf('concat(%s,%s)', self.escape(s0), str);
str = sprintf('concat(%s,%s)', str, self.escape(s0));
}
index += 1;
}
Expand Down

0 comments on commit 11c2084

Please sign in to comment.