yiisoft / yiisoft/active-record

Get table name and alias from string with symbols

Open
#560 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
119
Forks
38
Avg merge
1h 11m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced pull request diff and the TableNameAndAliasResolver tests, especially testGetTableNameAndAliasDoesNotTrimTrailingGarbage and testGetTableNameAndAliasDoesNotExtractAliasFromSuffixAfterNewline. Reproduce both inputs, determine the intended handling of symbols and newlines, and finish with tests that document and verify the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.