Skip to content

Commit ab560a7

Browse files
committed
Fixed problem binding string params for procedures
Parameters for stored procedures were being bound as the type of the parameter regardless of the type being passed in. Passing a string containing "150" into a parameter expecting an int should result in the value 150 being passed, but the value was being corrupted. This has been fixed. Change-Id: I3a867549df623bc5c5876e6a9ff178c527ba3451
1 parent 8d96a7c commit ab560a7

File tree

5 files changed

+7
-37
lines changed

5 files changed

+7
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "SQL ANYWHERE",
33
"name": "sqlanywhere",
44
"description": "SQL Anywhere JavaScript Driver.",
5-
"version": "1.0.20",
5+
"version": "1.0.21",
66
"repository": {
77
"url": "https://github.com/sqlanywhere/node-sqlanywhere"
88
},

src/sqlanywhere.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,9 @@ void executeWork( uv_work_t *req )
133133
getErrorMsg( baton->obj->conn, baton->error_msg );
134134
return;
135135
}
136-
137-
if( param.value.type == A_INVALID_TYPE &&
138-
( baton->params[i].value.is_null == NULL ||
139-
!(*(baton->params[i].value.is_null)) ) ) {
140-
param.value.type = baton->params[i].value.type;
141-
}
142-
param.value.buffer = baton->params[i].value.buffer;
143-
param.value.is_address = baton->params[i].value.is_address;
144-
145-
if( param.value.type == A_STRING || param.value.type == A_BINARY ) {
146-
param.value.length = baton->params[i].value.length;
147-
param.value.buffer_size = baton->params[i].value.buffer_size;
148-
}
149-
150-
if( baton->params[i].value.is_null != NULL ) {
151-
param.value.is_null = baton->params[i].value.is_null;
152-
}
153-
136+
137+
memcpy( &param.value, &baton->params[i].value, sizeof( param.value ) );
138+
154139
if( !api.sqlany_bind_param( sqlany_stmt, i, &param ) ) {
155140
baton->err = true;
156141
getErrorMsg( baton->obj->conn, baton->error_msg );

src/sqlanywhere_v0_10.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,7 @@ void executeWork( uv_work_t *req )
126126
return;
127127
}
128128

129-
if( param.value.type == A_INVALID_TYPE &&
130-
( baton->params[i].value.is_null == NULL ||
131-
!(*(baton->params[i].value.is_null)) ) ) {
132-
param.value.type = baton->params[i].value.type;
133-
}
134-
param.value.buffer = baton->params[i].value.buffer;
135-
param.value.is_address = baton->params[i].value.is_address;
136-
137-
if( param.value.type == A_STRING || param.value.type == A_BINARY ) {
138-
param.value.length = baton->params[i].value.length;
139-
param.value.buffer_size = baton->params[i].value.buffer_size;
140-
}
141-
142-
if( baton->params[i].value.is_null != NULL ) {
143-
param.value.is_null = baton->params[i].value.is_null;
144-
}
129+
memcpy( &param.value, &baton->params[i].value, sizeof( param.value ) );
145130

146131
if( !api.sqlany_bind_param( sqlany_stmt, i, &param ) ) {
147132
baton->err = true;

src/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ bool getBindParameters( std::vector<ExecuteData *> &execData,
371371
param.value.buffer_size = sizeof( param_char );
372372

373373
} else if( bind_params->Get(i)->IsNull() ) {
374-
param.value.type = A_VAL32;
374+
param.value.type = A_STRING;
375375
sacapi_bool *is_null = new sacapi_bool;
376376
param.value.is_null = is_null;
377377
ex->addNull( is_null );

src/utils_v0_10.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ bool getBindParameters( std::vector<ExecuteData *> &execData
340340
param.value.buffer_size = sizeof( param_char );
341341

342342
} else if( bind_params->Get(i)->IsNull() ) {
343-
param.value.type = A_VAL32;
343+
param.value.type = A_STRING;
344344
sacapi_bool *is_null = new sacapi_bool;
345345
param.value.is_null = is_null;
346346
ex->addNull( is_null );

0 commit comments

Comments
 (0)