-
-
Notifications
You must be signed in to change notification settings - Fork 534
Description
What version of Effect is running?
3.12.10
What steps can reproduce the bug?
Use a debugger to inspect the results in one of the sql-kysely test files, or update one of the test files (Sqlite in this example) to accept null values, and try to access them in the results:
export interface User {
id: Generated<number>
name: string | null
}
yield* db.schema
.createTable("users")
.addColumn("id", "integer", (c) => c.primaryKey().autoIncrement())
.addColumn("name", "text")
yield* db.insertInto("users").values({ name: null })
const testResults = yield* db.selectFrom("users").selectAll()
testResults.map((item) => item.name)
This will output the following error:
TypeError: Cannot create proxy with a non-object as target or handler
❯ effectifyWith src/internal/patch.ts:41:10
39| return obj
40| }
41| return new Proxy(obj, {
| ^
42| get(target, prop): any {
43| const prototype = Object.getP…
❯ Object.get src/internal/patch.ts:53:14
What is the expected behavior?
Using sql-kysely with Effect.gen simply returns a plain object/array of objects.
What do you see instead?
No response
Additional information
sql-kysley is essentially recursively proxying all of the methods of the query builder, and then rewriting the commit method to call execute on the query builder, wrapping it in a tryPromise. When used with Effect.gen, it also is proxying the iterator coming from yield*. The execution of next on the iterator returns something like { value: YieldWrapped, done: false }, and I suppose this object is reused throughout the lifecycle of the iterator, as the next call of next returns { value: queryResults, done: true }, and this object is still a Proxy, and due to the recursive nature of the proxying, queryResults is also a proxy, etc.