Add: Field numberOfItems to the custom query

This commit is contained in:
machiav3lli 2022-01-12 23:41:46 +01:00
parent 4cd50b971d
commit cb56f9b053

View File

@ -172,7 +172,7 @@ interface ProductDao : BaseDao<Product> {
return query(SimpleSQLiteQuery(builder.build())) return query(SimpleSQLiteQuery(builder.build()))
} }
@RawQuery @RawQuery(observedEntities = [Product::class])
fun queryList( fun queryList(
query: SupportSQLiteQuery query: SupportSQLiteQuery
): List<Product> ): List<Product>
@ -181,7 +181,7 @@ interface ProductDao : BaseDao<Product> {
@Transaction @Transaction
fun queryList( fun queryList(
installed: Boolean, updates: Boolean, searchQuery: String, installed: Boolean, updates: Boolean, searchQuery: String,
section: ProductItem.Section, order: ProductItem.Order section: ProductItem.Section, order: ProductItem.Order, numberOfItems: Int = 0
): List<Product> { ): List<Product> {
val builder = QueryBuilder() val builder = QueryBuilder()
@ -189,7 +189,7 @@ interface ProductDao : BaseDao<Product> {
product.${ROW_SIGNATURES} LIKE ('%.' || installed.${ROW_SIGNATURE} || '.%') AND product.${ROW_SIGNATURES} LIKE ('%.' || installed.${ROW_SIGNATURE} || '.%') AND
product.${ROW_SIGNATURES} != ''""" product.${ROW_SIGNATURES} != ''"""
builder += """SELECT product.rowid AS _id, product.${ROW_REPOSITORY_ID}, builder += """SELECT ${if (numberOfItems > 0) "TOP $numberOfItems " else ""}product.rowid AS _id, product.${ROW_REPOSITORY_ID},
product.${ROW_PACKAGE_NAME}, product.${ROW_NAME}, product.${ROW_PACKAGE_NAME}, product.${ROW_NAME},
product.${ROW_SUMMARY}, installed.${ROW_VERSION}, product.${ROW_SUMMARY}, installed.${ROW_VERSION},
(COALESCE(lock.${ROW_VERSION_CODE}, -1) NOT IN (0, product.${ROW_VERSION_CODE}) AND (COALESCE(lock.${ROW_VERSION_CODE}, -1) NOT IN (0, product.${ROW_VERSION_CODE}) AND