samdark
(Alexander Makarov)
July 11, 2009, 6:54pm
1
Not sure if it's a bug or I just don't know how to do it properly.
I have following table in Postgres:
CREATE TABLE "Report" (
id serial NOT NULL,
description text NOT NULL,
"createdOn" integer NOT NULL
)
Trying to get all reports ordered by createdOn DESC:
$criteria=new CDbCriteria;
$criteria->order = '"createdOn" DESC';
$models=Report::model()->findAll($criteria);
Getting:
Quote
CDbCommand failed to execute the SQL statement: SQLSTATE[42803]: Grouping error: 7 ERROR: column "Report.createdOn" must appear in the GROUP BY clause or be used in an aggregate function
So it escapes table name along with column name.
"Report.createdOn" should be "Report"."createdOn".
chippen
(Chippen3)
July 27, 2009, 12:33am
2
Not sure if it’s a bug or I just don’t know how to do it properly.
I have following table in Postgres:
<pre class=‘prettyprint’>
CREATE TABLE "Report" (
id serial NOT NULL,
description text NOT NULL,
"createdOn" integer NOT NULL
)
</pre>
Trying to get all reports ordered by createdOn DESC:
<pre class=‘prettyprint’>
$criteria=new CDbCriteria;
$criteria->order = ‘“createdOn” DESC’;
$models=Report::model()->findAll($criteria);
</pre>
Getting:
<p class=‘citation’>Quote</p><div class=“blockquote”><div class=‘quote’>CDbCommand failed to execute the SQL statement: SQLSTATE[42803]: Grouping error: 7 ERROR: column “Report.createdOn” must appear in the GROUP BY clause or be used in an aggregate function</div></div>
So it escapes table name along with column name.
"Report.createdOn" should be "Report"."createdOn".
Arent all columns in postgres converted to lowercase by the database? If so your criteria order clause should be ‘“createdon” DESC’;