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

One-many self joins fail without explicit @primary directive #2620

Closed
AndrewSisley opened this issue May 14, 2024 · 1 comment · Fixed by #2799
Closed

One-many self joins fail without explicit @primary directive #2620

AndrewSisley opened this issue May 14, 2024 · 1 comment · Fixed by #2799
Assignees
Labels
area/schema Related to the schema system bug Something isn't working
Milestone

Comments

@AndrewSisley
Copy link
Contributor

AndrewSisley commented May 14, 2024

For example, this SDL works:

type User {
  boss: User @primary
  minions: [User]
}

However, this returns an error:

type User {
  boss: User
  minions: [User]
}

relation missing field. Object: User, RelationName: user_user. Stack: /home/andy/Projects/Source/defradb/internal/db/errors.go:620 (0x1c13b7d)
NewErrRelationMissingField: return errors.New(
/home/andy/Projects/Source/defradb/internal/db/collection.go:760 (0x1bfc8d8)
validateSecondaryFieldsPairUp: return NewErrRelationMissingField(underlying, field.RelationName.Value())
/home/andy/Projects/Source/defradb/internal/db/collection.go:683 (0x1bf7e5b)

Note: one-ones are fine, as they have to be declared with an @primary directive on one side anyway.

@AndrewSisley AndrewSisley added bug Something isn't working area/schema Related to the schema system labels May 14, 2024
@AndrewSisley
Copy link
Contributor Author

AndrewSisley commented Jun 28, 2024

Bizarrely, the below appears to work fine:

type User {
  name: User
  dogs: [User]
}

So does:

type User {
  boss: User
  aminions: [User]
}

Suggesting that the field name (and thus field order) may have an impact on this issue

@AndrewSisley AndrewSisley self-assigned this Jun 28, 2024
@AndrewSisley AndrewSisley added this to the DefraDB v0.12 milestone Jun 28, 2024
AndrewSisley added a commit that referenced this issue Jun 28, 2024
## Relevant issue(s)

Resolves #2620

## Description

Support one-many self joins without primary directive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/schema Related to the schema system bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant