orm.php.diff

Patch - Vladimir Kolesnikov, 02/20/2010 04:14 am

Download (1.2 kB)

 
kohana/modules/orm/classes/kohana/orm.php
637 637
		// Use the keys of the empty object to determine the columns
638 638
		foreach (array_keys($target->_object) as $column)
639 639
		{
640
			$name   = $target_path.'.'.$column;
640
			$name   = '"'.$target_path.'"."'.$column . '"';
641 641
			$alias  = $target_path.':'.$column;
642 642

  
643 643
			// Add the prefix so that load_result can determine the relationship
......
647 647
		if (isset($parent->_belongs_to[$target_alias]))
648 648
		{
649 649
			// Parent belongs_to target, use target's primary key and parent's foreign key
650
			$join_col1 = $target_path.'.'.$target->_primary_key;
650
			$join_col1 = '"'.$target_path.'"."'.$target->_primary_key.'"';
651 651
			$join_col2 = $parent_path.'.'.$parent->_belongs_to[$target_alias]['foreign_key'];
652 652
		}
653 653
		else
654 654
		{
655 655
			// Parent has_one target, use parent's primary key as target's foreign key
656 656
			$join_col1 = $parent_path.'.'.$parent->_primary_key;
657
			$join_col2 = $target_path.'.'.$parent->_has_one[$target_alias]['foreign_key'];
657
			$join_col2 = '"'.$target_path.'"."'.$parent->_has_one[$target_alias]['foreign_key'] .'"';
658 658
		}
659 659

  
660 660
		// Join the related object into the result