-
-
Notifications
You must be signed in to change notification settings - Fork 879
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
Add 'rows affected' output when using sql engine #2051
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -555,8 +555,8 @@ eng_sql = function(options) { | |||||||||||||||||||||
|
||||||||||||||||||||||
data = tryCatch({ | ||||||||||||||||||||||
if (is_sql_update_query(query)) { | ||||||||||||||||||||||
DBI::dbExecute(conn, query) | ||||||||||||||||||||||
NULL | ||||||||||||||||||||||
data = DBI::dbExecute(conn, query) | ||||||||||||||||||||||
data | ||||||||||||||||||||||
} else if (is.null(varname) && max.print > 0) { | ||||||||||||||||||||||
# execute query -- when we are printing with an enforced max.print we | ||||||||||||||||||||||
# use dbFetch so as to only pull down the required number of records | ||||||||||||||||||||||
|
@@ -633,6 +633,11 @@ eng_sql = function(options) { | |||||||||||||||||||||
|
||||||||||||||||||||||
} else print(display_data) # fallback to standard print | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
if (is.numeric(data) && length(data) == 1 && is.null(varname)) { | ||||||||||||||||||||||
options$results = 'asis' | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really know if we want to force I understand why it makes sens to have it as markdown text in the output document, but it may not please everyone who would prefer to have it code output. I don't really know but usually users have control over how the output is show. 🤔 @yihui what do you think ? |
||||||||||||||||||||||
# format = "fg" instead of "d". Row counts on DB may be greater than integer max value | ||||||||||||||||||||||
output = paste0("Number of affected rows: ", formatC(data, format = "fg", big.mark = ',')) | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition to previous comment, just wondering about internationalization:
Maybe we could / should make at least all that configurable ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree! What I did was trying to keep it similar to how the caption is formatted (line 614 on the same file)
but you are right that in that case, the user has options to configure the output |
||||||||||||||||||||||
} | ||||||||||||||||||||||
Comment on lines
+636
to
+640
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To follow the style of the previous output assignment, and making it more clear about the different output possible, I would use a
Suggested change
|
||||||||||||||||||||||
if (options$results == 'hide') output = NULL | ||||||||||||||||||||||
|
||||||||||||||||||||||
# assign varname if requested | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so you know, this should be under the last header 1 you see.
1.35 is the next version so this should be moved under.
I'll do it before merging.