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

Handle con object differently #2

Open
nbenn opened this issue Oct 25, 2017 · 2 comments
Open

Handle con object differently #2

nbenn opened this issue Oct 25, 2017 · 2 comments

Comments

@nbenn
Copy link
Owner

nbenn commented Oct 25, 2017

I also don't like the way that the default connection is defined/established, but I think that's fairly easy to fix (although it does have broader implications for the API) DBI/issues#74

@hadley I guess you don't like how I save the con object to the sqlr:::config env and subsequently get it from there (@krlmlr also didn't like this). Do you have any suggestions? Do you think it would make sense to wrap the query in an R6 class (inspired by dbplyr)?

@hadley
Copy link

hadley commented Oct 25, 2017

If the purpose of sqlr is SQL generation, and you imagine it being primarily used via other packages (e.g. dplyr or DBI), I think it would be better to rip this out altogether and require the user to always provide a connection.

@nbenn
Copy link
Owner Author

nbenn commented Oct 25, 2017

The reason for what I did is that currently the definition of a table is for example:

tbl_spec(name = "name",
         cols = col_spec(name = "id",
                         type = col_int(unsigned = TRUE),
                         nullable = FALSE,
                         auto_increment = TRUE),
         engine = "InnoDB")

At every level I need the con object. In order not to manually pass it along, one thing I have been looking into is: e.g. in col_spec() to capture type with rlang::enquo and using con passed to col_spec to rlang::lang_modify the call to col_int (cf. here)

Do you think such an approach makes more sense?

I will have a closer look at dbplyr. Maybe I can come up with something less clumsy. Thanks for your inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants