mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE: column names escaped
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@72426 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
2e8a572875
commit
6a21071e4c
@ -446,13 +446,13 @@ class Versioned extends DataObjectDecorator {
|
|||||||
|
|
||||||
foreach($query->from as $table => $join) {
|
foreach($query->from as $table => $join) {
|
||||||
if($join[0] == '"') $baseTable = str_replace('"','',$join);
|
if($join[0] == '"') $baseTable = str_replace('"','',$join);
|
||||||
else if (substr($join,0,5) != 'INNER') $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".RecordID = \"{$baseTable}_versions\".RecordID AND \"$table\".Version = \"{$baseTable}_versions\".Version";
|
else if (substr($join,0,5) != 'INNER') $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$table\".\"Version\" = \"{$baseTable}_versions\".\"Version\"";
|
||||||
$query->renameTable($table, $table . '_versions');
|
$query->renameTable($table, $table . '_versions');
|
||||||
}
|
}
|
||||||
$query->select[] = "\"{$baseTable}_versions\".AuthorID, \"{$baseTable}_versions\".Version, \"{$baseTable}_versions\".RecordID";
|
$query->select[] = "\"{$baseTable}_versions\".\"AuthorID\", \"{$baseTable}_versions\".\"Version\", \"{$baseTable}_versions\".\"RecordID\"";
|
||||||
|
|
||||||
$query->where[] = "\"{$baseTable}_versions\".RecordID = '{$this->owner->ID}'";
|
$query->where[] = "\"{$baseTable}_versions\".\"RecordID\" = '{$this->owner->ID}'";
|
||||||
$query->orderby = "\"{$baseTable}_versions\".LastEdited DESC, \"{$baseTable}_versions\".Version DESC";
|
$query->orderby = "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC";
|
||||||
|
|
||||||
|
|
||||||
$records = $query->execute();
|
$records = $query->execute();
|
||||||
@ -625,7 +625,7 @@ class Versioned extends DataObjectDecorator {
|
|||||||
if($idList) {
|
if($idList) {
|
||||||
// Validate the ID list
|
// Validate the ID list
|
||||||
foreach($idList as $id) if(!is_numeric($id)) user_error("Bad ID passed to Versioned::prepopulate_versionnumber_cache() in \$idList: " . $id, E_USER_ERROR);
|
foreach($idList as $id) if(!is_numeric($id)) user_error("Bad ID passed to Versioned::prepopulate_versionnumber_cache() in \$idList: " . $id, E_USER_ERROR);
|
||||||
$filter = "WHERE \"ID\" IN(" .implode(", ", $idList) . ")";
|
$filter = "WHERE \"ID\" IN(" .implode("\", \"", $idList) . "\")";
|
||||||
}
|
}
|
||||||
|
|
||||||
$baseClass = ClassInfo::baseDataClass($class);
|
$baseClass = ClassInfo::baseDataClass($class);
|
||||||
@ -681,10 +681,10 @@ class Versioned extends DataObjectDecorator {
|
|||||||
$query = $this->owner->extendedSQL($filter,$sort);
|
$query = $this->owner->extendedSQL($filter,$sort);
|
||||||
foreach($query->from as $table => $join) {
|
foreach($query->from as $table => $join) {
|
||||||
if($join[0] == '"') $baseTable = str_replace('"','',$join);
|
if($join[0] == '"') $baseTable = str_replace('"','',$join);
|
||||||
else $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".RecordID = \"{$baseTable}_versions\".RecordID AND \"$table\".Version = \"{$baseTable}_versions\".Version";
|
else $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$table\".\"Version\" = \"{$baseTable}_versions\".\"Version\"";
|
||||||
$query->renameTable($table, $table . '_versions');
|
$query->renameTable($table, $table . '_versions');
|
||||||
}
|
}
|
||||||
$query->select[] = "\"{$baseTable}_versions\".AuthorID, \"{$baseTable}_versions\".Version, \"{$baseTable}_versions\".RecordID AS ID";
|
$query->select[] = "\"{$baseTable}_versions\".\"AuthorID\", \"{$baseTable}_versions\".\"Version\", \"{$baseTable}_versions\".\"RecordID\" AS ID";
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,10 +692,10 @@ class Versioned extends DataObjectDecorator {
|
|||||||
$query = singleton($className)->extendedSQL($filter,$sort);
|
$query = singleton($className)->extendedSQL($filter,$sort);
|
||||||
foreach($query->from as $table => $join) {
|
foreach($query->from as $table => $join) {
|
||||||
if($join[0] == '"') $baseTable = str_replace('"','',$join);
|
if($join[0] == '"') $baseTable = str_replace('"','',$join);
|
||||||
else $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".RecordID = \"{$baseTable}_versions\".RecordID AND \"$table\".Version = \"{$baseTable}_versions\".Version";
|
else $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$table\".\"Version\" = \"{$baseTable}_versions\".\"Version\"";
|
||||||
$query->renameTable($table, $table . '_versions');
|
$query->renameTable($table, $table . '_versions');
|
||||||
}
|
}
|
||||||
$query->select[] = "\"{$baseTable}_versions\".AuthorID, \"{$baseTable}_versions\".Version, \"{$baseTable}_versions\".RecordID AS ID";
|
$query->select[] = "\"{$baseTable}_versions\".\"AuthorID\", \"{$baseTable}_versions\".\"Version\", \"{$baseTable}_versions\".\"RecordID\" AS ID";
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,7 +709,7 @@ class Versioned extends DataObjectDecorator {
|
|||||||
Versioned::$reading_stage = null;
|
Versioned::$reading_stage = null;
|
||||||
|
|
||||||
$baseTable = ClassInfo::baseDataClass($class);
|
$baseTable = ClassInfo::baseDataClass($class);
|
||||||
$query = singleton($class)->buildVersionSQL("\"{$baseTable}\".RecordID = $id", "\"{$baseTable}\".Version DESC");
|
$query = singleton($class)->buildVersionSQL("\"{$baseTable}\".\"RecordID\" = $id", "\"{$baseTable}\".\"Version\" DESC");
|
||||||
$query->limit = 1;
|
$query->limit = 1;
|
||||||
$record = $query->execute()->record();
|
$record = $query->execute()->record();
|
||||||
$className = $record['ClassName'];
|
$className = $record['ClassName'];
|
||||||
@ -732,7 +732,7 @@ class Versioned extends DataObjectDecorator {
|
|||||||
Versioned::$reading_stage = null;
|
Versioned::$reading_stage = null;
|
||||||
|
|
||||||
$baseTable = ClassInfo::baseDataClass($class);
|
$baseTable = ClassInfo::baseDataClass($class);
|
||||||
$query = singleton($class)->buildVersionSQL("\"{$baseTable}\".RecordID = $id AND \"{$baseTable}\".Version = $version");
|
$query = singleton($class)->buildVersionSQL("\"{$baseTable}\".\"RecordID\" = $id AND \"{$baseTable}\".\"Version\" = $version");
|
||||||
$record = $query->execute()->record();
|
$record = $query->execute()->record();
|
||||||
$className = $record['ClassName'];
|
$className = $record['ClassName'];
|
||||||
if(!$className) {
|
if(!$className) {
|
||||||
@ -751,7 +751,7 @@ class Versioned extends DataObjectDecorator {
|
|||||||
*/
|
*/
|
||||||
static function get_all_versions($class, $id, $version) {
|
static function get_all_versions($class, $id, $version) {
|
||||||
$baseTable = ClassInfo::baseDataClass($class);
|
$baseTable = ClassInfo::baseDataClass($class);
|
||||||
$query = singleton($class)->buildVersionSQL("\"{$baseTable}\".RecordID = $id AND \"{$baseTable}\".Version = $version");
|
$query = singleton($class)->buildVersionSQL("\"{$baseTable}\".\"RecordID\" = $id AND \"{$baseTable}\".\"Version\" = $version");
|
||||||
$record = $query->execute()->record();
|
$record = $query->execute()->record();
|
||||||
$className = $record[ClassName];
|
$className = $record[ClassName];
|
||||||
if(!$className) {
|
if(!$className) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user