Ensure constants always used for fields in ApkProvider.
This commit is contained in:
parent
942cfb59d6
commit
47fa5a94b3
@ -350,8 +350,8 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
appendField("rowid", "apk", "_id");
|
appendField("rowid", "apk", "_id");
|
||||||
} else if (field.equals(Cols._COUNT)) {
|
} else if (field.equals(Cols._COUNT)) {
|
||||||
appendField("COUNT(*) AS " + Cols._COUNT);
|
appendField("COUNT(*) AS " + Cols._COUNT);
|
||||||
} else if (field.equals(Cols._COUNT_DISTINCT_ID)) {
|
} else if (field.equals(Cols._COUNT_DISTINCT)) {
|
||||||
appendField("COUNT(DISTINCT apk.id) AS " + Cols._COUNT_DISTINCT_ID);
|
appendField("COUNT(DISTINCT apk." + Cols.PACKAGE_NAME + ") AS " + Cols._COUNT_DISTINCT);
|
||||||
} else {
|
} else {
|
||||||
appendField(field, "apk");
|
appendField(field, "apk");
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
private void addRepoField(String field, String alias) {
|
private void addRepoField(String field, String alias) {
|
||||||
if (!repoTableRequired) {
|
if (!repoTableRequired) {
|
||||||
repoTableRequired = true;
|
repoTableRequired = true;
|
||||||
leftJoin(RepoTable.NAME, "repo", "apk.repo = repo._id");
|
leftJoin(RepoTable.NAME, "repo", "apk." + Cols.REPO_ID + " = repo." + RepoTable.Cols._ID);
|
||||||
}
|
}
|
||||||
appendField(field, "repo", alias);
|
appendField(field, "repo", alias);
|
||||||
}
|
}
|
||||||
@ -374,7 +374,7 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private QuerySelection querySingle(Uri uri) {
|
private QuerySelection querySingle(Uri uri) {
|
||||||
final String selection = " vercode = ? and id = ? ";
|
final String selection = Cols.VERSION_CODE + " = ? and " + Cols.PACKAGE_NAME + " = ? ";
|
||||||
final String[] args = {
|
final String[] args = {
|
||||||
// First (0th) path segment is the word "apk",
|
// First (0th) path segment is the word "apk",
|
||||||
// and we are not interested in it.
|
// and we are not interested in it.
|
||||||
@ -412,7 +412,7 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
sb.append(" OR ");
|
sb.append(" OR ");
|
||||||
}
|
}
|
||||||
sb.append(" ( id = ? AND vercode = ? ) ");
|
sb.append(" ( " + Cols.PACKAGE_NAME + " = ? AND " + Cols.VERSION_CODE + " = ? ) ");
|
||||||
}
|
}
|
||||||
return new QuerySelection(sb.toString(), args);
|
return new QuerySelection(sb.toString(), args);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class RepoProvider extends FDroidProvider {
|
|||||||
|
|
||||||
public static int countAppsForRepo(Context context, long repoId) {
|
public static int countAppsForRepo(Context context, long repoId) {
|
||||||
ContentResolver resolver = context.getContentResolver();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
final String[] projection = {Schema.ApkTable.Cols._COUNT_DISTINCT_ID};
|
final String[] projection = {Schema.ApkTable.Cols._COUNT_DISTINCT};
|
||||||
Uri apkUri = ApkProvider.getRepoUri(repoId);
|
Uri apkUri = ApkProvider.getRepoUri(repoId);
|
||||||
Cursor cursor = resolver.query(apkUri, projection, null, null, null);
|
Cursor cursor = resolver.query(apkUri, projection, null, null, null);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -80,7 +80,7 @@ public interface Schema {
|
|||||||
String NAME = "fdroid_apk";
|
String NAME = "fdroid_apk";
|
||||||
|
|
||||||
interface Cols extends BaseColumns {
|
interface Cols extends BaseColumns {
|
||||||
String _COUNT_DISTINCT_ID = "countDistinct";
|
String _COUNT_DISTINCT = "countDistinct";
|
||||||
|
|
||||||
String PACKAGE_NAME = "id";
|
String PACKAGE_NAME = "id";
|
||||||
String VERSION_NAME = "version";
|
String VERSION_NAME = "version";
|
||||||
|
@ -131,9 +131,9 @@ public class TempApkProvider extends ApkProvider {
|
|||||||
final SQLiteDatabase db = db();
|
final SQLiteDatabase db = db();
|
||||||
final String memoryDbName = TempAppProvider.DB;
|
final String memoryDbName = TempAppProvider.DB;
|
||||||
db.execSQL("CREATE TABLE " + memoryDbName + "." + getTableName() + " AS SELECT * FROM main." + ApkTable.NAME);
|
db.execSQL("CREATE TABLE " + memoryDbName + "." + getTableName() + " AS SELECT * FROM main." + ApkTable.NAME);
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + memoryDbName + ".apk_vercode on " + getTableName() + " (vercode);");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + memoryDbName + ".apk_vercode on " + getTableName() + " (" + ApkTable.Cols.VERSION_CODE + ");");
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + memoryDbName + ".apk_id on " + getTableName() + " (id);");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + memoryDbName + ".apk_id on " + getTableName() + " (" + ApkTable.Cols.PACKAGE_NAME + ");");
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + memoryDbName + ".apk_compatible ON " + getTableName() + " (compatible);");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + memoryDbName + ".apk_compatible ON " + getTableName() + " (" + ApkTable.Cols.IS_COMPATIBLE + ");");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user