From 5388b357ac0d2a5bfdb15d3af9229929574d7fa0 Mon Sep 17 00:00:00 2001 From: Geert Josten Date: Wed, 10 Jan 2018 16:06:15 +0100 Subject: [PATCH] Fixed #821: allow executing sjs queries --- deploy/lib/MLClient.rb | 1 + deploy/lib/server_config.rb | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/deploy/lib/MLClient.rb b/deploy/lib/MLClient.rb index e4ade251..736c8443 100644 --- a/deploy/lib/MLClient.rb +++ b/deploy/lib/MLClient.rb @@ -110,6 +110,7 @@ def go(url, verb, headers = nil, params = nil, body = nil, xcc = false) end request_params[:request].use_xcc(xcc) + logger.debug(params) response = get_http.request request_params response.value response diff --git a/deploy/lib/server_config.rb b/deploy/lib/server_config.rb index 3bec2bcc..e67c8998 100644 --- a/deploy/lib/server_config.rb +++ b/deploy/lib/server_config.rb @@ -2652,9 +2652,9 @@ def execute_query_8(query, properties = {}) # If app_name is specified, wrap the eval in an xdmp:eval to create an eval context # that matches that of the selected app-server if properties[:app_name] != nil + eval_type = "javascript-" if properties[:javascript] != nil params[:xquery] = %Q{ xquery version "1.0-ml"; - (: derived from qconsole-amped.xqy :) declare function local:eval-options( $server-id as xs:unsignedLong @@ -2673,29 +2673,22 @@ def execute_query_8(query, properties = {}) { if ($database-id eq xdmp:database()) then () else element database { $database-id }, - if ($modules-id eq xdmp:modules-database()) then () else element modules { $modules-id }, - if ($collation eq default-collation()) then () else element default-collation { $collation }, - if (empty($default-coordinate-system)) then () else element default-coordinate-system { $default-coordinate-system }, - if ($xquery-version eq xdmp:xquery-version()) then () else element default-xquery-version { $xquery-version }, - (: we should always have a root path, but better safe than sorry :) if (empty($modules-root) or $modules-root eq xdmp:modules-root()) then () else element root { $modules-root }, - element isolation { "different-transaction" } } }; - let $query := - return xdmp:eval( + return xdmp:#{eval_type}eval( string($query), (), local:eval-options(xdmp:server("#{properties[:app_name]}")) @@ -2703,7 +2696,11 @@ def execute_query_8(query, properties = {}) } else # No app_name, just run the straight query - params[:xquery] = query + if properties[:javascript] != nil + params[:javascript] = query + else + params[:xquery] = query + end # Pass through selected database if specified, otherwise run against App-Services if properties[:db_name] != nil