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

Embed quaint into prisma-engines #3905

Merged
merged 900 commits into from
Apr 25, 2023
Merged

Embed quaint into prisma-engines #3905

merged 900 commits into from
Apr 25, 2023

Conversation

miguelff
Copy link
Contributor

@miguelff miguelff commented Apr 20, 2023

This PR:

  • embeds github.com/prisma/quaint into this repository's /quaint path, preserving quaint's history
  • sets up the test pipeline of quaint to trigger only when there are changes to /quaint/** or the PR is merged into main

Notes for reviewers:

  • /quaint is pulled from the git repository's main branch. You only need to focus on files outside that directory.

Julius de Bruijn and others added 30 commits September 12, 2020 08:10
- Postgres BYTEA
- SQLite datetime text format
- deserialize_bytes in serde module
All macros now test both versions. The tag for 5.7 is `mysql` and for 8
`mysql8`.
Adds support of Common Table Expressions (CTE). The starting point is
the `with` method of `Select`, allowing the user to add expressions to
the queries `WITH` block.

Additionally, on MSSQL queries if certain conditions apply, the query is
converted to use the CTEs:

- If comparing a tuple (a,b) against a selection of (SELECT x, y ..)
- ... and both sides have as many variables, more than one

Then a query where we do

```sql
SELECT * FROM X
WHERE (a, b) IN (SELECT x, y FROM ..)
```

converts into the following on SQL Server.

```sql
WITH cte_0 AS (SELECT x, y FROM ..)
WHERE a IN (SELECT x FROM cte_0 WHERE b = y)
```

This should work in every position of the query. The CTE is created to
the first selection when going up the tree, adding multiple CTEs if
having more than one tuple against select comparision, upping the index
of the `cte` by one.

Additionally, when comparing tuples, e.g. in a join context, we can
do in the open source database the following:

```sql
ON (a,b) = (x,y)
```

... but in MSSQL we convert it to:

```sql
ON a = x AND b = y
```

The same conversion applies to all tuple conversions in every position,
either when comparing equals `=` or not `<>`.
Deal with it by actually having a compatibility function in the visiors.
- Defaults to `dbo`
- Added to every query as an identifier
* Test and fix raw_cmd() on MySQL

The previous behaviour was to return errors only for the first
statement, without giving feedback on the success or failure of
subsequent statements. This would also leave the connection in an
invalid state for the next queries.

We now consume all result sets from the server response in `raw_cmd()`
on MySQL.

This commit also includes as part of the fix an upgrade to mysql_async
0.24.

* Use temporary tables in new tests

* rustfmt

* Move tests

* Run raw_cmd test on all connectors
This does not fix everything, far from it, but this is a start.
This allows referring to possibly-nonexistent tables
with their unqualified names in raw commands.

Co-authored-by: Lily Chung <[email protected]>
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 20, 2023

CodSpeed Performance Report

Merging #3905 quaint-embedding (3c7284f) will not alter performances.

Summary

🔥 0 improvements
❌ 0 regressions
✅ 6 untouched benchmarks

🆕 0 new benchmarks
⁉️ 0 dropped benchmarks

@miguelff miguelff added this to the 4.14.0 milestone Apr 20, 2023
@miguelff miguelff force-pushed the quaint-embedding branch 2 times, most recently from 2464cfd to f907d17 Compare April 24, 2023 11:43
* quaint/main: (800 commits)
  chore: move all files into quaint subdir
  fix: set search path via query when pgbouncer is on (#453)
  Revert "Back to mainline mysql-async: (#450)" (#451)
  feat(pg): optimize search_path network roundtrip (#448)
  Back to mainline mysql-async: (#450)
  tech-debt: use upstream mobc + small fixes (#438)
  Add to_vec to a value (#446)
  Revert search_path and client-encoding optimization (#445)
  fix(pg): quote schema path (#443)
  Revert "Cargo.toml: connection-string 0.10.0 -> 0.14.0 (#437)" (#442)
  perf(pg): remove one roundtrip on connection (#441)
  Move rust-postgres fork to Prisma (#440)
  Cargo.toml: connection-string 0.10.0 -> 0.14.0 (#437)
  Revert "Updating to the latest mysql_async (#433)" (#435)
  We don't need to use our fork of mysql anymore (#434)
  Updating to the latest mysql_async (#433)
  chore: bump tiberius to 0.11.6 (#432)
  Emit query log in quaint:query span, rather than in its parent (#431)
  feat(PostgreSQL): support channel_binding query param (#424)
  added missing #[cfg(feature = "uuid")] (#420)
  ...
   From: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-members-and-exclude-fields

    > All path dependencies residing in the workspace directory automatically become members. [...]

    The moment we embedded quaint in prisma-engines, their crates became workspace members, and thus compiled as part of the build of the workspace. Because one of the crates in quaint (test-macros) had a circular dependency with quaint, this time enabling the `serde_support` flag, cargo tried to compile quaint with that feature enabled as part of the workspace, causing the compilation error in the `sql-query-connector` crate that assumed the `serde_support` feature was not enabled.
@miguelff miguelff changed the title (draft) Quaint embedding - preserving history Embed quaint into prisma-engines Apr 24, 2023
@miguelff miguelff marked this pull request as ready for review April 24, 2023 12:42
@prisma prisma deleted a comment from CLAassistant Apr 24, 2023
@prisma prisma deleted a comment from CLAassistant Apr 24, 2023
@CLAassistant

This comment was marked as outdated.

Copy link
Contributor

@tomhoule tomhoule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nicely executed!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this on quaint main too? That looks like something that was potentially committed by mistake. We can merge and delete later too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, I don't know if by mistake also in quain yet. Will investigate and remove if that's the case!

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.