Skip to content

Commit

Permalink
0.9.12
Browse files Browse the repository at this point in the history
  • Loading branch information
babyfish-ct committed Nov 10, 2024
1 parent bff2f0e commit 44e6eec
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void throwTargetIsNotTransferable(ImmutableSpi entity) {
path,
"Can the move the child object whose type is \"" +
entity.__type() +
"\" and id \"" +
"\" and id is \"" +
entity.__get(entity.__type().getIdProp().getId()) +
"\" to " +
"another parent object because the property \"" +
Expand All @@ -243,15 +243,6 @@ void throwIncompleteProperty(ImmutableProp prop, String catalog) {
);
}

void throwNoVersion(ImmutableProp prop) {
throw new SaveException.IncompleteProperty(
path,
"Cannot save the entity, the value of the property \"" +
prop +
"\" is unloaded, the version must be specified for update/upsert"
);
}

SaveException.NotUnique createConflictId(ImmutableProp idProp, Object id) {
return new SaveException.NotUnique(
path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ private Table tableOf(ImmutableType type) throws SQLException {
type,
null,
"Too many matched tables: " + tables +
conflictReason()
conflictReason() +
", please try configure `setDatabaseValidationCatalog` " +
"or `setDatabaseValidationSchema`"
)
);
tableRef = Ref.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1749,4 +1749,58 @@ public void beforeSave(@NotNull NamedEntityDraft draft, NamedEntity original) {
}
}
}

@Test
public void testTransferForbid() {
BookStore store = Immutables.createBookStore(draft -> {
draft.setName("TURING");
draft.addIntoBooks(book -> {
book.setName("GraphQL in Action");
book.setEdition(1);
});
});
setAutoIds(
BookStore.class,
UUID.fromString("85c9e0b9-b8f8-4aa5-b025-405cb3fbbcc4")
);
executeAndExpectResult(
getSqlClient()
.getEntities()
.saveCommand(store),
ctx -> {
ctx.statement(it -> {
it.queryReason(QueryReason.IDENTITY_GENERATOR_REQUIRED);
it.sql(
"select tb_1_.ID, tb_1_.NAME " +
"from BOOK_STORE tb_1_ " +
"where tb_1_.NAME = ?"
);
});
ctx.statement(it -> {
it.sql(
"insert into BOOK_STORE(ID, NAME, VERSION) values(?, ?, ?)"
);
});
ctx.statement(it -> {
it.queryReason(QueryReason.TARGET_NOT_TRANSFERABLE);
it.sql(
"select tb_1_.ID, tb_1_.NAME, tb_1_.EDITION, tb_1_.STORE_ID " +
"from BOOK tb_1_ " +
"where (tb_1_.NAME, tb_1_.EDITION) = (?, ?)"
);
});
ctx.throwable(it -> {
it.message(
"Save error caused by the path: \"<root>.books\": " +
"Can the move the child object whose type is " +
"\"org.babyfish.jimmer.sql.model.Book\" and " +
"id is \"a62f7aa3-9490-4612-98b5-98aae0e77120\" " +
"to another parent object because the property " +
"\"org.babyfish.jimmer.sql.model.BookStore.books\" " +
"does not support target transfer"
);
});
}
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public void testUpsertNotMatchedWithOneToMany() {
"Save error caused by the path: \"<root>.books\": " +
"Can the move the child object whose type is " +
"\"org.babyfish.jimmer.sql.model.Book\" " +
"and id \"e110c564-23cc-4811-9e81-d587a13db634\" " +
"and id is \"e110c564-23cc-4811-9e81-d587a13db634\" " +
"to another parent object because the property " +
"\"org.babyfish.jimmer.sql.model.BookStore.books\" " +
"does not support target transfer"
Expand Down

0 comments on commit 44e6eec

Please sign in to comment.