Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from prisma:main #122

Open
wants to merge 722 commits into
base: main
Choose a base branch
from
Open

[pull] main from prisma:main #122

wants to merge 722 commits into from

Conversation

pull[bot]
Copy link

@pull pull bot commented Jun 12, 2023

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

renovate bot and others added 28 commits March 7, 2024 14:18
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
* add env var for forcing relation strategy

* Default to RLS::Join if no env set

* add relation_load_strategy to qe ci tests matrix

---------

Co-authored-by: Alexey Orlenko <[email protected]>
* qe: Capabilities-based size optimizations for WASM engine

Core feature of this PR: `can_have_capability` function in `psl-core`
crate. For multi-connector builds it always returns `true` and has no
effect. If we are inside of a single connector build, however, it will
eveluate value based on the actual connector capabilities. In many
cases, this will allow optimizer to completely eliminate following code
if connector does not support specific feature.

Notable exeception to that were relation joins: for some reason,
optimizer can not eliminate those functions from SQLite bundle. So, this
is the only place in sql-query-connector where we have to introduce
conditionally compiled feature.

In order to take maximum advantage of this functionality, we have to
disable default features in `quaint` and `psl` crates and enable them
only in native engines.

Close prisma/team-orm#928

* Fix tests & lints

* Fix migrate tests

* Fix codspeed

* Now for real

* FFS

* Address some of the feedback

* Introduce reachble_only_with_capability macro

* Compile `returning` uncoditionally

* Restore benchmarks

* Fix benchmarks, but preserve all size gains

* Sigh
Example is outdated and generally agreed not to be useful anymore.
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alberto Schiabel <[email protected]>
Co-authored-by: Joël Galeran <[email protected]>
* Fix `relation_fields` validation to accept primary key indexes

This resolves prisma/language-tools#1387

---------

Co-authored-by: Jan Piotrowski <[email protected]>
Adds hidden preview feature only, without any implementation.

Close prisma/team-orm#1036
* Add comparison for decimal <-> str
add test for batching unquoted decimals

* Moved compact_batch -> q-e-tests/utils
assert 5952 is compacted

---------

Co-authored-by: Serhii Tatarintsev <[email protected]>
* feat(da-executor): use parallel build for faster local test runs

* chore(da-executor): update typescript

* chore(da-executor): move utilities to utils.ts

* feat(da-executor): validate json-rpc requests

* feat(da-executor): introduce type-safe driver-adapters-manager

* chore(da-executor): rename "dev" script to "test" to avoid conflicts with "pnpm build" run at the project root

* feat(query-tests-setup): facilitate driver-adapters JS-driven setup for D1, organise JSON-RPC roundtrips

* chore(da-executor): get rid of annoying bytes log and unused imports

* feat(da-executor): add first D1 support to TypeScript side

* add for d1:
test-config
map for d1 sqlite version

* add to makefile and yml

* dev-d1-wasm correct config path

* chore(da-executor): minor setup fixes

* feat(da-executor): allow qe-setup to delegate both initialisation and schema migration to JavaScript

* feat(da-executor): wrap up D1, fix teardown issues

* feat(da-executor): fix package.json scripts

* feat(da-executor): fix package.json scripts

* chore(da-executor): remove unused line

* chore(da-executor): remove unused line

* exclude itx tests for d1

* feat(da-executor): implement migrate reset for D1 + workaround for flakiness

* chore(da-executor): disable workaround for busy loop, try to see which tests pass

* chore(da-executor): disable tokio::time::sleep

* chore(da-executor): minor updates to driver-adapters-manager

* chore(da-executor): fix lints

* fix(driver-adapters): libsql tests

* fix(driver-adapters): clippy

* feat(da-executor): ensure the given DRIVER_ADAPTER_CONFIG'S proxy_url isn't empty

* feat(da-executor): fix planetscale tests

* chore(da-executor): use DROP TABLE IF EXISTS, adjust access modifiers

* feat(da-executor): remove PRAGMA foreign_keys

* feat(da-executor): remove DROP INDEX

* feat(query-engine-tests): fix byoid tests on D1

* feat(query-engine-tests): fix nested byoid tests on D1

* feat(query-engine-tests): expose SqliteVersion publicly

* feat(query-engine-tests): comment out most failing D1 tests

* feat(query-engine-tests): fix D1 TS setup pipeline. Co-authored-by: @Jolg42 <[email protected]>

* feat(query-engine-tests): comment out metrics tests on D1

* feat(query-engine-tests): comment out other tests on D1

* chore(query-engine-tests): reduce console spam on D1

* chore(query-engine-tests): fix TypeScript suites after updates to prisma

* feat(query-engine-tests): comment out tests that succeed locally

* feat(query-engine-tests): comment out remaining itx tests

* fix(query-engine-tests): fix mongodb

* feat(adapter-d1): comment out some remaining D1 tests. DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* feat(adapter-d1): allow parsing bool from double. DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* feat(adapter-d1): comment out some tests. DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* feat(adapter-d1): comment out some tests. DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* feat(da-executor): delete "sqlite_sequence" outside of the batch transaction. DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* feat(da-executor): comment out top_level_mutations test. DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* feat(da-executor): fix reset? DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* feat(da-executor): comment out failing tests on D1. DRIVER_ADAPTERS_BRANCH=jkomyno/fix/d1-tests

* chore: retrigger CI/CD

---------

Co-authored-by: Sophie Atkins <[email protected]>
- Added batch_boolean test and assert that unique booleans can compact
- Handle unique boolean selection set
- Added test for batching multi-case for booleans

---------

Co-authored-by: Serhii Tatarintsev <[email protected]>
Co-authored-by: Alberto Schiabel <[email protected]>
* fix(adapter-d1): uncomment tests that now work locally

* fix(adapter-d1): add more context around group_by_having tests

* fix(adapter-d1): uncomment more tests that now work locally

* fix(adapter-d1): uncomment other tests that now work locally, explain why certain tests still fail

* fix(adapter-d1): uncomment remain tests that now work, explain why they fail
* driver-adapters: Serialize i32 arguments as `number`

Before this PR, we serialized all integers as bigint. This was not a
problem for any of the adapters that supported bigint natively, however,
it turned into a problem for D1.

When we are doing order by aggregations, we inserd `ORDER BY
COALESCE(count, 0)` into the query, where `0` is passed as i32 argument.

As mentioned earlier, i32 argument got converted to `bigint` before this
PR. In D1 adapter, we convert all bigints to strings. Which means, that
above SQL query would become `ORDER BY COALESCE(count, '0')` now and
produce different order for the rows where `count = NULL`.

Since i32 bounds are below `Number.MAX_SAFE_INTEGER`, it is safe to convert it
to `number` instead of `bigint`. `0` in above query is hardcoded to
always be `i32`, so this fixes the issue.

Close prisma/team-orm#1049

* fix(adapter-d1): uncomment remaining tests that now work

---------

Co-authored-by: jkomyno <[email protected]>
* test 23343

* Fixed test batch_23343

Updated SelectionSet to allow for same field from compound index and extra field in findUnique Where.

Co-authored-by: Flavian Desverne <[email protected]>

* quick ref (#4795)

Co-authored-by: Flavian Desverne <[email protected]>

---------

Co-authored-by: Flavian Desverne <[email protected]>
Co-authored-by: Serhii Tatarintsev <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
jkomyno and others added 30 commits December 5, 2024 21:58
* fix(psl): prevent panics on ID generator parsing logic

* test(psl): add missing test for uuid
* fix: correctly handle foreign keys when dropping mysql indexes

* doc: clarify comments

* doc: clarify comment

* chore: add tests and clean up code
* fix: strip traceparent comment from info_span

* fix: handle non-eoi traceparent coment

* fix: update assertion check

* fix: assert on logs_contain

* fix: simplify test to avoid db differences

* fix: fix a lint
* fix: include traceparent in nested queries

* fix: include additional field to make sure nested queries happen

* fix: fix a lint

* fix: corrections for different setups
* feat: configurable caching with support for tracing

* fix: correct TypedQuery creation

* fix: store columns in TypedQuery

* fix: store column names as well

* fix: define aliases and fix some references to PostgreSql

* chore: doc comments and cleanup

* chore: doc comment adjustments and renames

* test: cover the queries and caches

* fix: actually pass tracing flag

* refactor: merge the two prepared query caches

* fix: make sure to return the caller-provided sql with TypedQuery

* chore: get rid of some unneeded accessors

* chore: update assertion text

* doc: clarify comment

* chore: use rsplit because we expect traceparent at the end

* doc: correct comment

* test: cover higher capacity in the tests

* [integration]

* chore: correct typo

* fix: remove unneeded outlives trick

* chore: less annoying trace message

* chore: switch over to tokio mutex

* refactor: use a NoOp hasher
* libs/telemetry: use tracing-futures from workspace deps

* libs/telemetry: remove obsolete dependency

* Update tracing and tracing-subscriber

* Add capturing::ng module

* We don't use tide anymore

* Add TraceParent and WithContext

* Add SpanBuilder

* Implement SpanBuilder and SpanAttributeVisitor

* Add Collector trait

* Add tests for layer

* Fix import

* Sort attributes map

* Style change

* Fix redacting span IDs in `Option`s

* Remove unnecessary qualifier

* Update snapshot to what's expected

* Declare empty field in test

* Add test for renamed span

* Add test_follows_from

* Remove sleep

* Add on_event

* Implement events capturing in subscriber layer

* Add span IDs to events

* Add some comments

* Add ExporterInner

* Introduce SerializableNonZeroU64

* Make SerializableNonZeroU64 deserializable

* Add `RequestId`

* Support RequestId in layer

* Add `#[repr(transparent)]`

* Make request IDs non-zero to make use of NPO and reduce struct size

* Move Exporter to its own module

* Hide RequestId::from_u64

* Hide RequestId::from_u64 even more

* First pass at exporter

* Add CaptureSettings

* Fix compile error

* Use background task in exporter

* Re-implement Exporter using channel

* Get rid of Arc<Inner>, channel is already refcounted

* Add exporter tests

* Implement filtering by capture settings

* Get query engine to build

* wip node-api support

* wip

* use or combinator

* pass request id in library engine

* some cleanup

* use str for request id

* update c-abi engine

* remove unnecessary async block

* use ManuallyDrop

* only capture when traceparent is sampled

* simplify user facing spans filter

* add missing request_id field in library engine

* panic on send failures

* Implement attribute filtering

* clarify

* add missing otel.name

* add request_id in c-abi engine

* add empty request_id field in binary engine

* always expose traces in response in binary engine

* fix formatting issue

* cosmetic changes

* Remove otel deps and add tracing to wasm

* add rt feature lost when removing otel deps

* remove obsolete feature

* use ahash\

* post-rebase fixes

* fix attrs order in test

* oops

* remove unused feature

* remove unused import

* use info level by default

* oops again

* implement fetching boot spans

* use a more descriptive name

* better semantic conventions compat

* oops 3

* capture target and not name in events

* fix snapshot

* fix log level casing

* fix logging on mongodb

* hide some spans

* add request ids to wasm test executor

* add missing file

* wasm time

* remove stray extension

* rename prisma-specific attribute

* disambiguate

* fix error

* rebuild

* don't pass `-fuse-ld=lld` when compiling for wasm

* make rand dependency conditional on target

* [skip ci]
Fixup #5049 and rename one
missed span attribute. The tests on the client were updated to expect
the new name but the attribute was only updated in one of two places.
Add missing `prisma:engine:response_json_serialization` span in the WASM
query engine. After this we can enable running the tracing tests with
WASM in the client repo.
* fix(query-engine-wasm): expand scope of `prisma:engine:query` span

Expand the scope of the `prisma:engine:query` span to contain both the
request handler and the response serialization, identical to the
Node-API engine, preventing `prisma:engine:response_json_serialization`
from being orphaned outside the trace.

This is a follow up to #5089.

* [integration]

* Add missing bits for transactions

* [integration]

* strip traceparents in attributes with driver adapters

* [integration]
Our logic assumed that span IDs were unique within a trace but that's
incorrect: they can be reused as long as the spans don't overlap in time
(e.g. sequential siblings). Now we assign our own IDs which are
guaranteed to be unique within a trace as long as the trace has less
than 18446744073709551616 (2**64) spans.

`tracing` tries not to reuse them immediately so this wasn't caught in
tests until we started running tests with WASM where the issue
immediately became evident (presumably due to the lack of a high quality
source of randomness but I haven't actually investigated what the reason
behind the difference in behaviour is).
* feat: sqlite JSON support

* chore: unneeded clone

* fix: fix tests

* fix: correct snapshot

* fix: pass sqlite Json args as strings

* fix: update json arg test

* fix: disable unwanted adaptors

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

* chore: address comments

* chore: address comments fix

* chore: bring back json_support test with a new assertion

* chore: remove clone

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

* fix: fix edge cases around plain JSON values

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

* feat: conditionally generate the ArrayContains filter

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

* fix: correct copy paste errors

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

* fix: null handling for unknown number for d1

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

* chore: minor cleanups

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI

---------

Co-authored-by: jkomyno <[email protected]>
Co-authored-by: Alberto Schiabel <[email protected]>
…ers (#5094)

* fix: convert small integers of unknown type into i32 for driver adapters

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI
* feat: ULID support

* chore: remove unwanted files

* chore: remove serde feature

* test: update assertion

* fix: add ULID to KNOWN_FUNCTIONS

* test: check the ulid format

* chore: correct comment

* DRIVER_ADAPTERS_BRANCH=feat/sqlite-json chore: re-trigger CI
…5095)

Due to the lack of Nix buy-in from the team and with most of Nix users
leaving, and given the increased overhead of keeping multiple separate
build systems and workflows in sync after the introduction of the
WebAssembly tooling and difficulties in making changes in Nix code for
team members who don't use it, it was previously decided to decrease our
reliance on Nix and stop using it on CI, leaving it as optional and only
for local development, which mostly happened [in
February](#4713). However,
the engines size dashboard was still powered by Nix because we ran out
of the allocated time for the tech debt task.

After the Nix flake was updated last time, the workflow was broken
because `wasm-bindgen-cli` in the flake was at 0.2.95 while we are
currently pinned to 0.2.93 and are blocked from upgrading to a newer
version at the moment. Rather than pinning `wasm-bindgen-cli` to 0.2.93
in the flake by taking it from a different nixpkgs commit, it's a good
opportunity to start using the same infrastructure we use for other
GitHub Actions jobs instead.

With that, and given the fact that our workflows and build scripts are
heavily dependent on rustup and we even used rustup within the dev shell
instead of the toolchain from `rust-overlay`, there's not much benefit
for the local dev shell for Nix users to be a flake, a classic
`shell.nix` is more appropriate: pinning the state of the environment in
`flake.lock` is no longer useful and only gets in the way. As an added
bonus, classic Nix doesn't require copying the sources to the store,
which makes the shell startup a bit faster.

Fixes: prisma/team-orm#1444
Closes: #5072
* chore(driver-adapters): refactor query-engine test executor, in preparation for schema-engine-wasm playground

* chore: update Node.js version to v20 for Driver Adapters

* feat(driver-adapters-executor): log request on "initializeeSchema"; add brand type + sanity check to SchemaId

* feat(connector-test-kit-rs): use workspace root only, add warnings on config loading errors (hidden behind RUST_LOG=warn)

* fix(driver-adapters-executor): schema path setting

---------

Co-authored-by: jkomyno <[email protected]>
* feat: implement updateManyAndReturn

* fix: correct update_one_without_selection

* feat: add the mutation

* test: update snapshot

* test: update snapshot

* test: add a test suite

* test: add UpdateReturning capability

* test: correct test suite attributes

* fix: add missing case in From<&str> for QueryTag

* test: test relational reads

* chore: trigger integration

* [integration]
* feat: sqlite enums

* test: update capability test and rename a test

* [integration]

* test: make sqlite enum tests actually run

* test: skip remapping introspection tests

* test: fix tests

* test: fix typo

* test: cover invalid enum runtime error

* test: cover mongo runtime error

* doc: explain default comparison between enum and string

* doc: correct mistake
)

* feat(driver-adapters): add "version()" support to QuaintQueryable

* feat(driver-adapters): add "version()" support to QuaintQueryable

* chore: fix lint

---------

Co-authored-by: jkomyno <[email protected]>
…hema-connector` (#5106)

* feat(schema-engine-wasm): wasm-compatible sql-schema-describer

* fix(schema-engine-wasm): wasm compilation, move "SqlSchemaDescriberBackend" to sqlite-native impl

* fix(schema-engine-wasm): tests

* feat(schema-engine-wasm): wasm-compatible schema-connector

* fix(schema-engine-wasm): tests

* fix(schema-engine-wasm): tests

* fix(sql-schema-describer): tests

* fix(schema-engine-wasm): Cargo.toml features of schema-connector and sql-schema-describer

* chore(quaint): workaround for mongodb-schema-connector

---------

Co-authored-by: jkomyno <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.