From Mark Johnson: support long autogenerated fields.

This commit is contained in:
Ray Greenwell
2011-03-29 03:42:24 +00:00
parent 07e5b934b5
commit 903bb5181b
2 changed files with 20 additions and 3 deletions
@@ -20,6 +20,8 @@
package com.samskivert.depot.impl;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
@@ -285,6 +287,12 @@ public class PostgreSQLBuilder
return fm.getColumnType(TYPER, length);
}
@Override
protected String getSerialType (Field field)
{
return field.getType().equals(Long.TYPE) ? "BIGSERIAL" : "SERIAL";
}
protected static String massageFTQuery (FullText match)
{
// The tsearch2 engine takes queries on the form
@@ -127,7 +127,7 @@ public abstract class SQLBuilder
GeneratedValue genValue = fm.getGeneratedValue();
if (genValue != null) {
maybeMutateForGeneratedValue(genValue, coldef);
maybeMutateForGeneratedValue(field, genValue, coldef);
} else if (coldef.defaultValue == null) {
maybeMutateForPrimitive(field, coldef);
@@ -163,12 +163,13 @@ public abstract class SQLBuilder
}
}
protected void maybeMutateForGeneratedValue (GeneratedValue genValue, ColumnDefinition coldef)
protected void maybeMutateForGeneratedValue (
Field field, GeneratedValue genValue, ColumnDefinition coldef)
{
switch (genValue.strategy()) {
case AUTO:
case IDENTITY:
coldef.type = "SERIAL";
coldef.type = getSerialType(field);
coldef.unique = true;
break;
@@ -181,6 +182,14 @@ public abstract class SQLBuilder
}
}
/**
* The serial type for the field.
*/
protected String getSerialType (Field field)
{
return "SERIAL";
}
/**
* Returns the boolean literal that corresponds to false.
*/