You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Guoyou Jiang <gu...@jsvest.com> on 2009/08/13 16:46:32 UTC
some bugs about migration tools
when i use migration tools, i find some bugs about it:
1ćbootstrap.sql and scripts sql file not support i18n file, so when sql
contains chinese language code, it will print error and insert illegal value
to database.
i have change command code like this:
runner.runScript(new MigrationReader(new InputStreamReader(new
FileInputStream(bootstrap), "utf-8"), false, environmentProperties()));
that's seems ok, so is it possible to add a property value to
environments property file for indicate what charset the .sql file used?
2. another problem is about changelog table, because i run on windows xp, so
the uppercase column name like 'ID' is auto change to 'id', so the
change.get("ID") always return null, cause nullpoint error like:
Exception in thread "main" java.lang.NullPointerException
at java.math.BigDecimal.<init>(BigDecimal.java:647)
at
org.apache.ibatis.migration.commands.BaseCommand.getChangelog(BaseCom
mand.java:65)
at
org.apache.ibatis.migration.commands.StatusCommand.execute(StatusComm
and.java:20)
at
org.apache.ibatis.migration.CommandLine.runCommand(CommandLine.java:7
7)
at
org.apache.ibatis.migration.CommandLine.execute(CommandLine.java:56)
at org.apache.ibatis.migration.Migrator.main(Migrator.java:6)
so i change code like this:
List<Map<String, Object>> changelog = runner.selectAll("select ID,
APPLIED_AT, DESCRIPTION from " + changelogTable() + " order by id");
List<Change> changes = new ArrayList<Change>();
for (Map<String, Object> change : changelog) {
if(change.get("ID") != null) {
//out.println("change: " + change.get("ID") + " " +
change.get("APPLIED_AT") + " " + change.get("DESCRIPTION"));
String id = change.get("ID") == null ? null :
change.get("ID").toString();
String appliedAt = change.get("APPLIED_AT") == null ? null :
change.get("APPLIED_AT").toString();
String description = change.get("DESCRIPTION") == null ? null :
change.get("DESCRIPTION").toString();
changes.add(new Change(new BigDecimal(id), appliedAt,
description));
} else {
//out.println("change: " + change.get("id") + " " +
change.get("applied_at") + " " + change.get("description"));
String id = change.get("id") == null ? null :
change.get("id").toString();
String appliedAt = change.get("applied_at") == null ? null :
change.get("applied_at").toString();
String description = change.get("description") == null ? null :
change.get("description").toString();
changes.add(new Change(new BigDecimal(id), appliedAt,
description));
}
}
that's ok now.