<commit_before><?php defined('SYSPATH') or die('No direct script access.');

class Jelly_Field_BelongsTo extends Jelly_Field_ForeignKey
{	
	protected $in_db = TRUE;
	
	/**
	 * Overrides the initialize to automatically provide the column name
	 *
	 * @param string $model 
	 * @param string $column 
	 * @return void
	 * @author <NAME>
	 */
	public function initialize($model, $column)
	{
		// Check to see if we need to dynamically generate the column name
		if (empty($this->column))
		{
			$this->column = $column.'_id';
		}
		
		if (empty($this->foreign_model))
		{
			$this->foreign_model = $column;
		}
		
		if (empty($this->foreign_column))
		{
			$this->foreign_column = 'id';
		}
		
		// Column is set and won't be overridden
		parent::initialize($model, $column);
	}
	
	/**
	 * @param mixed An integer or another model for this to belong to 
	 * @return void
	 * @author <NAME>
	 */
	public function set($value)
	{
		if (is_object($value))
		{
			if ($value->loaded())
			{
				$this->value = $value->id();
			}
			else
			{
				$this->value = $this->default;
			}
		}
		else<commit_msg>Updating Field_BelongsTo::column to default to the foreign_model plus '_id' instead of the column plus '_id'<commit_after><?php defined('SYSPATH') or die('No direct script access.');

class Jelly_Field_BelongsTo extends Jelly_Field_ForeignKey
{	
	protected $in_db = TRUE;
	
	/**
	 * Overrides the initialize to automatically provide the column name
	 *
	 * @param string $model 
	 * @param string $column 
	 * @return void
	 * @author <NAME>
	 */
	public function initialize($model, $column)
	{
		if (empty($this->foreign_model))
		{
			$this->foreign_model = $column;
		}
		
		if (empty($this->column))
		{
			$this->column = $this->foreign_model.'_id';
		}
		
		if (empty($this->foreign_column))
		{
			$this->foreign_column = 'id';
		}
		
		// Column is set and won't be overridden
		parent::initialize($model, $column);
	}
	
	/**
	 * @param mixed An integer or another model for this to belong to 
	 * @return void
	 * @author <NAME>
	 */
	public function set($value)
	{
		if (is_object($value))
		{
			if ($value->loaded())
			{
				$this->value = $value->id();
			}
			else
			{
				$this->value = $this->default;
			}
		}
		else
{'fraction_non_alphanumeric': 0.14612281488121917, 'fraction_numerical': 0.0, 'mean_word_length': 3.1256931608133085, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 30, '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': '1058799', 'n_tokens_mistral': 870, 'n_tokens_neox': 728, 'n_words': 199}