dirigible icon indicating copy to clipboard operation
dirigible copied to clipboard

[EDM] It should be possible to update only a few properties of an entity

Open iliyan-velichkov opened this issue 1 year ago • 2 comments

When you have an entity which has properties like the following: image it should be possible to update only some of the properties using the generated DAO. image It shouldn't be required to provide all the properties which are required for the create entity. This is the case with the generated DAOs for the OpenCart. I want to update only a few fields. In my case there are properties which are required to be provided but I don't have them in the Electra DB. Only OpenCart knows them. image image If I don't provide the required fields, the validation fails:

org.graalvm.polyglot.PolyglotException: Error: Illegal store_id attribute value in oc_order entity: undefined
	at <js>.DAO.validateEntity(./dao:274) ~[na:na]
	at <js>.DAO.update(./dao:377) ~[na:na]
	at <js>.update(../../../dao/oc_orderRepository:18) ~[na:na]
	at <js>.upsert(../../../dao/oc_orderRepository:27) ~[na:na]
	at <js>.handle(merge-order-to-open-cart.js:37) ~[na:na]
	at <js>.onMessage(merge-order-to-open-cart.js:12) ~[na:na]
	at org.graalvm.polyglot.Value.execute(Value.java:881) ~[polyglot-23.1.1.jar!/:na]
	at org.eclipse.dirigible.graalium.core.DirigibleJavascriptCodeRunner.runEsmMethod(DirigibleJavascriptCodeRunner.java:193) ~[dirigible-engine-graalium-execution-core-11.0.0-SNAPSHOT.jar!/:na]
	at org.eclipse.dirigible.graalium.core.DirigibleJavascriptCodeRunner.runMethod(DirigibleJavascriptCodeRunner.java:186) ~[dirigible-engine-graalium-execution-core-11.0.0-SNAPSHOT.jar!/:na]
	at org.eclipse.dirigible.components.engine.camel.invoke.Invoker.invoke(Invoker.java:41) ~[dirigible-components-engine-camel-11.0.0-SNAPSHOT.jar!/:na]

iliyan-velichkov avatar Feb 20 '24 11:02 iliyan-velichkov

As workaround, I'm getting the entity first to get the required fields.

iliyan-velichkov avatar Feb 20 '24 11:02 iliyan-velichkov

@iliyan-velichkov I guess this should be fixed once we make it possible to generate a *.edm file from the *.model file and there you could modify which columns are required and which aren't. As a workaround this could be also manually adjusted in the *.model file. As this feature is only applicable for the "reverse-engineered" approach, I doubt that we should change the existing implementation, as it can mislead about the usage of the DAO/Repository.

ThuF avatar Feb 27 '24 16:02 ThuF