arambalakjian / DataObject-as-Page

A SilverStripe module for displaying DataObjects as Pages
53 stars 27 forks source link

Unknown column ClassName when Saving in DataObjectAsPageAdmin #2

Closed lingo closed 12 years ago

lingo commented 12 years ago

I don't have time right now to chase this down, but this comes about, but this is based on a quick install and follow of instructions. If I find more info, will post it.

Here's what the AJAX request showed:

POST http://esp/admin/articles/Article/1/EditForm?action_doSave=Save 500 (Error: "Couldn't run query: INSERT INTO "Article_versions" ("ClassName", "Created", "LastEdited", "Title", "Date", "Category", "Content", "AuthorID", "HeroImageID", "Image1ID", "Image2ID", "Summary", "BannerImageID", "RecordID", "Version") VALUES ('Article', '2012-01-29 13:38:14', '2012-01-29 13:41:01', 'Obra de arte -- review', '2012-11-21', 'Art', '

This is a new item with various stuff in it.

', '1', '0', '0', '0', '

This is a new item

', '6', 1, 7) Unknown column 'ClassName' in 'field list'" at line 525 of /.../sapphire/core/model/MySQLDatabase.php)

Cheers, - L

lingo commented 12 years ago

And.. yes, I ran dev/build! :) I can't remember how the Versions system works off the top of my head, so not sure if it's normal to expect ClassName in a _live table.

arambalakjian commented 12 years ago

Hi Lingo,

Can you post your article.php code?

Aram

lingo commented 12 years ago

Here you go. I now have problems with "Created" columns, which should be in every DataObject... not sure what's happening so I will try removing some of the modules I'm using and retrying this.

Cheers.

<?php

class Article extends DataObjectAsPage {

    static $listing_class = 'ArticleListPage';

    static $db = array(
        'ArticleDate'   => 'Date',
        'Category'  => 'Varchar',
            'Summary'   => 'HTMLVarchar',
    );

    static $has_one = array(
        'Author'    => 'Author',
            'BannerImage'   => 'Image',
        'HeroImage' => 'Image',
        'Image1'    => 'Image',
        'Image2'    => 'Image'

    );
    static $many_many = array(
            'Tags'  => 'Tag'
    );

}
lingo commented 12 years ago

Okay, well, I still don't really understand it, but a deletion of the database completely. Rebuild and now it does seem to work. Just one of those things? I'd tried clearing manifests, flushing, trying complete dev rebuild, but something wasn't working right.

Thanks for your quick response, in any case.

arambalakjian commented 12 years ago

Cool, glad to hear it, it did sounds very strange! :)

threesquared commented 10 years ago

Just in case anyone finds this like I did, I believe this is because of left over columns. I just had to delete the 'ClassName' column from the 'Article' table so it would stop trying to copy it into 'Article_versions'.