Issue in editing the DataObject managed in the ModelAdmin

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

My project is using Silverstripe version 4.5
It has a Standalone DataObject management ModelAdmin section. It was working well on Silverstripe v3 but after upgrading to v4.5 its not working. On clicking on any of the DataObject to edit the details it gives an Internal Server Error.
And a SQL query error is logged in the error logs:

[2020-10-13 13:07:31] error-log.ERROR:
Uncaught Exception SilverStripe\ORM\Connect\DatabaseException: "Couldn’t run query:

SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“buildkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15

Unknown column ‘Property.ClassName’ in ‘field list’" at /var/www/html/my-ss-project/vendor/silverstripe/framework/src/ORM/Connect/DBConnector.php line 64 {“exception”:"[object] (SilverStripe\ORM\Connect\DatabaseException(code: 0): Couldn’t run query:\n\nSELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“buildkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, \n\t\t\tCASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName”\n\t\t\tELSE ‘Builder’ END AS “RecordClassName”\n\nFROM “Builder”\nINNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID”\n\nWHERE (“Property_Builder”.“PropertyID” = ?)\n\nLIMIT 15\n\nUnknown column ‘Property.ClassName’ in ‘field list’ at /var/www/html/my-ss-project/vendor/silverstripe/framework/src/ORM/Connect/DBConnector.php:64)"}

Trace
SilverStripe\ORM\Connect\DBConnector->databaseError(Couldn’t run query: SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15 Unknown column ‘Property.ClassName’ in ‘field list’, 256, SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15, Array)
MySQLiConnector.php:302
SilverStripe\ORM\Connect\MySQLiConnector->preparedQuery(SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15, Array, 256)
Database.php:185
SilverStripe\ORM\Connect\Database->SilverStripe\ORM\Connect{closure}(SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15)
Database.php:258
SilverStripe\ORM\Connect\Database->benchmarkQuery(SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15, Closure, Array)
Database.php:183
SilverStripe\ORM\Connect\Database->preparedQuery(SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15, Array, 256)
MySQLDatabase.php:386
SilverStripe\ORM\Connect\MySQLDatabase->preparedQuery(SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15, Array, 256)
DB.php:445
SilverStripe\ORM\DB::prepared_query(SELECT DISTINCT CASE WHEN “Property”.“ClassName” IN (‘Property’) THEN “Property_Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” WHEN “Builder”.“ClassName” IN (‘Builder’) THEN “Builder”.“propertykey” ELSE NULL END AS “propertykey”, “Property_Builder”.“builderkey”, “Property_Builder”.“sortorder”, “Builder”.“ClassName”, “Builder”.“LastEdited”, “Builder”.“Created”, “Builder”.“Version”, “Builder”.“preferred_name”, “Builder”.“mid_name”, “Builder”.“last_name”, “Builder”.“suffix”, “Builder”.“bio”, “Builder”.“ID”, CASE WHEN “Builder”.“ClassName” IS NOT NULL THEN “Builder”.“ClassName” ELSE ‘Builder’ END AS “RecordClassName” FROM “Builder” INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?) LIMIT 15, Array)
SQLExpression.php:115
SilverStripe\ORM\Queries\SQLExpression->execute()
DataList.php:743
SilverStripe\ORM\DataList->toArray()
DataList.php:868
SilverStripe\ORM\DataList->getIterator()
GridField.php:541
SilverStripe\Forms\GridField\GridField->FieldHolder()
call_user_func_array(Array, Array)
ViewableData.php:485
SilverStripe\View\ViewableData->obj(FieldHolder, , 1)
ViewableData.php:547
SilverStripe\View\ViewableData->XML_val(FieldHolder, , 1)
SSViewer_Scope.php:323
SilverStripe\View\SSViewer_Scope->__call(XML_val, Array)
SSViewer_DataPresenter.php:309
SilverStripe\View\SSViewer_DataPresenter->__call(XML_val, Array)
.cachevendor.silverstripe.admin.themes.cms-forms.templates.SilverStripe.Forms.CMSTabSet.ss:52
include(/tmp/silverstripe-cache-php7.3.23-1+ubuntu18.04.1+deb.sury.org+1-var-www-html-my-ss-project/www-data/.cachevendor.silverstripe.admin.themes.cms-forms.templates.SilverStripe.Forms.CMSTabSet.ss)
SSViewer.php:602
SilverStripe\View\SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-php7.3.23-1+ubuntu18.04.1+deb.sury.org+1-var-www-html-my-ss-project/www-data/.cachevendor.silverstripe.admin.themes.cms-forms.templates.SilverStripe.Forms.CMSTabSet.ss, SilverStripe\Forms\TabSet, , Array, )
SSViewer.php:674
SilverStripe\View\SSViewer->process(SilverStripe\Forms\TabSet, )
ViewableData.php:401
SilverStripe\View\ViewableData->renderWith(SilverStripe\View\SSViewer)
TabSet.php:136
SilverStripe\Forms\TabSet->FieldHolder()
call_user_func_array(Array, Array)
ViewableData.php:485
SilverStripe\View\ViewableData->obj(FieldHolder, , 1)
ViewableData.php:547
SilverStripe\View\ViewableData->XML_val(FieldHolder, , 1)
SSViewer_Scope.php:323
SilverStripe\View\SSViewer_Scope->__call(XML_val, Array)
SSViewer_DataPresenter.php:309
SilverStripe\View\SSViewer_DataPresenter->__call(XML_val, Array)
.cachevendor.silverstripe.admin.templates.SilverStripe.Admin.Includes.LeftAndMain_EditForm.ss:161
include(/tmp/silverstripe-cache-php7.3.23-1+ubuntu18.04.1+deb.sury.org+1-var-www-html-my-ss-project/www-data/.cachevendor.silverstripe.admin.templates.SilverStripe.Admin.Includes.LeftAndMain_EditForm.ss)
SSViewer.php:602
SilverStripe\View\SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-php7.3.23-1+ubuntu18.04.1+deb.sury.org+1-var-www-html-my-ss-project/www-data/.cachevendor.silverstripe.admin.templates.SilverStripe.Admin.Includes.LeftAndMain_EditForm.ss, SilverStripe\Forms\Form, , Array, )
SSViewer.php:674
SilverStripe\View\SSViewer->process(SilverStripe\Forms\Form, )
ViewableData.php:401
SilverStripe\View\ViewableData->renderWith(SilverStripe\View\SSViewer)
Form.php:1586
SilverStripe\Forms\Form->forTemplate()
ViewableData.php:549
SilverStripe\View\ViewableData->XML_val(ItemEditForm, , 1)
SSViewer_Scope.php:323
SilverStripe\View\SSViewer_Scope->__call(XML_val, Array)
SSViewer_DataPresenter.php:309
SilverStripe\View\SSViewer_DataPresenter->__call(XML_val, Array)
.cachevendor.silverstripe.framework.templates.SilverStripe.Forms.GridField.GridFieldDetailForm_ItemRequest.ss:2
include(/tmp/silverstripe-cache-php7.3.23-1+ubuntu18.04.1+deb.sury.org+1-var-www-html-my-ss-project/www-data/.cachevendor.silverstripe.framework.templates.SilverStripe.Forms.GridField.GridFieldDetailForm_ItemRequest.ss)
SSViewer.php:602
SilverStripe\View\SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-php7.3.23-1+ubuntu18.04.1+deb.sury.org+1-var-www-html-my-ss-project/www-data/.cachevendor.silverstripe.framework.templates.SilverStripe.Forms.GridField.GridFieldDetailForm_ItemRequest.ss, SilverStripe\View\ViewableData_Customised, , Array, )
SSViewer.php:674
SilverStripe\View\SSViewer->process(SilverStripe\View\ViewableData_Customised, )
ViewableData.php:401
SilverStripe\View\ViewableData->renderWith(SilverStripe\View\SSViewer)
GridFieldDetailForm_ItemRequest.php:147
SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest->edit(SilverStripe\Control\HTTPRequest)
RequestHandler.php:323
SilverStripe\Control\RequestHandler->handleAction(SilverStripe\Control\HTTPRequest, edit)
RequestHandler.php:202
SilverStripe\Control\RequestHandler->handleRequest(SilverStripe\Control\HTTPRequest)
GridFieldDetailForm.php:130
SilverStripe\Forms\GridField\GridFieldDetailForm->handleItem(SilverStripe\Forms\GridField\GridField, SilverStripe\Control\HTTPRequest)
GridField.php:1138
SilverStripe\Forms\GridField\GridField->handleRequest(SilverStripe\Control\HTTPRequest)
RequestHandler.php:226
SilverStripe\Control\RequestHandler->handleRequest(SilverStripe\Control\HTTPRequest)
RequestHandler.php:226
SilverStripe\Control\RequestHandler->handleRequest(SilverStripe\Control\HTTPRequest)
Controller.php:212
SilverStripe\Control\Controller->handleRequest(SilverStripe\Control\HTTPRequest)
LeftAndMain.php:757
SilverStripe\Admin\LeftAndMain->handleRequest(SilverStripe\Control\HTTPRequest)
AdminRootController.php:123
SilverStripe\Admin\AdminRootController->handleRequest(SilverStripe\Control\HTTPRequest)
Director.php:360
SilverStripe\Control\Director->SilverStripe\Control{closure}(SilverStripe\Control\HTTPRequest)
VersionedHTTPMiddleware.php:41
SilverStripe\Versioned\VersionedHTTPMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
ConfirmationMiddleware.php:254
SilverStripe\Control\Middleware\ConfirmationMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
ConfirmationMiddleware.php:254
SilverStripe\Control\Middleware\ConfirmationMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
PasswordExpirationMiddleware.php:84
SilverStripe\Security\PasswordExpirationMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
BasicAuthMiddleware.php:68
SilverStripe\Security\BasicAuthMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
AuthenticationMiddleware.php:61
SilverStripe\Security\AuthenticationMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
ExecMetricMiddleware.php:20
SilverStripe\Control\Middleware\ExecMetricMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
CanonicalURLMiddleware.php:190
SilverStripe\Control\Middleware\CanonicalURLMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
HTTPCacheControlMiddleware.php:42
SilverStripe\Control\Middleware\HTTPCacheControlMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
ChangeDetectionMiddleware.php:28
SilverStripe\Control\Middleware\ChangeDetectionMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
FlushMiddleware.php:27
SilverStripe\Control\Middleware\FlushMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
RequestProcessor.php:66
SilverStripe\Control\RequestProcessor->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
SessionMiddleware.php:20
SilverStripe\Control\Middleware\SessionMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
AllowedHostsMiddleware.php:60
SilverStripe\Control\Middleware\AllowedHostsMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
TrustedProxyMiddleware.php:176
SilverStripe\Control\Middleware\TrustedProxyMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\Director->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
HTTPMiddlewareAware.php:65
SilverStripe\Control\Director->callMiddleware(SilverStripe\Control\HTTPRequest, Closure)
Director.php:369
SilverStripe\Control\Director->handleRequest(SilverStripe\Control\HTTPRequest)
HTTPApplication.php:117
SilverStripe\Control\HTTPApplication::SilverStripe\Control{closure}(SilverStripe\Control\HTTPRequest)
call_user_func(Closure, SilverStripe\Control\HTTPRequest)
HTTPApplication.php:136
SilverStripe\Control\HTTPApplication->SilverStripe\Control{closure}(SilverStripe\Control\HTTPRequest)
call_user_func(Closure, SilverStripe\Control\HTTPRequest)
ErrorControlChainMiddleware.php:67
SilverStripe\Core\Startup\ErrorControlChainMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62
SilverStripe\Control\HTTPApplication->SilverStripe\Control\Middleware{closure}(SilverStripe\Control\HTTPRequest)
HTTPMiddlewareAware.php:65
SilverStripe\Control\HTTPApplication->callMiddleware(SilverStripe\Control\HTTPRequest, Closure)
HTTPApplication.php:137
SilverStripe\Control\HTTPApplication->execute(SilverStripe\Control\HTTPRequest, Closure, )
HTTPApplication.php:116
SilverStripe\Control\HTTPApplication->handle(SilverStripe\Control\HTTPRequest)
index.php:25

