Comments (2)
Not related to rusqlite:
You should try this on https://sqlite.org/fiddle/index.html:
sqlite> CREATE TABLE producer (producer_id integer, producer_label string NOT NULL, PRIMARY KEY(producer_id));
sqlite> INSERT INTO producer VALUES (1, 'Lisa'), (2, '1234');
sqlite> SELECT *, typeof(producer_label) FROM producer;
1|Lisa|text
2|1234|integer
To understand why the last row has an integer
type,
First read typeof
documentation: https://sqlite.org/lang_corefunc.html#typeof
Then you should read this page:
https://sqlite.org/datatype3.html#determination_of_column_affinity
where you can find that currently, string
type has affinity NUMERIC
:
If the declared type of the column contains any of the strings "CHAR", "CLOB", or "TEXT" then that column has TEXT affinity. Notice that the type VARCHAR contains the string "CHAR" and is thus assigned TEXT affinity.
Otherwise, the affinity is NUMERIC.
So you must fix the column type here:
producer_label string NOT NULL,
You may also use STRICT mode for your table if you are not comfortable with SQLite dynamic typing.
from rusqlite.
Thanks for this very detailed answer ! and for the documentation pointers.
It is much more clear to me.
I will fix my DB definition.
Thanks.
from rusqlite.
Related Issues (20)
- Trait for abstracting over `Connection`/`Transaction`? HOT 3
- SqlInputError { error: Error { code: Unknown, extended_code: 1 }, msg: "unrecognized token: \"{\"" HOT 1
- Release 0.31.0 with SQLite 3.45? HOT 2
- wasm32-wasi target fails on Apple M3
- How to get "returning *" from insert HOT 3
- Stale Connection Handler on Multi-Threaded Situation HOT 2
- sqlite3_snapshot iteration HOT 2
- Creating `Value::Blob` without necessarily allocating heap HOT 5
- Using rusqlite::vtab::VTabConnection::handle() HOT 4
- Add bindings for `sqlite3_trace_v2` API HOT 4
- iOS Linker Warning: SQLite was build for newer version than being linked HOT 2
- the first query is failure due to below error HOT 1
- Segmentation fault when writing encrypted database with vendored SQLCipher and OpenSSL on OpenBSD
- Adding feature `array` seems to cause a compile failure HOT 1
- rusqlite ignoring sqlite3_hard_heap_limit64 (and soft limit), and sqlite3_memory_used always returns 0 HOT 11
- Allow provinding own sqlite3.c HOT 2
- libsqlite3-sys build broken for visionos with feature `bundled` HOT 1
- New release with sqlite 3.46 HOT 5
- wasm32-wasip1-threads, passing `atomics` and `bulk-memory` option
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 rusqlite.