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

use surreal variable into query #18

Open
josselinchevalay opened this issue Sep 19, 2024 · 9 comments
Open

use surreal variable into query #18

josselinchevalay opened this issue Sep 19, 2024 · 9 comments

Comments

@josselinchevalay
Copy link

josselinchevalay commented Sep 19, 2024

Hello,

i need to create a complex request with variable and if also:

LET $name="john";
 SELECT salary FROM employee WHERE name ~ $name

into surreal db LET / IF statements exists LET statement / if statement

but if i use my example query on section explore of grafana with surreal db source i don,t see anything

do you have an idea ?

@ppaulweber
Copy link
Member

Hi @josselinchevalay, did you check the logs in the data query view? Or are there any error messages in the web console to provide more context to this issue? Thx 🙏

@josselinchevalay
Copy link
Author

sure here you can see explore test

image

same request into explore with inspect console open :

image

on grafan server i don,t see any error

but this request on my surreal db respond 2081 lines

i don't understand. Maybe grafana respond directly after the LET STATEMENTS and not return the result of my seconds request

@josselinchevalay
Copy link
Author

josselinchevalay commented Sep 19, 2024

qucik update i use http cli like postman when i execute my script :

LET $name="ADMIN";
SELECT jobName FROM builds WHERE jobName ~ $name;

i receive it

[
  {
    "result": null,
    "status": "OK",
    "time": "34.68µs"
  },
 {
    "result": [......],
    "status": "OK",
    "time": "34.68µs"
  }
]

so i think by default we use only je first occurence of respond object but here we need to use the second

@ppaulweber
Copy link
Member

Ah I see, yes makes sense ... so maybe we could consider in the plugin only to evaluate/return the last result set.

Would be a rather small insertion into the code base. Are you by change familiar with golang and do want maybe to make your first contribution in this effort? 😃

@josselinchevalay
Copy link
Author

helas, i'm not too golang developer i suppose the change is in datasource.go or something in this taste but locally i donn't have tools to develop under golang

@josselinchevalay
Copy link
Author

josselinchevalay commented Sep 19, 2024

or better into

dataMap, ok := array[0].(map[string]interface{})

i guess

josselinchevalay added a commit to josselinchevalay/grafana.surrealdb that referenced this issue Sep 19, 2024
When we have a request with IF and LET statements get last result elements fiskaly#18
@josselinchevalay
Copy link
Author

let me know is ok for you

@coutouly
Copy link

coutouly commented Oct 7, 2024

did you upgrade to surrealdb v2 ?

@josselinchevalay
Copy link
Author

@coutouly i tested with v2 of surreal i continue to have an array where each line of my script return an json line of this array with result etc is more link how we consume this array of response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants