Skip to content

console: bump kysely to 0.29 - #39686

Closed
leedqin wants to merge 1 commit into
MaterializeInc:mainfrom
leedqin:console-kysely-0.29
Closed

leedqin wants to merge 1 commit into
MaterializeInc:mainfrom
leedqin:console-kysely-0.29

Conversation

@leedqin

@leedqin leedqin commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Motivation

Supersedes #39534. Dependabot's version of this bump fails typecheck, and it would break yarn gen:types.

Description

  • kysely 0.28.17 → 0.29.6 and kysely-codegen 0.17 → 0.20.
  • 0.29 rejects limit(sql.raw(...)). lagHistory and our rawLimit helper now use limit(sql.lit(n)). The compiled SQL is unchanged: the limit is still inlined as a literal, which Materialize requires.
  • rawLimit used to append its limit with modifyEnd. In 0.29, compiling end modifiers calls Array.prototype.toSorted, which Chrome 109 (still in our browserslist defaults) doesn't have. With the old helper, the Query History list and sink errors would throw there. The API tokens page already calls toSorted on main, so Chrome 109 isn't fully supported either way. This just avoids adding more breakage.
  • kysely-codegen 0.18 renamed --schema to --default-schema, and 0.20 rejects the old flag, so bin/generate-types is updated.

kysely 0.29 is ESM-only, and kysely-codegen 0.20 requires it, so yarn gen:types needs Node 22.12 or later. CI and the Volta pin already run Node 26, and #39683 updates engines.node.

Verification

Existing tests, including the SQL builder tests under src/api. I also compiled 64 query shapes (every rawLimit caller, the Query History filters, all lag-history branches, the replica utilization subscribes and the Object Explorer queries) on 0.28 with the old code and on 0.29 with the new code. The SQL text and parameters matched exactly.

Worth checking on the preview:

  • Query History list;
  • a sink's Errors tab;
  • the freshness lag charts on the environment overview and the cluster pages.

🤖 Generated with Claude Code

0.29 rejects limit(sql.raw(...)), so lagHistory and rawLimit use
limit(sql.lit()), which compiles to the same literal limit. rawLimit no
longer goes through kysely's end-modifier path, which calls
Array.prototype.toSorted (missing in Chrome 109). kysely-codegen 0.18
renamed --schema to --default-schema.
leedqin added a commit to leedqin/materialize that referenced this pull request Nov 6, 2026
kysely 0.28.17 -> 0.29.8 and kysely-codegen 0.17 -> 0.20.0. Supersedes
MaterializeInc#39686.

0.29 rejects limit(sql.raw(...)), so rawLimit and the lag history limit
call query.limit(sql.lit(n)). rawLimit used modifyEnd before, and 0.29
sorts end modifiers with Array.prototype.toSorted, which Chrome 109
lacks. Neither rawLimit caller has an OFFSET or another end modifier, so
the compiled SQL is unchanged.

kysely-codegen 0.20 renames generate's schemas option to defaultSchemas,
lists materialized views itself, and writes to a default file in
node_modules unless outFile is null. kysely 0.29's TableMetadata adds
isForeign. The generated types are identical to 0.17's.
leedqin added a commit that referenced this pull request Nov 6, 2026
### Motivation

`yarn gen:types` fails with `function "pg_get_serial_sequence" does not
exist`. kysely-codegen runs kysely's Postgres introspector for its table
query. Since the bump to kysely 0.28 (#35669), that query calls
`pg_get_serial_sequence`, which Materialize lacks. kysely 0.29 still
does. The query also lists only relkinds `r`, `v` and `p`, so the
catalog's builtin materialized views (`m`) never reached the types under
kysely-codegen 0.17. #40044's types were generated with both patched by
hand in `node_modules`.

This also bumps kysely to 0.29 and kysely-codegen to 0.20, superseding
#39686.

### Description

- `bin/kysely-codegen.ts` runs kysely-codegen programmatically with an
introspector that overrides only the table query. kysely-codegen's
materialized view query, enum handling and serializer still apply.
- The script writes the copyright header to `types/materialize.d.ts`.
The codegen output lacks it, and the copyright lint fails without it.
- `bin/generate-types` exits on errors, pulls the requested image (a
cached `latest` went stale), and stops the container on exit. Before,
each run left a container bound to port 6875, and the next run generated
types from that old container.
- kysely 0.28.17 → 0.29.8 and kysely-codegen 0.17 → 0.20.0:
- 0.29 rejects `limit(sql.raw(...))`. `rawLimit` and the lag history
limit now call `query.limit(sql.lit(n))`, which still inlines the limit
as a literal, as Materialize requires.
- `rawLimit` used to append its limit with `modifyEnd`. In 0.29,
compiling end modifiers calls `Array.prototype.toSorted`, which Chrome
109 lacks. No console query uses end modifiers now. Neither `rawLimit`
caller has an OFFSET or another end modifier, so the compiled SQL is
unchanged.
- kysely 0.29 is ESM-only and kysely-codegen 0.20 `require`s it, so
`yarn gen:types` needs Node 22.12 or later. CI and the Volta pin run
Node 26, and #39683 updates `engines.node`.
- `types/materialize.d.ts` is regenerated against v26.49.1.
kysely-codegen 0.17 and 0.20 produce identical output.
  - Adds `mz_builtin_columns` and `mz_builtin_index_columns`.
- Builtin columns lose their `Generated<>` wrappers, because #40316
changed `pg_attribute.atthasdef` to report no default for them. The
console only selects from these relations, where `Generated<T>` and `T`
read the same.
- Drops the two hand-added `TODO` markers from #39992. The generator now
emits `mz_cluster_auto_scaling_strategies` and
`mz_cluster_reconfigurations`, and `AUTO_SCALING_MIN_VERSION` still
gates them at runtime. The file is now exactly the generator output.

Worth checking on the preview, since these run the changed limits:
- the Query History list;
- a sink's Errors tab;
- the freshness lag charts on the environment overview and the cluster
pages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@leedqin

leedqin commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Closed becaue I fixed yarn gen:types here: #40550

@leedqin leedqin closed this Nov 10, 2026
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.

2 participants