7912 Posts in 1355 Topics by 930 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, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 561 Views |
-
Column 'ClassName' in where clause is ambiguous

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?
-
Re: Column 'ClassName' in where clause is ambiguous

25 January 2012 at 8:58am Last edited: 25 January 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 classThen 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
| 561 Views | ||
|
Page:
1
|
Go to Top |

