From 44e6eecdad6b21fcf2444269ee43fe63c68c50c0 Mon Sep 17 00:00:00 2001 From: babyfish-ct Date: Mon, 11 Nov 2024 05:06:21 +0800 Subject: [PATCH] 0.9.12 --- .../ast/impl/mutation/MutationContext.java | 11 +--- .../sql/runtime/DatabaseValidators.java | 4 +- .../jimmer/sql/mutation/CascadeSaveTest.java | 54 +++++++++++++++++++ .../sql/trigger/SaveWithTriggerTest.java | 2 +- 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/MutationContext.java b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/MutationContext.java index 98b869eb9..01f4baa61 100644 --- a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/MutationContext.java +++ b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/ast/impl/mutation/MutationContext.java @@ -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 \"" + @@ -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, diff --git a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/DatabaseValidators.java b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/DatabaseValidators.java index 2c6057e6b..f3914d199 100644 --- a/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/DatabaseValidators.java +++ b/project/jimmer-sql/src/main/java/org/babyfish/jimmer/sql/runtime/DatabaseValidators.java @@ -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(); diff --git a/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/mutation/CascadeSaveTest.java b/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/mutation/CascadeSaveTest.java index eb952a517..0386c67f2 100644 --- a/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/mutation/CascadeSaveTest.java +++ b/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/mutation/CascadeSaveTest.java @@ -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: \".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" + ); + }); + } + ); + } } diff --git a/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/trigger/SaveWithTriggerTest.java b/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/trigger/SaveWithTriggerTest.java index 004396b8a..058354c79 100644 --- a/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/trigger/SaveWithTriggerTest.java +++ b/project/jimmer-sql/src/test/java/org/babyfish/jimmer/sql/trigger/SaveWithTriggerTest.java @@ -509,7 +509,7 @@ public void testUpsertNotMatchedWithOneToMany() { "Save error caused by the path: \".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"