removing null values for bindArgs so database plugin doesn't throw exception for beta builds

Summary:
Removing use of ```database.query``` with null values because its stopping the database plugin from working for whatsapp android.

The [release version of FrameworkSQLiteDatabase](https://androidx.tech/artifacts/sqlite/sqlite-framework/2.2.0-source/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.java.html) is written in java which accepts a null value (although its still annotated NonNull for Object[] bindArgs)

But the [beta version of FrameworkSQLiteDatabase](https://androidx.tech/artifacts/sqlite/sqlite-framework/2.3.0-beta01-source/androidx/sqlite/db/framework/FrameworkSQLiteDatabase.kt.html) is written in kotlin which throws an exception for null values.

Reviewed By: passy, mweststrate

Differential Revision: D40870552

fbshipit-source-id: 72c99c1b62d052887d298145a3019d6123ea94f3
This commit is contained in:
Akinola Orederu
2022-11-01 09:41:25 -07:00
committed by Facebook GitHub Bot
parent 226ccf91f6
commit 42ecf919d6

View File

@@ -162,9 +162,9 @@ public class SqliteDatabaseDriver extends DatabaseDriver<SqliteDatabaseDescripto
SupportSQLiteDatabase database = SupportSQLiteDatabase database =
sqliteDatabaseConnectionProvider.openDatabase(databaseDescriptor.file); sqliteDatabaseConnectionProvider.openDatabase(databaseDescriptor.file);
try { try {
Cursor structureCursor = database.query("PRAGMA table_info(" + table + ")", null); Cursor structureCursor = database.query("PRAGMA table_info(" + table + ")");
Cursor foreignKeysCursor = database.query("PRAGMA foreign_key_list(" + table + ")", null); Cursor foreignKeysCursor = database.query("PRAGMA foreign_key_list(" + table + ")");
Cursor indexesCursor = database.query("PRAGMA index_list(" + table + ")", null); Cursor indexesCursor = database.query("PRAGMA index_list(" + table + ")");
try { try {
// Structure & foreign keys // Structure & foreign keys
@@ -210,7 +210,7 @@ public class SqliteDatabaseDriver extends DatabaseDriver<SqliteDatabaseDescripto
while (indexesCursor.moveToNext()) { while (indexesCursor.moveToNext()) {
List<String> indexedColumnNames = new ArrayList<>(); List<String> indexedColumnNames = new ArrayList<>();
String indexName = indexesCursor.getString(indexesCursor.getColumnIndex("name")); String indexName = indexesCursor.getString(indexesCursor.getColumnIndex("name"));
Cursor indexInfoCursor = database.query("PRAGMA index_info(" + indexName + ")", null); Cursor indexInfoCursor = database.query("PRAGMA index_info(" + indexName + ")");
try { try {
while (indexInfoCursor.moveToNext()) { while (indexInfoCursor.moveToNext()) {
indexedColumnNames.add( indexedColumnNames.add(
@@ -307,7 +307,7 @@ public class SqliteDatabaseDriver extends DatabaseDriver<SqliteDatabaseDescripto
private static DatabaseExecuteSqlResponse executeSelect( private static DatabaseExecuteSqlResponse executeSelect(
SupportSQLiteDatabase database, String query) { SupportSQLiteDatabase database, String query) {
Cursor cursor = database.query(query, null); Cursor cursor = database.query(query);
try { try {
String[] columnNames = cursor.getColumnNames(); String[] columnNames = cursor.getColumnNames();
List<List<Object>> rows = cursorToList(cursor); List<List<Object>> rows = cursorToList(cursor);