Skip to content

PostgresGrammar@compileColumnExists does not take the connection's schema into account and can return incorrect results. #13862

@ghost

Description

The current code is:

public function compileColumnExists($table)
{
     return "select column_name from information_schema.columns where table_name = '$table'";
}

The issue is that this function does not take into account the connection's schema so Schema::hasColumn($table, $column) can return incorrect results.

A quick explanation:

Tables:
schema_1.table_name: column_1, column_2
schema_2.table_name: column_1

Connections:
connection_1 -> schema_1
connection_2 -> schema_2

The following call will return an incorrect result:

$hasColumn = Schema::connection('connection_2')->hasColumn('table_name','column_2');

$hasColumn will have an incorrect value of true because compileColumnExists() only checks against the table name when it should check against the table name AND the current connection's schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions