Update ORM and improve SQL
This commit is contained in:
parent
c7ee15ea9c
commit
15445c2c0d
3 changed files with 14 additions and 9 deletions
|
@ -357,13 +357,18 @@ public class DatabaseConnectionOrm {
|
|||
|
||||
public String getAllItemsIdsForFeedSQL(long idFeed, boolean onlyUnread, boolean onlyStarredItems, DatabaseConnection.SORT_DIRECTION sortDirection) {
|
||||
|
||||
//TODO does this sql statement work properly?
|
||||
String buildSQL = "SELECT " + RssItemDao.Properties.Id.columnName +
|
||||
" FROM " + RssItemDao.TABLENAME +
|
||||
" WHERE " + RssItemDao.Properties.FeedId.columnName + " = " + idFeed;
|
||||
/*
|
||||
String buildSQL = "SELECT " + RssItemDao.Properties.Id.columnName +
|
||||
" FROM " + RssItemDao.TABLENAME +
|
||||
" WHERE " + RssItemDao.Properties.FeedId.columnName + " IN " +
|
||||
"(SELECT " + FeedDao.Properties.Id.columnName +
|
||||
" FROM " + FeedDao.TABLENAME +
|
||||
" WHERE " + FeedDao.Properties.Id.columnName + " = " + idFeed + ")";
|
||||
|
||||
*/
|
||||
if(onlyUnread && !onlyStarredItems)
|
||||
buildSQL += " AND " + RssItemDao.Properties.Read_temp.columnName + " != 1";
|
||||
else if(onlyStarredItems)
|
||||
|
@ -462,7 +467,7 @@ public class DatabaseConnectionOrm {
|
|||
}
|
||||
|
||||
public SparseArray<String> getUnreadItemCountForFeed() {
|
||||
String buildSQL = "SELECT " + RssItemDao.Properties.FeedId.columnName + ", COUNT(" + RssItemDao.Properties.Id.columnName + ")" + // rowid as _id,
|
||||
String buildSQL = "SELECT " + RssItemDao.Properties.FeedId.columnName + ", COUNT(1)" + // rowid as _id,
|
||||
" FROM " + RssItemDao.TABLENAME +
|
||||
" WHERE " + RssItemDao.Properties.Read_temp.columnName + " != 1 " +
|
||||
" GROUP BY " + RssItemDao.Properties.FeedId.columnName;
|
||||
|
@ -471,7 +476,7 @@ public class DatabaseConnectionOrm {
|
|||
}
|
||||
|
||||
public SparseArray<String> getStarredItemCountForFeed() {
|
||||
String buildSQL = "SELECT " + RssItemDao.Properties.FeedId.columnName + ", COUNT(" + RssItemDao.Properties.Id.columnName + ")" + // rowid as _id,
|
||||
String buildSQL = "SELECT " + RssItemDao.Properties.FeedId.columnName + ", COUNT(1)" + // rowid as _id,
|
||||
" FROM " + RssItemDao.TABLENAME +
|
||||
" WHERE " + RssItemDao.Properties.Starred_temp.columnName + " = 1 " +
|
||||
" GROUP BY " + RssItemDao.Properties.FeedId.columnName;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class DatabaseOrmGenerator {
|
|||
public static void main(String[] args) throws IOException, Exception {
|
||||
List<SchemaVersion> versions = new ArrayList<SchemaVersion>();
|
||||
|
||||
versions.add(new Version3(true));
|
||||
versions.add(new Version4(true));
|
||||
|
||||
validateSchemas(versions);
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ import de.greenrobot.daogenerator.Schema;
|
|||
*
|
||||
* @author Jeremy
|
||||
*/
|
||||
public class Version3 extends SchemaVersion {
|
||||
public class Version4 extends SchemaVersion {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param current
|
||||
*/
|
||||
public Version3(boolean current) {
|
||||
public Version4(boolean current) {
|
||||
super(current);
|
||||
|
||||
Schema schema = getSchema();
|
||||
|
@ -32,7 +32,7 @@ public class Version3 extends SchemaVersion {
|
|||
*/
|
||||
@Override
|
||||
public int getVersionNumber() {
|
||||
return 3;
|
||||
return 4;
|
||||
}
|
||||
|
||||
private static void addEntitysToSchema(Schema schema) {
|
||||
|
@ -45,7 +45,7 @@ public class Version3 extends SchemaVersion {
|
|||
/* Feed */
|
||||
Entity feed = schema.addEntity("Feed");
|
||||
Property feedId = feed.addIdProperty().notNull().getProperty();
|
||||
Property folderIdProperty = feed.addLongProperty("folderId").getProperty();
|
||||
Property folderIdProperty = feed.addLongProperty("folderId").index().getProperty();
|
||||
|
||||
feed.addStringProperty("feedTitle").notNull();
|
||||
feed.addStringProperty("faviconUrl");
|
||||
|
@ -57,7 +57,7 @@ public class Version3 extends SchemaVersion {
|
|||
/* RSS Item */
|
||||
Entity rssItem = schema.addEntity("RssItem");
|
||||
Property rssItemId = rssItem.addIdProperty().notNull().getProperty();
|
||||
Property rssItemFeedId = rssItem.addLongProperty("feedId").notNull().getProperty();
|
||||
Property rssItemFeedId = rssItem.addLongProperty("feedId").notNull().index().getProperty();
|
||||
|
||||
rssItem.addStringProperty("link");
|
||||
rssItem.addStringProperty("title");
|
Loading…
Reference in a new issue