sql-switch - v1.0.1
    Preparing search index...

    Class InvalidValueError

    Thrown when a value (or a key) can't be stored the same way by both engines.

    Covers the payloads JSON.stringify is happy to mangle — undefined, NaN, Infinity — plus NUL (\u0000), which SQLite keeps as TEXT and Postgres JSONB rejects outright. Also the older two: circular references & BigInt.

    Extends TypeError on purpose => set() has always thrown a TypeError for a value it can't serialize, so anything catching that keeps working, and new code gets err.code & instanceof InvalidValueError to branch on.

    try {
    await db.schema('economy').table('balances').key(userId).set({ coins: total });
    } catch (err) {
    // total came out NaN => the write was refused instead of storing null
    if (err instanceof InvalidValueError) logger.warn(err.message);
    }

    Hierarchy

    • TypeError
      • InvalidValueError
    Index
    code: "INVALID_VALUE" = ...