Git Product home page Git Product logo

Comments (10)

gwenn avatar gwenn commented on May 23, 2024

See gwenn@d8d220e

from rusqlite.

jgallagher avatar jgallagher commented on May 23, 2024

Ick. Great catch. I would like for that to not compile, but AFAICT an Iterator impl can't return references to itself from next, which is what I believe we'd need.

Options:

  • Leave it as is and document it. This is related to the already-documented issue that if you call next twice, you'll get errors trying to access the first row which is now stale.
  • Don't reset when Rows is dropped, and go back to reset_if_needed. We can keep the reset on error / SQLITE_DONE to still reset ASAP when possible.

Thoughts? Other options?

from rusqlite.

jgallagher avatar jgallagher commented on May 23, 2024

Another option is to deprecate/remove query. We already recommend people use query_map and/or query_and_then instead, neither of which expose this problem.

from rusqlite.

gwenn avatar gwenn commented on May 23, 2024

Could you please confirm that the problem is related to streaming iterators ?

from rusqlite.

jgallagher avatar jgallagher commented on May 23, 2024

Yes, that's the exact problem.

from rusqlite.

jgallagher avatar jgallagher commented on May 23, 2024

I think #153 is a decent compromise. Keep Rows but change next() to return a Row<'a, 'stmt> where 'a is tied to the vending Rows handle. This means Rows no longer implements Iterator, but it's at least still usable, and this change doesn't affect anyone using query_map/query_and_then.

from rusqlite.

gwenn avatar gwenn commented on May 23, 2024

This change breaks the current API (when users iterate on Rows), no ?

from rusqlite.

jgallagher avatar jgallagher commented on May 23, 2024

It does, yeah.

We're still in 0.x versioning, so breaking changes are allowed between minor versions. I was okay with runtime checks to let Rows implement Iterator when the only thing that could go wrong was if you used a row after calling next() again, but adding more runtime checks (or disabling resetting the statement when a Rows is dropped) seems bad.

from rusqlite.

gwenn avatar gwenn commented on May 23, 2024

Ok.

from rusqlite.

jgallagher avatar jgallagher commented on May 23, 2024

Closed with #153.

from rusqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.