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

On the relationship between ResultSet and PreparedStatement #38

Closed
ericsink opened this issue Jul 26, 2015 · 1 comment
Closed

On the relationship between ResultSet and PreparedStatement #38

ericsink opened this issue Jul 26, 2015 · 1 comment
Labels

Comments

@ericsink
Copy link

I've worked myself into an unhappy spot.

Basically, I'm building an API which wants to return a set of rows. The API is not sqlite-specific, but this implementation of it is.

Normally I would just return a struct that wraps the sqlite3_stmt. Something like this:

struct MyRows {
    stmt: PreparedStatement,
}

Currently I am trying to code against the core layer of rust-sqlite3. So in order to return a struct that contains what I need, it has to look kinda like this:

struct MyRows {
    stmt: PreparedStatement,
    rset: ResultSet,
}

But ResultSet is a reference to a PreparedStatement, so Rust isn't going to allow this. (Google for things talking about a struct which contains both data and a reference to it.)

Basically, right now I wish that ResultSet owned its PreparedStatement instead of having a reference to same. Then I would just do this:

struct MyRows {
    rset: ResultSet,
}

But I also realize that if it were designed this way, I would very likely be wishing for the other approach, since I would want the ability to reuse the statement handle after the current result set has been processed.

I think maybe I wish that ResultSet didn't exist at all, which means I would end up with an API more similar to the sqlite3 API to which I am accustomed. But I haven't worked through the implications of that here in Rust land.

I could get around this by coding against the ffi layer instead. And I might end up doing that. But for now I wanted to raise this issue about the design of the core layer.

@dckc
Copy link
Owner

dckc commented Jan 6, 2017

This is now Somebody Else's Problem :)
See #46

@dckc dckc closed this as completed Jan 6, 2017
@dckc dckc added the wontfix label Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants