Skip to content

Commit

Permalink
Merge pull request #175 from natverse/fix/better-error-missing-field
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferis authored Jul 25, 2024
2 parents 5ca4f7b + 93c7f45 commit 1117fdc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions R/name.R
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ neuprint_search <- function(search, field = "name", fixed=FALSE, exact=NULL,
where=search
} else {
fieldtype=neuprint_typeof(field, type = 'neo4j', conn=conn, dataset = dataset)
if(length(fieldtype)==0) {
stop("Sorry, the `", field,
"` field doesn't exist in neuprint database (which is case-sensitive)!")
}
if(fieldtype=="STRING") {
search=glue('\\"{search}\\"')
operator=ifelse(fixed, ifelse(exact, "=", "CONTAINS"), "=~")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-ids.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ test_that("neuprint_ids works", {
expect_true(all(neuprint_ids("!MBON01") %in% mbons))
expect_equal(neuprint_ids("/MBON[0-9]+"),
as.character(neuprint_search("type:MBON[0-9]+", meta=FALSE)))

expect_error(neuprint_ids('rhubarb:.+'), "rhubarb.*doesn't.*exist")
})

0 comments on commit 1117fdc

Please sign in to comment.