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

Exclude constraints are PG only, lighten up the api #3887

Merged

Conversation

pimeys
Copy link
Contributor

@pimeys pimeys commented Apr 17, 2023

What we do here:

  • The get_constraints is now a top level call, we don't need to do it in the get_table_names.
  • Storing exclude constraint to pg_ext
  • Use simpler vectors for constraint data
  • Split the postgres tests into separate files

@pimeys pimeys requested a review from a team as a code owner April 17, 2023 14:41
@pimeys pimeys added this to the 4.14.0 milestone Apr 17, 2023
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 17, 2023

CodSpeed Performance Report

Merging #3887 alberto/constraint-fixes (214d031) will not alter performances.

Summary

🔥 0 improvements
❌ 0 regressions
✅ 6 untouched benchmarks

🆕 0 new benchmarks
⁉️ 0 dropped benchmarks

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.

nice, cleaner

@jkomyno jkomyno merged commit b9af982 into feat/postgres-check-constraints-stopgap Apr 17, 2023
@jkomyno jkomyno deleted the alberto/constraint-fixes branch April 17, 2023 17:09
jkomyno added a commit that referenced this pull request Apr 19, 2023
…stgres (#3860)

* feat(schema-engine): add constraints_query.sql for postgres

* feat(schema-engine): add check and exclusion constraints stopgap support for postgres

* feat(schema-engine): add skeleton for stopgap warnings for check and exclusion constraints in postgres

* feat(schema-engine): emit warnings when finding check and exclusion constraints when introspecting postgres

* chore: remove comments

* chore: remove dbg

* test(schema-engine): add missing defaults in describer tests

* chore: update warning messages so that they make more sense

* feat(schema-engine): updated check and exclusion constraints warning messages

* test(schema-engine): validate introspected schemas for check and exclusion constraints

* feat(schema-engine): introspecting models with check or exclusion constraints now adds a comment to such models

* feat(schema-engine): fix edge case of model having both check and exclusion constraints

* feat(schema-engine): fix prisma/prisma#17515

* chore: remove dead code

* chore: fix conflicts

* fix: avoid duplicated model commments upon reintrospection

* feat(schema-engine): use ModelAndConstraint rather than CheckConstraint and ExclusionConstraint

* feat(schema-engine): replace IndexMap with BTreeMap for leaner flag "upsert" capabilities

* chore: add TODO to answer Tom's review comment

* Exclude constraints are PG only, lighten up the api (#3887)

* Exclude constraints are PG only, lighten up the api

* Split constraint tests into its own file

* Fix describer tests

* feat(schema-engine): apply review comments

---------

Co-authored-by: Julius de Bruijn <julius+github@nauk.io>
Comment on lines +126 to +133
/// The check constraint names for the table.
pub fn check_constraints(self) -> impl ExactSizeIterator<Item = &'a str> {
let low = self.schema.check_constraints.partition_point(|(id, _)| *id < self.id);
let high = self.schema.check_constraints[low..].partition_point(|(id, _)| *id <= self.id);

self.schema.check_constraints[low..high]
.iter()
.map(|(_, name)| name.as_str())
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: this has caused dramatic issues in introspection-ci.

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.

3 participants