bimsina
bimsina
DTDrizzle Team
Created by bimsina on 12/10/2024 in #help
Reconstruct Queries from toSQL() data
Hey everyone, I have an interesting use case. I'm trying to figure out if there's a way to reconstruct/run a query from a Query object obtained via query.toSQL(). Something like:
ts
const query = db.select().from(usersTable).limit(1);
const sql: Query = query.toSQL();

// Is there a way to do something like this?
const queryFromSql = db.fromSQL(sql); // or any other approach?
ts
const query = db.select().from(usersTable).limit(1);
const sql: Query = query.toSQL();

// Is there a way to do something like this?
const queryFromSql = db.fromSQL(sql); // or any other approach?
I know this might seem unusual, but I have a specific use case where I need to serialize and later reconstruct queries. Would love to hear if anyone has ideas on how to achieve this or alternative approaches I could explore.
2 replies