Replace full text search with pattern matching
This commit is contained in:
@@ -6,13 +6,12 @@ import gq.kirmanak.mealient.database.recipe.RecipeDao
|
||||
import gq.kirmanak.mealient.database.recipe.entity.*
|
||||
|
||||
@Database(
|
||||
version = 7,
|
||||
version = 6,
|
||||
entities = [
|
||||
RecipeSummaryEntity::class,
|
||||
RecipeEntity::class,
|
||||
RecipeIngredientEntity::class,
|
||||
RecipeInstructionEntity::class,
|
||||
RecipeSummaryFtsEntity::class,
|
||||
],
|
||||
exportSchema = true,
|
||||
autoMigrations = [
|
||||
@@ -20,7 +19,6 @@ import gq.kirmanak.mealient.database.recipe.entity.*
|
||||
AutoMigration(from = 3, to = 4),
|
||||
AutoMigration(from = 4, to = 5, spec = AppDb.From4To5Migration::class),
|
||||
AutoMigration(from = 5, to = 6, spec = AppDb.From5To6Migration::class),
|
||||
AutoMigration(from = 6, to = 7),
|
||||
]
|
||||
)
|
||||
@TypeConverters(RoomTypeConverters::class)
|
||||
|
||||
@@ -9,7 +9,7 @@ interface RecipeDao {
|
||||
@Query("SELECT * FROM recipe_summaries ORDER BY date_added DESC")
|
||||
fun queryRecipesByPages(): PagingSource<Int, RecipeSummaryEntity>
|
||||
|
||||
@Query("SELECT * FROM recipe_summaries JOIN recipe_summaries_fts ON recipe_summaries_fts.remote_id == recipe_summaries.remote_id WHERE recipe_summaries_fts.name MATCH :query ORDER BY date_added DESC")
|
||||
@Query("SELECT * FROM recipe_summaries WHERE recipe_summaries.name LIKE '%' || :query || '%' ORDER BY date_added DESC")
|
||||
fun queryRecipesByPages(query: String): PagingSource<Int, RecipeSummaryEntity>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package gq.kirmanak.mealient.database.recipe.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Fts4
|
||||
|
||||
|
||||
@Entity(tableName = "recipe_summaries_fts")
|
||||
@Fts4(contentEntity = RecipeSummaryEntity::class)
|
||||
data class RecipeSummaryFtsEntity(
|
||||
@ColumnInfo(name = "remote_id") val remoteId: String,
|
||||
@ColumnInfo(name = "name") val name: String,
|
||||
)
|
||||
Reference in New Issue
Block a user