Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [0.92.0](https://github.com/5app/dare/compare/v0.91.0...v0.92.0) (2024-11-04)


### Features

* **field_expression:** support [FUNCNAME](field AS [UPPERCASE|String|Number]) ([#385](https://github.com/5app/dare/issues/385)) ([e2d1764](https://github.com/5app/dare/commit/e2d17642b4d1b96ead7e729c454164f333e798dc))

# [0.91.0](https://github.com/5app/dare/compare/v0.90.2...v0.91.0) (2024-09-23)


Expand Down
137 changes: 100 additions & 37 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dare",
"version": "0.91.0",
"version": "0.92.0",
"description": "Database to REST, REST to Database",
"type": "module",
"main": "./src/index.js",
Expand Down Expand Up @@ -70,10 +70,10 @@
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-security": "^3.0.1",
"husky": "^9.1.5",
"is-ci": "^3.0.1",
"mocha": "^10.7.3",
"is-ci": "^4.0.0",
"mocha": "^11.0.0",
"mocha-circleci-reporter": "0.0.3",
"mysql2": "3.11",
"mysql2": "3.12",
"pg": "^8.12.0",
"pg-query-stream": "^4.6.0",
"prettier": "^3.3.3",
Expand Down
6 changes: 4 additions & 2 deletions src/utils/unwrap_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function unwrap_field(expression, allowValue = true) {
// Split out comma variables
while (
(int_m = str.match(
/^(.*)(,\s*(?<suffix>(?<quote>["'])?[\s\w%./-]*\k<quote>))$/i
/^(.*)((,|AS)\s*(?<suffix>(?<quote>["'])?[\s\w%./-]*\k<quote>))$/
))
) {
/*
Expand All @@ -64,7 +64,7 @@ export default function unwrap_field(expression, allowValue = true) {
);
}

str = int_m[1];
str = int_m[1].trim();
suffix = int_m[2] + suffix;
}

Expand Down Expand Up @@ -133,6 +133,8 @@ export default function unwrap_field(expression, allowValue = true) {
};
}



// Is this a valid field
throw new DareError(
DareError.INVALID_REFERENCE,
Expand Down
4 changes: 4 additions & 0 deletions test/specs/unwrap_field.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ describe('utils/unwrap_field', () => {
'IF(field IS NULL, "yes", "no")',
'IF(field IS NOT NULL, "yes", "no")',
'COALESCE(field, "")',
'CAST(field AS SIGNED)',
'CONVERT(field , SIGNED)',
'NULLIF(field, "is null")',
'ROUND(field, 2)',
'ROUND(AVG(field) * 100, 2)',
Expand Down Expand Up @@ -69,6 +71,8 @@ describe('utils/unwrap_field', () => {
'field(',
'IF(field < "string"str, "yes", "no")',
'IF(field = \'string", "yes", "no")',
'IF(field, SELECT 1 FROM table)',
'IF(field, ""), SELECT 1 FROM table)',
'DATE_FORMAT(field, ',
'IF(field <<< 123, "yes", "no")',

Expand Down
Loading