Saturday 21 November 2020

Is it possible to create case insensitive Index via Room?

Currently, I have a Room entity which looks like

@Entity(
        tableName = "holiday_country",
        indices = {
                @Index(value = "code", unique = true)
        }
)
public class HolidayCountry

which is equivalent of having index

CREATE UNIQUE INDEX `index_holiday_country_code` ON `holiday_country` (`code`)

However, I also need to have the following 2nd index as I will be performing case insensitive query sometimes.

CREATE UNIQUE INDEX `index_holiday_country_code_nocase` ON `holiday_country` (`code`  COLLATE NOCASE)

If that is so, how should such index be declared in Room entity?



from Is it possible to create case insensitive Index via Room?

No comments:

Post a Comment