Use a type object for type casting behavior on SQLite3

Note: I'm not sure we actually need to be logging when this happens.
This code would be a fair bit cleaner if we didn't need to log it.
Merge pull request #16003 from sgrif/sg-refactor-sqlite3-strings

Use a type object for type casting behavior on SQLite3