Make it explicit that the CATEGORIES
column is not for selecting from.
Renamed the `Schema.AppMetadata.Categories.CATEGORIES` constant into the `Schema.AppMetadata.ForWriting.Categories.CATEGORIES` constant. This is to make it very clear that it is not for reading from the database.
This commit is contained in:
parent
68f666685f
commit
354f0a9b53
@ -503,7 +503,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
values.put(Cols.SUGGESTED_VERSION_CODE, suggestedVersionCode);
|
||||
values.put(Cols.UPSTREAM_VERSION_NAME, upstreamVersionName);
|
||||
values.put(Cols.UPSTREAM_VERSION_CODE, upstreamVersionCode);
|
||||
values.put(Cols.Categories.CATEGORIES, Utils.serializeCommaSeparatedString(categories));
|
||||
values.put(Cols.ForWriting.Categories.CATEGORIES, Utils.serializeCommaSeparatedString(categories));
|
||||
values.put(Cols.ANTI_FEATURES, Utils.serializeCommaSeparatedString(antiFeatures));
|
||||
values.put(Cols.REQUIREMENTS, Utils.serializeCommaSeparatedString(requirements));
|
||||
values.put(Cols.IS_COMPATIBLE, compatible ? 1 : 0);
|
||||
|
@ -310,9 +310,6 @@ public class AppProvider extends FDroidProvider {
|
||||
case Cols._COUNT:
|
||||
appendCountField();
|
||||
break;
|
||||
case Cols.Categories.CATEGORIES:
|
||||
appendCategoriesField();
|
||||
break;
|
||||
default:
|
||||
appendField(field, getTableName());
|
||||
break;
|
||||
@ -341,10 +338,6 @@ public class AppProvider extends FDroidProvider {
|
||||
appendField(fieldName, "suggestedApk", alias);
|
||||
}
|
||||
|
||||
private void appendCategoriesField() {
|
||||
appendField("GROUP_CONCAT(" + CategoryTable.NAME + "." + CategoryTable.Cols.NAME + ")", null, Cols.Categories.CATEGORIES);
|
||||
}
|
||||
|
||||
private void addInstalledAppVersionName() {
|
||||
addInstalledAppField(
|
||||
InstalledAppTable.Cols.VERSION_NAME,
|
||||
@ -862,12 +855,12 @@ public class AppProvider extends FDroidProvider {
|
||||
|
||||
String[] categories = null;
|
||||
boolean saveCategories = false;
|
||||
if (values.containsKey(Cols.Categories.CATEGORIES)) {
|
||||
if (values.containsKey(Cols.ForWriting.Categories.CATEGORIES)) {
|
||||
// Hold onto these categories, so that after we have an ID to reference the newly inserted
|
||||
// app metadata we can then specify its categories.
|
||||
saveCategories = true;
|
||||
categories = Utils.parseCommaSeparatedString(values.getAsString(Cols.Categories.CATEGORIES));
|
||||
values.remove(Cols.Categories.CATEGORIES);
|
||||
categories = Utils.parseCommaSeparatedString(values.getAsString(Cols.ForWriting.Categories.CATEGORIES));
|
||||
values.remove(Cols.ForWriting.Categories.CATEGORIES);
|
||||
}
|
||||
|
||||
long appMetadataId = db().insertOrThrow(getTableName(), null, values);
|
||||
|
@ -158,8 +158,15 @@ public interface Schema {
|
||||
String PACKAGE_NAME = "package_packageName";
|
||||
}
|
||||
|
||||
interface Categories {
|
||||
String CATEGORIES = "categories_commaSeparatedCateogryNames";
|
||||
/**
|
||||
* This is to make it explicit that you cannot request the {@link Categories#CATEGORIES}
|
||||
* field when selecting app metadata from the database. It is only here for the purpose
|
||||
* of inserting/updating apps.
|
||||
*/
|
||||
interface ForWriting {
|
||||
interface Categories {
|
||||
String CATEGORIES = "categories_commaSeparatedCateogryNames";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +196,7 @@ public interface Schema {
|
||||
ANTI_FEATURES, REQUIREMENTS, ICON_URL, ICON_URL_LARGE,
|
||||
SUGGESTED_VERSION_CODE, SuggestedApk.VERSION_NAME,
|
||||
InstalledApp.VERSION_CODE, InstalledApp.VERSION_NAME,
|
||||
InstalledApp.SIGNATURE, Package.PACKAGE_NAME, Categories.CATEGORIES,
|
||||
InstalledApp.SIGNATURE, Package.PACKAGE_NAME,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -161,10 +161,10 @@ public class TempAppProvider extends AppProvider {
|
||||
// Package names for apps cannot change...
|
||||
values.remove(Cols.Package.PACKAGE_NAME);
|
||||
|
||||
if (values.containsKey(Cols.Categories.CATEGORIES)) {
|
||||
String[] categories = Utils.parseCommaSeparatedString(values.getAsString(Cols.Categories.CATEGORIES));
|
||||
if (values.containsKey(Cols.ForWriting.Categories.CATEGORIES)) {
|
||||
String[] categories = Utils.parseCommaSeparatedString(values.getAsString(Cols.ForWriting.Categories.CATEGORIES));
|
||||
ensureCategories(categories, packageName, repoId);
|
||||
values.remove(Cols.Categories.CATEGORIES);
|
||||
values.remove(Cols.ForWriting.Categories.CATEGORIES);
|
||||
}
|
||||
|
||||
int count = db().update(getTableName(), values, query.getSelection(), query.getArgs());
|
||||
|
@ -154,7 +154,7 @@ public class CategoryProviderTest extends FDroidProviderTest {
|
||||
|
||||
private void insertAppWithCategory(String id, String name, String categories) {
|
||||
ContentValues values = new ContentValues(1);
|
||||
values.put(Cols.Categories.CATEGORIES, categories);
|
||||
values.put(Cols.ForWriting.Categories.CATEGORIES, categories);
|
||||
AppProviderTest.insertApp(contentResolver, context, id, name, values);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user