@@ -64,8 +64,6 @@ public static TableDataResponse getTableData(SQLiteDatabase db, String selectQue
6464
6565 TableDataResponse tableData = new TableDataResponse ();
6666
67- // TODO : Handle JOIN query
68-
6967 if (tableName == null ) {
7068 tableName = getTableName (selectQuery );
7169 }
@@ -134,7 +132,7 @@ public static TableDataResponse getTableData(SQLiteDatabase db, String selectQue
134132
135133 }
136134
137- public static List <TableDataResponse .TableInfo > getTableInfo (SQLiteDatabase db , String pragmaQuery ) {
135+ private static List <TableDataResponse .TableInfo > getTableInfo (SQLiteDatabase db , String pragmaQuery ) {
138136
139137 Cursor cursor ;
140138 try {
@@ -228,75 +226,6 @@ public static UpdateRowResponse updateRow(SQLiteDatabase db, String tableName, L
228226 return updateRowResponse ;
229227 }
230228
231- public static TableDataResponse query (SQLiteDatabase database , String sql ) {
232- Cursor cursor ;
233- try {
234- cursor = database .rawQuery (sql , null );
235- } catch (Exception e ) {
236- e .printStackTrace ();
237- TableDataResponse errorResponse = new TableDataResponse ();
238- errorResponse .isSuccessful = false ;
239- errorResponse .errorMessage = e .getMessage ();
240- return errorResponse ;
241- }
242-
243- if (cursor != null ) {
244- cursor .moveToFirst ();
245- TableDataResponse response = new TableDataResponse ();
246- response .isSuccessful = true ;
247-
248- response .tableInfos = new ArrayList <>();
249- for (int i = 0 ; i < cursor .getColumnCount (); i ++) {
250- TableDataResponse .TableInfo tableInfo = new TableDataResponse .TableInfo ();
251- tableInfo .title = cursor .getColumnName (i );
252- tableInfo .isPrimary = false ;
253-
254- response .tableInfos .add (tableInfo );
255- }
256-
257- response .rows = new ArrayList <>();
258- if (cursor .getCount () > 0 ) {
259- do {
260- List <TableDataResponse .ColumnData > row = new ArrayList <>();
261- for (int i = 0 ; i < cursor .getColumnCount (); i ++) {
262- TableDataResponse .ColumnData columnData = new TableDataResponse .ColumnData ();
263- switch (cursor .getType (i )) {
264- case Cursor .FIELD_TYPE_BLOB :
265- columnData .dataType = DataType .TEXT ;
266- columnData .value = ConverterUtils .blobToString (cursor .getBlob (i ));
267- break ;
268- case Cursor .FIELD_TYPE_FLOAT :
269- columnData .dataType = DataType .REAL ;
270- columnData .value = cursor .getDouble (i );
271- break ;
272- case Cursor .FIELD_TYPE_INTEGER :
273- columnData .dataType = DataType .INTEGER ;
274- columnData .value = cursor .getLong (i );
275- break ;
276- case Cursor .FIELD_TYPE_STRING :
277- columnData .dataType = DataType .TEXT ;
278- columnData .value = cursor .getString (i );
279- break ;
280- default :
281- columnData .dataType = DataType .TEXT ;
282- columnData .value = cursor .getString (i );
283- }
284- row .add (columnData );
285- }
286- response .rows .add (row );
287-
288- } while (cursor .moveToNext ());
289- }
290- cursor .close ();
291- return response ;
292- } else {
293- TableDataResponse errorResponse = new TableDataResponse ();
294- errorResponse .isSuccessful = false ;
295- errorResponse .errorMessage = "Cursor is null" ;
296- return errorResponse ;
297- }
298- }
299-
300229 public static Response exec (SQLiteDatabase database , String sql ) {
301230 Response response = new Response ();
302231 try {
@@ -311,7 +240,8 @@ public static Response exec(SQLiteDatabase database, String sql) {
311240 return response ;
312241 }
313242
314- public static String getTableName (String selectQuery ) {
243+ private static String getTableName (String selectQuery ) {
244+ // TODO find tableName from query and also handle JOIN query
315245 return null ;
316246 }
317247
0 commit comments