Formatted so can see it better…

Did you run /dev/build to create the tables from your DataObjects?

SELECT DISTINCT CASE
WHEN “Property”.“ClassName” IN (‘Property’)
THEN “Property_Builder”.“propertykey”
WHEN “Builder”.“ClassName” IN (‘Builder’)
THEN “Builder”.“propertykey”
WHEN “Builder”.“ClassName” IN (‘Builder’)
THEN “Builder”.“propertykey”
WHEN “Builder”.“ClassName” IN (‘Builder’)
THEN “Builder”.“propertykey”
ELSE NULL END AS “propertykey”
, “Property_Builder”.“buildkey”
, “Property_Builder”.“sortorder”
, “Builder”.“ClassName”
, “Builder”.“LastEdited”
, “Builder”.“Created”
, “Builder”.“Version”
, “Builder”.“preferred_name”
, “Builder”.“mid_name”
, “Builder”.“last_name”
, “Builder”.“suffix”
, “Builder”.“bio”
, “Builder”.“ID”
, CASE WHEN “Builder”.“ClassName” IS NOT NULL
THEN “Builder”.“ClassName”
ELSE ‘Builder’
END AS “RecordClassName”
FROM “Builder”
INNER JOIN “Property_Builder” ON “Property_Builder”.“BuilderID” = “Builder”.“ID” WHERE (“Property_Builder”.“PropertyID” = ?)
LIMIT 15

Yes, I did run a /dev/build.
It was running fine in Silverstripe version 3 but on upgrading to version 4.5 now its not working.
The table and data were already there in the Database. So, in the CMS I can see the list of Property DataObjects there, when I click on one of them to edit it gives an Internal Server Error and the above error is reported in the error logs.

I also tried to setup the same code in a fresh copy of Silverstripe v4.5 it also gives the same error.

Source code for the Property DataObject:

use SilverStripe\ORM\DataObject;
use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\HTMLEditor\HTMLEditorField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RelationEditor;
use SilverStripe\Forms\ReadonlyField;
use UndefinedOffset\SortableGridField\Forms\GridFieldSortableRows;
use SilverStripe\Forms\TabSet;
use SilverStripe\Assets\Image;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\Versioned\Versioned;

class Property extends DataObject {

private static $db = array(
'builderkey' => 'Decimal(10,0)',
'id_number' => 'Varchar(48)',
'category1' => 'Varchar(100)',
'item_name' => 'Varchar(500)',
'builder' => 'Varchar(500)',
'Title' => 'Varchar(500)',
'date_made' => 'Varchar(500)',
'place_made' => 'Varchar(500)',
'culture' => 'Varchar(500)',
'materials' => 'Varchar(500)',
'measurements' => 'Varchar(500)',
'credit_line' => 'Varchar(500)',
'option1' => 'HTMLText',
'option2' => 'Varchar(2000)',
'option3' => 'HTMLText',
'option4' => 'Varchar(500)',
'number2' => 'Varchar(14)',
'flag3' => 'Varchar(1)',
'flag4' => 'Varchar(1)',
'location' => 'Varchar(500)',
'location_levels' => 'Varchar(500)',
'earliest_year' => 'Varchar(18)',
'latest_year' => 'Varchar(18)',
'image_type' => 'Varchar(30)',
'audio_tour' => 'Varchar(50)',
'flag2' => 'Varchar(1)',
'option10' => 'HTMLText',
'spanish_tour' => 'Varchar(50)',
'XrayOriginalImage' => 'Varchar(100)',
'XrayImage' => 'Varchar(100)',
'builder_firstlast' => 'Varchar(500)'
);

private static $has_one = array(
'DetailImage' => Image::class,
'SquareImage' => Image::class
);
private static $has_many = array(
"PropertyResources" => PropertyResources::class,
"PropertyAdditionalImages" => PropertyAdditionalImage::class
);
private static $many_many = array(
"builders" => Builders::class
);
private static $many_many_extraFields = array(
'builders' => array(
'propertykey' => 'Decimal(10,0)',
'builderkey' => 'Decimal(10,0)',
'sortorder' => 'Decimal(10,0)'
)
);
private static $summary_fields = array(
'id_number' => 'Accession ID',
'category1' => 'Category 1',
'Title' => 'Title'
);
const FT_INDEX = 'FT_Search';
private static $extensions = [
Versioned::class
];
private static $owns = array(
'DetailImage',
'SquareImage',
'PropertyResources',
'PropertyAdditionalImages'
);

public function getCMSFields() {

$detailUpload = new UploadField('DetailImage', 'Detail Image');
$detailUpload->setFolderName(Property_DETAIL);

$squareUpload = new UploadField('SquareImage', 'Square Image');
$squareUpload->setFolderName(Property_SQUARE);

$fields = FieldList::create(TabSet::create('Root'));

// Main Property Fields
$fields->addFieldsToTab('Root.Mimsy', array(
		LiteralField::create('literalDesc0', '<div><strong>Mimsy Property Information</strong></div>'),
		TextField::create('id_number',_t('Property.ID_NUMBER','Accession ID')),
		TextField::create('category1',_t('Property.IMAGETITLE','Object Type')),
		TextField::create('item_name',_t('Property.ITEM_NAME','Origin')),
		TextField::create('builder',_t('Property.builder','builder')),
		TextField::create('Title',_t('Property.TITLE','Title')),
		TextField::create('date_made',_t('Property.DATE_MADE','Date Made')),
		TextField::create('place_made',_t('Property.PLACE_MADE','Place Made')),
		TextField::create('culture',_t('Property.CULTURE','Culture')),
		TextField::create('materials',_t('Property.MATERIALS','Materials')),
		TextField::create('measurements',_t('Property.MEASUREMENTS','Measurements')),
		TextField::create('credit_line',_t('Property.CREDIT_LINE','Credit Line')),
		TextField::create('option2',_t('Property.OPTION2','Permission')),
		TextField::create('option4',_t('Property.OPTION4','Tags')),
		TextField::create('location',_t('Property.LOCATION','Location (City)')),
		TextField::create('location_levels',_t('Property.LOCATION_LEVELS','Location')),
		NumericField::create('earliest_year',_t('Property.EARLIEST_YEAR','Earliest Year')),
		NumericField::create('latest_year',_t('Property.LATEST_YEAR','Latest Year')),
		TextField::create('image_type',_t('Property.IMAGE_TYPE','Image Type')),
		TextField::create('audio_tour',_t('Property.AUDIO_TOUR','Audio Tour')),
		TextField::create('spanish_tour',_t('Property.AUDIO_TOUR','Spanish Tour'))
	)
);

// Description
$fields->addFieldsToTab('Root.MimsyDescription', array(
		HTMLEditorField::create('option1', 'Description', $this->option1),
		HTMLEditorField::create('option3','Copyright', $this->option3)
	)
);

// Provenance
$fields->addFieldsToTab('Root.MimsyProvenance', array(
		TextareaField::create('option10', 'Provenance', $this->option10)
	)
);

// builders
if ($this->isInDB()) {
	$grid = GridField::create(
		'builders',
		'The builders for this Artwork',
		$this->builders(),
		GridFieldConfig_RelationEditor::create()
	);
} else {
	$grid = ReadonlyField::create('builders', '', 'builders can be added after creating');
}
$fields->addFieldsToTab('Root.Mimsybuilders', array(
		$grid
	)
);

// Property Resources
$confPropertyResources = GridFieldConfig_RelationEditor::create();
$confPropertyResources->addComponent(new GridFieldSortableRows('SortOrder'));

$fields->addFieldToTab('Root.SiteResources', GridField::create('PropertyResources', 'Property Resources',
	$this->PropertyResources(), $confPropertyResources)
);

// Property Additional Images
$confAdditionalImages = GridFieldConfig_RelationEditor::create();
$confAdditionalImages->addComponent(new GridFieldSortableRows('SortOrder'));

$fields->addFieldToTab('Root.SiteImages', TextField::create('XrayImage',_t('Property.XRAYIMAGE','Link Text for Xray Image')));
$fields->addFieldToTab('Root.SiteImages', TextField::create('XrayOriginalImage',_t('Property.XRAYORIGINALIMAGE','Link Text for Xray Original Image')));
$fields->addFieldToTab('Root.SiteImages', new LiteralField ('literalDesc0', '<div><strong>Max Upload Image Size : 570px x 855px.</strong></div>'));
$fields->addFieldToTab('Root.SiteImages', $detailUpload);
$fields->addFieldToTab('Root.SiteImages', new LiteralField ('literalDesc2', '<div><strong>Upload Image Size : 600px x 600px.</strong></div>'));
$fields->addFieldToTab('Root.SiteImages', $squareUpload);


$fields->addFieldToTab('Root.SiteImages', GridField::create('PropertyAdditionalImages', 'Additional Images',
	$this->PropertyAdditionalImages(), $confAdditionalImages)
);

return $fields;

}

public function searchableField() {
return array(
'Title' => array(
'filter' => 'PartialMatchFilter',
'title' => 'Title',
'field' => 'TextField'
),
'id_number' => array(
'filter' => 'PartialMatchFilter',
'title' => 'Accession ID',
'field' => 'TextField'
),
'category1' => array(
'filter' => 'PartialMatchFilter',
'title' => 'Category 1',
'field' => 'TextField'
)
);
}

/**
* Get Other Property Bybuilder
*/
public function GetOtherPropertyBybuilder($limit) {// Get builder (propertykey)
$sqlQuery = new SQLSelect();
$sqlQuery->setSelect('propertykey as propertykey')
->setFrom('Property_builders')
->addWhere(array('builderkey = ?' => $this->builderkey))
->setLimit(1);if($record = $sqlQuery->execute()->nextRecord()) {
$propertykey = $record['propertykey'];
} else {
return null;
}$records = DataObject::get('Property')
->leftJoin(
'Property_builders',
'"Property"."builderkey" = "Property_builders"."builderkey"')
->where(array(
'"Property_builders"."builderkey" != ?' => $this->builderkey,
'"Property_builders"."propertykey"' => $propertykey
)
)
->distinct(true)
->limit($limit);return $records;
}

/**

* Get Other Property builders propertykey
* [@return] DataObject
*/
public function GetOtherPropertybuilderID() {// Get builder (propertykey)
$sqlQuery = new SQLSelect();
$sqlQuery->setSelect('propertykey as propertykey')
->setFrom('Property_builders')
->addWhere(array('builderkey = ?' => $this->builderkey))
->setLimit(1);if($record = $sqlQuery->execute()->nextRecord()) {
$propertykey = $record['propertykey'];
} else {
return null;
}
return $propertykey;
}

/**

* Get
* Function to fetch Property by number
* [@param] string $id_number
* [@return] DataList
*/
public static function getPropertyByNumber($id_number) {return Property::get()
->filter(array('id_number' => $id_number))
->first();
}
}

Code for Property Model Admin:

use SilverStripe\Admin\ModelAdmin;

class PropertyAdmin extends ModelAdmin {

private static $menu_title = 'Property';

private static $url_segment = 'Property';

private static $managed_models = array(
'Property'
);

private static $menu_icon = 'images/icon-property-16.png';
}

Source Code for Builder DataObject:

use SilverStripe\ORM\DataObject;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TabSet;
use SilverStripe\Forms\TextField;
use SilverStripe\Versioned\Versioned;

class Builders extends DataObject {

private static $db = array(
'propertykey' => 'Decimal(18,0)',
'preferred_name' => 'Varchar(500)',
'mid_name' => 'Varchar(500)',
'last_name' => 'Varchar(500)',
'suffix_name' => 'Varchar(100)',
'brief_bio' => 'Varchar(100)',
);

private static $has_one = array(
);

private static $many_many = array(
'Property' => 'Property'
);

private static $summary_fields = array(
'preferred_name' => 'Name',
'brief_bio' => 'Brief Bio'
);
private static $extensions = [
Versioned::class
];
private static $owns = array(
'Property'
);

public function searchableField() {
return array(
'preferred_name' => array(
'filter' => 'PartialMatchFilter',
'title' => 'Preferred Name',
'field' => 'TextField'
),
'brief_bio' => array(
'filter' => 'PartialMatchFilter',
'title' => 'Brief Bio',
'field' => 'TextField'
)
);
}

public function getCMSFields() {
$fields = FieldList::create(TabSet::create('Root'));

$fields->addFieldsToTab('Root.Main', array(
		TextField::create('preferred_name',_t('Property.PREFERRED_NAME','Preferred Name')),
		TextField::create('mid_name',_t('Property.MID_NAME','First/Mid Name')),
		TextField::create('last_name',_t('Property.LAST_NAME','Last/Suffix Name')),
		TextField::create('suffix_name',_t('Property.SUFFIX_NAME','Suffix Name')),
		TextField::create('brief_bio',_t('Property.BRIEF_BIO','Brief Bio'))
	)
);

return $fields;

}

public function getTitle(){
return $this->preferred_name;
}
}

