@@ -7,6 +7,7 @@ package worker
77
88import (
99 "context"
10+ "fmt"
1011 "math/rand"
1112 "os"
1213 "testing"
@@ -133,6 +134,61 @@ func TestDatetime(t *testing.T) {
133134
134135}
135136
137+ func TestStringIndexWithLang (t * testing.T ) {
138+ // Setup temporary directory for Badger DB
139+ dir , err := os .MkdirTemp ("" , "storetest_" )
140+ require .NoError (t , err )
141+ defer os .RemoveAll (dir )
142+
143+ opt := badger .DefaultOptions (dir )
144+ ps , err := badger .OpenManaged (opt )
145+ require .NoError (t , err )
146+ posting .Init (ps , 0 , false )
147+ Init (ps )
148+
149+ // Set schema
150+ schemaTxt := `
151+ name: string @index(fulltext, trigram, term, exact) @lang .
152+ `
153+
154+ err = schema .ParseBytes ([]byte (schemaTxt ), 1 )
155+ require .NoError (t , err )
156+
157+ ctx := context .Background ()
158+ newRunMutation := func (startTs , commitTs uint64 , edges []* pb.DirectedEdge ) {
159+ txn := posting .Oracle ().RegisterStartTs (startTs )
160+ for _ , edge := range edges {
161+ require .NoError (t , newRunMutation (ctx , edge , txn ))
162+ }
163+ txn .Update ()
164+ writer := posting .NewTxnWriter (ps )
165+ require .NoError (t , txn .CommitToDisk (writer , commitTs ))
166+ require .NoError (t , writer .Flush ())
167+ txn .UpdateCachedKeys (commitTs )
168+ }
169+
170+ attr := x .AttrInRootNamespace ("name" )
171+
172+ newRunMutation (1 , 3 , []* pb.DirectedEdge {
173+ {
174+ Entity : 1 ,
175+ Attr : attr ,
176+ Value : []byte ("John" ),
177+ ValueType : pb .Posting_DEFAULT ,
178+ Lang : "en" ,
179+ Op : pb .DirectedEdge_SET ,
180+ },
181+ })
182+
183+ key := x .DataKey (attr , 1 )
184+ txnRead := posting .Oracle ().RegisterStartTs (10 )
185+
186+ list , err := txnRead .Get (key )
187+ require .NoError (t , err )
188+
189+ fmt.Println (list .GetLangTags ()
190+ }
191+
136192func TestDeleteSetWithVarEdgeCorruptsData (t * testing.T ) {
137193 // Setup temporary directory for Badger DB
138194 dir , err := os .MkdirTemp ("" , "storetest_" )
0 commit comments