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.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2204 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2007-08-22 02:40:44 +00:00
parent ed88407fe9
commit 0be54aa3ae
@@ -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");
}
}