Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RNotebooks - Add error=TRUE support for sql chunks #1208

Closed
colearendt opened this issue Nov 22, 2017 · 4 comments · Fixed by yihui/knitr#1910
Closed

RNotebooks - Add error=TRUE support for sql chunks #1208

colearendt opened this issue Nov 22, 2017 · 4 comments · Fixed by yihui/knitr#1910

Comments

@colearendt
Copy link

I think documentation about what chunk options are supported for non-R chunks in R Notebooks would be helpful, in general, but I am thinking about the sql chunk in particular. I was unable to find such documentation for R notebooks. Maybe the (very thorough) RMarkdown reference could include such a note?

Below is an example where the error=TRUE option is honored by R, but not by sql.

Of course, maybe this is just a bug request if the intent is for all options to be universally supported across all engines - but it seems like that might be a tall order!

---
title: "Error Not Honored"
output:
  html_document
---
```{r, message=FALSE}
knitr::opts_chunk$set(error = TRUE)

library(DBI)

con <- dbConnect(RSQLite::SQLite(), ":memory:")

```


```{r}
stop('error message that I want to print')
```


```{sql, connection=con}
select test;
```
@yihui
Copy link
Member

yihui commented Nov 22, 2017

The error option should be respected by all engines. I guess the support for sql chunks is currently missing.

@colearendt colearendt changed the title RNotebooks - Document Engine-Available Chunk Options RNotebooks - Add error=TRUE support for sql chunks Nov 22, 2017
@colearendt
Copy link
Author

Thanks! I changed the title accordingly, as I have tested no other options that I expected to work and didn't.

cderv added a commit to yihui/knitr that referenced this issue Oct 22, 2020
cderv added a commit to cderv/knitr-examples that referenced this issue Oct 22, 2020
yihui pushed a commit to yihui/knitr that referenced this issue Oct 22, 2020
yihui pushed a commit to yihui/knitr-examples that referenced this issue Oct 22, 2020
@cderv
Copy link
Collaborator

cderv commented Oct 22, 2020

Thanks for the long-time-ago report @colearendt ! Better late than never ! 😅

This should work ok now. Tested with

 ---
title: "Error Not Honored"
output: html_document
---

```{r, message=FALSE}
knitr::opts_chunk$set(error = TRUE)
library(DBI)
con <- dbConnect(RSQLite::SQLite(), ":memory:")
```

```{r}
stop('error message that I want to print')
```

```{r}
dbWriteTable(con, "mtcars", mtcars)
```

```{sql, connection=con}
SELECT * FROM mtcars WHERE cyl = 4
```

```{sql, connection=con}
DROP TABLE mtcars
```

```{r}
dbListTables(con)
```

```{sql, connection=con}
select test;
```

clrpackages pushed a commit to clearlinux-pkgs/R-knitr that referenced this issue Jan 28, 2021
Christophe Dervieux (20):
      fix #1893: make collapse = TRUE work when attr.source or classe.source is provided (#1902)
      fix rstudio/rmarkdown#1208: capture error in eng_sql() if the chunk option error = TRUE (#1910)
      fix #1912: stop early if RWordPress is not installed, and also warn against using this knit2wp() function (#1913)
      add lock bot (#1917)
      Run lock bot every week now
      Rename lock bot GHA workflow
      Use github actions instead of travis (#1920)
      Use linux on test-coverage workflow to avoid errors due to no binaries available in CRAN for macos
      do not check for newer source only-version
      forgot to remove travis
      do not error in R CMD CHECK if one suggested package is not installed
      Improve documentation following discussion in rstudio/rmarkdown#1954
      wrong place for _R_CHECK_FORCE_SUGGESTS_ env var.
      merge coverage in R-CMD-CHECK
      Workflow was renamed
      no more test coverage workflow
      close #1326: vectorize include_app() and include_url() (#1948)
      Add a fig.alt chunk option to provide alternative text different than fig.cap (#1900)
      the `table.attr` argument in `kable(.., format = 'html')` can take the value from the global option `knitr.table.html.attr` now (#1922)
      export and document pandoc_to() and pandoc_from() (#1951)

David C Hall (1):
      knit_exit() will exit the whole knitting process, even when called from a child document (#1810)

Luís Fonseca (1):
      close #1767: allows for a custom label for a table generated by kable() (#1890)

Sam Thompson (1):
      Extended combine_words with support for exclusion of the Oxford comma (#1946)

Yihui Xie (29):
      it seems I don't really need to import methods
      put methods back in Imports but don't import it in NAMESPACE
      just use xfun::read_utf8(), in case users have set options(encodng = ...), which I strongly recommend against
      install libharfbuzz-dev and libfribidi-dev for the new textshaping package (although I have no idea what it is), which is required by ragg, which is suggested by knitr
      TODO: remove these functions in knitr, and import them from xfun in the future
      remove some internal functions from knitr and import them from xfun 0.19 instead
      pandoc-citeproc has gone since Pandoc 2.11, so don't check for its existence any more
      also get rid of this hack for RStudio, and actually check for availability of Pandoc
      will asymptote work after installing dvisvgm?
      also install ghostscript
      fewer instances of ::: (highr:::group_src has been moved to xfun::split_source, and knit_code has been exported)
      suggest https://yihui.r-universe.dev instead for installing the dev version
      replace the download stats with CRAN badge instead
      generalize png_available() to dev_available() to test if a device is available
      close #1947: allow the graphical device to fall back to other operational devices when options(knitr.device.fallback = TRUE), which is the default for R CMD check
      move the code to select the graphical device out of save_plot(), and put it into dev_get() instead (renamed check_dev() to dev_get())
      use xfun helper functions
      63d153bf439dc7df73071bbf3d7d1ed0937e3eb7 changed the logic: we must make sure tikzDevice is loadable before we check other conditions
      make sure dpi is not NULL or NA
      initialize opts_current to the values of opts_chunk
      units of devices are always in inches, so we need to use smaller width and height to test if a device is available (close #1949)
      close #1925: delete the instructions on R CMD INSTALL/build; https://yihui.r-universe.dev is much more convenient and even has binaries
      fix #1945: instead of removing the YAML metadata from child document, replace it with blank lines, so the line numbers in error messages will not be affected
      close #1937: disable the table label with kable(label = NA)
      opts_current$get('label') is NULL when not running inside code chunks
      add an argument `fully` to knit_exit() to make it possible to exit the child document only (#1810)
      bookdown still uses :::is_abs_path()
      the bottomless hell of URL checking...
      CRAN release v1.31

atusy (1):
      Let collapse work even if class.* or attr.* are provided (closes #1906) (#1909)

christophe dervieux (5):
      Add a skip for NOT_CRAN
      Use full length commit sha to pin the action
      Change workflow name to try having the correct UI in Github Action pane
      Correct name so it avoids confusion in the UI
      Revert "Add a skip for NOT_CRAN"

dmurdoch (1):
      When counting plots, html_screenshots are missed. (#1908)
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants