| 1 | diff --git a/lib/Drizzle/Postgres.d.ts b/lib/Drizzle/Postgres.d.ts |
| 2 | index ddba2e1..31335e2 100644 |
| 3 | --- a/lib/Drizzle/Postgres.d.ts |
| 4 | +++ b/lib/Drizzle/Postgres.d.ts |
| 5 | @@ -4,6 +4,11 @@ import type { EffectPgDatabase } from "drizzle-orm/effect-postgres"; |
| 6 | import type { EffectDrizzlePgConfig } from "drizzle-orm/pg-core/effect/utils"; |
| 7 | import * as Effect from "effect/Effect"; |
| 8 | import type * as Redacted from "effect/Redacted"; |
| 9 | +/** |
| 10 | + * `@effect/sql-pg` client settings that cannot be carried in the URL, e.g. |
| 11 | + * `prepare: false` for transaction-mode poolers such as Hyperdrive. |
| 12 | + */ |
| 13 | +export type PostgresClientOptions = Omit<PgClient.PgPoolConfig, "url" | "ssl">; |
| 14 | /** |
| 15 | * Open a Drizzle/Postgres database from a connection URL using the |
| 16 | * `drizzle-orm/effect-postgres` integration. |
| 17 | @@ -39,7 +44,7 @@ import type * as Redacted from "effect/Redacted"; |
| 18 | * |
| 19 | * @binding |
| 20 | */ |
| 21 | -export declare const Postgres: <TRelations extends AnyRelations = EmptyRelations, E = never, R = never>(connectionString: Effect.Effect<Redacted.Redacted<string>, E, R>, config?: EffectDrizzlePgConfig<TRelations>) => Effect.Effect<EffectPgDatabase<TRelations> & { |
| 22 | +export declare const Postgres: <TRelations extends AnyRelations = EmptyRelations, E = never, R = never>(connectionString: Effect.Effect<Redacted.Redacted<string>, E, R>, config?: EffectDrizzlePgConfig<TRelations>, pgClient?: PostgresClientOptions) => Effect.Effect<EffectPgDatabase<TRelations> & { |
| 23 | $client: PgClient.PgClient; |
| 24 | }, never, never>; |
| 25 | //# sourceMappingURL=Postgres.d.ts.map |
| 26 | \ No newline at end of file |
| 27 | diff --git a/lib/Drizzle/Postgres.js b/lib/Drizzle/Postgres.js |
| 28 | index fdd0942..e745228 100644 |
| 29 | --- a/lib/Drizzle/Postgres.js |
| 30 | +++ b/lib/Drizzle/Postgres.js |
| 31 | @@ -38,13 +38,13 @@ import { proxyChain } from "../Util/proxy-chain.js"; |
| 32 | * |
| 33 | * @binding |
| 34 | */ |
| 35 | -export const Postgres = (connectionString, config) => Effect.map(makeExecutionMemo(Effect.gen(function* () { |
| 36 | +export const Postgres = (connectionString, config, pgClient) => Effect.map(makeExecutionMemo(Effect.gen(function* () { |
| 37 | const [PgClient, PgDrizzle] = yield* Effect.promise(() => Promise.all([ |
| 38 | import("@effect/sql-pg/PgClient"), |
| 39 | import("drizzle-orm/effect-postgres"), |
| 40 | ])); |
| 41 | const url = yield* connectionString; |
| 42 | - const pgCtx = yield* Layer.build(PgClient.layer(resolveConnectionOptions(url))); |
| 43 | + const pgCtx = yield* Layer.build(PgClient.layer({ ...pgClient, ...resolveConnectionOptions(url) })); |
| 44 | return yield* PgDrizzle.makeWithDefaults(config).pipe(Effect.provideContext(pgCtx)); |
| 45 | })), (db) => proxyChain(db)); |
| 46 | //# sourceMappingURL=Postgres.js.map |
| 47 | \ No newline at end of file |
| 48 | diff --git a/lib/Test/Vitest.js b/lib/Test/Vitest.js |
| 49 | index bada542..f135b00 100644 |
| 50 | --- a/lib/Test/Vitest.js |
| 51 | +++ b/lib/Test/Vitest.js |
| 52 | @@ -3,7 +3,7 @@ import { it } from "@effect/vitest"; |
| 53 | import * as Effect from "effect/Effect"; |
| 54 | import * as Exit from "effect/Exit"; |
| 55 | import * as Scope from "effect/Scope"; |
| 56 | -import { afterAll as vitestAfterAll, afterEach as vitestAfterEach, beforeAll as vitestBeforeAll, beforeEach as vitestBeforeEach, } from "vitest"; |
| 57 | +import { afterAll as vitestAfterAll, afterEach as vitestAfterEach, beforeAll as vitestBeforeAll, beforeEach as vitestBeforeEach, } from "vite-plus/test"; |
| 58 | import * as Core from "./Core.js"; |
| 59 | export { executeWhenReady, getWhenReady, guardContentType, guardedFetchLayer, rpcClientLayer, WorkerNotReady, } from "./Http.js"; |
| 60 | export const defaultStage = Core.defaultStage; |
| 61 | diff --git a/src/Drizzle/Postgres.ts b/src/Drizzle/Postgres.ts |
| 62 | index 2d13891..61ae549 100644 |
| 63 | --- a/src/Drizzle/Postgres.ts |
| 64 | +++ b/src/Drizzle/Postgres.ts |
| 65 | @@ -48,6 +48,15 @@ import { proxyChain } from "../Util/proxy-chain.ts"; |
| 66 | * @binding |
| 67 | */ |
| 68 | |
| 69 | +/** |
| 70 | + * `@effect/sql-pg` client settings that cannot be carried in the URL, e.g. |
| 71 | + * `prepare: false` for transaction-mode poolers such as Hyperdrive. |
| 72 | + */ |
| 73 | +export type PostgresClientOptions = Omit< |
| 74 | + PgClient.PgPoolConfig, |
| 75 | + "url" | "ssl" |
| 76 | +>; |
| 77 | + |
| 78 | export const Postgres = < |
| 79 | TRelations extends AnyRelations = EmptyRelations, |
| 80 | E = never, |
| 81 | @@ -55,6 +64,7 @@ export const Postgres = < |
| 82 | >( |
| 83 | connectionString: Effect.Effect<Redacted.Redacted<string>, E, R>, |
| 84 | config?: EffectDrizzlePgConfig<TRelations>, |
| 85 | + pgClient?: PostgresClientOptions, |
| 86 | ) => |
| 87 | Effect.map( |
| 88 | makeExecutionMemo( |
| 89 | @@ -67,7 +77,7 @@ export const Postgres = < |
| 90 | ); |
| 91 | const url = yield* connectionString; |
| 92 | const pgCtx = yield* Layer.build( |
| 93 | - PgClient.layer(resolveConnectionOptions(url)), |
| 94 | + PgClient.layer({ ...pgClient, ...resolveConnectionOptions(url) }), |
| 95 | ); |
| 96 | return yield* PgDrizzle.makeWithDefaults(config).pipe( |
| 97 | Effect.provideContext(pgCtx), |
| 98 | diff --git a/src/Test/Vitest.ts b/src/Test/Vitest.ts |
| 99 | index 7dd3576..0bcfc4d 100644 |
| 100 | --- a/src/Test/Vitest.ts |
| 101 | +++ b/src/Test/Vitest.ts |
| 102 | @@ -8,7 +8,7 @@ import { |
| 103 | afterEach as vitestAfterEach, |
| 104 | beforeAll as vitestBeforeAll, |
| 105 | beforeEach as vitestBeforeEach, |
| 106 | -} from "vitest"; |
| 107 | +} from "vite-plus/test"; |
| 108 | |
| 109 | import type { AlchemyContext } from "../AlchemyContext.ts"; |
| 110 | import type { CompiledStack } from "../Stack.ts"; |