Jump to:

7938 Posts in 1540 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Column 'ClassName' in where clause is ambiguous

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 878 Views
  • CHD
    Community Member
    218 Posts

    Column 'ClassName' in where clause is ambiguous Link to this post

    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?

  • UncleCheese
    4085 Posts

    Re: Column 'ClassName' in where clause is ambiguous Link to this post

    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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.