-
Notifications
You must be signed in to change notification settings - Fork 69
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
Getting Parsing Error When Use Fetch with map[string]interface #40
Comments
Thanks! We will add a test for this. |
Can I take this up as discussed in Discord? Here's how I am looking to do this. Step 1: Write a test in |
Yes please @sbshah97 ! That is exactly what is needed |
Hi had some work, picking this back up |
Sorry for delay here to way to reproduce func (s *SurrealDBTestSuite) TestFetch() {
userSlice := []testUser{
{Username: "arthur", Personal: PersonalInfo{Name: "arthur", Surname: "morgan"}, Password: "deer", Friends: []string{"users:john"}},
}
for _, v := range userSlice {
data, err := s.db.Create(v.ID, v)
s.NoError(err)
s.NotNil(data)
}
for _, v := range userSlice {
res, err := s.db.Query("select * from $table fetch $fetchstr;", map[string]interface{}{
"record": v.ID,
"fetchstr": "friends.*",
})
// it will throw err
fmt.Println(res, err)
s.NoError(err)
s.NotNil(res)
}
} ElecTwix@6af3184#diff-842765a20a0a937a8eb5267b53fb11b7493cc6c2a6a8871e1da2b684702c5bc9R502 db_test.go:503:
Error Trace: /home/electwix/dev/go/surrealdb.go/db_test.go:503
Error: Received unexpected error:
sending request failed for method 'query': There was a problem with the database: Parse error: Failed to parse query at line 1 column 28 expected a idiom
1 | select * from $table fetch $fetchstr;
Test: TestSurrealDBSuite/gorilla/TestFetch to reproducejust clone the repo and run |
What is |
came from Update: It was my bad updated commit with ElecTwix@fde06eb |
From the looks of it issue here seems to be not being able to parse the fetch string. Just want to confirm if we are seeing this in other drivers or not ? cc: @timpratim @phughk ? If not probably will dive again in on this but from what I could see adding fmt statements till the end of the call stack, the query is being sent as correctly as possible. |
After reproducing the issue with SurrealQL, |
Hi Everyone,
I was selecting the record and fetching it is the field record link with the fetch keyword
but when I try to use it with the parameter it gives
There was a problem with the database: Parse error when parsing 'fetch $fetchstr'
this error I checkout the source code this line JSON Marshaling giving the error.
Also, I tried with not safe method string merge ( fmt.sprintf ) and added my string at the end it worked that way.
Am I doing something wrong?
if that's the case please let me know.
The Code I'm trying to fetch
UPDATE:
for clear out
The problem I was facing was:
After the FETCH statement, arguments are no longer parsed.
Example:
select * from $table FETCH $fetchstr;
$table will parse but $fetchstr will not parse
The text was updated successfully, but these errors were encountered: