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

[FEATURE]: Predicates i18n for unique fields #9105

Open
AoAnima opened this issue Jun 25, 2024 · 0 comments
Open

[FEATURE]: Predicates i18n for unique fields #9105

AoAnima opened this issue Jun 25, 2024 · 0 comments
Labels
kind/feature Something completely new we should consider.

Comments

@AoAnima
Copy link

AoAnima commented Jun 25, 2024

Use case

When using i18n predicates, such as those in Cyrillic, for unique fields, these predicates are added without <> in the addQueryIfUnique function, leading to a query error.

I propose adding the following code to dgraph/graph/server.go at line 1744 before
if !strings.HasPrefix(pred.ObjectId, "val("){....}

such a code

if !isLatinString(predicateName) {
				predicateName = fmt.Sprintf(`<%v>`, predicateName)
}
func isLatinString(s string) bool {
	for _, r := range s {
		if !unicode.IsLetter(r) || !unicode.Is(unicode.Latin, r) {
			return false
		}
	}
	return true
}
func addQueryIfUnique(qc *queryContext) error {
...

                      if !isLatinString(predicateName) {
				predicateName = fmt.Sprintf(`<%v>`, predicateName)
			}
			if !strings.HasPrefix(pred.ObjectId, "val(") { 
                              ....
                        }

}

Links to Discuss, RFC or previous Issues and PRs

No response

Links to examples and research

No response

Current state

No response

Solution proposal

No response

Additional Information

No response

@AoAnima AoAnima added the kind/feature Something completely new we should consider. label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Something completely new we should consider.
Development

No branches or pull requests

1 participant