#Database query fails over proxy

1 messages · Page 1 of 1 (latest)

static hare
#

Hey, first of all, I know this is neither the right channel nor server for this but I am unable to get this fixed and I know there are a lot of competent developers here so I thought I might try my luck here.

I am currently trying to use drizzle on durable objects via the drizzle sqlite-proxy adapter. I am running the sql queries on durable object sqlite storage and then returning the rows to drizzle, but I am always running into issues when trying to use json columns. Drizzle will just error out with this:


TypeError: value is not iterable (cannot read property undefined)
    at SQLiteBlobJson.mapFromDriverValue (C:/Users/finni/Documents/GitHub/odysseus/workers/odysseus/node_modules/.vite/deps_odysseus/chunk-2PKXMLJU.js:307:30)

I am returning the data correctly but it just fails parsing any and all json columns.

This is my query method: ```ts
async query(sqlBody: string, params: any[] = [], method: 'all' | 'first' | 'run' | 'values' | 'get' = 'all') {
console.log('Query method:', method, 'SQL:', sqlBody);

    try {
        const cursor = this.sql.exec(sqlBody, ...params);
        let rows: any[];

        if (method === 'first' || method === 'get') {
            const row = cursor.one();
            rows = row ? [row] : [];
        } else {
            rows = cursor.toArray();
        }

        console.log('Query result rows:', rows);

        // Debug each row's field values
        rows.forEach((row, index) => {
            console.log(`Row ${index}:`, row);
            Object.entries(row).forEach(([key, value]) => {
                console.log(`  ${key}: ${value} (type: ${typeof value})`);
            });
        });

        return rows;
    } catch (error) {
        console.error('Query error:', error);
        throw error;
    }
#

and this is my drizzle instance code: ```ts
export const getDB = (identifier: string) => {
const db = drizzle(async (sql, params, method) => {
const doId = env.DATABASE_DO.idFromName("test");
const durableObject = env.DATABASE_DO.get(doId);
const rows = await durableObject.query(sql, params, method);
// @ts-ignore
return { rows };
});

return db;

};