Skip to content

Commit 7533fdf

Browse files
committed
MLE-15254 : DatabaseClient.eval() returning true when the result is a boolean
1 parent 44a8533 commit 7533fdf

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/server-exec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ function execOutputTransform(headers, data) {
7373
value: data.content
7474
};
7575
case 'boolean':
76+
const booleanValue = (typeof data.content === 'string')?(data.content.toLowerCase() === 'true'):data.content;
7677
return {
7778
format: 'text',
7879
datatype: primitive,
79-
value: Boolean(data.content)
80+
value: Boolean(booleanValue)
8081
};
8182
case 'dateTime':
8283
return {

test-basic/server-exec.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ describe('server-side call', function() {
7575
})
7676
.catch(done);
7777
});
78-
it('should generate a boolean value', function(done) {
78+
it('should generate a boolean value true', function(done) {
7979
db.eval('true;').result(function(values) {
8080
values.length.should.equal(1);
8181
checkValue(values[0], 'text', 'boolean');
@@ -84,6 +84,15 @@ describe('server-side call', function() {
8484
})
8585
.catch(done);
8686
});
87+
it('should generate a boolean value false', function(done) {
88+
db.eval('false;').result(function(values) {
89+
values.length.should.equal(1);
90+
checkValue(values[0], 'text', 'boolean');
91+
values[0].value.should.equal(false);
92+
done();
93+
})
94+
.catch(error => done(error));
95+
});
8796
it('should generate an integer value', function(done) {
8897
db.eval('3;').result(function(values) {
8998
values.length.should.equal(1);

0 commit comments

Comments
 (0)