[Fixed] Set orderBy on owning inverse side (Doctrine 1)

0 votes
asked Apr 21, 2015 in Solved by chielsen (150 points)
edited Oct 13, 2015 by ludek.vodicka

When i set the orderBy property on an association at the owning side, it automatically set the same property at the inverse side in skipper.
In the end what this create is actually only an orderBy at the owning side, and nothing at the inverse side. I can't find any way to set the orderBy at the inverse side.

Example:

"User" has many "Action"

Action has a field 'user_id'

I want to get all "Action"s for a "User", ordered by "Action" name.
So i set the orderby At User on 'name', however this creates an orderBy at Action..

If i run this, it won't add the orderBy at the User part, but only at the Action part. How can i change this around?

User:
  columns:
    id:
      unique: true
      primary: true
      type: integer(4)
      notnull: true
      autoincrement: true
      unsigned: true
Action:
  columns:
    id:
      unique: true
      primary: true
      type: integer(4)
      notnull: true
      autoincrement: true
      unsigned: true
    user_id:
      type: integer(4)
      unsigned: true
    name:
      type: string
  relations:
    User:
      class: User
      foreignAlias: Action
      orderBy: name
      local: user_id
      foreign: id
commented Apr 21, 2015 by ludek.vodicka Skipper developer (140,450 points)

Can you please post required (expected) schema definition?

commented Apr 21, 2015 by chielsen (150 points)
edited Apr 21, 2015 by ludek.vodicka
User:
  columns:
    id:
      unique: true
      primary: true
      type: integer(4)
      notnull: true
      autoincrement: true
      unsigned: true
  relations:
    User:
      local: id
      foreign: user_id
      type: many
      orderBy: name
Action:
  columns:
    id:
      unique: true
      primary: true
      type: integer(4)
      notnull: true
      autoincrement: true
      unsigned: true
    user_id:
      type: integer(4)
      unsigned: true
    name:
      type: string
  relations:
    User:
      class: User
      foreignAlias: Action      
      local: user_id
      foreign: id
commented Apr 21, 2015 by ludek.vodicka Skipper developer (140,450 points)

And are your trying to create many-to-many or one-to-many relation?

Beause what you currently have is "one-to-many" relation and as far as I know it's useless to set orderBy property in inverse side because there is always only one item.

In case you're trying to create many-to-many association, you need to use manyToMany tool.

commented Apr 21, 2015 by chielsen (150 points)

Its one to many (1 user, many actions). I dont see why it is useless?
I want all actions to be ordered on name.
Manually changing this works for me, but it gets reset everytime I do an export.

commented Apr 21, 2015 by ludek.vodicka Skipper developer (140,450 points)

Oh, so Skipper generates it on useless side instead of on the correct side. In this case we will check it

commented Apr 21, 2015 by chielsen (150 points)

Yep.. Owning side often is the useless side.. for a 1 to many. Since you want all manys for the 1, and the many side is the owning side.. lol

commented Apr 21, 2015 by ludek.vodicka Skipper developer (140,450 points)

Ok, I overlooked the sides. I will let you know when I have more info

1 Answer

0 votes
answered Apr 24, 2015 by ludek.vodicka Skipper developer (140,450 points)

Hi, new beta version with bug fix for this issue is ready. Can you please try it and let me know?

http://support.skipper18.com/402/downloads-skipper-beta

Ludek

...