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

Code quality: Fix single table inheritance classkey type #1982

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mringler
Copy link
Contributor

@mringler mringler commented Oct 13, 2023

When using single table inheritance, the keys for the individual classes are written to the TableMap as constants. Those are used during instantiation of the subclasses.

For example, an inheritance declaration like

        <column name="type_indicator"  inheritance="single">
            <inheritance key="firstClassIdentifier" class="..." extends="..."/>
        </column>

will create a constant in the TableMap:

    public const CLASSKEY_FIRSTCLASSIDENTIFIER = 'firstClassIdentifier';

and a constructor of the subclass:

    public function __construct()
    {
        parent::__construct();
        $this->setTypeIndicator(FooTableMap::CLASSKEY_FIRSTCLASSIDENTIFIER);
    }

The value of the classkey constant is always written as a string, even for numeric values:

    public const CLASSKEY_1 = '1';'

This leads to a type error in the generated constructor code, since the setter function for the numeric field will expect a numeric value.

With the changes in this PR, numeric class key constants are written as numeric values, fixing the type error.

Includes the test fix from #1980.

@mringler mringler changed the title Fix single table inheritance classkey type Code quality: Fix single table inheritance classkey type Apr 25, 2024
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.

None yet

1 participant