Skip to content

Get table name and alias from string with symbols #560

@Tigrov

Description

@Tigrov

https://github.com/yiisoft/active-record/pull/545/changes/BASE..dc1ccc01420b562a7c675b133c4e8847baa40fd6#diff-9a722a8f10f10a61d4444baf5eee0a7a2579e501f69e37489202a2e5b647084cR228-R244

    public function testGetTableNameAndAliasDoesNotTrimTrailingGarbage(): void
    {
        [$tableName, $alias] = TableNameAndAliasResolver::resolve(Customer::query()->from(['customer c!']));

        $this->assertSame('customer c!', $tableName);
        $this->assertSame('customer c!', $alias);
    }

    public function testGetTableNameAndAliasDoesNotExtractAliasFromSuffixAfterNewline(): void
    {
        $from = "ignored\ncustomer c";

        [$tableName, $alias] = TableNameAndAliasResolver::resolve(Customer::query()->from([$from]));

        $this->assertSame($from, $tableName);
        $this->assertSame($from, $alias);
    }

Doesn't it looks like a bug?

Originally posted by @Tigrov in #545

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions