Skip to content

->count method with quote_char = q{"} generates bad SQL #23

@djerius

Description

@djerius

If a DBIx::Lite object is created with abstract => { quote_char => q{"} }
a resultset ->count call results in incorrect SQL, e.g. from Postgres:

DBD::Pg::st execute failed: ERROR:  column "COUNT(*)" does not exist
LINE 1: SELECT "COUNT(*)" FROM "temp0002" AS "me"
                ^ [for Statement "SELECT "COUNT(*)" FROM "temp0002" AS "me""]

The code in DBIx::ResultSet::count

my $count_rs = $self->select(\ "COUNT(*)")->order_by(undef);

results in SQL::Abstract::More treating COUNT(*) as a column name, which it then quotes.

Changing the code to

my $count_rs = $self->select( [ \'COUNT(*)', 'count' ] )->order_by( undef );

fixes the issue by providing a real column name for SQL::Abstract::More

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions