[3.0.0-beta2] Index/IndexGroup not working
See original GitHub issueI’ve followed the instructions. Here’s the relevant part of my table showing what I want to index:
@Table(
database = SNOCRUDatabase.class,
name = ChatterConversation.TABLE_NAME,
indexGroups = {@IndexGroup(number = 1, name = "serverOrder")})
public class ChatterConversation extends BaseTable implements Serializable {
@Index(indexGroups = 1)
@Column long serverOrder = 0;
}
And then a query to get rows ordered by the index:
@Override
public List<ChatterConversation> getChatterConversationList() {
chatterGateway.getChatterConversations(new GetChatterConversationsListResponseCallback());
return SQLite.select()
.from(ChatterConversation.class)
.indexedBy(ChatterConversation_Table.index_serverOrder)
.orderBy(ChatterConversation_Table.serverOrder, true)
.queryList();
}
Pretty straight forward and it all compiles. However pulling the database from my emulator shows that no index was created and of course I get an exception as soon as I run the query.
java.lang.RuntimeException: Unable to resume activity {com.phonegap.snocru.review/com.snocru.snocru.MainActivity}: android.database.sqlite.SQLiteException: no such index: serverOrder (code 1): , while compiling: SELECT * FROM `chatter_conversation`INDEXED BY `serverOrder` ORDER BY `serverOrder` ASC
If I yank the .indexedBy() call, It’ll run but there still is no index. Yes I’ve tried making the index name something other than the column name. What am I missing?
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Why do you need a migration on a new table?? It should be part of the table creation. It’s also not consistent with unique index creation. Also tried this and it only runs the migration on a database upgrade. So new users/fresh install will still not get my index. This is broken IMO.
just create a subclass of
BaseMigration
like so:and subclass it with proper annotation: