Skip to main content

Type conversion

Review converting from JavaScript to SQL types.

When working in JavaScript, types must properly map to the protocol's requirements. Both SQLite and Tableland's constrained version of it have some types that don't perfectly align. Additionally, any object that implements a toSQL method can also be used.

NumberINTEGERTableland supports 64-bit signed INTEGERs internally, and we mostly support BigInt on the client side. These values will be converted to INTEGERs. Note that Javascript integer's are safe up to MAX_SAFE_INTEGER (2531)(2^{53} - 1).
BooleansINTEGERBooleans will be turned into integers where 1 is true and 0 is false.
DateINTEGERDates are converted to their UNIX timestamp representation.
Object or JSONTEXTA plain old JavaScript object (POGO) that can be converted to JSON strings will be converted to JSON and inserted as TEXT.