Refetch sql query LIKE #236

Closed
opened 2025-12-29 18:24:42 +01:00 by adam · 3 comments
Owner

Originally created by @dufflink on GitHub (Oct 21, 2018).

Hi
I have a problem.
allChats.refetch([OrderBy<ChatsData>(.descending(\.time)), Where<ChatsData>("title LIKE '%a%' ")])
This request should return to me all objects of class ChatsData, whose name contains the character 'a'. But he doesn't do it.

Originally created by @dufflink on GitHub (Oct 21, 2018). Hi I have a problem. `allChats.refetch([OrderBy<ChatsData>(.descending(\.time)), Where<ChatsData>("title LIKE '%a%' ")])` This request should return to me all objects of class ChatsData, whose name contains the character 'a'. But he doesn't do it.
adam added the question label 2025-12-29 18:24:42 +01:00
adam closed this issue 2025-12-29 18:24:42 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Oct 22, 2018):

CoreStore still runs with NSPredicates in the back, so I think what you're looking for is the CONTAINS operation: https://stackoverflow.com/a/2741046

@JohnEstropia commented on GitHub (Oct 22, 2018): CoreStore still runs with `NSPredicate`s in the back, so I think what you're looking for is the `CONTAINS` operation: https://stackoverflow.com/a/2741046
Author
Owner

@dufflink commented on GitHub (Oct 22, 2018):

Thank you very much! This code work for me

let predicate = NSPredicate(format: "title CONTAINS[cd] %@", searchText.lowercased())
allChats.refetch([OrderBy<ChatsData>(.descending(\.time)), Where<ChatsData>(predicate)])

@dufflink commented on GitHub (Oct 22, 2018): Thank you very much! This code work for me ` let predicate = NSPredicate(format: "title CONTAINS[cd] %@", searchText.lowercased()) ` ` allChats.refetch([OrderBy<ChatsData>(.descending(\.time)), Where<ChatsData>(predicate)])`
Author
Owner

@JohnEstropia commented on GitHub (Oct 22, 2018):

👍

@JohnEstropia commented on GitHub (Oct 22, 2018): 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#236