Minor Changes
-
#3457
a07990d
Thanks @IMax153! - Add support for executing raw SQL queries with the underlying SQL client.This is primarily useful when the SQL client returns special results for certain
query types.For example, because MySQL does not support the
RETURNING
clause, themysql2
client will return aResultSetHeader
forINSERT
,UPDATE
,DELETE
, andTRUNCATE
operations.To gain access to the raw results of a query, you can use the
.raw
property on
theStatement
:import * as Effect from "effect/Effect"; import * as SqlClient from "@effect/sql/SqlClient"; import * as MysqlClient from "@effect/sql/MysqlClient"; const DatabaseLive = MysqlClient.layer({ database: Config.succeed("database"), username: Config.succeed("root"), password: Config.succeed(Redacted.make("password")), }); const program = Effect.gen(function* () { const sql = yield* SqlClient.SqlClient; const result = yield* sql`INSERT INTO usernames VALUES ("Bob")`.raw; console.log(result); /** * ResultSetHeader { * fieldCount: 0, * affectedRows: 1, * insertId: 0, * info: '', * serverStatus: 2, * warningStatus: 0, * changedRows: 0 * } */ }); program.pipe(Effect.provide(DatabaseLive), Effect.runPromise);