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

fix(sqlite): enable foreign keys for sqlite #98

Merged

Conversation

ecordell
Copy link
Member

Description of the change:
Foreign key constraints were not being enforced - thanks @gallettilance for finding this issue!

There were a couple of problems with the foreign keys that are fixed in this PR

Motivation for the change:
We want to rely on sqlite's enforcement of foreign keys so that we don't need to enforce them ourselves.

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

Sorry, something went wrong.

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 12, 2019
@@ -35,7 +35,7 @@ func NewSQLLiteLoader(outFilename string) (*SQLLoader, error) {
CREATE TABLE IF NOT EXISTS package (
name TEXT PRIMARY KEY,
default_channel TEXT,
FOREIGN KEY(default_channel) REFERENCES channel(name)
FOREIGN KEY(name, default_channel) REFERENCES channel(package_name,name)
Copy link
Member Author

Choose a reason for hiding this comment

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

referencing a field that's part of a compound primary key requires referencing the full primary key - this was the main issue.

@@ -53,9 +53,7 @@ func NewSQLLiteLoader(outFilename string) (*SQLLoader, error) {
replaces INTEGER,
depth INTEGER,
FOREIGN KEY(replaces) REFERENCES channel_entry(entry_id) DEFERRABLE INITIALLY DEFERRED,
FOREIGN KEY(channel_name) REFERENCES channel(name),
FOREIGN KEY(package_name) REFERENCES channel(package_name),
FOREIGN KEY(operatorbundle_name) REFERENCES operatorbundle(name)
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to remove the foreign key to operator_bundle, since synthesized channel entries for skiped releases may not have a corresponding bundle.

@ecordell ecordell mentioned this pull request Oct 12, 2019
5 tasks
@njhale
Copy link
Member

njhale commented Oct 14, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ecordell, gallettilance, njhale

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit b6b79d0 into operator-framework:master Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants