requery / requery

requery - modern SQL based query & persistence for Java / Kotlin / Android
Apache License 2.0
3.13k stars 245 forks source link

Type mismatch where clause #881

Closed MisterWeeMan closed 5 years ago

MisterWeeMan commented 5 years ago

Can't compile because of this error using the where clause in the same way it is used in the wiki (version 1.5.1 but same in 1.6.0)

Type mismatch.
Required: Condition<out Expression<TypeVariable(R)>, *>
Found: Logical<out Expression<Int>, Int>

Here's the code:

Model

@Entity
@Table(name = "ipad_catalog_cards_availability")
internal data class RequeryProductAvailability(
        @get:Key @get:Generated @get:Column(name = "id_availability") val idAvailability: Int,
        @get:Column(name = "card_code", length = 128) val cardCode: String = "0",
        @get:Column(name = "context", length = 64) val context: String = "",
        @get:Column(name = "type", length = 32) val type: String? = null,
        @get:Column(name = "availability") val availability: Double = 0.0000,
        @get:Column(name = "availability_scheduled") val availabilityScheduled: Double? = null,
        @get:Column(name = "availability_scheduled_date") val availabilityScheduledDate: Timestamp? = null,
        @get:Column(name = "date_modification") val dateModification: Timestamp = Timestamp(System.currentTimeMillis()),
        @get:Column(name = "record_status") val recordStatus: Int = 1
)

Database initialization

private val dataSource by lazy {
    object : DatabaseSource(context, Models.DEFAULT, CATALOG_DB_NAME, 1) {
        // needed to use escape names like "order"
        override fun onConfigure(builder: ConfigurationBuilder) {
            super.onConfigure(builder)
            builder.setQuoteColumnNames(true)
        }
    }
}

private val dataStoreAvailability by lazy {
    KotlinEntityDataStore<RequeryProductAvailability>(dataSource.configuration)
}

Call that lunch exception

val requeryAvailability = dataStoreAvailability
                    .select(RequeryProductAvailability::class)
                    .where(RequeryProductAvailability::cardCode eq "code")
                    .get()
                    .toList()

// tried also this
dataStoreAvailability.invoke {
        val result = select(RequeryProductAvailability::class) where (RequeryProductAvailability::cardCode eq "code")
        result.get().toList()
    }

Any idea causing this?

MisterWeeMan commented 5 years ago

So I tried to build and compile and the application works fine. It is probably a bug in the AS static analyzer.