database icon indicating copy to clipboard operation
database copied to clipboard

PostgreSQL: select() fails when column name has all big letters

Open jkuchar opened this issue 11 years ago • 4 comments

$context->query('DROP SCHEMA IF EXISTS public CASCADE');
$context->query('CREATE SCHEMA public');
$context->query('
    CREATE TABLE "public"."bug12" (
        "id" serial,
        "PSC" varchar(5),
        PRIMARY KEY ("id")
    )
');

$context->table("bug12")->insert(array(
    'PSC' => "61600"
));

$row = $context->table("bug12")->select("PSC")->fetch();

Throws: PDOException: SQLSTATE[42703]: Undefined column: 7 ERROR: column "psc" does not exist

jkuchar avatar Jun 02 '14 12:06 jkuchar

This is already fixed, it should be closed.

Unlink avatar Jun 02 '16 14:06 Unlink

IMHO this is not fixed.

dg avatar Jun 02 '16 14:06 dg

You're right, but workaround for this could be sth. like this

$row = $context->table("bug12")->select('"PSC"')->fetch()

Unlink avatar Jun 02 '16 15:06 Unlink

Yep, but this is really wrong. The same mistake that has been done in Doctrine. http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/basic-mapping.html#quoting-reserved-words

You are moving DBAL responsibilities into your application code.

jkuchar avatar Jun 02 '16 15:06 jkuchar