Comments (2)
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.
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)
- Please include a LICENSE file in each crate you publish
- GROUP BY with aggregate functions gives strange types HOT 2
- Mariadb connection from pool fails HOT 1
- DB ERROR: pool timed out while waiting for an open connection in thread HOT 2
- Test cleanup should use the same pool & connection options as the test itself and not DATABASE_URL unconditionally HOT 3
- Cannot provide a custom default value for `#[sqlx(default = "..")]` HOT 1
- QueryBuilder::push_bind doesn't work within JSOB query HOT 1
- to_url_lossy() does not generate a valid postgres URL for ssl-mode HOT 1
- `ParseError(TooLong)` when using macro `sqlx::query_as!` to map NaiveDateTime
- Support SSL in postgres without an upgrade request HOT 4
- Bug: Set statement does't support non-constant expr HOT 1
- `#[sqlx::test]` manage the full lifecycle of the test DB (inside a container) HOT 3
- Can not disable Prepared statement in SqlX
- sqlx::test error message incorrectly implies `migrate` feature is disabled HOT 2
- Cross compile failed with OpenHarmony HOT 1
- Question around sqlx::test and MySql HOT 1
- SQLx fails to infer subquery is not nullable and fails to infer type (with SQLite)
- Feature SQLite fails to build on aarch64
- The Postgres type `Bool` should be mapped to the `Any` type `Bool`
- If I insert an `Option<sqlx::types::Json<Struct>>` sqlx writes the text `null` in DB instead of mark that field as `NULL` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlx.