Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-23599

Legacy search location gateway is not correctly quoting depth column

    XMLWordPrintable

Details

    Description

      Legacy search location gateway is not correctly quoting depth column, which led to an error stating that "depth" column is ambiguous when I was trying to create custom SortClauseHandler, in which I was joining external table which also contained depth column.

      In my controller, I create a LocationQuery with some basic criterions:

      $criterions = array(
                  new Criterion\Subtree( $location->pathString ),
                  new Criterion\Visibility( Criterion\Visibility::VISIBLE ),
                  new Criterion\LogicalNot( new Criterion\LocationId( $location->id )
          )
      );
      
      $query = new LocationQuery();
      $query->criterion = new Criterion\LogicalAnd( $criterions );
      

      I also create sort clause, in which I use custom sort clause handler:

      $query->sortClauses = array(
                 new CustomSortClause('my_type_identifier', 'my_field_identifier')
      );
      

      In the custom sort clause handler, I have something like this inside applyJoin method:

      $query
          ->innerJoin(
              $query->alias(
                  $this->dbHandler->quoteTable( "ezcontentobject_attribute" ),
                  $this->dbHandler->quoteIdentifier( $table )
              ),
              $query->expr->lAnd(
                  $query->expr->eq(
                      $this->dbHandler->quoteColumn( "contentobject_id", $table ),
                      $this->dbHandler->quoteColumn( "id", "ezcontentobject" )
                  ),
                 $query->expr->eq(
                     $this->dbHandler->quoteColumn( "version", $table ),
                     $this->dbHandler->quoteColumn( "current_version", "ezcontentobject" )
                  ),
                  $query->expr->gt(
                      $query->expr->bitAnd(
                          $query->expr->bitAnd( $this->dbHandler->quoteColumn( "language_id", $table ), ~1 ),
                          $this->dbHandler->quoteColumn( "initial_language_id", "ezcontentobject" )
                      ),
                      0
                  )    
              )
          )
                  ->innerJoin(
                      $query->alias(
                          $this->dbHandler->quoteTable( "my_external_table" ),
                          $this->dbHandler->quoteIdentifier( $externalTable )
                      ),
                      $query->expr->eq(
                              $this->dbHandler->quoteColumn( "id", $externalTable ),
                              $this->dbHandler->quoteColumn( "data_int", $table )
                      )
                  )
      );
      

      where "my_external_table" is the table which also contains "depth" column.

      Attachments

        Activity

          People

            Unassigned Unassigned
            7c6f1a9a-f94a-4ef5-89df-6ecd72b88afd@accounts.ibexa.co Ivan Herak
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: