When creating column names for with(), : is used to join the table and column, the column name now needs to be escape in databases such as Postgres, since : isn't a valid identifier ins ANSI SQL. A possible solution could be to use ___ (3 underscores) as the separator to avoid having to rework many things. A possible patch is included.
:100644 100644 5418cdd... 0000000... M modules/orm/classes/Kohana/ORM.php
diff --git a/modules/orm/classes/Kohana/ORM.php b/modules/orm/classes/Kohana/ORM.php
index 5418cdd..6e900f1 100644
--- a/modules/orm/classes/Kohana/ORM.php
+++ b/modules/orm/classes/Kohana/ORM.php
@@ -849,7 +849,7 @@ class Kohana_ORM extends Model implements serializable {
}
// Split object parts
- $aliases = explode(':', $target_path);
+ $aliases = explode('___', $target_path);
$target = $this;
foreach ($aliases as $alias)
{
@@ -869,7 +869,7 @@ class Kohana_ORM extends Model implements serializable {
// Pop-off top alias to get the parent path (user:photo:tag becomes user:photo - the parent table prefix)
array_pop($aliases);
- $parent_path = implode(':', $aliases);
+ $parent_path = implode('___', $aliases);
if (empty($parent_path))
{
@@ -892,7 +892,7 @@ class Kohana_ORM extends Model implements serializable {
foreach (array_keys($target->_object) as $column)
{
$name = $target_path.'.'.$column;
- $alias = $target_path.':'.$column;
+ $alias = $target_path.'___'.$column;
// Add the prefix so that load_result can determine the relationship
$this->select(array($name, $alias));
@@ -1119,7 +1119,7 @@ class Kohana_ORM extends Model implements serializable {
foreach ($values as $column => $value)
{
- if (strpos($column, ':') === FALSE)
+ if (strpos($column, '___') === FALSE)
{
// Load the value to this model
$this->_object[$column] = $value;
@@ -1127,7 +1127,7 @@ class Kohana_ORM extends Model implements serializable {
else
{
// Column belongs to a related model
- list ($prefix, $column) = explode(':', $column, 2);
+ list ($prefix, $column) = explode('___', $column, 2);
$related[$prefix][$column] = $value;
}
When creating column names for with(), : is used to join the table and column, the column name now needs to be escape in databases such as Postgres, since : isn't a valid identifier ins ANSI SQL. A possible solution could be to use ___ (3 underscores) as the separator to avoid having to rework many things. A possible patch is included.