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


Reply


2 Posts   937 Views

Avatar
CHD

Community Member, 218 Posts

25 January 2012 at 3:12am

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: https://github.com/unclecheese/Uploadify/commit/88a3b16973c17382e81a13261dae187ba60c7cc0

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?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

25 January 2012 at 8:58am

Edited: 25/01/2012 8:59am

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: http://www.leftandmain.com