package world.respect.datalayer.db.school.daos

import androidx.room.EntityInsertAdapter
import androidx.room.RoomDatabase
import androidx.room.util.performSuspending
import androidx.sqlite.SQLiteStatement
import javax.`annotation`.processing.Generated
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.reflect.KClass
import world.respect.datalayer.db.school.SchoolTypeConverters
import world.respect.datalayer.db.school.entities.AssignmentAssigneeRefEntity

@Generated(value = ["androidx.room.RoomProcessor"])
@Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION", "REMOVAL"])
public class AssignmentAssigneeRefEntityDao_Impl(
  __db: RoomDatabase,
) : AssignmentAssigneeRefEntityDao {
  private val __db: RoomDatabase

  private val __insertAdapterOfAssignmentAssigneeRefEntity:
      EntityInsertAdapter<AssignmentAssigneeRefEntity>

  private val __schoolTypeConverters: SchoolTypeConverters = SchoolTypeConverters()
  init {
    this.__db = __db
    this.__insertAdapterOfAssignmentAssigneeRefEntity = object : EntityInsertAdapter<AssignmentAssigneeRefEntity>() {
      protected override fun createQuery(): String = "INSERT OR REPLACE INTO `AssignmentAssigneeRefEntity` (`aarAeUidNum`,`aarType`,`aarAeAssigneeUid`,`aarAeAssigneeUidNum`) VALUES (?,?,?,?)"

      protected override fun bind(statement: SQLiteStatement, entity: AssignmentAssigneeRefEntity) {
        statement.bindLong(1, entity.aarAeUidNum)
        val _tmp: Int = __schoolTypeConverters.fromAssignmentAssigneeRefTypeEnum(entity.aarType)
        statement.bindLong(2, _tmp.toLong())
        statement.bindText(3, entity.aarAeAssigneeUid)
        statement.bindLong(4, entity.aarAeAssigneeUidNum)
      }
    }
  }

  public override suspend fun upsert(entities: List<AssignmentAssigneeRefEntity>): Unit = performSuspending(__db, false, true) { _connection ->
    __insertAdapterOfAssignmentAssigneeRefEntity.insert(_connection, entities)
  }

  public override suspend fun deleteByAssignmentUidNum(uidNum: Long) {
    val _sql: String = """
        |
        |        DELETE FROM AssignmentAssigneeRefEntity
        |         WHERE aarAeUidNum = ?
        |    
        """.trimMargin()
    return performSuspending(__db, false, true) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, uidNum)
        _stmt.step()
      } finally {
        _stmt.close()
      }
    }
  }

  public companion object {
    public fun getRequiredConverters(): List<KClass<*>> = emptyList()
  }
}
