Update only specific column
See original GitHub issueI’m using DBFlow 4.0.0-beta1
I have model:
@Table(database = MyDatabase.class, name = “hero”) public class Hero extends BaseModel{
@Column(name = "id")
@PrimaryKey
private int id;
@SerializedName("code")
@Column(name = "code")
private String code;
@SerializedName("name")
@Column(name = "name")
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
I’m insert value Hero hero = new Hero(); hero.setId(390); hero.setCode(“823kjh12u3i1k2j3k1j2kj1h2jk32j3kj1h”); hero.setName(“TARFIRE”); hero.save();
Im trying to update only name column
Hero hero = new Hero(); hero.setId(390); hero.setName(“TARFIRE”); hero.update();
but i had code column to be null in my row table
I’m i missing something?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
How to update the field value of specific's column in SQL ...
Try this one - UPDATE aspx_itemimages SET ImagePath = ImagePath + ...
Read more >SQL UPDATE Statement - Updating Data in a Table
The UPDATE statement changes existing data in one or more rows in a table. The following illustrates the syntax of the UPDATE statement:...
Read more >How to Update a Column Based on a Filter of Another ...
Learn how to update a column based on a filter of another column. This tutorial will cover ways to update rows, including full...
Read more >SQL | UPDATE Statement
The UPDATE statement in SQL is used to update the data of an existing table in database. We can update single columns as...
Read more >How to Execute a Trigger Only When a Specific Column is ...
You can do this by using the UPDATE() function inside your trigger. This function accepts the column name as its argument. It returns...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
the idea behind this is upsert. But event native sqlite not support this. Just have replace function that set code column to be null when you dont operate
I get this example from this, I have not used dbflow for a long time. Hope it help https://agrosner.gitbooks.io/dbflow/content/SQLiteWrapperLanguage.html
// Native SQL wrapper SQLite.update(Ant.class) .set(Ant_Table.type.eq(“other”)) .where(Ant_Table.type.is(“worker”)) .and(Ant_Table.isMale.is(true)) .async() .execute(); // non-UI blocking
what I do is create a new table for each variable that is optional.