question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update only specific column

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
nirwannursabdacommented, Jun 8, 2017

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

  1. select -> replace or
  2. select -> update to bring existing data

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

1reaction
abiemanncommented, Jul 15, 2017

what I do is create a new table for each variable that is optional.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found