Giter VIP home page Giter VIP logo

Comments (2)

abonander avatar abonander commented on June 18, 2024

This is actually a well defined type conversion according to SQLite (scroll down for the conversion table): https://www.sqlite.org/c3ref/column_blob.html

Normally, we don't explicitly implement type conversions, because that should be handled in the database itself. For the MySQL or Postgres driver, this would be an error. However, since the SQLite API functions implement this conversion internally, it's actually more work for us to prevent the conversion, so it was just omitted.

If you use the checked Row::get() or ::try_get() methods, this will panic or error, respectively, but the FromRow derive uses ::try_get_unchecked() to avoid an extra branch on decoding the value. This also allows conversion between types that are binary-compatible but not considered compatible in the API.

I'm not particularly married to any of these decisions, but there's a high likelihood that there are people out there who depend on the current behavior.

from sqlx.

msberk avatar msberk commented on June 18, 2024

Oof, fair enough. I didn’t know this was inherent behavior of SQLite, and I think it really caught me off guard since the behavior is a significant departure from how most other Rust deserializations I have used work and figured since the SQLx macros disallowed the mismatch it was an unintended inconsistency.

I’m not going to fight to have this changed though I might ask that the docs are updated to specifically note that FromRow derivations when using SQLite will not Err if a NULL value on a required field is encountered. That would be helpful, I got spun around on this for a few hours.

Thanks for explaining what was going on so well.

from sqlx.

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.