Recently I've helped to analyze an issue about guile-dbd-sqlite3. And it's worth to record here.
The reporter used string to define a field named ISBN, however, it became a negative integer when fetched it from DB.
The negative integer suddenly reminded me that I've patched guile-dbd-sqlite3 to use int64 to replace int32 when fetching numbers, which is an older bug. So the reporter may use an older version to trigger this bug.
However, why the string was hiddenly converted to integer?
Because SQLite doesn't have a string storage type. It uses type affinity rules to determine the actual storage type. If a string looks like an integer, SQLite may convert it to an integer due to its NUMERIC affinity.
CREATE TABLE t1 (value STRING);
INSERT INTO t1 VALUES ('978013536077');
SELECT typeof(value) FROM t1;
-- integer
So if you have a type contract in your business logic that you have to ensure the type is a string, you shouldn't set it as a string, but as text.
CREATE TABLE books (isbn TEXT);
INSERT INTO books VALUES ('978013536077');
SELECT typeof(isbn) FROM books;
-- text