summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Schwertfeger <jschwertfeger@gmail.com>2010-11-12 11:42:28 +0100
committerJonas Schwertfeger <jschwertfeger@gmail.com>2010-11-12 12:18:37 +0100
commit84029037239fec6e54327519c3e5ad30088c28ce (patch)
tree7e271f9333da9258e02d8e9713b9e242d809b63e
parentdb65907a2148f053e51f941979f0f7694acd5923 (diff)
downloadbase-84029037239fec6e54327519c3e5ad30088c28ce.tar.gz
Added buildQuery and buildUnionSubQuery methods without misleading selectionArgs parameter.
The signatures of the existing buildQuery and buildUnionSubQuery methods include a selectionArgs parameter that is not actually being used in the method implementations. This parameter leads to the misconception that SQL paramter substitution is carried out by these methods. I added new variants of these methods without that parameter and deprecated the old variants. Change-Id: I1bf770d5c777649e9aac36d93aa93bd65bbcc2a3
-rw-r--r--api/current.xml52
-rw-r--r--core/java/android/database/sqlite/SQLiteQueryBuilder.java54
2 files changed, 92 insertions, 14 deletions
diff --git a/api/current.xml b/api/current.xml
index 4c9743eb3a9c..7dc498d31305 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -55246,6 +55246,29 @@
</parameter>
<parameter name="selection" type="java.lang.String">
</parameter>
+<parameter name="groupBy" type="java.lang.String">
+</parameter>
+<parameter name="having" type="java.lang.String">
+</parameter>
+<parameter name="sortOrder" type="java.lang.String">
+</parameter>
+<parameter name="limit" type="java.lang.String">
+</parameter>
+</method>
+<method name="buildQuery"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="deprecated"
+ visibility="public"
+>
+<parameter name="projectionIn" type="java.lang.String[]">
+</parameter>
+<parameter name="selection" type="java.lang.String">
+</parameter>
<parameter name="selectionArgs" type="java.lang.String[]">
</parameter>
<parameter name="groupBy" type="java.lang.String">
@@ -55323,6 +55346,33 @@
</parameter>
<parameter name="selection" type="java.lang.String">
</parameter>
+<parameter name="groupBy" type="java.lang.String">
+</parameter>
+<parameter name="having" type="java.lang.String">
+</parameter>
+</method>
+<method name="buildUnionSubQuery"
+ return="java.lang.String"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="deprecated"
+ visibility="public"
+>
+<parameter name="typeDiscriminatorColumn" type="java.lang.String">
+</parameter>
+<parameter name="unionColumns" type="java.lang.String[]">
+</parameter>
+<parameter name="columnsPresentInTable" type="java.util.Set&lt;java.lang.String&gt;">
+</parameter>
+<parameter name="computedColumnsOffset" type="int">
+</parameter>
+<parameter name="typeDiscriminatorValue" type="java.lang.String">
+</parameter>
+<parameter name="selection" type="java.lang.String">
+</parameter>
<parameter name="selectionArgs" type="java.lang.String[]">
</parameter>
<parameter name="groupBy" type="java.lang.String">
@@ -216168,7 +216218,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="t" type="T">
+<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
diff --git a/core/java/android/database/sqlite/SQLiteQueryBuilder.java b/core/java/android/database/sqlite/SQLiteQueryBuilder.java
index 610bf7013e09..4ab646ea89c7 100644
--- a/core/java/android/database/sqlite/SQLiteQueryBuilder.java
+++ b/core/java/android/database/sqlite/SQLiteQueryBuilder.java
@@ -321,7 +321,7 @@ public class SQLiteQueryBuilder
}
String sql = buildQuery(
- projectionIn, selection, selectionArgs, groupBy, having,
+ projectionIn, selection, groupBy, having,
sortOrder, limit);
if (Log.isLoggable(TAG, Log.DEBUG)) {
@@ -345,10 +345,6 @@ public class SQLiteQueryBuilder
* formatted as an SQL WHERE clause (excluding the WHERE
* itself). Passing null will return all rows for the given
* URL.
- * @param selectionArgs You may include ?s in selection, which
- * will be replaced by the values from selectionArgs, in order
- * that they appear in the selection. The values will be bound
- * as Strings.
* @param groupBy A filter declaring how to group rows, formatted
* as an SQL GROUP BY clause (excluding the GROUP BY itself).
* Passing null will cause the rows to not be grouped.
@@ -365,8 +361,8 @@ public class SQLiteQueryBuilder
* @return the resulting SQL SELECT statement
*/
public String buildQuery(
- String[] projectionIn, String selection, String[] selectionArgs,
- String groupBy, String having, String sortOrder, String limit) {
+ String[] projectionIn, String selection, String groupBy,
+ String having, String sortOrder, String limit) {
String[] projection = computeProjection(projectionIn);
StringBuilder where = new StringBuilder();
@@ -394,6 +390,19 @@ public class SQLiteQueryBuilder
}
/**
+ * @deprecated This method's signature is misleading since no SQL parameter
+ * substitution is carried out. The selection arguments parameter does not get
+ * used at all. To avoid confusion, call
+ * {@link #buildQuery(String[], String, String, String, String, String)} instead.
+ */
+ @Deprecated
+ public String buildQuery(
+ String[] projectionIn, String selection, String[] selectionArgs,
+ String groupBy, String having, String sortOrder, String limit) {
+ return buildQuery(projectionIn, selection, groupBy, having, sortOrder, limit);
+ }
+
+ /**
* Construct a SELECT statement suitable for use in a group of
* SELECT statements that will be joined through UNION operators
* in buildUnionQuery.
@@ -422,10 +431,6 @@ public class SQLiteQueryBuilder
* formatted as an SQL WHERE clause (excluding the WHERE
* itself). Passing null will return all rows for the given
* URL.
- * @param selectionArgs You may include ?s in selection, which
- * will be replaced by the values from selectionArgs, in order
- * that they appear in the selection. The values will be bound
- * as Strings.
* @param groupBy A filter declaring how to group rows, formatted
* as an SQL GROUP BY clause (excluding the GROUP BY itself).
* Passing null will cause the rows to not be grouped.
@@ -443,7 +448,6 @@ public class SQLiteQueryBuilder
int computedColumnsOffset,
String typeDiscriminatorValue,
String selection,
- String[] selectionArgs,
String groupBy,
String having) {
int unionColumnsCount = unionColumns.length;
@@ -463,12 +467,36 @@ public class SQLiteQueryBuilder
}
}
return buildQuery(
- projectionIn, selection, selectionArgs, groupBy, having,
+ projectionIn, selection, groupBy, having,
null /* sortOrder */,
null /* limit */);
}
/**
+ * @deprecated This method's signature is misleading since no SQL parameter
+ * substitution is carried out. The selection arguments parameter does not get
+ * used at all. To avoid confusion, call
+ * {@link #buildUnionSubQuery(String, String[], Set<String>, int, String, String, String, String)}
+ * instead.
+ */
+ @Deprecated
+ public String buildUnionSubQuery(
+ String typeDiscriminatorColumn,
+ String[] unionColumns,
+ Set<String> columnsPresentInTable,
+ int computedColumnsOffset,
+ String typeDiscriminatorValue,
+ String selection,
+ String[] selectionArgs,
+ String groupBy,
+ String having) {
+ return buildUnionSubQuery(
+ typeDiscriminatorColumn, unionColumns, columnsPresentInTable,
+ computedColumnsOffset, typeDiscriminatorValue, selection,
+ groupBy, having);
+ }
+
+ /**
* Given a set of subqueries, all of which are SELECT statements,
* construct a query that returns the union of what those
* subqueries return.