<commit_before><?php
/*
 * Created by <NAME> on 2009-08-09.
 * Copyright (c) 2009 <NAME>.
 * All rights reserved.
 */

/**
 * Renders the joinRelated() method of a Db_Mapper descendant.
 */
class Db_Mapper_Part_JoinRelated extends Db_CodeBuilder_Method
{
	function __construct(Db_Descriptor $descriptor)
	{
		$this->name = 'joinRelated';
		$this->param_list = '$query, $relation_name, $alias_of_linked';
		
		$this->addPart('switch($relation_name)
{');
		
		foreach($descriptor->getRelations() as $rel)
		{
			$this->addPart("\tcase '".$rel->getName()."':");
			$this->addPart("\t\t".self::indentCode(self::indentCode($rel->getJoinRelatedCode('$query', '$alias_of_linked'))));
			
			// add column mappings
			$php_names = array();
			$sql_names = array();
			foreach($rel->getRelatedDescriptor()->getColumns() as $col)
			{
				$p = $col->getLocalColumn('$alias_of_linked-'.$rel->getName());
				$s = $col->getSourceColumn('$alias_of_linked-'.$rel->getName());
				
				// smaller optimization, makes for fewer replaces
				if(strtolower($p) != strtolower($s))
				{
					$php_names[] = '"'.addcslashes($p, '"').'"';
					$sql_names[] = '"'.addcslashes($s, '"').'"';
				}
			}
			
			if( ! empty($php_names))
			{
				$this->addPart("\n\t\t\n\t\t// Add column translations\$query->php_columns = array_merge(\$query->php_columns, array(".implode(', ', $php_names)."));
		\$query->sql_names = array_merge(\$query->sql_names, array(".implode(', ', $sql_names)."));");
			}<commit_msg>Fixed typos of generated variable names<commit_after><?php
/*
 * Created by <NAME> on 2009-08-09.
 * Copyright (c) 2009 <NAME>.
 * All rights reserved.
 */

/**
 * Renders the joinRelated() method of a Db_Mapper descendant.
 */
class Db_Mapper_Part_JoinRelated extends Db_CodeBuilder_Method
{
	function __construct(Db_Descriptor $descriptor)
	{
		$this->name = 'joinRelated';
		$this->param_list = '$query, $relation_name, $alias_of_linked';
		
		$this->addPart('switch($relation_name)
{');
		
		foreach($descriptor->getRelations() as $rel)
		{
			$this->addPart("\tcase '".$rel->getName()."':");
			$this->addPart("\t\t".self::indentCode(self::indentCode($rel->getJoinRelatedCode('$query', '$alias_of_linked'))));
			
			// add column mappings
			$php_names = array();
			$sql_names = array();
			foreach($rel->getRelatedDescriptor()->getColumns() as $col)
			{
				$p = $col->getLocalColumn('$alias_of_linked-'.$rel->getName());
				$s = $col->getSourceColumn('$alias_of_linked-'.$rel->getName());
				
				// smaller optimization, makes for fewer replaces
				if(strtolower($p) != strtolower($s))
				{
					$php_names[] = '"'.addcslashes($p, '"').'"';
					$sql_names[] = '"'.addcslashes($s, '"').'"';
				}
			}
			
			if( ! empty($php_names))
			{
				$this->addPart("\n\t\t\n\t\t// Add column translations\n\t\t\$query->php_columns = array_merge(\$query->php_columns, array(".implode(', ', $php_names)."));
		\$query->sql_columns = array_merge(\$query->sql_columns, array(".implode(', ', $sql_names)."));");
			}
{'fraction_non_alphanumeric': 0.21552298467688208, 'fraction_numerical': 0.007994670219853431, 'mean_word_length': 4.098471986417657, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '650429', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1027, 'n_words': 167}