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

S4 objects #31

Closed
moodymudskipper opened this issue Aug 31, 2022 · 0 comments · Fixed by #180
Closed

S4 objects #31

moodymudskipper opened this issue Aug 31, 2022 · 0 comments · Fixed by #180
Milestone

Comments

@moodymudskipper
Copy link
Collaborator

Now we assume everything to be S3

con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
x <- glue::glue_sql("a", .con = con)

constructive::construct(x)
#> "a" |>
#>   structure(
#>     class = "SQL" |>
#>       structure(package = "DBI")
#>   )
#> Error in `constructive::construct()`:
#> ! {constructive} couldn't create code that reproduces perfectly the output
#> `original` is an S4 object of class <SQL>
#> `recreated` is an S3 object of class <SQL>, a character vector
#> `original` is an S4 object of class <character>
#> `recreated` is an S3 object of class <SQL>, a character vector
#> `original` is an S4 object of class <vector>
#> `recreated` is an S3 object of class <SQL>, a character vector
#> `original` is an S4 object of class <data.frameRowLabels>
#> `recreated` is an S3 object of class <SQL>, a character vector
#> `original` is an S4 object of class <SuperClassMethod>
#> `recreated` is an S3 object of class <SQL>, a character vector
#> ℹ use `check = FALSE` to ignore this error

dput(x)
#> new("SQL", .Data = "a")

identical(x, new("SQL", .Data = "a"))
#> [1] TRUE

We cannot just fall back on dput though since it might be brittle/verbose on recursive elements.

Then of course, it would be nice to have constructors for main S4 classes, such as DBI::SQL() (in other issues/PRs)

@moodymudskipper moodymudskipper modified the milestones: 0.0.2, 0.2 Oct 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant