Certainly. in the given piece of code fullInfo is jsonObject
I try
$a = [ 'a' => 'b' ]
1. 'fullInfo' => $a
2. 'fullInfo' => json_encode($a)
Improve insertOnDuplicateUpdate
Collapse
X
-
1. In the context of Mapper an ID should not be set inside the method. The current behavior is right.
2. Did you try jsonObject type in espo? I don't think that tne problem is with the mapper and is related to insertonduplicateupdate method.
4. Impossible. -
Too bad you post this too late, I think v7 also been finalized unless bug appear but I think it feature frozen. Otherwise this would have been good addition.Leave a comment:
-
Improve insertOnDuplicateUpdate
insertOnDuplicateUpdate is very useful when integrating with external services.
External entities have their own Id's and in the espo we have
It would be nice if insertOnDuplicateUpdate have full entity support:Code:{ "fields": { "externalId": { "type": "int" } }, "indexes": { "externalIdUnique": { "type": "unique", "columns": [ "externalId", "deleted" ] } }
1. Default ID (this code without setting ID don't work, cause PDOException SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value in /application/Espo/ORM/SqlExecutor.php:72)
2. Support all field types, included jsonType. jsonType fullinfo is null after insertOnDuplicateUpdate($e ...PHP Code:$em = $this->getEntityManager(); $e = $em->getEntity('Host'); $id = \Espo\Core\Utils\Util::generateId(); $e->set([ // 'id' => $id, 'externalId'=> '999', 'name' => 'Модифицированный' ]); $s = $em->getMapper('RDB')->insertOnDuplicateUpdate($e, [ 'name' ]);
3. Support fetched id if duplicate founded.PHP Code:$e->set([ 'fullInfo' => '{"a":"b"}' ]);
Now $e->id is preliminarily generated value, not actual.
4. Support additional link fields. This code cause exception. But in saveEntity all ok.
PHP Code:set([ 'HostUsersIds' => $hI, 'HostUsersNames' => $hN, 'HostUsersColumns' => $hC ]);Tags: None

Leave a comment: