-
-
Notifications
You must be signed in to change notification settings - Fork 522
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Effect is running?
No response
What steps can reproduce the bug?
-
Initialize a project
$ bun init
-
Install dependencies
$ bun add effect @effect/platform @effect/platform-bun @effect/sql @effect/sql-drizzle # Check drizzle-orm version and add it to overrides on package.json $ bun pm why drizzle-orrm # After adding to overrides: $ bun install
-
Modify
index.ts:import { SqlClient } from "@effect/sql"; import * as SqliteDrizzle from "@effect/sql-drizzle/Sqlite"; import * as LibsqlClient from "@effect/sql-libsql/LibsqlClient"; import { randomUUIDv7 } from "bun"; import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; import { Effect, Layer } from "effect"; const todos = sqliteTable("todos", { id: text().$defaultFn(() => randomUUIDv7()).primaryKey(), status: text({enum: ["pending", "in-progress", "completed", "cancelled"]}).default("pending"), content: text().notNull(), createdAt: integer({ mode: "timestamp" }).$defaultFn(() => new Date()), updatedAt: integer({ mode: "timestamp" }).$defaultFn(() => new Date()).$onUpdateFn(() => new Date()), }) const LibsqlLive = LibsqlClient.layer({ url: "file:test.db" }) const DrizzleLive = SqliteDrizzle.layer.pipe(Layer.provide(LibsqlLive)) const DbLive = Layer.mergeAll(LibsqlLive, DrizzleLive) Effect.gen(function*() { const sql = yield* SqlClient.SqlClient const db = yield* SqliteDrizzle.SqliteDrizzle yield* sql`CREATE TABLE IF NOT EXISTS todos ( id TEXT PRIMARY KEY, status TEXT DEFAULT 'pending', content TEXT NOT NULL, createdAt INTEGER DEFAULT (strftime('%s', 'now')), updatedAt INTEGER DEFAULT (strftime('%s', 'now')) )` yield* db.delete(todos) yield* db.insert(todos).values({ content: "Sample todo" }) const result = yield* db.$count(todos) console.log(result) }).pipe( Effect.provide(DbLive), Effect.runPromise )
-
Run using
bun run index.ts
What is the expected behavior?
It should yield the count result.
What do you see instead?
Diagnostics:
Type 'SQLiteCountBuilder<SQLiteSession<"async", SqliteRemoteResult<unknown>, Record<string, never>, ExtractTablesWithRelations<Record<string, never>>>>' must have a '[Symbol.iterator]()' method that returns an iterator. [2488]
Runtime:
$ bun run index.ts
27 | createdAt INTEGER DEFAULT (strftime('%s', 'now')),
28 | updatedAt INTEGER DEFAULT (strftime('%s', 'now'))
29 | )`
30 | yield* db.delete(todos)
31 | yield* db.insert(todos).values({ content: "Sample todo" })
32 | const result = yield* db.$count(todos)
^
(FiberFailure) TypeError: yield* db.$count is not a function. (In 'yield* db.$count(todos)', 'yield* db.$count' is undefined)
effect/Runtime/FiberFailure: Symbol(effect/Runtime/FiberFailure),
effect/Runtime/FiberFailure/Cause: {
_tag: "Die",
defect: 27 | createdAt INTEGER DEFAULT (strftime('%s', 'now')),
28 | updatedAt INTEGER DEFAULT (strftime('%s', 'now'))
29 | )`
30 | yield* db.delete(todos)
31 | yield* db.insert(todos).values({ content: "Sample todo" })
32 | const result = yield* db.$count(todos)
^
TypeError: yield* db.$count is not a function. (In 'yield* db.$count(todos)', 'yield* db.$count' is undefined)
at /home/vini/Code/effect-count-repro/index.ts:32:25
,
[Symbol(effect/Cause)]: [Object ...],
[Symbol(effect/Hash)]: [Function],
[Symbol(effect/Equal)]: [Function],
pipe: [Function: pipe],
toJSON: [Function: toJSON],
toString: [Function: toString],
[Symbol(nodejs.util.inspect.custom)]: [Function],
},
at /home/vini/Code/effect-count-repro/index.ts:32:25
Bun v1.2.19 (Linux x64)Additional information
Reproduction repository: https://github.com/vinicius507/effect-count-repro
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working