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

How to query a key that has ":" in the dictionary #2027

Closed
Prabhanjali opened this issue Apr 18, 2024 · 5 comments
Closed

How to query a key that has ":" in the dictionary #2027

Prabhanjali opened this issue Apr 18, 2024 · 5 comments

Comments

@Prabhanjali
Copy link

Summary

Suppose I have my data as below

{
    "col1" : "firstcolumn",
    "col2" : "secondcolumn",
    "col3" : {
	 "abc:text" : "environment",
	 "cde"      : "hello"
    }
}

Now if I want to filter the rows that has cde as key and value hello, I can use the below query

query{
    table(filter : {col3 : {contains : {cde : "hello"}}}){
	nodes{
	    col2,
	    col1
	}
    }
}

How to query if I want to get the rows where the key is having a colon (:) in it?
Ex: How to query if I need to get the rows that has abc:text as key and value is environment?

Additional context

@benjie
Copy link
Member

benjie commented Apr 18, 2024

A GraphQL Name cannot contain a : so this cannot occur.

@benjie benjie closed this as completed Apr 18, 2024
@Prabhanjali
Copy link
Author

But, I have a key named as cde:tag1 and its value is value1. Can't I filter based on this?

@benjie
Copy link
Member

benjie commented Apr 19, 2024

A key in what? Do you mean a column in your database? Or a key in a JSON object? Or...?

@Prabhanjali
Copy link
Author

A key in JSON Object

@benjie
Copy link
Member

benjie commented Apr 19, 2024

We don't have any built in functionality for querying JSON fields; use makeAddPgTableConditionPlugin or similar to make your own filter however you want (or use a database function).

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

No branches or pull requests

2 participants