Skip to content

Commit

Permalink
Fix bug for losing data when upgrading db if model field has uppercas…
Browse files Browse the repository at this point in the history
…e character.
  • Loading branch information
zcc1234567 committed Jun 2, 2020
1 parent fbee859 commit 1b2e3e6
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.litepal.tablemanager.model;

import org.litepal.util.BaseUtility;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -89,7 +91,7 @@ public void setClassName(String className) {
* A column model contains name, type and constraints.
*/
public void addColumnModel(ColumnModel columnModel) {
columnModelMap.put(columnModel.getColumnName(), columnModel);
columnModelMap.put(BaseUtility.changeCase(columnModel.getColumnName()), columnModel);
}

/**
Expand All @@ -107,7 +109,7 @@ public Collection<ColumnModel> getColumnModels() {
* @return A ColumnModel which can map the column name passed in. Or null.
*/
public ColumnModel getColumnModelByName(String columnName) {
return columnModelMap.get(columnName);
return columnModelMap.get(BaseUtility.changeCase(columnName));
}

/**
Expand All @@ -116,7 +118,7 @@ public ColumnModel getColumnModelByName(String columnName) {
* Name of the column to remove.
*/
public void removeColumnModelByName(String columnName) {
columnModelMap.remove(columnName);
columnModelMap.remove(BaseUtility.changeCase(columnName));
}

/**
Expand All @@ -126,7 +128,7 @@ public void removeColumnModelByName(String columnName) {
* @return True if matches a column in the table model. False otherwise.
*/
public boolean containsColumn(String columnName) {
return columnModelMap.containsKey(columnName);
return columnModelMap.containsKey(BaseUtility.changeCase(columnName));
}

}

0 comments on commit 1b2e3e6

Please sign in to comment.