Skip to content

Commit 294f4a3

Browse files
committed
ajustando delete
1 parent f520a3f commit 294f4a3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ public Select selectTable(Object typeObject) {
3333
return new Select(typeObject);
3434
}
3535

36-
public DeleteColumn deleteColumn(Object o) {
37-
return new DeleteColumn(o);
36+
public DeleteColumn deleteColumn(String tableName) {
37+
return new DeleteColumn(tableName);
3838
}
3939

4040

41+
4142
public Update updateTable(Object typeObject) {
4243
return new Update(typeObject);
4344
}
@@ -573,9 +574,9 @@ public String deleteTable(Object obj, SQLiteDatabase db) {
573574
public class DeleteColumn {
574575
private String table, SQLString;
575576

576-
public DeleteColumn(Object o) {
577-
this.table = o.getClass().getSimpleName();
578-
this.SQLString = "";
577+
public DeleteColumn(String tableName) {
578+
this.table = tableName;
579+
this.SQLString = "DELETE FROM "+tableName;
579580
}
580581

581582
public DeleteColumn equals() {
@@ -604,7 +605,7 @@ public DeleteColumn like(String s) {
604605
}
605606

606607
public DeleteColumn fieldString(String value) {
607-
SQLString += value;
608+
SQLString += "\""+value+"\"";
608609
return this;
609610
}
610611

@@ -641,7 +642,7 @@ public DeleteColumn writeSQL(String sql) {
641642
public boolean execute() {
642643
SQLiteDatabase write = helperBD.getWritableDatabase();
643644
try {
644-
write.execSQL("DELETE FROM " + table + " " + SQLString);
645+
write.execSQL(SQLString);
645646
return true;
646647
} catch (Exception e) {
647648
return false;

0 commit comments

Comments
 (0)