Skip to content

Bug: multi-column WHERE not prefixed #2532

Description

@MGatner

Describe the bug
When referencing a fully-qualified column as the target of a WHERE operator the second table name is not prefixed.

CodeIgniter 4 version
Latest develop

Affected module(s)
Builder (tested with MySQLi)

Expected behavior, and steps to reproduce if appropriate

$config['DBPrefix'] = 'foo_';
...
$builder = db_connect()->table('mytable');
$builder->where('mytable.created_at < mytable.updated_at')->get()->getResult();

The above will thrown an exception "Table not found: mytable" because the generated query looks like:
SELECT * FROM foo_mytable WHERE foo_mytable.created_at < mytable.updated_at

(Notice the missing prefix on the latter table reference)

Context

  • OS: Ubuntu 18.04
  • Web server: Apache
  • PHP version: 7.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions