refactor(effect-drizzle-sqlite): simplify single-row reads
This commit is contained in:
parent
25e546c837
commit
fd4887d45d
4 changed files with 34 additions and 14 deletions
|
|
@ -5,7 +5,7 @@ import { relations } from "drizzle-orm/_relations"
|
|||
import { drizzle as drizzleBun } from "drizzle-orm/bun-sqlite"
|
||||
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"
|
||||
import { Cause, Effect, Exit } from "effect"
|
||||
import { EffectDrizzleQueryError, make, type EffectSQLiteDatabase } from "../src"
|
||||
import { EffectDrizzleQueryError, getOne, make, type EffectSQLiteDatabase } from "../src"
|
||||
|
||||
const users = sqliteTable("users", {
|
||||
id: integer().primaryKey(),
|
||||
|
|
@ -176,6 +176,15 @@ describe("effect drizzle sqlite", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
testEffect("supports single-row select effects", () =>
|
||||
Effect.gen(function* () {
|
||||
yield* db.insert(users).values({ id: 1, name: "Ada" })
|
||||
|
||||
expect(yield* getOne(db.select().from(users).where(eq(users.id, 1)))).toEqual({ id: 1, name: "Ada" })
|
||||
expect(yield* getOne(db.select().from(users).where(eq(users.id, 2)))).toBeUndefined()
|
||||
}),
|
||||
)
|
||||
|
||||
testEffect("nested pipeable transactions commit or roll back with the outer transaction", () =>
|
||||
Effect.gen(function* () {
|
||||
yield* Effect.gen(function* () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue