-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unknown column 'ClassName' in 'field list' #10737
Comments
I don't think you can use |
Hmm, actually looking at the docs for the module, it looks like it supports many_many. So someone would need to figure out whether it's an issue with the module or with the framework. |
It is an odd error. By the query SELECT it looks as though the model might have previously CASE
WHEN "Information"."ClassName" IN ('Information') THEN "Information_Links"."Sort"
WHEN "Link"."ClassName" IN ('gorriecoe\\Link\\Models\\Link') THEN "Link"."Sort"
ELSE NULL
END AS "Sort" Has an error happened while you try to perform a |
No. Also, I didn't extend Link. I only used to extend DataObject. One thing I want to add is that ClassName is a column in Information. I would also want to add that if I only use has_one everything works fine. My create table:
|
@MauritzFunke can you please confirm this — is this an issue when you start a fresh project using the installer instructions and just add your dataobject as specified in the issue description and run |
This was not a fresh project. It is a longer project I'm working on. Will check if error persists on a fresh project |
These fields should exist on every DataObject: silverstripe-framework/src/ORM/DataObject.php Lines 284 to 289 in c278576
This is why the error is so confusing and needs more information to debug :) I suppose this is configurable... if the project were to override or add to this |
I am experiencing the same issue. It only occurs when there are class Doctor extends DataObject
{
private static $belongs_many_many = [
'AdditionalOfficeBranches' => OfficeBranch::class . '.AdditionalDoctors',
];
} class OfficeBranch extends DataObject
{
private static $many_many = [
'AdditionalDoctors' => Doctor::class,
];
private static $many_many_extraFields = [
'AdditionalDoctors' => [
'Suite' => 'Varchar',
'Phone' => 'Varchar',
'Fax' => 'Varchar',
'SortOrder' => 'Int',
],
];
} Without the "SELECT DISTINCT "OfficeBranch_Live"."ClassName", "OfficeBranch_Live"."LastEdited", "OfficeBranch_Live"."Created", "OfficeBranch_Live"."Version", "OfficeBranch_Live"."Title", "OfficeBranch_Live"."AddressOne", "OfficeBranch_Live"."AddressTwo", "OfficeBranch_Live"."City", "OfficeBranch_Live"."State", "OfficeBranch_Live"."Zip", "OfficeBranch_Live"."Phone", "OfficeBranch_Live"."Fax", "OfficeBranch_Live"."Latitude", "OfficeBranch_Live"."Longitude", "OfficeBranch_Live"."SortOrder", "OfficeBranch_Live"."ExternalLink", "OfficeBranch_Live"."OfficeID", "OfficeBranch_Live"."LocationID", "OfficeBranch_Live"."InternalLinkID", "OfficeBranch_Live"."ID", CASE WHEN "OfficeBranch_Live"."ClassName" IS NOT NULL THEN "OfficeBranch_Live"."ClassName" ELSE 'OfficeBranch' END AS "RecordClassName" FROM "OfficeBranch_Live" INNER JOIN "OfficeBranch_AdditionalDoctors" ON "OfficeBranch_AdditionalDoctors"."OfficeBranchID" = "OfficeBranch_Live"."ID" WHERE ("OfficeBranch_AdditionalDoctors"."DoctorID" = ?) ORDER BY "OfficeBranch_Live"."SortOrder" ASC" If
A temporary solution I have found is to simply define a new function and apply the join yourself: $officeBranch->AdditionalDoctors()->innerJoin('OfficeBranch', 'OfficeBranch_AdditionalDoctors.OfficeBranchID = OfficeBranch.ID'), |
@michalkleiner i can confirm the issue as well, just stumbled upon it while upgrading a project for ss3 to ss5. it was working fine before. as @tiller1010 said, it's indeed when there is a many_many_extraFields, the last inner join is missing and therefore the [ManyMany].ClassName field is not found |
to be more precise, it seems the two classes need to share a common has_one or field name, like "Sort" in the OP ticket (or Member in mine) |
PR merged. This will be automatically tagged by GitHub actions. |
Affected Version
4.11.0
Description
ClassName not found
Steps to Reproduce
I created the following DataObject
and make a /dev/build
And now, every time I want to add a link I get the following error
The text was updated successfully, but these errors were encountered: