2
I was testing and seeing what happens if android create a database with wrong input values.
For example, if I unintentionally typed NOOT instead of NOT or INTEGET instead of INTEGER, I expected SQL to point out a return error saying that the SQL keywords were incorrect. Or at least that the entry is invalid.
But that’s not what happens. Look at this snippet:
sqlite> CREATE TABLE asd (_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, breed TEXT NOT NULL, gender INTEGET NOT NULL DEFAULT 0, weight INTEGER NOT NULL DEFAULT 0);
sqlite> .schema asd
CREATE TABLE asd (_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, breed TEXT NOT NULL, gender INTEGET NOT NULL DEFAULT 0, weight INTEGER NOT NULL DEFAULT 0);
sqlite>
See that gender I purposely entered the data type as INTEGET instead of INTEGER and it seems SQL accepted.
Another example:
CREATE TABLE qwe (_id INTEGET PRIMARY KEY);
sqlite> INSERT INTO qwe (_ID) VALUES (0);
sqlite> .header on
sqlite> .mode column
sqlite> SELECT * FROM qwe;
_id
----------
0
sqlite>
See that again, instead of using INTEGER I put INTEGET and SQL does not report error. He adds the information, even though in my view, a kind of invalid data.
My question is, if SQL processes error entries, how do I check if my database is valid when creating applications?
In Sqlite you can create non-ctiped columns, including. Integer values are treated especially in the primary key, if it is
autoincrement
if I’m not mistaken.– Jefferson Quesado