loopback-next icon indicating copy to clipboard operation
loopback-next copied to clipboard

Filter by the concatenation of two columns

Open A-Corregidor opened this issue 3 years ago • 5 comments

Suggestion

It would be nice to be able to filter a Model by the concatenation of two columns. I mean, to be able to replicate this type of SQL query:

SELECT * FROM User WHERE CONCAT(name, ' ', lastName) LIKE '%PARTIAL FULLNAME%'

Use Cases

The most common example is filtering a User model by its full name when it's stored in two columns (name, lastName). Currently, the only way this is possible (AFAIK) is by sending the RAW query, which makes it almost incompatible with adding more filters.

Examples

Table example:

id name lastName
1 Jackson Bell
2 Sarah Parker
3 Mason Brown

Example of one (possible) implementation of filter object:

{
  "limit": 10,
  "offset": 0,
  "where": {
    "leavingDate": null,
    "concat": {
      "eq": "%on B%",
      "separator": " ",
      "columns": [
        "name",
        "lastName"
      ]
    }
  }
}

Should return:

id name lastName
1 Jackson Bell
3 Mason Brown

Acceptance criteria

TBD - will be filled by the team.

A-Corregidor avatar Nov 25 '20 12:11 A-Corregidor

Thank you for the suggestion! This would be a big feature that involve changes in all the supported SQL/NoSQL connectors. First we need to agree on the signature, like you suggested using concat, then each connector builds the query accordingly.

jannyHou avatar Nov 30 '20 01:11 jannyHou

At a glance, I think the preceding feature we need to implement is referencing other values within the same model (e.g. Model.propA == Model.propB). From there, we can build on top of that feature to create more complex intra-model property comparators.

achrinza avatar Dec 23 '20 14:12 achrinza

This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

stale[bot] avatar Jul 14 '21 04:07 stale[bot]

Any news on this?

Habbiton avatar Dec 16 '21 14:12 Habbiton

@Habbiton This feature isn't being actively worked on at the moment.

achrinza avatar Dec 16 '21 15:12 achrinza

Hi @achrinza ! It's been 2 years, any news? Is it scheduled to be resolved?

A-Corregidor avatar Dec 09 '22 08:12 A-Corregidor