From: Bill Erickson Date: Tue, 13 Dec 2011 16:03:23 +0000 (-0500) Subject: json_query boolean function param support X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6349068fe22ff9431fca5ad9f1adadd6a5d0aea6;p=evergreen%2Fmasslnc.git json_query boolean function param support Solves the following problem when passing boolean parameter values to json_query functions using the 'from' construct. E.g. {"from" : ["some_func_name", true]} oils_sql.c:2568 open-ils.cstore: Error quoting key string [(null)] Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index b79c5799a5..e0b545c72f 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -2560,16 +2560,24 @@ static char* searchValueTransform( const jsonObject* array ) { if( func_item->type == JSON_NULL ) { buffer_add( sql_buf, "NULL" ); } else { - char* val = jsonObjectToSimpleString( func_item ); - if( dbi_conn_quote_string( dbhandle, &val )) { - OSRF_BUFFER_ADD( sql_buf, val ); - free( val ); + if( func_item->type == JSON_BOOL ) { + if( jsonBoolIsTrue(func_item) ) { + buffer_add( sql_buf, "TRUE" ); + } else { + buffer_add( sql_buf, "FALSE" ); + } } else { - osrfLogError( OSRF_LOG_MARK, "%s: Error quoting key string [%s]", - modulename, val ); - buffer_free( sql_buf ); - free( val ); - return NULL; + char* val = jsonObjectToSimpleString( func_item ); + if( dbi_conn_quote_string( dbhandle, &val )) { + OSRF_BUFFER_ADD( sql_buf, val ); + free( val ); + } else { + osrfLogError( OSRF_LOG_MARK, + "%s: Error quoting key string [%s]", modulename, val ); + buffer_free( sql_buf ); + free( val ); + return NULL; + } } } }