<commit_before>(:~
 : Query resources.
 :
 : @author <NAME>, BaseX Team 2005-21, BSD License
 :)
module namespace dba = 'dba/databases';

import module namespace util = 'dba/util' at '../../lib/util.xqm';

(:~
 : Runs a query on a document and returns the result as string.
 : @param  $name      name of database
 : @param  $resource  resource
 : @param  $query     query
 : @return result string
 :)
declare
  %rest:POST('{$query}')
  %rest:path('/dba/db-query')
  %rest:query-param('name',     '{$name}')
  %rest:query-param('resource', '{$resource}')
  %rest:single
  %output:method('text')
function dba:db-query(
  $name      as xs:string,
  $resource  as xs:string,
  $query     as xs:string
) as xs:string {
  util:query(if($query) then $query else '.', db:open($name, $resource))
};<commit_msg>Signature resilient to missing query<commit_after>(:~
 : Query resources.
 :
 : @author <NAME>, BaseX Team 2005-21, BSD License
 :)
module namespace dba = 'dba/databases';

import module namespace util = 'dba/util' at '../../lib/util.xqm';

(:~
 : Runs a query on a document and returns the result as string.
 : @param  $name      name of database
 : @param  $resource  resource
 : @param  $query     query
 : @return result string
 :)
declare
  %rest:POST('{$query}')
  %rest:path('/dba/db-query')
  %rest:query-param('name',     '{$name}')
  %rest:query-param('resource', '{$resource}')
  %rest:single
  %output:method('text')
function dba:db-query(
  $name      as xs:string,
  $resource  as xs:string,
  $query     as xs:string?
) as xs:string {
  util:query(if($query) then $query else '.', db:open($name, $resource))
};
{'fraction_non_alphanumeric': 0.17404674046740468, 'fraction_numerical': 0.007380073800738007, 'mean_word_length': 3.7159420289855074, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2368490', 'n_tokens_mistral': 578, 'n_tokens_neox': 557, 'n_words': 154}