Coverage Summary for Class: CategoriesDao_Impl (com.imecatro.products.data.datasource)
| Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| CategoriesDao_Impl |
0%
(0/17)
|
0%
(0/16)
|
0%
(0/121)
|
0%
(0/487)
|
| CategoriesDao_Impl$1 |
0%
(0/3)
|
|
0%
(0/4)
|
0%
(0/13)
|
| CategoriesDao_Impl$2 |
0%
(0/3)
|
|
0%
(0/5)
|
0%
(0/18)
|
| CategoriesDao_Impl$Companion |
0%
(0/1)
|
|
0%
(0/1)
|
0%
(0/1)
|
| Total |
0%
(0/24)
|
0%
(0/16)
|
0%
(0/131)
|
0%
(0/519)
|
package com.imecatro.products.`data`.datasource
import androidx.room.EntityDeleteOrUpdateAdapter
import androidx.room.EntityInsertAdapter
import androidx.room.RoomDatabase
import androidx.room.coroutines.createFlow
import androidx.room.util.getColumnIndexOrThrow
import androidx.room.util.performSuspending
import androidx.sqlite.SQLiteStatement
import com.imecatro.products.`data`.model.CategoryRoomEntity
import com.imecatro.products.`data`.model.ProductRoomEntity
import javax.`annotation`.processing.Generated
import kotlin.Double
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.collections.mutableListOf
import kotlin.reflect.KClass
import kotlinx.coroutines.flow.Flow
@Generated(value = ["androidx.room.RoomProcessor"])
@Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION", "REMOVAL"])
public class CategoriesDao_Impl(
__db: RoomDatabase,
) : CategoriesDao {
private val __db: RoomDatabase
private val __insertAdapterOfCategoryRoomEntity: EntityInsertAdapter<CategoryRoomEntity>
private val __updateAdapterOfCategoryRoomEntity: EntityDeleteOrUpdateAdapter<CategoryRoomEntity>
init {
this.__db = __db
this.__insertAdapterOfCategoryRoomEntity = object : EntityInsertAdapter<CategoryRoomEntity>() {
protected override fun createQuery(): String = "INSERT OR REPLACE INTO `categories_table` (`id`,`name`) VALUES (nullif(?, 0),?)"
protected override fun bind(statement: SQLiteStatement, entity: CategoryRoomEntity) {
statement.bindLong(1, entity.id)
statement.bindText(2, entity.name)
}
}
this.__updateAdapterOfCategoryRoomEntity = object : EntityDeleteOrUpdateAdapter<CategoryRoomEntity>() {
protected override fun createQuery(): String = "UPDATE OR ABORT `categories_table` SET `id` = ?,`name` = ? WHERE `id` = ?"
protected override fun bind(statement: SQLiteStatement, entity: CategoryRoomEntity) {
statement.bindLong(1, entity.id)
statement.bindText(2, entity.name)
statement.bindLong(3, entity.id)
}
}
}
public override suspend fun insertCategory(cat: CategoryRoomEntity): Long = performSuspending(__db, false, true) { _connection ->
val _result: Long = __insertAdapterOfCategoryRoomEntity.insertAndReturnId(_connection, cat)
_result
}
public override suspend fun updateCategory(cat: CategoryRoomEntity): Unit = performSuspending(__db, false, true) { _connection ->
__updateAdapterOfCategoryRoomEntity.handle(_connection, cat)
}
public override fun getAll(): Flow<List<CategoryRoomEntity>> {
val _sql: String = "SELECT * FROM categories_table ORDER BY name"
return createFlow(__db, false, arrayOf("categories_table")) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
val _columnIndexOfId: Int = getColumnIndexOrThrow(_stmt, "id")
val _columnIndexOfName: Int = getColumnIndexOrThrow(_stmt, "name")
val _result: MutableList<CategoryRoomEntity> = mutableListOf()
while (_stmt.step()) {
val _item: CategoryRoomEntity
val _tmpId: Long
_tmpId = _stmt.getLong(_columnIndexOfId)
val _tmpName: String
_tmpName = _stmt.getText(_columnIndexOfName)
_item = CategoryRoomEntity(_tmpId,_tmpName)
_result.add(_item)
}
_result
} finally {
_stmt.close()
}
}
}
public override suspend fun getProductsByCategory(categoryId: Long?): List<ProductRoomEntity> {
val _sql: String = """
|
| SELECT p.* FROM products_table p
| WHERE (? IS NULL AND p.category_id IS NULL)
| OR (? IS NOT NULL AND p.category_id = ?)
| ORDER BY name
|
""".trimMargin()
return performSuspending(__db, true, false) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
if (categoryId == null) {
_stmt.bindNull(_argIndex)
} else {
_stmt.bindLong(_argIndex, categoryId)
}
_argIndex = 2
if (categoryId == null) {
_stmt.bindNull(_argIndex)
} else {
_stmt.bindLong(_argIndex, categoryId)
}
_argIndex = 3
if (categoryId == null) {
_stmt.bindNull(_argIndex)
} else {
_stmt.bindLong(_argIndex, categoryId)
}
val _columnIndexOfId: Int = getColumnIndexOrThrow(_stmt, "id")
val _columnIndexOfName: Int = getColumnIndexOrThrow(_stmt, "name")
val _columnIndexOfPrice: Int = getColumnIndexOrThrow(_stmt, "price")
val _columnIndexOfCurrency: Int = getColumnIndexOrThrow(_stmt, "currency")
val _columnIndexOfUnit: Int = getColumnIndexOrThrow(_stmt, "unit")
val _columnIndexOfStock: Int = getColumnIndexOrThrow(_stmt, "stock")
val _columnIndexOfDetails: Int = getColumnIndexOrThrow(_stmt, "details")
val _columnIndexOfImageUri: Int = getColumnIndexOrThrow(_stmt, "imageUri")
val _columnIndexOfCategoryId: Int = getColumnIndexOrThrow(_stmt, "category_id")
val _columnIndexOfBarcode: Int = getColumnIndexOrThrow(_stmt, "barcode")
val _result: MutableList<ProductRoomEntity> = mutableListOf()
while (_stmt.step()) {
val _item: ProductRoomEntity
val _tmpId: Long
_tmpId = _stmt.getLong(_columnIndexOfId)
val _tmpName: String
_tmpName = _stmt.getText(_columnIndexOfName)
val _tmpPrice: Double
_tmpPrice = _stmt.getDouble(_columnIndexOfPrice)
val _tmpCurrency: String
_tmpCurrency = _stmt.getText(_columnIndexOfCurrency)
val _tmpUnit: String
_tmpUnit = _stmt.getText(_columnIndexOfUnit)
val _tmpStock: Double
_tmpStock = _stmt.getDouble(_columnIndexOfStock)
val _tmpDetails: String
_tmpDetails = _stmt.getText(_columnIndexOfDetails)
val _tmpImageUri: String
_tmpImageUri = _stmt.getText(_columnIndexOfImageUri)
val _tmpCategoryId: Long?
if (_stmt.isNull(_columnIndexOfCategoryId)) {
_tmpCategoryId = null
} else {
_tmpCategoryId = _stmt.getLong(_columnIndexOfCategoryId)
}
val _tmpBarcode: String?
if (_stmt.isNull(_columnIndexOfBarcode)) {
_tmpBarcode = null
} else {
_tmpBarcode = _stmt.getText(_columnIndexOfBarcode)
}
_item = ProductRoomEntity(_tmpId,_tmpName,_tmpPrice,_tmpCurrency,_tmpUnit,_tmpStock,_tmpDetails,_tmpImageUri,_tmpCategoryId,_tmpBarcode)
_result.add(_item)
}
_result
} finally {
_stmt.close()
}
}
}
public override suspend fun getCategoryByName(name: String): CategoryRoomEntity? {
val _sql: String = "SELECT * FROM categories_table WHERE name = ?"
return performSuspending(__db, true, false) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindText(_argIndex, name)
val _columnIndexOfId: Int = getColumnIndexOrThrow(_stmt, "id")
val _columnIndexOfName: Int = getColumnIndexOrThrow(_stmt, "name")
val _result: CategoryRoomEntity?
if (_stmt.step()) {
val _tmpId: Long
_tmpId = _stmt.getLong(_columnIndexOfId)
val _tmpName: String
_tmpName = _stmt.getText(_columnIndexOfName)
_result = CategoryRoomEntity(_tmpId,_tmpName)
} else {
_result = null
}
_result
} finally {
_stmt.close()
}
}
}
public override suspend fun assignCategory(productId: Long, categoryId: Long) {
val _sql: String = "UPDATE products_table SET category_id = ? WHERE id = ?"
return performSuspending(__db, false, true) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, categoryId)
_argIndex = 2
_stmt.bindLong(_argIndex, productId)
_stmt.step()
} finally {
_stmt.close()
}
}
}
public override suspend fun clearCategory(productId: Long) {
val _sql: String = "UPDATE products_table SET category_id = NULL WHERE id = ?"
return performSuspending(__db, false, true) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, productId)
_stmt.step()
} finally {
_stmt.close()
}
}
}
public override suspend fun deleteCategory(categoryId: Long) {
val _sql: String = "DELETE FROM categories_table WHERE id = ?"
return performSuspending(__db, false, true) { _connection ->
val _stmt: SQLiteStatement = _connection.prepare(_sql)
try {
var _argIndex: Int = 1
_stmt.bindLong(_argIndex, categoryId)
_stmt.step()
} finally {
_stmt.close()
}
}
}
public companion object {
public fun getRequiredConverters(): List<KClass<*>> = emptyList()
}
}