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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Column 'ClassName' in where clause is ambiguous


2 Posts   898 Views


25 January 2012 at 3:12am Community Member, 218 Posts

Today, we published a site, then realised everything worked fine except for the Assets panel. When opening the Assets page we had this error:

"Column 'ClassName' in where clause is ambiguous"

A quick Google led us to this page:

But we already had the latest uploadify module installed, so it wasn't that. We couldn't find any problems in our DB tables. No missing classNames etc.

In our site we had a HomePage.php with:

static $has_many = array(
   'AttachedFiles' => 'Slideshow'   

and in Slideshow.php we had:

class Slideshow extends Image {

   static $has_one = array (
      'HomePage' => 'HomePage'

All worked fine in the front end, and the CMS, but we couldn't get the Assets to work with what ever we tried!
Eventually, we just renamed the Slideshow to SlideshowItem and it fixed everything.

Can anybody shed in light on why this happened? We've never seen it before and re-use the HomePage.php & Slideshow.php files all the time, s why would this suddenly die?


25 January 2012 at 8:58am (Last edited: 25 January 2012 8:59am), 4085 Posts

Yeah, this is a nasty error. I can't remember exactly how I've solved it in the past, but if I had to guess I'd say it has to do with SilverStripe's not-quite-complete management of columns. Because the ORM is designed a bit paranoid, it only creates columns, and won't' delete them. It's therefore possible (I think), that if you did:

class MyClass extends DataObject
--> Table MyClass has a ClassName column, because its parent is the base data class

Then change it to:

class MyClass extends Image
--> Table MyClass now has a ClassName column but it should not, and SilverStripe won't delete that column.

I could be wrong about that, but it sounds right to me. If it's true, when the tables join, you have an ambiguous column error.

SilverStripe tips, tutorials, screencasts and more: