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:
Michael Bayne
2007-08-22 02:40:44 +00:00
parent 5191c6d967
commit a6f5211db4
@@ -164,6 +164,14 @@ public abstract class SQLBuilder
// append the default value if one was specified // append the default value if one was specified
if (defval.length() > 0) { if (defval.length() > 0) {
builder.append(" DEFAULT ").append(defval); 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");
} }
} }