8000 aql char length null returns now 0 by baslr · Pull Request #2973 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

aql char length null returns now 0 #2973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 8, 2017
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
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
devel
-----

* AQL CHAR_LENGTH(null) returns now 0. Since AQL TO_STRING(null) is '' (string of length 0)

* ui: now supports single js file upload for foxx services in addition to zip files

* fixed a multi-threading issue in the agency when callElection was called
Expand Down
2 changes: 1 addition & 1 deletion Documentation/Books/AQL/Functions/String.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Return the number of characters in *value* (not byte length).
|Array / Object|number of unicode characters from the resulting stringification|
|true| 4 |
|false| 5 |
|null| 4 |
|null| 0 |

### CONCAT()

Expand Down
2 changes: 1 addition & 1 deletion arangod/Aql/Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ AqlValue Functions::CharLength(arangodb::aql::Query* query,
length = buffer->length();

} else if (value.isNull(true)) {
length = 4;
length = 0;

} else if (value.isBoolean()) {
if (value.toBoolean()) {
Expand Down
4 changes: 0 additions & 4 deletions js/server/modules/@arangodb/aql.js
Original file line number Diff line number Diff line change
Expand Up @@ -2037,10 +2037,6 @@ function AQL_CONCAT_SEPARATOR () {
function AQL_CHAR_LENGTH (value) {
'use strict';

if (value === undefined || value === null) {
return 4;
}

// https://mathiasbynens.be/notes/javascript-unicode
return [...AQL_TO_STRING(value)].length;
}
Expand Down
4 changes: 2 additions & 2 deletions js/server/tests/aql/aql-functions-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -1635,8 +1635,8 @@ function ahuacatlStringFunctionsTestSuite () {
assertEqual([ 13 ], getQueryResults("RETURN NOOPT(CHAR_LENGTH('the quick fox'))"));
assertEqual([ 13 ], getQueryResults("RETURN NOOPT(V8(CHAR_LENGTH('the quick fox')))"));

assertEqual([ 4 ], getQueryResults("RETURN NOOPT(CHAR_LENGTH(null))"));
assertEqual([ 4 ], getQueryResults("RETURN NOOPT(V8(CHAR_LENGTH(null)))"));
assertEqual([ 0 ], getQueryResults("RETURN NOOPT(CHAR_LENGTH(null))"));
assertEqual([ 0 ], getQueryResults("RETURN NOOPT(V8(CHAR_LENGTH(null)))"));

assertEqual([ 4 ], getQueryResults("RETURN NOOPT(CHAR_LENGTH(true))"));
assertEqual([ 4 ], getQueryResults("RETURN NOOPT(V8(CHAR_LENGTH(true)))"));
Expand Down
0