Skip to content

Update kysely - #33

Merged
nedtwigg merged 1 commit into
mainfrom
renovate/kysely
Sep 29, 2026
Merged

nedtwigg merged 1 commit into
mainfrom
renovate/kysely

Conversation

@renovate

@renovate renovate Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
kysely (source) 0.29.5 → 0.29.6 age adoption passing confidence
kysely-codegen ^0.19.0 → ^0.20.0 age adoption passing confidence

Release Notes

kysely-org/kysely (kysely)

v0.29.6: 0.29.6

Compare Source

Hey 👋

A small batch of bug fixes. Please report any issues. 🤞😰🤞

🚀 Features

🐞 Bugfixes

PostgreSQL 🐘 / SQLite 📘

📖 Documentation

📦 CICD & Tooling

⚠️ Breaking Changes

🐤 New Contributors

What's Changed

Full Changelog: kysely-org/kysely@v0.29.5...v0.29.6

RobinBlomberg/kysely-codegen (kysely-codegen)

v0.20.0

Compare Source

Many great contributions, bug fixes and new features.

Resolves #​284, #​287, #​307, #​308, #​72, #​301, #​275, #​283.

defineConfig() and postprocess()

kysely-codegen@​0.20.0 adds a defineConfig function that makes it easy to configure kysely-codegen in a type-safe way. It also adds a new Config#postprocess function that makes it possible to process the introspected metadata before generating code. This function allows you to reuse the active kysely-codegen connection to further introspect the database and modify the metadata as needed.

Example of generating enum types from PostGraphile enum tables:

import { sql } from "kysely";
import { defineConfig } from "kysely-codegen";
import pluralize from "pluralize";

export default defineConfig({
  camelCase: false,
  dateParser: "timestamp",
  dialect: "postgres",
  excludePattern: "(graphile_migrate.*|graphile_worker._private_*)",
  outFile: "./types/database-types.ts",
  postprocess: async ({ db, metadata }) => {
    const rows = await db
      .selectFrom("pg_catalog.pg_constraint as foreign_key_constraint")
      .innerJoin(
        "pg_catalog.pg_class as from_table",
        "from_table.oid",
        "foreign_key_constraint.conrelid",
      )
      .innerJoin(
        "pg_catalog.pg_namespace as from_table_namespace",
        "from_table_namespace.oid",
        "from_table.relnamespace",
      )
      .innerJoin("pg_catalog.pg_attribute as from_column", (join) =>
        join
          .onRef("from_column.attrelid", "=", "from_table.oid")
          .on(sql`from_column.attnum = any(foreign_key_constraint.conkey)`),
      )
      .innerJoin(
        "pg_catalog.pg_class as to_table",
        "to_table.oid",
        "foreign_key_constraint.confrelid",
      )
      .innerJoin(
        "pg_catalog.pg_namespace as to_table_namespace",
        "to_table_namespace.oid",
        "to_table.relnamespace",
      )
      .innerJoin("pg_catalog.pg_attribute as to_column", (join) =>
        join
          .onRef("to_column.attrelid", "=", "to_table.oid")
          .on(sql`to_column.attnum = any(foreign_key_constraint.confkey)`),
      )
      .select([
        "from_table_namespace.nspname as fromSchema",
        "from_table.relname as fromTable",
        "from_column.attname as fromColumn",
        "to_table_namespace.nspname as enumSchema",
        "to_table.relname as enumTable",
        "to_column.attname as enumColumn",
      ])
      .where("foreign_key_constraint.contype", "=", "f")
      .where(sql<any>`obj_description(to_table.oid, 'pg_class') like '%@enum%'`)
      .execute();

    await Promise.all(
      rows.map(
        async ({
          fromColumn,
          fromSchema,
          fromTable,
          enumColumn,
          enumSchema,
          enumTable,
        }) => {
          const fromTableMetadata = metadata.tables.find(
            (table) => table.schema === fromSchema && table.name === fromTable,
          );
          const fromColumnMetadata = fromTableMetadata?.columns.find(
            (column) => column.name === fromColumn,
          );
          const enumTableMetadata = metadata.tables.find(
            (table) => table.schema === enumSchema && table.name === enumTable,
          );
          const enumColumnMetadata = enumTableMetadata?.columns.find(
            (column) => column.name === enumColumn,
          );

          if (fromColumnMetadata || enumColumnMetadata) {
            const dataType = `${pluralize.singular(enumTable)}.${enumColumn}`;
            const enumValues = await db
              .selectFrom(`${enumSchema}.${enumTable}`)
              .select(enumColumn)
              .execute()
              .then((rows) =>
                rows.map((row) => (row as Record<string, string>)[enumColumn]),
              );

            metadata.enums.set(`${enumSchema}.${dataType}`, enumValues);

            if (fromColumnMetadata) {
              fromColumnMetadata.dataTypeSchema = enumSchema;
              fromColumnMetadata.dataType = dataType;
            }

            if (enumColumnMetadata) {
              enumColumnMetadata.dataTypeSchema = enumSchema;
              enumColumnMetadata.dataType = dataType;
            }
          }
        },
      ),
    );

    return metadata;
  },
  singularize: true,
  url: process.env.DATABASE_URL,
});

Example output:

+type EventTypeName = "TICKET_CREATED" | "TICKET_DELETED" | "TICKET_UPDATED";
+
 type Event = {
   createdAt: Generated<Timestamp>;
   data: JsonValue;
-  type: string;
+  type: EventTypeName;
 };

 type EventType = {
   description: string;
-  name: string;
+  name: EventTypeName;
 };

What's Changed

New Contributors

Full Changelog: RobinBlomberg/kysely-codegen@0.19.0...0.20.0


Configuration

📅 Schedule: (in timezone America/Los_Angeles)

  • Branch creation
    • Only on Thursday (* * * * 4)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@nedtwigg
nedtwigg merged commit f198938 into main Sep 29, 2026
2 checks passed
@renovate
renovate Bot deleted the renovate/kysely branch September 29, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant