silverstripe/sapphire — pull request #1840 by halkyon (2013-05-07 00:38:31+00:00)
Title: BUG Fixing queries on non-existent table breaking archive site

With a many to many relation, e.g. SiteTree_MyRelation, and listing
them in your template then adding ?archiveDate=x in the URL, a SQL
error is shown because Versioned::augmentSQL() tries to query the
non-existent table "SiteTree_MyRelation_versions" assuming there's
versioning setup, but there isn't.

I've added a test to expose this scenario, and the fix is to simply check
the table exists before augmenting the SQL in Versioned.