Doctrine 1
  1. Doctrine 1
  2. DC-193

Importing fixtures from YAML in PostgreSQL can fail with column aggregation since sfYaml is an svn external

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 1.2.0-BETA2
    • Fix Version/s: None
    • Component/s: Data Fixtures, Inheritance
    • Labels:
      None
    • Environment:
      PostgreSQL 8.3.7, PHP 5.2.11

      Description

      Hi,

      While I'm reloading my fixtures, I get this exception:

      SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: character varying = integer
        LINE 1: ...ET deleted_at = $1 WHERE (deleted_at IS NULL AND (type = 1))
                                                                          ^
        HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
      

      I get this issue since revision 6623, when sfYaml has been made an svn external.

      The interesting point is that I can reload my fixtures properly under MySQL, but not under PostgreSQL. This bug is probably related to the new sfYaml type checking (DC-165).

      I did some investigation and in reality the fixture loading fails when a relation implementing column aggregation inheritance uses an integer as a key value.

      For instance, this piece of YAML should fail at reloading when some EyContactAuthor fixtures are added :

      EyContact:
        actAs:
          Timestampable:
          SoftDelete:
        columns:
          id:
            type:              integer(6)
            primary:           true
            autoincrement:     true
          title:
            type:              string(4)
            notnull:           true
            default:           M
          first_name:
            type:              string(150)
            notnull:           true
          last_name:
            type:              string(150)
            notnull:           true
      
      EyContactAuthor:
        actAs:
          Timestampable:
          SoftDelete:
        inheritance:
          extends:             EyContact
          type:                column_aggregation
          keyField:            type
          keyValue:            1
        columns:
          published_first_name:
            type:              string(150)
            notnull:           false
          published_last_name:
            type:              string(150)
            notnull:           false
          biography:
            type:              string(5000)
            notnull:           false
      

      Conversely, the following piece of YAML is fine:

      EyContact:
        actAs:
          Timestampable:
          SoftDelete:
        columns:
          id:
            type:              integer(6)
            primary:           true
            autoincrement:     true
          title:
            type:              string(4)
            notnull:           true
            default:           M
          first_name:
            type:              string(150)
            notnull:           true
          last_name:
            type:              string(150)
            notnull:           true
      
      EyContactAuthor:
        actAs:
          Timestampable:
          SoftDelete:
        inheritance:
          extends:             EyContact
          type:                column_aggregation
          keyField:            type
          keyValue:            author
        columns:
          published_first_name:
            type:              string(150)
            notnull:           false
          published_last_name:
            type:              string(150)
            notnull:           false
          biography:
            type:              string(5000)
            notnull:           false
      

      So there are two solutions: either the key value should be compatible again with the integer type under PostgreSQL, or the compulsory use of a string should be documented.

      Thanks for your time,
      Jérémy Subtil, Sensio Labs

        Activity

        Hide
        Jonathan H. Wage added a comment -

        The type column that is added is a string I believe. So in your YAML when you use 1 as the value, in PHP it ends up being a integer 1, which that param is then bound to the type column. So in pgsql you get the error. You can fix this by doing '1' forcing the yaml parser to read it in as a string, or change the type column on the top most parent model to be a string.

        Show
        Jonathan H. Wage added a comment - The type column that is added is a string I believe. So in your YAML when you use 1 as the value, in PHP it ends up being a integer 1, which that param is then bound to the type column. So in pgsql you get the error. You can fix this by doing '1' forcing the yaml parser to read it in as a string, or change the type column on the top most parent model to be a string.
        Hide
        Jonathan H. Wage added a comment -

        No code fix is necessary for this ticket.

        Show
        Jonathan H. Wage added a comment - No code fix is necessary for this ticket.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Jérémy Subtil
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: