Skip to content

Commit c771255

Browse files
Handle case when tableName is not unknown, send isPrimary true for all so that it becomes non-editable
1 parent 40b79a5 commit c771255

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

debug-db/src/main/java/com/amitshekhar/utils/DatabaseHelper.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,19 @@ public static TableDataResponse getTableData(SQLiteDatabase db, String selectQue
8787

8888
if (cursor != null) {
8989
cursor.moveToFirst();
90+
91+
// setting tableInfo when tableName is not known and making
92+
// it non-editable also by making isPrimary true for all
93+
if (tableData.tableInfos == null) {
94+
tableData.tableInfos = new ArrayList<>();
95+
for (int i = 0; i < cursor.getColumnCount(); i++) {
96+
TableDataResponse.TableInfo tableInfo = new TableDataResponse.TableInfo();
97+
tableInfo.title = cursor.getColumnName(i);
98+
tableInfo.isPrimary = true;
99+
tableData.tableInfos.add(tableInfo);
100+
}
101+
}
102+
90103
tableData.isSuccessful = true;
91104
tableData.rows = new ArrayList<>();
92105
if (cursor.getCount() > 0) {

0 commit comments

Comments
 (0)