@@ -1492,7 +1492,8 @@ docdb_query.src_mariadb <- function(src, key, query, ...) {
14921492 fldQ $ selectFields [i ] <- paste0(
14931493 ' (CASE WHEN JSON_EXISTS(`/** key **/`.json, \' $."' ,
14941494 gsub(' [.]' , ' [0].' , fldQ $ selectFields [i ]), ' "\' ) ' ,
1495- ' THEN JSON_EXTRACT(`/** key **/`.json, \' $."' , gsub(' "[.]"' , ' "**."' , fldQ $ selectFields [i ]), ' "\' ) ' ,
1495+ ' THEN JSON_EXTRACT(`/** key **/`.json, \' $."' ,
1496+ gsub(' "[.]"' , ' "**."' , fldQ $ selectFields [i ]), ' "\' ) ' ,
14961497 " ELSE 'null' END) " )
14971498
14981499 }
@@ -1550,19 +1551,21 @@ docdb_query.src_mariadb <- function(src, key, query, ...) {
15501551
15511552 # - - - - - - - - -
15521553
1553- # TODO if query concerns only _id and excludeField
1554- # id empty, then could do query only as SQL
1555-
15561554 # - if query needs jqr, which for src_mariadb is
15571555 # whenever there is a query specified by the
15581556 # user, at any level of depth in the json structure,
15591557 # since queries cannot sufficiently be translated
15601558 # with SQ and JSON functions in MariaDB 12.
15611559 fldQ $ jqrWhere <- character (0L )
15621560 if (length(fldQ $ queryCondition )) fldQ $ jqrWhere <- fldQ $ queryJq
1563- # special case: if no query and only includeFields, no need for jq
1561+ #
1562+ # special case: if no query and only root includeFields, no need for jq
15641563 if (! length(fldQ $ queryCondition ) &&
1565- ! length(fldQ $ excludeFields )) fldQ $ includeFields <- character (0L )
1564+ ! length(fldQ $ excludeFields ) &&
1565+ length(fldQ $ includeFields ) &&
1566+ ! grepl(" ." , fldQ $ includeFields , fixed = TRUE )) fldQ $ includeFields <-
1567+ character (0L )
1568+ #
15661569 # special case: jq needed, _id not in excludeFields,
15671570 # thus _id needs to be in includeFields
15681571 if (length(fldQ $ queryCondition ) &&
0 commit comments