Tencent / wcdb

WCDB is a cross-platform database framework developed by WeChat.
Other
10.78k stars 1.41k forks source link

安卓使用2.1.4 orm映射 联合唯一以及索引相关问题 #1097

Closed zl15074769846 closed 4 months ago

zl15074769846 commented 4 months ago

The language of WCDB

e.g. Java

The version of WCDB

e.g. v2.1.4

The platform of WCDB

e.g. Android

The installation of WCDB

e.g. Cocoapods, Carthage, Maven, AAR Package or Git clone

@WCDBTableCoding // (multiUnique = @MultiUnique(columns = {"nick_name", "avatar"})) public class MgImUser implements Serializable{ //只支持绑定 public 的属性 @WCDBField(isAutoIncrement = true,isPrimary = true) public long id; @WCDBField(isUnique = false) // @WCDBIndex(name="userinfo_indexSessionId") public String session_id; @WCDBField(isUnique = false) public String nick_name; @WCDBField(isUnique = true,columnName ="AVATAR") public String avatar;

What's the issue?

After using version 2.1.4, Android found that using the ORM mapping table structure, if the union unique attribute or index attribute is removed, the database will not synchronously remove the union unique and index attributes. At the same time, when using the union unique configuration, if the table field name and naming are different, the union unique attribute naming will report an error regardless of whether the field name or naming is used

zl15074769846 commented 4 months ago

If I want to split tables, what is a good way to create indexes? The orm method is not user-friendly and At the beginning, there was no addition of union unique or unique attributes. Subsequent additions using the orm method will not take effect, and the database cannot update field attributes. Is there currently a good way to add union unique and unique attributes

Qiuwen-chen commented 4 months ago

You should drop useless indexes manually.

Table constraints and column constraints can not be changed if you have created the table. This is the limitation of SQLite. You should drop the table and recreate it if you really want to change the table constraints or existing column constraints.