orm icon indicating copy to clipboard operation
orm copied to clipboard

[Cycle 2.0] SchemaInterface::TYPECAST_HANDLER

Open sergey-telpuk opened this issue 3 years ago • 3 comments

Hi, I have an error Error : Object of classUserId could not be converted to string /app/vendor/cycle/orm/src/Heap/Heap.php:154

All objects were converted to string fine, but I have this error

sergey-telpuk avatar Dec 30 '21 17:12 sergey-telpuk

Insert works correct but when we do syncHeap we get from Node not correct data and transaction fails

 public function attach(object $entity, Node $node, array $index = []): void
    {
        $this->storage->offsetSet($entity, $node);
        $role = $node->getRole();

        if ($node->hasState()) {
            $this->eraseIndexes($role, $node->getData(), $entity);
            $data = $node->getState()->getData();
        } else {
            $data = $node->getData();
        }

........
 } else {
                if (!isset($data[$indexName])) {
                    continue;
                }
                $value = (string)$data[$indexName]; <-------------------- converts not stingable objects
                $rolePath[$value] = $entity;
            }

sergey-telpuk avatar Dec 30 '21 18:12 sergey-telpuk

@roxblnfk Hello, do you have any updates for this bug. I really want to start using cycle 2.0 but this one stop me, thanks

sergey-telpuk avatar Jan 04 '22 13:01 sergey-telpuk

@sergey-telpuk Hello. I have an understanding of the issue and i am saddened to realize that we made it. Right now i'm on my day off and i'm not doing development.

But i have a few solutions:

  • As a temporary solution, you can implement a Stringable interface in the classUserId class.
  • In the future, when i go back to work, i might adjust the existing Heap to do cast/uncast actions on the Node data, or i might write new Heap for such cases.

In any case, this issue will be resolved, but later

roxblnfk avatar Jan 04 '22 15:01 roxblnfk