# API docs getRecords() gives error with 'related'

**URL:** <https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127>\
**Category:** REST API\
**Created:** [May 23, 2015, 6:21am UTC](https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127 "2015-05-23T06:21:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![praveen](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@praveen](https://community.dreamfactory.com/u/praveen)\
**Post date:** [May 23, 2015, 6:21am UTC](https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127/1 "2015-05-23T06:21:23Z")

</div>

I have a table Establishment, and I also have couple of related tables, which I want to fetch on the basis of id field in Establishment.  
id of establishment is the foreign key of the other related tables.

The error I get is as below in API Docs when I just enter related=\*  
The getRecords works fine without \* in related.

{  
“error”: [  
{  
“context”: null,  
“message”: “Failed to retrieve records from ‘establishment’.\nCDbCommand failed to execute the SQL statement: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near “)”\nLINE 3: WHERE “id” IN () LIMIT 1000\n ^”,  
“code”: 500  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [May 26, 2015, 2:55pm UTC](https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127/2 "2015-05-26T14:55:19Z")

</div>

Could you post the full query? The error does not appear to be related to the related=\* parameter.

---

<div class="post-metadata">

**Author:** ![praveen](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@praveen](https://community.dreamfactory.com/u/praveen)\
**Post date:** [May 27, 2015, 6:59pm UTC](https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127/3 "2015-05-27T18:59:26Z")

</div>

@jeffreystables  
There is no query.

Its just that when I add \* in the related, I see the error, other wise I do not.  
I am using this in the API DOCs, not sure what are you looking for in query.

Its simple getRecords with table name as ‘establishment’. and \* in related

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [May 27, 2015, 7:17pm UTC](https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127/4 "2015-05-27T19:17:34Z")

</div>

Thank you, so the query is something like `http://localhost:8080/rest/db/table?related=*`

I have tested this in DSP 1.9.2 with a MySQL DB connection, and can `GET /db/{table_name} getRecordsByFilter()` with `related=*` from API Docs without seeing this error. Can you provide some more details on how your environment might be different from mine? I recommend trying the same query from a MySQL client to ensure that it’s the DSP and not the DB that’s causing the error.

---

<div class="post-metadata">

**Author:** ![praveen](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@praveen](https://community.dreamfactory.com/u/praveen)\
**Post date:** [May 27, 2015, 7:31pm UTC](https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127/5 "2015-05-27T19:31:17Z")

</div>

Ok @jeffreystables  
Let me try and paste the SQL to you which gives an error, as the error only comes sometimes with some \* related tables, and not with all.

So it could be due to some data or otherwise with some configuration.  
Whatever the issue is since the data is very well getting inserted into the DB, so I guess it should also get shown with DSP’s get records without giving error.

let me try and send you some simple table and data which will reproduce the issue for you.  
I use PGSQL by the way. Not sure if that could be the issue.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [June 2, 2015, 2:31pm UTC](https://community.dreamfactory.com/t/api-docs-getrecords-gives-error-with-related/1127/6 "2015-06-02T14:31:13Z")

</div>

> [@praveen](#):
>
> I use PGSQL by the way.

Thank you for this information. We have tested with PostgreSQL on 1.9.2 and also see no errors or issues with a query like `http://localhost:8080/rest/db/table?related=*`.
