Skip to content

update queries - Allow set the value of one translated property. #178

@rfanjul

Description

@rfanjul

Having the next Document and values.

screen shot 2016-06-04 at 14 02 03

I am trying to create/update a new property "extid". Tested two queries which the first one , with success result is:
UPDATE nt:unstructured as a SET a.extid='1' WHERE phpcr:class="Joiz\CmsBundle\Document\ShowInstance";

However i am not be able to set the value of the property phpcr_locale:en-extid in the following second query:

UPDATE nt:unstructured as a SET a.extid=a.[phpcr_locale:en-extid] WHERE phpcr:class="Joiz\CmsBundle\Document\ShowInstance"; `

The error I got is:

[PHPCR\ValueFormatException] Invalid value for property "extid": Object values must implement PHPCR\NodeInterface, PHPCR\PropertyInterface or be \DateTime, supplied argument is of class: PHPCR\Shell\Query\ColumnOperand

Activity

dbu

dbu commented on Jun 9, 2016

@dbu
Member

@dantleech we also tried with
UPDATE nt:unstructured SET extid=[phpcr_locale:en-extid] WHERE phpcr:class="Joiz\CmsBundle\Document\ShowInstance" as the example on http://phpcr.readthedocs.io/en/latest/phpcr-shell/querying.html#updating looks like the name of the document is not used in the update. but still the same error.

dantleech

dantleech commented on Jun 9, 2016

@dantleech
Member

You can't use dynamic properties in an update at the moment.

But I think you can use the expr() funtion as follows to achieve what you want I think:

UPDATE nt:unstructured SET extid=expr("row.node.property('phpcr_locale:en-extid')") WHERE phpcr:class="Joiz\CmsBundle\Document\ShowInstance"
dbu

dbu commented on Jun 9, 2016

@dbu
Member

Thanks for looking at it. @rfanjul does the expr work for you?

What do you mean with dynamic properties @dantleech ? That setting a property to the value of another property is not implemented? ah, i think i misread the join example... should we add a note about this in the doc? its something people are used to from SQL, so making it explicit this is not yet supported and point to the expr would help.

dantleech

dantleech commented on Jun 9, 2016

@dantleech
Member

it is something we could support. but indeed we could add a note in the docs now and explain that expr() can be used as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dbu@dantleech@rfanjul

        Issue actions

          update queries - Allow set the value of one translated property. · Issue #178 · phpcr/phpcr-shell