Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.15
version: 1.24.0

# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.6.8
ref: v1.7.0
uri: https://github.com/trunk-io/plugins

# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- [email protected]
- node@18.20.5
- node@22.16.0
- [email protected]

# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
Expand All @@ -27,22 +27,22 @@ lint:
- protos/pb/pb.pb.go
enabled:
- [email protected]
- trivy@0.62.1
- trivy@0.63.0
- [email protected]
- [email protected].421
- [email protected].442
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- markdownlint@0.44.0
- [email protected].2
- markdownlint@0.45.0
- [email protected].3
- [email protected]
- [email protected]
- renovate@40.0.6
- renovate@40.57.1
- [email protected]
- [email protected]
- tflint@0.57.0
- trufflehog@3.88.29
- tflint@0.58.0
- trufflehog@3.89.1
- [email protected]
actions:
enabled:
Expand Down
20 changes: 20 additions & 0 deletions dgraph/cmd/alpha/upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2998,3 +2998,23 @@ func TestLargeStringIndex(t *testing.T) {
require.Contains(t, dqlSchema,
`{"predicate":"name_term","type":"string","index":true,"tokenizer":["term"]}`)
}

func TestStringWithQuote(t *testing.T) {
require.NoError(t, dropAll())
require.NoError(t, alterSchemaWithRetry(`name: string @unique @index(exact) .`))
mu := `{ set { <0x01> <name> "\"problem\" is the quotes (json)" . } }`
require.NoError(t, runMutation(mu))

var data struct {
Data struct {
Q []struct {
Name string `json:"name"`
} `json:"q"`
} `json:"data"`
}
q := `{ q(func: has(name)) { name } }`
res, _, err := queryWithTs(queryInp{body: q, typ: "application/dql"})
require.NoError(t, err)
require.NoError(t, json.Unmarshal([]byte(res), &data))
require.Equal(t, `"problem" is the quotes (json)`, data.Data.Q[0].Name)
}
4 changes: 2 additions & 2 deletions edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1746,8 +1746,8 @@ func addQueryIfUnique(qctx context.Context, qc *queryContext) error {
// in the mutation, then we reject the mutation.

if !strings.HasPrefix(pred.ObjectId, "val(") {
query := fmt.Sprintf(`%v as var(func: eq(%v,"%v"))`, queryVar, predicateName,
dql.TypeValFrom(pred.ObjectValue).Value)
val := strconv.Quote(fmt.Sprintf("%v", dql.TypeValFrom(pred.ObjectValue).Value))
query := fmt.Sprintf(`%v as var(func: eq(%v,"%v"))`, queryVar, predicateName, val[1:len(val)-1])
if _, err := buildQuery.WriteString(query); err != nil {
return errors.Wrapf(err, "error while writing string")
}
Expand Down