Skip to content

Release 3.2.1 regression: [PDOException] SQLSTATE[42P01]: Undefined table #84

Closed

Description

@lnedialkov

Problem

Release 3.2.1 seems to introduce a regression in the following use case:

$I->haveInDatabase('schema.table', [
    'id' => 999,
    'id_one' => $id1,
    'id_two' => $id2
]);

The error is the following: [PDOException] SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "schema.table" does not exist
The PostgreSql#getPrimaryKey query is:

SELECT a.attname
FROM   pg_index i
JOIN   pg_attribute a ON a.attrelid = i.indrelid
                     AND a.attnum = ANY(i.indkey)
WHERE  i.indrelid = '"schema.table"'::regclass
AND    i.indisprimary

Solution

Removing the quotes that were introduced in #82 fixes the problem.
Perhaps there is another way to support upper case table names?

Activity

  1. jandrusku commented on Feb 21, 2025

    @jandrusku
    Contributor

    In my initial commit quotes were only added when upper case names were detected, but this solution was discarded as seemed not necessary. Adding function again should fix it: a64585c

  2. lnedialkov commented on Feb 24, 2025

    @lnedialkov
    Author

    Not really, at least not for $tableName var containing the schema name as well. These two lines should provide a fix for all scenarios:

    $tableNameParts = explode('.', $tableName);
    $tableName = '"' . implode('"."', $tableNameParts) . '"';
  3. szhajdu commented on Mar 3, 2025

    @szhajdu
    Collaborator

    I have found out that the getQuotedName method already exists, so I replaced the custom-made escaping with it. It also properly supports schema definitions. Feedback is welcome. Sorry for the interruption.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions