Skip to content

Queries items with list attribute type #3316

@nnnvinh

Description

@nnnvinh

Amplify Gen 2

Description

When I run queries like :

await client.models.Posts.list({
     filter : {
       post_tags : { contains : 't' }
     }
});

or

await client.models.Posts.list({
     filter : {
       post_tags : { beginsWith : 't' }
     }
});

It return empty data

{
  "data": {
    "listPosts": {
      "items": []
    }
  }
}

But when i run queries with exactly values in list attribute it return expected result

await client.models.Posts.list({
      filter : {
        post_tags : {contains : 'tag1'}
      }
});

returned data

{
  "data": {
    "listPosts": {
      "items": [
        {
          "post_id": "1"
        }
      ]
    }
  }
}

does it normal or a bug?

Database schema

 Posts : a.model({
   post_id : a.string().required(),
   post : a.string(),
   post_tags : a.string().array()
 }).identifier(['post_id'])

Example data to input

{
   post_id : "1",
   post : "post_exmaple",
   post_tags : ["tag1","tag2","tag3"]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions