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 unique index definitions #12

Merged
merged 2 commits into from
Jun 10, 2024
Merged

Conversation

jhoward-lm
Copy link
Contributor

@jhoward-lm jhoward-lm commented Jun 9, 2024

This PR contains fixes for schema unique index definitions and Document relations.

Document

  • Use Metadata.ID string as ID
  • Set Document as owner of its NodeList and Metadata edges (reverse edge.To() and edge.From() definitions in schemas)
  • Store document ID (which is now Metadata.ID) as a field in NodeList schema

ExternalReference

  • Fix unique index to include URL and Type fields

NodeList

  • Fix unique index to include DocumentID field

Miscellaneous

  • Fix backend debug option (client was nil at the time of calling its Debug() method)

Signed-off-by: Jonathan Howard <[email protected]>
@jhoward-lm
Copy link
Contributor Author

@eddiezane @houdini91 @cpanato requesting review, I couldn't add to the reviewers directly

All changes are auto-generated except:

  • internal/backends/ent/schema/*.go
  • backends/ent/store.go
  • backends/ent/backend.go
  • Makefile

Copy link
Member

@puerco puerco left a comment

Choose a reason for hiding this comment

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

One non-blocking question but looks good to me

@@ -77,7 +77,6 @@ func (backend *Backend) CloseClient() {

func (backend *Backend) Debug() *Backend {
backend.Options.Debug = true
backend.client.Debug()
Copy link
Member

Choose a reason for hiding this comment

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

Is this breaking something with the client? or why would we not want to debug the client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, at this point, client isn't initialized yet. It just sets the debug flag in the options, then in InitClient() this gets run:

	clientOpts := []ent.Option{}
	if backend.Options.Debug {
		clientOpts = append(clientOpts, ent.Debug())
	}

	client, err := ent.Open("sqlite3", backend.Options.DatabaseFile+dsnParams, clientOpts...)

@puerco puerco merged commit 32a66cb into protobom:main Jun 10, 2024
1 check passed
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.

2 participants