Files
effect/packages/sql/CHANGELOG.md
T
github-actions[bot]andgithub-actions[bot] cd154fe259 Version Packages (#3498)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-08-27 09:17:31 +12:00

60 KiB

@effect/sql

0.9.5

Patch Changes

0.9.4

Patch Changes

0.9.3

Patch Changes

0.9.2

Patch Changes

0.9.1

Patch Changes

  • #3455 e9da539 Thanks @tim-smart! - add Model module to /sql

    The Model module can be used to create domain schemas with common variants for the database and serializing to JSON.

    import { Schema } from "@effect/schema";
    import { Model } from "@effect/sql";
    
    export const GroupId = Schema.Number.pipe(Schema.brand("GroupId"));
    
    export class Group extends Model.Class<Group>("Group")({
      id: Model.Generated(GroupId),
      name: Schema.NonEmptyTrimmedString,
      createdAt: Model.DateTimeInsertFromDate,
      updatedAt: Model.DateTimeUpdateFromDate,
    }) {}
    
    // schema used for selects
    Group;
    
    // schema used for inserts
    Group.insert;
    
    // schema used for updates
    Group.update;
    
    // schema used for json api
    Group.json;
    Group.jsonCreate;
    Group.jsonUpdate;
    
    // you can also turn them into classes
    class GroupJson extends Schema.Class<GroupJson>("GroupJson")(Group.json) {
      get upperName() {
        return this.name.toUpperCase();
      }
    }
    
  • #3460 4fabf75 Thanks @tim-smart! - support partial objects in sql helpers

  • Updated dependencies [e9da539]:

0.9.0

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, the mysql2 client will return a ResultSetHeader for INSERT, UPDATE, DELETE, and TRUNCATE operations.

    To gain access to the raw results of a query, you can use the .raw property on the Statement:

    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);
    

Patch Changes

0.8.7

Patch Changes

0.8.6

Patch Changes

0.8.5

Patch Changes

0.8.4

Patch Changes

0.8.3

Patch Changes

0.8.2

Patch Changes

0.8.1

Patch Changes

0.8.0

Minor Changes

  • #3387 42d0706 Thanks @tim-smart! - allow sql Statement transformers to be effectful

Patch Changes

0.7.0

Patch Changes

0.6.3

Patch Changes

0.6.2

Patch Changes

0.6.1

Patch Changes

0.6.0

Patch Changes

0.5.3

Patch Changes

0.5.2

Patch Changes

0.5.1

Patch Changes

0.5.0

Minor Changes

  • #3260 53c0db0 Thanks @tim-smart! - replace /platform RefailError with use of the "cause" property

Patch Changes

0.4.27

Patch Changes

0.4.26

Patch Changes

0.4.25

Patch Changes

0.4.24

Patch Changes

0.4.23

Patch Changes

0.4.22

Patch Changes

0.4.21

Patch Changes

0.4.20

Patch Changes

0.4.19

Patch Changes

0.4.18

Patch Changes

0.4.17

Patch Changes

0.4.16

Patch Changes

0.4.15

Patch Changes

0.4.14

Patch Changes

0.4.13

Patch Changes

0.4.12

Patch Changes

0.4.11

Patch Changes

0.4.10

Patch Changes

0.4.9

Patch Changes

0.4.8

Patch Changes

0.4.7

Patch Changes

0.4.6

Patch Changes

0.4.5

Patch Changes

0.4.4

Patch Changes

0.4.3

Patch Changes

0.4.2

Patch Changes

0.4.1

Patch Changes

0.4.0

Minor Changes

  • #3035 d33d8b0 Thanks @tim-smart! - restructure sql modules to have flat imports

Patch Changes

0.3.18

Patch Changes

0.3.17

Patch Changes

0.3.16

Patch Changes

0.3.15

Patch Changes

0.3.14

Patch Changes

0.3.13

Patch Changes

0.3.12

Patch Changes

0.3.11

Patch Changes

0.3.10

Patch Changes

0.3.9

Patch Changes

0.3.8

Patch Changes

0.3.7

Patch Changes

0.3.6

Patch Changes

0.3.5

Patch Changes

0.3.4

Patch Changes

0.3.3

Patch Changes

0.3.2

Patch Changes

  • #2867 3e86ced Thanks @jamiehodge! - fix sql mysql migrator

0.3.1

Patch Changes

0.3.0

Minor Changes

  • #2833 af0543c Thanks @tim-smart! - remove file system migrator from web sql implementations

Patch Changes

0.2.17

Patch Changes

0.2.16

Patch Changes

0.2.15

Patch Changes

0.2.14

Patch Changes

0.2.13

Patch Changes

0.2.12

Patch Changes

0.2.11

Patch Changes

0.2.10

Patch Changes

0.2.9

Patch Changes

0.2.8

Patch Changes

0.2.7

Patch Changes

0.2.6

Patch Changes

0.2.5

Patch Changes

0.2.4

Patch Changes

0.2.3

Patch Changes

0.2.2

Patch Changes

0.2.1

Patch Changes

0.2.0

Minor Changes

  • #2693 0724274 Thanks @tim-smart! - make @effect/sql dialect agnostic

    All of the client implementations now share the same Context.Tag. This means you can create services that support multiple SQL flavors.

    You can now use the @effect/sql package to access the client apis:

    import * as Sql from "@effect/sql";
    import { Effect } from "effect";
    
    Effect.gen(function* () {
      const sql = yield* Sql.client.Client;
      yield* sql`SELECT * FROM users`;
    });
    

    If you need a functionality that is specific to a implementation, you can use the tag from the implementation package:

    import * as Sqlite from "@effect/sql-sqlite-node";
    import { Effect } from "effect";
    
    Effect.gen(function* () {
      const sql = yield* Sqlite.client.SqliteClient;
      const dump = yield* sql.export;
    });
    

    If you need to run a different query depending on the dialect, you can use the sql.onDialect api:

    import * as Sql from "@effect/sql";
    import { Effect } from "effect";
    
    Effect.gen(function* () {
      const sql = yield* Sql.client.Client;
      yield* sql.onDialect({
        sqlite: () => sql`SELECT * FROM sqlite_master`,
        mysql: () => sql`SHOW TABLES`,
        mssql: () => sql`SELECT * FROM sys.tables`,
        pg: () => sql`SELECT * FROM pg_catalog.pg_tables`,
      });
    });
    

Patch Changes

0.1.17

Patch Changes

0.1.16

Patch Changes

0.1.15

Patch Changes

0.1.14

Patch Changes

0.1.13

Patch Changes

0.1.12

Patch Changes

0.1.11

Patch Changes

0.1.10

Patch Changes

0.1.9

Patch Changes

0.1.8

Patch Changes

0.1.7

Patch Changes

0.1.6

Patch Changes

0.1.5

Patch Changes

0.1.4

Patch Changes

0.1.3

Patch Changes

0.1.2

Patch Changes

0.1.1

Patch Changes

0.1.0

Minor Changes

Patch Changes