I have trouble with hex numbers in sqlite.
Given a CSV file with numbers, one of them is written as hex (0x1)
❯ cat my.csv
A,B
1,0x1
Import it and check the schema
❯ sqlite3 my.db ".import --csv my.csv somet"
❯ sqlite3 my.db ".schema somet"
CREATE TABLE IF NOT EXISTS "somet"(
"A" TEXT, "B" TEXT);
Now we can select A as a real number (no single quotes), but B not.
❯ sqlite3 my.db "select * from somet where a = 0x1;"
1|0x1
❯ sqlite3 my.db "select * from somet where b = 0x1;"
This is unexpected to me. We can see that SQLite understand hex representation of digits, when filtering on column A, but not on B.
Whe looking at the output for A, we also see that b hasnt been stored as a number, but as a litteral hex string it seems.
So, given sqlite3 understands hex representation, and it will use numbers as "numbers", when importing csv, why is B not imported as number?
hexstr ->> '$'. See my answer to another question for details