Closed nmcharlton closed 2 years ago
@bstetzer32 Would you mind looking at this one?
Fix reverted – see #612
I think this issue requires the specification of which column names( necessary to return and distinct)
SELECT DISTINCT id, (other column names) FROM ...
Though actually, it seems to me that the below solution (which was reverted) should work.
const columnNames = this.dataSource.connector
.buildColumnNames('Trees', filter)
.replace('"id"', 'trees.id as "id"');
const selectStmt = `SELECT DISTINCT ${columnNames} from trees ${this.getTreeTagJoinClause(
tagId,
)}`;
OR use of the DISTINCT ON clause.
https://www.postgresql.org/docs/current/sql-select.html https://www.geekytidbits.com/postgres-distinct-on/
Passing the following query to GET /trees returns duplicate records:
Trees (captures) appear to be included once per tag that they have applied, e.g., a tree with three tags appears three times in the results.