package world.respect.datalayer.db.schooldirectory.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.schooldirectory.entities.SchoolDirectoryEntryLangMapEntity

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

  private val __insertAdapterOfSchoolDirectoryEntryLangMapEntity:
      EntityInsertAdapter<SchoolDirectoryEntryLangMapEntity>
  init {
    this.__db = __db
    this.__insertAdapterOfSchoolDirectoryEntryLangMapEntity = object : EntityInsertAdapter<SchoolDirectoryEntryLangMapEntity>() {
      protected override fun createQuery(): String = "INSERT OR REPLACE INTO `SchoolDirectoryEntryLangMapEntity` (`sdelUid`,`sdelReUid`,`sdelLang`,`sdelRegion`,`sdelValue`,`sdelPropId`) VALUES (nullif(?, 0),?,?,?,?,?)"

      protected override fun bind(statement: SQLiteStatement, entity: SchoolDirectoryEntryLangMapEntity) {
        statement.bindLong(1, entity.sdelUid.toLong())
        statement.bindLong(2, entity.sdelReUid)
        statement.bindText(3, entity.sdelLang)
        val _tmpSdelRegion: String? = entity.sdelRegion
        if (_tmpSdelRegion == null) {
          statement.bindNull(4)
        } else {
          statement.bindText(4, _tmpSdelRegion)
        }
        statement.bindText(5, entity.sdelValue)
        statement.bindLong(6, entity.sdelPropId.toLong())
      }
    }
  }

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

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

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