SQLite Forum

Integer becomes blob
It is quite an ask to suggest others should go paw through that code to see where you messed up.  You need to reduce the problem yourself, until you have isolated a small subset of the operations invoked by all that code, where the subset's input-to-output transformation escapes your understanding. This is basic troubleshooting or debugging.  If you intend to write much code, (and it appears you do), you need to learn the divide-and-conquer strategy.  Running the code under a debugger, where you can examine variable values going into an operation and the values coming out of it, is one, excellent way to do this.