Filter in a GET request not working for more than one parameter


#1

Hi!

I have one service that connects to a MySQL database, and I want to fetch records using a filter with two fields. Basically, I’m doing the request like this:

http://dsp_url/api/v2/service/_table/tablename?filter=[field1='value1' AND field2='value2']
(I’m using test_rest.html utility, that’s why I’m using brackets here)

This request returns exatly one record, which is what I want. The problem is when I execute the same request to my second DF instance: it returns no record at all!

Lets say the instance A is where this request works, and intance B where it returns no records.

In the instance B, when I use no filter I get all the records. When I specify only one field in the filter the result is ok (the filter is appropriately applied). But when I add the second parameter I get no records in the response. If I use swagger using the very same credentials, the result is the same.

I took some desperate measures :sweat:: the instance B connecting to the same database as instance A - the result is the same. I installed a brand new instance of DF on AWS and configured everything again, and the result is the same. I checked the logs and no error is reported (neither in DF logs or Nginx logs).

If I connect to the database served by instance B using mysql command line utility, I’m able to select the desired record using the appropriate SQL statement (SELECT * FROM tablename WHERE field1 = 'value1' AND field2 = 'value2')

Both DF instances are on 2.0.4.

Honestly I don’t know what else to check for error. Any ideas will be much appreciated.

Thanks in advance!

Elvis Fernandes


#2

Problem fixed. The problem were the missing parenthesis. Here is the correct query:

http://dsp_url/api/v2/service/_table/tablename?filter=(field1%3D'value1')%20AND%20(field2%3D'value2')

The clue came from here: Service Type list missing after update to 2.04/ admin 2.06

Considering the need for parenthesis were added on 2.0.4, I got one intriguing question on top of my head: instance B were installed using an AWS Bitnami image, already running 2.0.4. Intance A (were the query worked without parenthesis) were updated from 2.0.3 to 2.0.4 a while ago. Could this be some problem during the upgrade process that made this instance run the query without parenthesis even though it was running DF 2.0.4?


#3

Shooting in the dark here, but best guess is that your upgraded instance isn’t really fully upgraded. Check your vendor/dreamfactory/df-sqldb and vendor/dreamfactory/df-core directories. The changelog files should match for both your 2.0.4 image, and the instance upgraded from 2.0.3 to 2.0.4. If they don’t match then your instance didn’t successfully complete the upgrade. You’ll need to rerun the composer install and subsequent steps of the upgrade process, ensuring that you troubleshoot any errors that pop up.


#4

I use you fixing method. Thanks a lot.


#5

Hi,

like filter not working in my dreamfactory. I was give my filtering section like,

http://52.23.226.68/api/v2/hotfuse_webservice/_table/users?filter=username%20like%20h%

Response Body:
{
“resource”: []
}

But if I Give like

http://52.36.182.60/api/v2/hotfuse_webservice/_table/users?filter=username%3Dharry

which give output like:

Response Body:
{
“resource”: [
"_id": “5720f6c8342c2efe01b4af35”,
“username”: “harry”,
]
}

Than why like is not working.please give a solution.???

Waiting for your response

Cheers


#6

I tested this on a DreamFactory 2.2.0 instance with SQLite and MySQL and it seems to be working properly. What version of DreamFactory are you running and what type of database are you connecting to?


#7

Hi todd,

I am using [ api version: 2.0 ], and I was connect Mongo DB


#8

GET test/_table/{table_name} /////////////// getHotfuseWebRecords() - Retrieve one or more records.

Order of parameter getting different in same version(dreamfactory) but different hosting(is there any issue).

Here I attach screenshot.

HOST 1:

HOST2:

HOST2 working perfectly with same filter queries.
HOST1 Not giving perfect answer.

Still I love your product…!:slight_smile:


#9

These look like they belong to two separate API calls, not the same call.


#10

Like filter not working in v2.1.6 and above in Dreamfactory.

Is there any solution for it??


#11

Closing this thread. The discussion has moved to Is there support for filtering WHERE x LIKE y?


#12