Hack in a default value for integer types so that Postgres doesn't freak out
when we add a new non-null integer column. Maybe we should just specify default values for all our integer columns, but decades of programming history point toward zero as a pretty sensible default.
This commit is contained in:
@@ -164,6 +164,14 @@ public abstract class SQLBuilder
|
||||
// append the default value if one was specified
|
||||
if (defval.length() > 0) {
|
||||
builder.append(" DEFAULT ").append(defval);
|
||||
|
||||
} else if (field.getType().equals(Integer.TYPE) || // TODO: how to do this properly?
|
||||
field.getType().equals(Integer.class) ||
|
||||
field.getType().equals(Byte.TYPE) ||
|
||||
field.getType().equals(Byte.class) ||
|
||||
field.getType().equals(Short.TYPE) ||
|
||||
field.getType().equals(Short.class)) {
|
||||
builder.append(" DEFAULT 0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user