amplify-swift icon indicating copy to clipboard operation
amplify-swift copied to clipboard

QueryField should support notContains operator

Open richardmcclellan opened this issue 4 years ago • 2 comments

This documentation indicates that DataStore supports the notContains operator, but it does not appear to be implemented in the library.

On amplify-js, It appears to be supported.

On Android, it is not supported, currently. A customer reported this missing functionality, here. Support is being added for Android in https://github.com/aws-amplify/amplify-android/pull/1145/

richardmcclellan avatar Feb 01 '21 18:02 richardmcclellan

Hi @richardmcclellan, thanks for opening the issue

What does the SQL look like? I couldn't decipher exactly from the Android PR. Is it "NOT LIKE"? select * from table_name where table_column_name NOT LIKE '%1%' SO ref

What does the AppSync operator look like? this one looks simply as notContains

lawmicha avatar Feb 03 '21 22:02 lawmicha

What does the SQL look like?

The SQL for contains is: select * from table_name where instr(table_column_name,?) > 0

I believe LIKE could be used instead of instr? The performance of the two appears to be about the same. But, given that we were already using instr for contains, I chose to add support for notContains with a similar SQL command:

select * from table_name where instr(table_column_name,?) = 0

What does the AppSync operator look like? this one looks simply as notContains

Correct, it is notContains.

richardmcclellan avatar Feb 03 '21 22:02 richardmcclellan

Working implementation for strings, but still early exploratory phase. https://github.com/aws-amplify/amplify-swift/pull/2789

atierian avatar Mar 04 '23 02:03 atierian