Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to stop Silverstripe SearchContext from throwing Version Table_Live error


Go to End


753 Views

Avatar
Lamin Barrow

Community Member, 22 Posts

5 April 2013 at 10:16am

Edited: 05/04/2013 10:17am

Consider the following Silverstripe page class

class Page extends SiteTree{

static $has_many = array('OtherDataObjects' => 'DataObjectClass');

public function getSearchContext() {

    $fields = new FieldSet(

        new TextField('Title', 'Tour'),
        new DropdownField('OtherDataObjects', 'Other Data Object', array('data', 'value')
    );

    $filters = array(
      'Title' => new PartialMatchFilter('Title'),
      'OtherDataObjects' => new PartialMatchFilter('OtherDataObjects.Title')
    );
    return new SearchContext(
      'Page', 
      $fields, 
      $filters
   );
}

Adding this search form to a front-end form and posting a search form always results in a [User Error] with a SQL error containing something like this at the end.

  AND ("DataObjectClass_Live"."DataObjectClass_Live" LIKE 'title') ORDER BY "Sort" LIMIT 25 OFFSET 0 Table 'database DataObjectClass_Live' doesn't exist

I always get this error when search for items based on the has_many or many_many object relations. I get the same error in SIlverstripe versions 2.4.x and the latest 3.0.x versions.

Any help or pointers will be appreciated.