Skip to content

Commit

Permalink
correct delimiter processing for listfields
Browse files Browse the repository at this point in the history
  • Loading branch information
rfhb committed Mar 3, 2024
1 parent b2b4541 commit 688682b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions R/query.R
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ docdb_query.src_sqlite <- function(src, key, query, ...) {
n = -1L)[["flds"]]

# remove "$.", array elements "$.item[0]"
fields <- unique(stringi::stri_replace_all_regex(fields, "\\$[.]?|\\[[-#0-9]+\\]", ""))
fields <- unique(stringi::stri_replace_all_regex(
fields, "\"|\\$[.]?|\\[[-#0-9]+\\]", ""))
fields <- sort(fields[fields != ""])

# return field names
Expand Down Expand Up @@ -841,7 +842,7 @@ docdb_query.src_sqlite <- function(src, key, query, ...) {
# process
fields <- unique(processDbGetQuery(
getData = 'paste0(DBI::dbGetQuery(conn = src$con,
statement = statement, n = n)[["json"]], "")',
statement = statement, n = n)[["json"]], "")',
jqrWhere = fldQ$jqrWhere)[["out"]])

} else {
Expand All @@ -862,11 +863,12 @@ docdb_query.src_sqlite <- function(src, key, query, ...) {
statement = statement,
n = -1L)[["flds"]]

# remove "$.", array elements "$.item[0]"
fields <- unique(stringi::stri_replace_all_regex(fields, "\\$[.]?|\\[[-#0-9]+\\]", ""))

}

# remove "$.", array elements "$.item[0]"
fields <- unique(stringi::stri_replace_all_regex(
fields, "\"|\\$[.]?|\\[[-#0-9]+\\]", ""))

# finalise
fields <- fields[fields != "" & fields != "_id"]

Expand Down

0 comments on commit 688682b

Please sign in to comment.