Skip to content

Commit 18e9e87

Browse files
author
Lucas Nascimento
committed
add field byteArray
1 parent 12e21e0 commit 18e9e87

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77

88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.5.0'
10+
classpath 'com.android.tools.build:gradle:3.5.1'
1111

1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files

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 28
11-
versionName "1.0.27"
10+
versionCode 29
11+
versionName "1.0.28"
1212

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

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public class Select {
8787
private static final String KEY_FUNCTION_PARAMETER = "%column";
8888
private static final String KEY_COLIMN_NAME_MAX = "value_function";
8989
private String type;
90+
9091
/**
9192
* @param typeObject
9293
* @param type
@@ -104,7 +105,7 @@ public Select(Object typeObject, String type) {
104105
this.functionParameter = true;
105106
break;
106107
case "MAX":
107-
SQLString = "SELECT MAX(" + KEY_FUNCTION_PARAMETER + ") INTO "+KEY_COLIMN_NAME_MAX;
108+
SQLString = "SELECT MAX(" + KEY_FUNCTION_PARAMETER + ") INTO " + KEY_COLIMN_NAME_MAX;
108109
this.functionParameter = true;
109110
break;
110111
case "MIN":
@@ -252,19 +253,19 @@ public Object execute() {
252253
if (functionParameter) {
253254
if (fields[0] == null || fields[0].equals(""))
254255
columnFunction = "*";
255-
SQLString = SQLString.replace(fields[0],"").replace(KEY_FUNCTION_PARAMETER, (CharSequence) getString(fields[0]));
256+
SQLString = SQLString.replace(fields[0], "").replace(KEY_FUNCTION_PARAMETER, (CharSequence) getString(fields[0]));
256257
}
257258
SQLString = SQLString + ";";
258259
List lstClasses = new ArrayList<>();
259260
Field[] fields = typeObject.getClass().getDeclaredFields();
260261
HashMap<String, Object> hashMap = new HashMap<>();
261262
try {
262-
Cursor cursor = read.rawQuery(SQLString, null);
263-
if(type.equals("COUNT")){
263+
Cursor cursor = read.rawQuery(SQLString, null);
264+
if (type.equals("COUNT")) {
264265
cursor.moveToFirst();
265266
return cursor.getInt(0);
266-
}else if(type.equals("MAX") || type.equals("MIN")){
267-
if(cursor !=null){
267+
} else if (type.equals("MAX") || type.equals("MIN")) {
268+
if (cursor != null) {
268269
cursor.moveToFirst();
269270
while (!cursor.isAfterLast()) {
270271
for (Field f : fields) {
@@ -421,6 +422,12 @@ public Update fieldInt(int value) {
421422
return this;
422423
}
423424

425+
public Update fiedlByteArray(byte[] value) {
426+
this.value = value;
427+
SQLString = SQLString + value;
428+
return this;
429+
}
430+
424431
public Update fieldLong(long value) {
425432
this.value = value;
426433
SQLString = SQLString + value;
@@ -473,13 +480,11 @@ public boolean execute() {
473480
}
474481

475482
public Object getString(String string) {
476-
String s = "A;B;C;D;E;F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;X;Y;Z;a;b;c;d;d;e;f;g;h;i;j;k;l;m;n;o;p;q;r;s;t;u;v;w;x;y;z;\\;\\*";
477-
String[] arrays = s.split(";");
478-
for (String array : arrays) {
479-
if (string.contains(array)) {
480-
return "\"" + string + "\"";
481-
}
483+
484+
if (string.contains("[a-zA-Z]")) {
485+
return "'" + string + "'";
482486
}
487+
483488
return string;
484489
}
485490

@@ -579,7 +584,7 @@ public boolean execute() {
579584
checkObject(field, obj);
580585
if (field.get(obj) == null && column.non_null())
581586
throw new SQLException("This " + field.getName() + " is not null but is empty");
582-
} else
587+
} else
583588
throw new SQLException("The " + field.getName() + "attribute did not have the column annotation");
584589
}
585590
long result = write.insert(table, null, values);

0 commit comments

Comments
 (0)