0 votes

I have an existing project that is already using doctrine2 yaml mappings and works fine.
My first test was to import my mapping files and export them again to see if everything worked.
Upon importing my yaml mappings into Skipper it automatically generated primary key 'id' fields on all the entities where my primary key was given a different name other than 'id'.

Here is an example with two separate entities that work fine in doctrine2:

MyApp\User:
    type: entity
    table: app_users
    oneToMany:
      photos:
        targetEntity: MyApp\Photos
        mappedBy: user
        fetch: EXTRA_LAZY
    id:
        userId:
            type: integer
            nullable: false
            id: true
            column: user_id
            generator:
                strategy: AUTO
    fields:
        fullName:
            type: string
            nullable: false
            length: 255
            fixed: false
            column: full_name
        email:
            type: string
            nullable: false
            length: 255
            fixed: false
        created:
            type: datetime
            nullable: false
            default: CURRENT_TIMESTAMP
    lifecycleCallbacks: {  }

MyApp\Photo:
    type: entity
    table: app_user_photos
    manyToOne:
      user:
        targetEntity: MyApp\User
        inversedBy: photos
        joinColumn:
          name: user_id
          referencedColumnName: user_id
    id:
        photoId:
            type: integer
            nullable: false
            id: true
            generator:
                strategy: AUTO
    fields:
        caption:
            type: string
            nullable: false
            length: 255
            fixed: false
        url:
            type: string
            nullable: false
            length: 255
            fixed: false
        created:
            type: datetime
            nullable: false
            default: CURRENT_TIMESTAMP
    lifecycleCallbacks: {  }

When Skipper imports this it ends up looking like the following:


The highlighted 'id' field was never defined in the entity yaml file and deleting this newly generated 'id' field removes my association.

When viewing the properties of the new 'id' field it looks as follows:
enter image description here

Why is the new 'id' field now a unique primary key with auto increment?

When I export these entities I end up with the following:

MyApp\User:
  type: entity
  table: app_users
  id:
    userId:
      type: integer
      column: user_id
      generator:
        strategy: AUTO
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    fullName:
      type: string
      length: 255
      nullable: false
      column: full_name
    email:
      type: string
      length: 255
      nullable: false
    created:
      type: datetime
      nullable: false


MyApp\Photo:
  type: entity
  table: app_user_photos
  id:
    photoId:
      type: integer
      generator:
        strategy: AUTO
  fields:
    caption:
      type: string
      length: 255
      nullable: false
    url:
      type: string
      length: 255
      nullable: false
    created:
      type: datetime
      nullable: false
  manyToOne:
    user:
      targetEntity: MyApp\User
      joinColumns:
        user_id:
          referencedColumnName: id

This newly generated YAML won't even get processed by doctrine2 as it chokes with an error complaining about the 'id' field.

Could you please advise whats wrong here?

asked in Solved by (120 points)
recategorized by

Hi, I didn't receive any email or project. Were you able to solve it?

1 Answer

0 votes

Hi, this is probably bug inside Skipper import process. There are mechanism to calculate missing fields (assocaition, pk,...) on obviously import template doesn't recognized your non "id" PK.

Can you please send one of your schema files which causing this bug to my email [email protected] so we can test it here and fix it?

Thanks

answered by Skipper developer (135k points)