Skip to content
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

Use DBClassName so that dev/build can migrate legacy classnames #852

Open
wants to merge 1 commit into
base: 4
Choose a base branch
from

Conversation

tractorcow
Copy link
Contributor

I had a few issues where I'd register a class name map with DatabaseAdmin, but elemental wasn't picking this up.

Slashes are double escaped intentionally, in case it looks weird. :P

@@ -25,7 +25,7 @@
class ElementalArea extends DataObject
{
private static $db = [
'OwnerClassName' => 'Varchar(255)',
'OwnerClassName' => 'DBClassName("SilverStripe\\\\ORM\\\\DataObject")',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be DBClassName("SilverStripe\\\\ORM\\\\FieldType\\\\DBVarchar") to keep it effectively a Varchar? Don't understand the change to DataObject.

Copy link
Contributor Author

@tractorcow tractorcow Nov 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the base class that DBClassName should use. The Value of 'OwnerClassName' is a subclass of dataobject.

If you don't add a base name it will assume self::class (which is ElementalArea, and thus wrong).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalkleiner I've just skim read this, but the change from varchar to DBClassName is to make it a proper polymorphic relationship, which means that dev/build in framework can perform modifications on it like it does for other polymorphic relations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should build a proper polymorphic belongs_to in core right @robbieaverill ? :P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! I guess it this were replaced with Owner -> DataObject then it'd be even more real

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants