0 votes

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
asked in Solved by (150 points)
edited by

Can you please post required (expected) schema definition?

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

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.

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.

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

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

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

1 Answer

0 votes

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

answered by Skipper developer (131k points)