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.entities.PersonRelatedPersonEntity

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

  private val __insertAdapterOfPersonRelatedPersonEntity:
      EntityInsertAdapter<PersonRelatedPersonEntity>
  init {
    this.__db = __db
    this.__insertAdapterOfPersonRelatedPersonEntity = object : EntityInsertAdapter<PersonRelatedPersonEntity>() {
      protected override fun createQuery(): String = "INSERT OR REPLACE INTO `PersonRelatedPersonEntity` (`prpUid`,`prpPersonUidNum`,`prpOtherPersonUid`,`prpOtherPersonUidNum`) VALUES (nullif(?, 0),?,?,?)"

      protected override fun bind(statement: SQLiteStatement, entity: PersonRelatedPersonEntity) {
        statement.bindLong(1, entity.prpUid.toLong())
        statement.bindLong(2, entity.prpPersonUidNum)
        statement.bindText(3, entity.prpOtherPersonUid)
        statement.bindLong(4, entity.prpOtherPersonUidNum)
      }
    }
  }

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

  public override suspend fun deleteByPersonUidNum(uidNum: Long) {
    val _sql: String = """
        |
        |        DELETE FROM PersonRelatedPersonEntity
        |         WHERE PersonRelatedPersonEntity.prpPersonUidNum = ?
        |    
        """.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()
  }
}
