Querying record with includes operator

Certified Senior Developer

Dear Team,

We have a column in DB say file_number which have text values example 1;12 , 12;32

We are trying to query records where file_number is "1" using includes operator. With includes in query it is getting all the records which have 1 (1,12,13). We want the search to match exact to 1 only .

Any suggestion ? One suggestion we have is to add a character when writing in DB like @1@;@12@ , and when searching pass @1@.

  Discussion posts and replies are publicly visible

  • Hi,

    Consider design approach to normalize the data by creating a separate one to many relationship or many to many relationship, as applicable, for storing file numbers in a separte table. This would allow you to create a view or Sync Record relationship that joins the main table with the table storing file numbers, and allow you to query based on exact file numbers using the '=' (equals) operator. 

  • 0
    Certified Senior Developer
    8 months ago

    The below piece of code should work, provided that the array is always sorted. 

    a!queryLogicalExpression(
      operator: "OR",
      filters: {
        a!queryFilter(
          field: "file_number",
          operator: "includes",
          value: "1,"
        ),
        a!queryFilter(
          field: "file_number",
          operator: "=",
          value: "1"
        )
      }
    )