Fix error when searching posts by Link attribute

* Make sure we have the correct table name from the Post_Link object
* Add test to search by link attribute
Return main SQL query in JSON from /posts (if not in production)
Make sure subquery aliases are unique when searching posts attributes

Use attribute key not attribute type.