Closed GoogleCodeExporter closed 8 years ago
I have got the build to quickly work by just changing the line for postgres,
but now of course MySQL wouldn't work.
I also had to change WHERE clauses and ORDER BY clauses where they also had
errors. Specifically Postgres doesn't accept the ` character, it has to be a ".
This means some escapes are necessary in php.
I could carry on, but I suspect there will be many other cases like this, and
I'd like to make it SQL generic rather than specific to Postgresql or MySQL.
Original comment by tculs...@gmail.com
on 18 Sep 2010 at 2:04
See http://doc.silverstripe.org/database-abstraction for a few hints;)
Original comment by tculs...@gmail.com
on 18 Sep 2010 at 2:17
Well here's the first one....
if(defined('DB::USE_ANSI_SQL')) {
$exist = DB::query("SELECT column_name FROM information_schema.columns WHERE table_name ='Order' AND column_name = 'Shipping'")->numRecords();
}
else {
$exist = DB::query("SHOW COLUMNS FROM `Order` LIKE 'Shipping'")->numRecords();
}
Original comment by tculs...@gmail.com
on 18 Sep 2010 at 3:26
VERY bad code also added to postgresql/code/PostgreSQLDatabase.php:
line 174: $handle = pg_query($this->dbConn, str_replace('`', '"', $sql));
The original queries should be fixed and then this line can be removed.
Original comment by tculs...@gmail.com
on 18 Sep 2010 at 3:47
But now I go into the CMS and click on "Example Product" and get an aggregator
problem (known because MySQL is slack on GROUP BY requirements), so there are a
few deeper problems (all fixable!)....
ERROR [Warning]: pg_query(): Query failed: ERROR: column
"Product_ProductGroups.ProductID" must appear in the GROUP BY clause or be used
in an aggregate function
IN POST /admin/getitem?ID=9&ajax=1
Line 174 in /var/www/tonyculshaw.com/postgresql/code/PostgreSQLDatabase.php
.......
Trace
=====
<ul>pg_query(Resource id #85,SELECT "SiteTree"."ClassName",
"SiteTree"."Created", "SiteTree"."LastEdited", "SiteTree"."URLSegment",
"SiteTree"."Title", "SiteTree"."MenuTitle", "SiteTree"."Content",
"SiteTree"."MetaTitle", "SiteTree"."MetaDescription",
"SiteTree"."MetaKeywords", "SiteTree"."ExtraMeta", "SiteTree"."ShowInMenus",
"SiteTree"."ShowInSearch", "SiteTree"."HomepageForDomain",
"SiteTree"."ProvideComments", "SiteTree"."Sort", "SiteTree"."HasBrokenFile",
"SiteTree"."HasBrokenLink", "SiteTree"."Status", "SiteTree"."ReportClass",
"SiteTree"."CanViewType", "SiteTree"."CanEditType", "SiteTree"."ToDo",
"SiteTree"."Version", "SiteTree"."Priority", "SiteTree"."ParentID",
"ProductGroup"."ChildGroupsPermission", "SiteTree"."ID", CASE WHEN
"SiteTree"."ClassName" IS NOT NULL THEN "SiteTree"."ClassName" ELSE 'SiteTree'
END AS "RecordClassName", CASE WHEN "ProductID" IS NULL THEN '0' ELSE '1' END
AS Checked FROM "SiteTree" LEFT JOIN "ProductGroup" ON "ProductGroup"."ID" =
"SiteTree"."ID" LEFT JOIN "Product_ProductGroups" ON ("SiteTree"."ID" =
"Product_ProductGroups"."ProductGroupID" AND "ProductID" = '9') WHERE
("SiteTree"."ClassName" IN ('ProductGroup')) GROUP BY "SiteTree"."ClassName",
"SiteTree"."Created", "SiteTree"."LastEdited", "SiteTree"."URLSegment",
"SiteTree"."Title", "SiteTree"."MenuTitle", "SiteTree"."Content",
"SiteTree"."MetaTitle", "SiteTree"."MetaDescription",
"SiteTree"."MetaKeywords", "SiteTree"."ExtraMeta", "SiteTree"."ShowInMenus",
"SiteTree"."ShowInSearch", "SiteTree"."HomepageForDomain",
"SiteTree"."ProvideComments", "SiteTree"."Sort", "SiteTree"."HasBrokenFile",
"SiteTree"."HasBrokenLink", "SiteTree"."Status", "SiteTree"."ReportClass",
"SiteTree"."CanViewType", "SiteTree"."CanEditType", "SiteTree"."ToDo",
"SiteTree"."Version", "SiteTree"."Priority", "SiteTree"."ParentID",
"ProductGroup"."ChildGroupsPermission", "SiteTree"."ID", CASE WHEN
"SiteTree"."ClassName" IS NOT NULL THEN "SiteTree"."ClassName" ELSE 'SiteTree'
END ORDER BY "Sort" LIMIT 30)
line 174 of PostgreSQLDatabase.php
Original comment by tculs...@gmail.com
on 18 Sep 2010 at 3:50
I think that's enough for one day!
Original comment by tculs...@gmail.com
on 18 Sep 2010 at 3:52
Tony, just let us know what the status is on this one. Probably fixed?
Original comment by nfranc...@gmail.com
on 29 Nov 2010 at 4:56
Yes, this one is fixed.
Original comment by tculs...@gmail.com
on 29 Nov 2010 at 7:13
Original issue reported on code.google.com by
tculs...@gmail.com
on 18 Sep 2010 at 1:38