Skip to content

Commit 33a0d26

Browse files
committed
adjustment in select max
1 parent 4f002d4 commit 33a0d26

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

simplesql/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
defaultConfig {
88
minSdkVersion 11
99
targetSdkVersion 29
10-
versionCode 26
11-
versionName "1.0.25"
10+
versionCode 27
11+
versionName "1.0.26"
1212

1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
consumerProguardFiles 'consumer-rules.pro'

simplesql/src/main/java/com/simplesql/simplesql/config/SimpleSQL.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class Select {
8383
private String SQLString;
8484
private Object typeObject;
8585
private static final String KEY_FUNCTION_PARAMETER = "%column";
86+
private static final String KEY_COLIMN_NAME_MAX = "value_function";
8687
private String type;
8788
/**
8889
* @param typeObject
@@ -101,7 +102,7 @@ public Select(Object typeObject, String type) {
101102
this.functionParameter = true;
102103
break;
103104
case "MAX":
104-
SQLString = "SELECT MAX(" + KEY_FUNCTION_PARAMETER + ")";
105+
SQLString = "SELECT MAX(" + KEY_FUNCTION_PARAMETER + ") INTO "+KEY_COLIMN_NAME_MAX;
105106
this.functionParameter = true;
106107
break;
107108
case "MIN":
@@ -261,13 +262,20 @@ public Object execute() {
261262
cursor.moveToFirst();
262263
return cursor.getInt(0);
263264
}else if(type.equals("MAX") || type.equals("MIN")){
264-
if(cursor.moveToFirst()){
265-
for(Field f:fields){
266-
Object object = checkItem(f, cursor);
267-
if (object != null)
268-
hashMap.put(f.getName(), object);
265+
if(cursor !=null){
266+
cursor.moveToFirst();
267+
while (!cursor.isAfterLast()) {
268+
for (Field f : fields) {
269+
Object object = checkItem(f, cursor);
270+
if (object != null)
271+
hashMap.put(f.getName(), object);
272+
}
273+
String hashJson = new Gson().toJson(hashMap);
274+
lstClasses.add(new Gson().fromJson(hashJson, (Type) typeObject.getClass()));
269275
}
270276
}
277+
cursor.close();
278+
return lstClasses;
271279
}
272280
while (cursor.moveToNext()) {
273281
for (Field f : fields) {

0 commit comments

Comments
 (0)