Closed jimmyg3g closed 4 years ago
Hi @jimmyg3g, thanks for reporting this!
This error was happening because of a problem in the queryparser package, which tidyquery depends on, and which I also maintain.
I believe I have now resolved this in the development version of queryparser on GitHub.
I have also made a change to queryparser that silences the numerous truncating string with embedded nuls
warnings.
Please reinstall the development version of queryparser from GitHub and let me know if it works for you:
remotes::install_github("ianmcook/queryparser")
Yes, it works for me, thanks!
The third example on this reprex is throwing an error:
library(tidyverse)
library(tidyquery)
mtcars_tibble <- mtcars %>% rownames_to_column(var = 'brand and model') %>%
as_tibble()
query('SELECT mt.`brand and model` FROM mtcars_tibble as mt LIMIT 1')
#> # A tibble: 1 x 1
#> `brand and model`
#> <chr>
#> 1 Mazda RX4
query("SELECT SUBSTRING_INDEX(`brand and model`, ' ', 1) as brand from mtcars_tibble LIMIT 1")
#> # A tibble: 1 x 1
#> brand
#> <chr>
#> 1 Mazda
query("SELECT SUBSTRING_INDEX(mt.`brand and model`, ' ', 1) as brand from mtcars_tibble as mt LIMIT 1")
#> Error in str2lang(expr_out): <text>:1:20: unexpected symbol
#> 1: SUBSTRING_INDEX(mt.`brand and model`
#> ^
Created on 2020-08-18 by the reprex package (v0.3.0.9001)
Oops, didn't catch that case. I just fixed it. The version of queryparser on GitHub should solve this for you.
That did the trick, thanks!
I inherited a bunch of SQL with spaces in field names. Does tidyquery support field names that have spaces like
brand and model
in this reprex:Created on 2020-08-11 by the reprex package (v0.3.0.9001)