Code for Builder Model Admin:

use SilverStripe\Admin\ModelAdmin;

class BuilderAdmin extends ModelAdmin {

private static $menu_title = 'Builder';

private static $url_segment = 'Builder';

private static $managed_models = array(
'Builder'
);

private static $menu_icon = 'images/icon-builder-16.png';
}

Can you please post the code for your Property class and the associated ModelAdmin subclass?

Thanks - it’s hard to read though - can you edit your post and wrap all the code blocks in back ticks (put ``` above and below each section) so it’s formatted properly.

The error happens when clicking a row in the property DataObject list view?

Is there a ClassName field in the property table at all? Share the schema please.

Not sure if this is the cause but you have declared a $many_many from Property to Builders, but also a $many_many from Builder to Property. On your Builder class it should instead say e.g.

private static $belongs_many_many = array(
    'Properties' => 'Property'
);

Yes, error occurs on clicking a row in the property DataObject list view. Below are the table stuctures for the Property, Builder and their pivot table

Property table structure:

CREATE TABLE Property (
ID int(11) NOT NULL,
ClassName enum(‘Property’) CHARACTER SET utf8 DEFAULT ‘Property’,
LastEdited datetime DEFAULT NULL,
Created datetime DEFAULT NULL,
Version int(11) NOT NULL DEFAULT ‘0’,
builderkey decimal(10,0) NOT NULL DEFAULT ‘0’,
id_number varchar(48) CHARACTER SET utf8 DEFAULT NULL,
category1 varchar(100) CHARACTER SET utf8 DEFAULT NULL,
item_name varchar(500) CHARACTER SET utf8 DEFAULT NULL,
builder varchar(500) CHARACTER SET utf8 DEFAULT NULL,
Title varchar(500) CHARACTER SET utf8 DEFAULT NULL,
date_made varchar(500) CHARACTER SET utf8 DEFAULT NULL,
place_made varchar(500) CHARACTER SET utf8 DEFAULT NULL,
culture varchar(500) CHARACTER SET utf8 DEFAULT NULL,
materials varchar(500) CHARACTER SET utf8 DEFAULT NULL,
measurements varchar(500) CHARACTER SET utf8 DEFAULT NULL,
credit_line varchar(500) CHARACTER SET utf8 DEFAULT NULL,
option1 mediumtext CHARACTER SET utf8,
option2 varchar(2000) CHARACTER SET utf8 DEFAULT NULL,
option3 mediumtext CHARACTER SET utf8,
option4 varchar(500) CHARACTER SET utf8 DEFAULT NULL,
number2 varchar(14) CHARACTER SET utf8 DEFAULT NULL,
flag3 varchar(1) CHARACTER SET utf8 DEFAULT NULL,
flag4 varchar(1) CHARACTER SET utf8 DEFAULT NULL,
location varchar(500) CHARACTER SET utf8 DEFAULT NULL,
location_levels varchar(500) CHARACTER SET utf8 DEFAULT NULL,
earliest_year varchar(18) CHARACTER SET utf8 DEFAULT NULL,
latest_year varchar(18) CHARACTER SET utf8 DEFAULT NULL,
image_type varchar(30) CHARACTER SET utf8 DEFAULT NULL,
audio_tour varchar(50) CHARACTER SET utf8 DEFAULT NULL,
flag2 varchar(1) CHARACTER SET utf8 DEFAULT NULL,
option10 mediumtext CHARACTER SET utf8,
spanish_tour varchar(50) CHARACTER SET utf8 DEFAULT NULL,
XrayOriginalImage varchar(100) CHARACTER SET utf8 DEFAULT NULL,
XrayImage varchar(100) CHARACTER SET utf8 DEFAULT NULL,
maker_firstlast varchar(500) CHARACTER SET utf8 DEFAULT NULL,
DetailImageID int(11) NOT NULL DEFAULT ‘0’,
SquareImageID int(11) NOT NULL DEFAULT ‘0’
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Builders table structure:

CREATE TABLE Builders (
ID int(11) NOT NULL,
ClassName enum(‘Builders’) CHARACTER SET utf8 DEFAULT ‘Builders’,
LastEdited datetime DEFAULT NULL,
Created datetime DEFAULT NULL,
Version int(11) NOT NULL DEFAULT ‘0’,
propertykey decimal(18,0) NOT NULL DEFAULT ‘0’,
preferred_name varchar(500) CHARACTER SET utf8 DEFAULT NULL,
mid_name varchar(500) CHARACTER SET utf8 DEFAULT NULL,
last_name varchar(500) CHARACTER SET utf8 DEFAULT NULL,
suffix varchar(100) CHARACTER SET utf8 DEFAULT NULL,
bio varchar(100) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Property_Builder table structure:

CREATE TABLE Property_Builder (
ID int(11) NOT NULL,
PropertyID int(11) NOT NULL DEFAULT ‘0’,
BuilderID int(11) NOT NULL DEFAULT ‘0’,
propertykey decimal(10,0) NOT NULL DEFAULT ‘0’,
builderkey decimal(10,0) NOT NULL DEFAULT ‘0’,
sortorder decimal(10,0) NOT NULL DEFAULT ‘0’
) ENGINE=InnoDB DEFAULT CHARSET=latin1;