@@ -1926,13 +1926,24 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
19261926 Log .e (TAG , "getAllRecords: Table name was null or empty." );
19271927 return null ;
19281928 }
1929+
1930+ // checking if order by column name is not null and not empty for ascending order
1931+ if (orderByColumnName != null && !orderByColumnName .isEmpty ())
1932+ {
1933+ Log .e (TAG , "getAllRecords: order by column name was null or empty." );
1934+ return null ;
1935+ }
19291936
19301937 // checking if isAscending is false
19311938 // and order by column name is not null and not empty for descending order
1932- if (!isAscending && ( orderByColumnName != null && ! orderByColumnName . isEmpty ()) )
1939+ if (!isAscending )
19331940 {
19341941 orderBy = " ORDER BY " + orderByColumnName + " DESC" ;
19351942 }
1943+ else
1944+ {
1945+ orderBy = " ORDER BY " + orderByColumnName + " ASC" ;
1946+ }
19361947
19371948 // checking if model class was provided or not
19381949 // it not then not proceeding further
@@ -2098,13 +2109,24 @@ public <T> ArrayList<T> getAllRecords(String tableName, boolean isAscending,
20982109 {
20992110 whereClause = " WHERE " + conditionalValues ;
21002111 }
2101-
2112+
2113+ // checking if order by column name is not null and not empty for ascending order
2114+ if (orderByColumnName != null && !orderByColumnName .isEmpty ())
2115+ {
2116+ Log .e (TAG , "getAllRecords: order by column name was null or empty." );
2117+ return null ;
2118+ }
2119+
21022120 // checking if isAscending is false
21032121 // and order by column name is not null and not empty for descending order
2104- if (!isAscending && ( orderByColumnName != null && ! orderByColumnName . isEmpty ()) )
2122+ if (!isAscending )
21052123 {
21062124 orderBy = " ORDER BY " + orderByColumnName + " DESC" ;
21072125 }
2126+ else
2127+ {
2128+ orderBy = " ORDER BY " + orderByColumnName + " ASC" ;
2129+ }
21082130
21092131 // checking if model class was provided or not
21102132 // it not then not proceeding further
0 commit comments