`to_tsvector(NULL)` returns NULL and `ts_rank(NULL, ...)` therefore
returns NULL — under Postgres's default `NULLS FIRST` for `ORDER BY DESC`
this would surface NULL-valued rows ahead of any matching ones, an
asymmetry with the multi-field path where `concat_ws(' ', ...)` already
skips NULLs and yields a 0.0 rank. Coalescing the field to `''` aligns
the two paths.
Adds `subtitle: String? @fullText` to the test fixture and a regression
test that orders a NULL-subtitle row against a matching one — without
the fix, the NULL row ranks first under DESC.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduces a Prisma-style full-text search capability gated by a new
field-level `@fullText` ZModel attribute. PostgreSQL only — MySQL/SQLite
throw NotSupported. Mirrors the existing `@fuzzy` design.
- Filter operator: `where: { title: { fts: { search, config? } } }`
emits `to_tsvector(field) @@ to_tsquery(query)` (or with a `::regconfig`
cast when `config` is provided; otherwise Postgres uses the database's
`default_text_search_config`).
- OrderBy operator: `_ftsRelevance: { fields, search, config?, sort }`
emits a single `ts_rank(...)`. Multi-field combines fields with
`concat_ws(' ', ...)` so AND queries match terms across fields
(matches Prisma's behavior).
- Type-level gating: the `fts` operator and `_ftsRelevance` orderBy
appear only on String fields annotated with `@fullText` and only when
the schema's provider is `postgresql`. Slicing's `'FullText'` filter
kind controls availability of the runtime operator.
- Cursor pagination is rejected when combined with `_ftsRelevance`
(parallel to `_fuzzyRelevance`).
Also refactors `buildOrderBy` to dispatch to small per-branch helpers
(`applyScalarOrderBy`, `applyAggregationOrderBy`, `applyRelationOrderBy`,
`applyFuzzyRelevanceOrderBy`, `applyFtsRelevanceOrderBy`).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduces a new `$diagnostics()` method on ZenStackClient that returns
Zod schema cache statistics and slow query information, helping users
monitor and debug ORM performance.
- Add `diagnostics` option to `ClientOptions` with `slowQueryThresholdMs`
and `slowQueryMaxRecords` settings
- Track slow queries in `ZenStackQueryExecutor` when diagnostics is enabled
- Share slow query collection across derived clients (via $setAuth,
$setOptions, $use, transactions, etc.)
- Cap slow query records with an eviction policy that keeps the slowest
queries (default max: 100)
- Validate diagnostics config with Zod in ClientImpl constructor
- Add `Diagnostics`, `QueryInfo`, and `ZodCacheStats` types
- Add e2e tests covering all diagnostics features
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* WIP(orm): mysql support
* WIP: more progress with fixing tests
* WIP: get all client api tests pass
* WIP: get all tests pass
* fix executor
* add MySQL to CI matrix
* fix sqlite test runs
* fix test
* fix delete readback check
* set mysql container max connections
* fix tests
* fix test
* refactor: extract duplicated mysql/pg code into base class
* address PR comments
* refactor: remove order by duplicated code
* refactor: optimize stripTableReference
* addressing PR comments
* fix tests
* add test for pg computed values across multiple schema
* Add an any cast to type check test file
---------
Co-authored-by: Yiming Cao <yiming@whimslab.io>
* fix(orm): add special treatment to enum arrays for postgres db
- For input, the string array needs to be casted with "Enum"[]
- For output, the raw pg array string needs to be parsed back to a proper JS string array
fixes#576
* fix enum array filtering and improve test cases
* update
* addressing PR comments
* feat: custom procs
* chore: cleanup
* fix: remove $procedures from client
* fix: failing test due to previous alias
* feat(custom-procs)!: make procedures envelope-only via $procs
- Switch procedure calls to `db.$procs.name({ args: {...} })` (no positional args)
- Remove legacy `$procedures` alias entirely (client API + server routing/logging)
- Validate procedure envelope input (`args` object, required/unknown keys)
- Keep TanStack Query procedure hooks as `(args, options)` (with conditional args optionality)
- Update server/ORM/client tests for the envelope API
* fix: code review feedback
* fix: code review comments
* fix: coderabbit review comments
* fix: remove useless proxy method
* test: add a couple of e2e tests that verify both typing and runtime
* test: improve e2e tests
* test: add missing mutation flag
* regenerate test schema
* refactor: procedure params generation fix and type refactors
- Simplified procedure's params definition from a tuple an object, since procs are now called with an envelop now
- Refactored procedure related typing to make them more consistent with other CURD types (that usually takes the schema as the first type parameter, and a name as the second)
- Moved detailed procedure's types to "crud-types" where other ORM client detailed types are defined
- Removed some type duplication from hooks side
- Updated the "orm" sample to demonstrate procedures
* fix: disable infinite custom proc queries for now
---------
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
* feat(orm): support where enum
* fix(orm): super transform for where
* feat(orm): support nested enum in where and/or
* fix: resolve field's model from scope instead of relying on table qualification
* fix(orm): cuid() generator should respect version argument
---------
Co-authored-by: FTB_lag <tabolskyy.git@gmail.com>
* feat(orm): support where enum
* fix(orm): super transform for where
* feat(orm): support nested enum in where and/or
* fix: resolve field's model from scope instead of relying on table qualification
---------
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>
* Add support for generated identifier format strings (ID prefixing).
* Add tests.
* Add missing semicolon.
* Cleanup logic.
* Fix typo.
* Use `replaceAll` instead.
* Add language support and tests.
* Simplify logic.
* allow using '\\%s' to escape replacement pattern, improve tests
* Shorten some test names.
---------
Co-authored-by: ymc9 <104139426+ymc9@users.noreply.github.com>