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

addToQuery() tableName is empty #10936 #10945

Closed
beerbohmdo opened this issue Sep 12, 2023 · 2 comments
Closed

addToQuery() tableName is empty #10936 #10945

beerbohmdo opened this issue Sep 12, 2023 · 2 comments
Assignees

Comments

@beerbohmdo
Copy link
Contributor

beerbohmdo commented Sep 12, 2023

Affected Version

4.13
5.0.22

Description

The change #10936 is broken. The tableName property is not populated.

Steps to Reproduce

Create a custom DBField with addToQuery function.

<?php

use SilverStripe\ORM\FieldType\DBField;

class MyDBField extends DBField
{
    /**
     * @param SQLSelect $query
     */
    public function addToQuery(&$query)
    {
        $query->addSelect([
            $this->name => '"' . $this->tableName . '"."' . $this->name . '"'
        ]);
    }
}

Will lead to SELECT ""."MyColumn" FROM "MyTable"

PR

@GuySartorelli
Copy link
Member

Thank you for raising this. I've created a pull request to fix it.

@emteknetnz emteknetnz self-assigned this Sep 13, 2023
@emteknetnz
Copy link
Member

Linked PR was merged

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

No branches or pull requests

3 participants