How to query text[] column in Supabase? - supabase

I want to retrieve rows based on a value being present in text column defined as multidimensional array in Supabase
Table looks like following
I am trying to query this records using following urls
https://DATABASE_URL.supabase.co/rest/v1/test_db?data=in.({"1"})
https://DATABASE_URL.supabase.co/rest/v1/test_db?data=in.(1)
But doesnt seem to work. Error message was operator does not exist: text[] ~~ unknown
with hint being No operator matches the given name and argument types. You might need to add explicit type casts.
Any help will be appreciated!
Thanks in advance.

To filter by the values inside of an array, you can use the cs operator, which is equivalent to #> (contains) in PostgreSQL.
For instance, this query will retrieve all the rows that have the value "1" present in the array of the data column.
https://DATABASE_URL.supabase.co/rest/v1/test_db?data=cs.{"1"}

Related

How to search an array element in SurrealDB

I'm trying to perform a query that evaluates if an array includes or contains a specif value or set of values.
SELECT * FROM table
WHERE data = ['value_a']
https://surrealdb.com/docs/surrealql/statements/select
I've read the documentation and try several queries, but I didn't find any function or way to create this query.
I've read the official documentation and performed several queries based on the examples, but nothing have worked.
https://surrealdb.com/docs/surrealql/statements/select
My expected behaviour is:
Matches a specific value or set of values like these examples in SQL relational database.
https://www.w3schools.com/sql/sql_in.asp
There is a CONTAINS operator :
https://surrealdb.com/docs/surrealql/operators#contains
The Query should be like:
SELECT * FROM table WHERE data CONTAINS 'value_a'

Is there a way to query two indexes and join the result in Opensearch/ElasticSearch (Just like we do in RDBMS)

My requirement is
I have a deeply nested filter condition
Params from filter condition is located in two elastic search indexes
I need to pass the filter condition as query and get results which are joined by a field
The existing way is to use two indexes comma separated and searching but is supports only or - should condition. Reference : https://discuss.elastic.co/t/query-multiple-indexes-but-apply-queries-to-specific-index/127858
I need a way to support to and - must condition also.
Is there a possibility to do that? Thanks in Advance

how to get list of attributes from a JSONata query

I want to know for the given JSONata query how can we find out list of attributes with their path. Is there any any API/function to get some metadata about the query. For e.g. for the following query I want to find out the attribute name as "Account.Order.Product.Price" and "Account.Order.Product.Quantity"
$sum(Account.Order.Product.(Price * Quantity))
This may not be simple Regx or string parsing as query can contain functions & operators as well.
Atul

How to add distinct to filter expression in Defined Selector in Openbravo?

The filter expression which I am using now is,
"e.contract= '" +OB.getParameters().get('subscriptionId') + "'"
Here, e is the current table which is populated in 'Table' , and contract is the column there (In the POJO class) which stores the value of subscriptionId.
The issue is the attribute in the next level Defined Selector Field ,which I display a certain column exColumn has many rows [selected from the above expression] with same value.
Here , I intend to add a distinct in the filter expression or in the HQL [which doesn't seem to be filtering at run time] or in the Defined Selector Field, so that we don't display repeated values.
You cannot add distinct in a Filter Expression, which is used to restrict the results of the datasource.
You have 2 different options:
Define the selector based on a Custom Query and write there the HQL to retrieve the values. In this query you can have the distinct. As example you can check Business Partner not filtered by default by customer/vendor selector which is implemented in this way.
Base your selector on a Table from a view:
Create a database view with the base SQL query you need including the distinct.
Register it as an Application Dictionary Table
Base your selector on it

Query a table and only match rows where a field matches "STRING"

During prototyping I have imported a bunch of Facebook posts into a table in batches. After the first batch I did a bulk update to convert the "created_date" column from string to a native timestamp (using the handy r.ISO8601 function):
r.db('db').table('table').update({'created_date': r.ISO8601(r.row('created_date'))
On the second pass, when I try to repeat this update, the server throws an error because not all row fields are of type STRING (ie the ones previously converted), which is what ISO861 expects.
I've already tried to filter on r.row('created_date').typeOf() == "STRING" but got no matches. I can't find any other way to refer to the STRING type as an object rather than a literal string either.
I know that I could import these out and do the if/else logic in code, but I'm interested to understand if there's a native query that will filter out rows that match a certain type.
You have to use eq for comparing like this:
r.row('created_date').typeOf().eq("STRING")
Using == only works on some language support operator overrding.

Resources