Skip to content

Commit

Permalink
Merge pull request #3274 from ebean-orm/feature/3269
Browse files Browse the repository at this point in the history
#3268 - @DbComment on @manytoone fields are ignored (ddl-generator)
  • Loading branch information
rbygrave authored Nov 21, 2023
2 parents b2b8167 + 589e198 commit 196cb09
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ private void readAssocOne(DeployBeanPropertyAssoc<?> prop) {
if (formula != null) {
prop.setSqlFormula(processFormula(formula.select()), processFormula(formula.join()));
}
DbComment comment = get(prop, DbComment.class);
if (comment != null) {
prop.setDbComment(comment.value());
}
initWhoProperties(prop);
initDbMigration(prop);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public void visitOneImported(BeanPropertyAssocOne<?> p) {
MColumn col = table.addColumn(dbCol, columnDefn, !p.isNullable());
col.setDbMigrationInfos(p.dbMigrationInfos());
col.setDefaultValue(p.dbColumnDefault());
col.setComment(p.dbComment());
if (addForeignKey) {
if (columns.length > 1) {
compoundKey.addColumnPair(dbCol, refColumn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void test() {
assert_discriminatorColumn_explicit(model);
assert_discriminatorColumn_implied(model);
assert_discriminatorColumn_length(model);
assert_comment_onManyToOne(model);
}

@Test
Expand Down Expand Up @@ -144,4 +145,11 @@ private void assert_discriminatorColumn_length(ModelContainer model) {
assertThat(discTypeColumn.getType()).isEqualTo("varchar(3)");
assertThat(discTypeColumn.isNotnull()).isTrue();
}

private void assert_comment_onManyToOne(ModelContainer model) {
MTable message = model.getTable("c_message");
MColumn conversation = message.getColumn("conversation_id");
assertThat(conversation.getType()).isEqualTo("bigint");
assertThat(conversation.getComment()).isEqualTo("A ManyToOne comment");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.tests.model.converstation;

import io.ebean.annotation.DbComment;
import org.tests.model.BaseModel;

import jakarta.persistence.Entity;
Expand All @@ -14,6 +15,7 @@ public class Message extends BaseModel {

String body;

@DbComment("A ManyToOne comment")
@ManyToOne
Conversation conversation;

Expand Down

0 comments on commit 196cb09

Please sign in to comment.