addWhere(sprintf( '"PublishDate" < \'%s\'', Convert::raw2sql(DBDatetime::now()) )); } } /** * {@inheritDoc} * * This is a fix so that when we try to fetch subclasses of BlogPost, lazy loading includes the * BlogPost table in its query. Leaving this table out means the default sort order column * PublishDate causes an error. * * @see https://github.com/silverstripe/silverstripe-framework/issues/1682 * * @param SQLSelect $query * @param DataQuery $dataQuery * @param DataObject $dataObject */ public function augmentLoadLazyFields(SQLSelect &$query, DataQuery &$dataQuery = null, $dataObject) { $blogPostTable = DataObject::getSchema()->tableName(BlogPost::class); $dataQuery->innerJoin( $blogPostTable, '"SiteTree"."ID" = "' . $blogPostTable . '"."ID"' ); } }