From: Tomasz Marciniak Date: Tue, 5 Jan 2016 09:29:14 +0000 (+0100) Subject: [DataControl] Added sort mode to select() function. X-Git-Tag: submit/tizen/20160114.064425^2~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2fac956aa75584bd8d557c64072fd64c2ab983b1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [DataControl] Added sort mode to select() function. [Verification] Code compiles. Data is sorted regardring to passed order mode. Change-Id: Idbe925600f6f0065011a088e12ee2ddf079b14f0 Signed-off-by: Tomasz Marciniak --- diff --git a/src/datacontrol/datacontrol_api.js b/src/datacontrol/datacontrol_api.js index d30d0f55..98b75595 100755 --- a/src/datacontrol/datacontrol_api.js +++ b/src/datacontrol/datacontrol_api.js @@ -243,7 +243,8 @@ SQLDataControlConsumer.prototype.select = function(reqId, columns, where, succes {'name': 'successCallback', 'type': types_.FUNCTION}, {'name': 'errorCallback', 'type': types_.FUNCTION, optional: true, nullable: true}, {'name': 'page', 'type': types_.LONG, optional: true}, - {'name': 'maxNumberPerPage', 'type': types_.LONG, optional: true} + {'name': 'maxNumberPerPage', 'type': types_.LONG, optional: true}, + {'name': 'order', 'type': types_.STRING, optional: true, nullable: true} ]); var nativeParam = { @@ -259,6 +260,10 @@ SQLDataControlConsumer.prototype.select = function(reqId, columns, where, succes if (args['maxNumberPerPage']) { nativeParam['maxNumberPerPage'] = args.maxNumberPerPage; } + if (args['order']) { + nativeParam['order'] = args.order; + } + try { var syncResult = callNativeWithCallback('SQLDataControlConsumer_select', nativeParam, function(result) { diff --git a/src/datacontrol/datacontrol_instance.cc b/src/datacontrol/datacontrol_instance.cc index dc9e6c85..8e6c258e 100755 --- a/src/datacontrol/datacontrol_instance.cc +++ b/src/datacontrol/datacontrol_instance.cc @@ -743,8 +743,13 @@ void DatacontrolInstance::SQLDataControlConsumerSelect( static_cast(args.get("maxNumberPerPage").get()); } + char* order = nullptr; + if (args.contains("order")) { + order = const_cast(args.get("order").get().c_str()); + } + int result = RunSQLDataControlJob(providerId, dataId, callbackId, reqId, - [&columns, &where, page, maxNumberPerPage]( + [&columns, &where, order, page, maxNumberPerPage]( data_control_h& handle, int *requestId) -> int { LoggerD("Enter"); @@ -756,11 +761,11 @@ void DatacontrolInstance::SQLDataControlConsumerSelect( if (page > 0 && maxNumberPerPage > 0) { return ::data_control_sql_select_with_page(handle, cColumns, columnCount, where.c_str(), - "1 ASC", page, + order, page, maxNumberPerPage, requestId); } else { return ::data_control_sql_select(handle, cColumns, columnCount, - where.c_str(), "1 ASC", requestId); + where.c_str(), order, requestId); } });