Skip to content

Commit 707cbd1

Browse files
committed
Handle null query binding value
1 parent 0e31a06 commit 707cbd1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ class Client_AuroraDataMySQL extends Client_MySQL { // eslint-disable-line camel
159159
);
160160
}
161161

162+
if (value === null) {
163+
return null;
164+
}
165+
162166
if (Buffer.isBuffer(value) || ArrayBuffer.isView(value)) {
163167
return {
164168
name,

tests/test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ describe('Query statement tests', () => {
163163
null: null,
164164
binary: Buffer.from([1, 2, 3]),
165165
date: new Date('2020-01-01')
166-
});
166+
}).whereRaw('null2 = ?', [null]);
167167

168168
expect(mockExecuteStatement).toHaveBeenCalledTimes(1);
169169
expect(mockExecuteStatement).toHaveBeenCalledWith({
170170
resourceArn: constants.AURORA_CLUSTER_ARN,
171171
secretArn: constants.SECRET_ARN,
172172
database: constants.DATABASE,
173-
sql: 'select * from `foo` where `boolean` = :0 and `int` = :1 and `float` = :2 and `text` = :3 and `null` is null and `binary` = :4 and `date` = :5',
173+
sql: 'select * from `foo` where `boolean` = :0 and `int` = :1 and `float` = :2 and `text` = :3 and `null` is null and `binary` = :4 and `date` = :5 and null2 = :6',
174174
parameters: [
175175
{
176176
name: '0',
@@ -209,7 +209,8 @@ describe('Query statement tests', () => {
209209
value: {
210210
stringValue: '2020-01-01 00:00:00.000'
211211
}
212-
}
212+
},
213+
null
213214
],
214215
includeResultMetadata: true
215216
});

0 commit comments

Comments
 (0)