From Mark Johnson: support long autogenerated fields.
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user