mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-19 23:02:24 +00:00
#2415 - SQL for Index and Foreign Key didn't get generated if I map ID column after @ManyToOne
Allow declaring the column twice with scalar type after ManyToOne type
This commit is contained in:
1 parent
a02fee7de0
commit
f7c83411c2
3 files changed
+47
-33
No files matched your search
@@ -561,6 +561,16 @@ public class MTable {
|
||||
return newCol;
|
||||
}
|
||||
|
||||
public MColumn addColumnScalar(String dbColumn, String columnDefn) {
|
||||
MColumn existingColumn = getColumn(dbColumn);
|
||||
if (existingColumn != null) {
|
||||
return existingColumn;
|
||||
}
|
||||
MColumn newCol = new MColumn(dbColumn, columnDefn);
|
||||
addColumn(newCol);
|
||||
return newCol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a 'new column' to the AddColumn migration object.
|
||||
*/
|
||||
|
||||
+2
-6
@@ -246,14 +246,13 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
lastColumn = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// using non-strict mode to render the DB type such that we have a
|
||||
// "logical" type like jsonb(200) that can map to JSONB or VARCHAR(200)
|
||||
MColumn col = new MColumn(p.dbColumn(), ctx.getColumnDefn(p, false));
|
||||
MColumn col = table.addColumnScalar(p.dbColumn(), ctx.getColumnDefn(p, false));
|
||||
//MColumn col = new MColumn(p.dbColumn(), ctx.getColumnDefn(p, false));
|
||||
col.setComment(p.dbComment());
|
||||
col.setDraftOnly(p.isDraftOnly());
|
||||
col.setHistoryExclude(p.isExcludedFromHistory());
|
||||
|
||||
if (p.isId() || p.isImportedPrimaryKey()) {
|
||||
col.setPrimaryKey(true);
|
||||
if (p.descriptor().isUseIdGenerator()) {
|
||||
@@ -279,7 +278,6 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
}
|
||||
|
||||
col.setDbMigrationInfos(p.dbMigrationInfos());
|
||||
|
||||
if (p.isUnique() && !p.isId()) {
|
||||
col.setUnique(uniqueConstraintName(col.getName()));
|
||||
indexSetAdd(col.getName());
|
||||
@@ -293,9 +291,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
|
||||
col.setCheckConstraint(buildCheckConstraint(p.dbColumn(), checkConstraintValues));
|
||||
col.setCheckConstraintName(checkConstraintName(col.getName()));
|
||||
}
|
||||
|
||||
lastColumn = col;
|
||||
table.addColumn(col);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user