<commit_before>
/*
 +------------------------------------------------------------------------+
 | Phalcon Framework                                                      |
 +------------------------------------------------------------------------+
 | Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com)       |
 +------------------------------------------------------------------------+
 | This source file is subject to the New BSD License that is bundled     |
 | with this package in the file docs/LICENSE.txt.                        |
 |                                                                        |
 | If you did not receive a copy of the license and are unable to         |
 | obtain it through the world-wide-web, please send an email             |
 | to <EMAIL> so we can send you a copy immediately.       |
 +------------------------------------------------------------------------+
 | Authors: <NAME> <<EMAIL>>                      |
 |          <NAME> <<EMAIL>>                         |
 |          <NAME> <<EMAIL>>                        |
 +------------------------------------------------------------------------+
 */

namespace Phalcon\Db\Adapter\Pdo;

use Phalcon\Db\Column;
use Phalcon\Db\RawValue;
use Phalcon\Db\AdapterInterface;
use Phalcon\Db\Adapter\Pdo as PdoAdapter;

/**
 * Phalcon\Db\Adapter\Pdo\Oracle
 *
 * Specific functions for the Oracle database system
 * <code>
 *
 * $config = array(
 *  "dbname" => "//localhost/dbname",
 *  "username" => "oracle",
 *  "password" => "<PASSWORD>"
 * );
 *
 * $connection = new \Phalcon\Db\Adapter\Pdo\Oracle($config);
 *
 * </code>
 */
class Oracle extends PdoAdapter implements AdapterInterface
{

	protected _type = "oci";

	protected _dialectType = "oracle";

	/**
	 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
	 * Call it when you need to restore a database connection.
	 *
	 * @param array descriptor
	 * @return boolean
	 */
	public function connect(descriptor = null) -> boolean
	{
		var startup, value, status;

		if !descriptor {
			let descriptor = this->_descriptor;
		}

		let status = parent::connect(descriptor);

		/**
		 * Database session settings initiated with each HTTP request. Oracle behaviour depends on particular NLS* parameter. Check if the developer has defined custom startup or create one from scratch
		 */
		if fetch startup, descriptor["startup"] {
			if typeof startup == "array" {
				for value in startup {
					this->execute(value);
				}
			}
		}

		return status;
	}

	/**
	 * Returns an array of Phalcon\Db\Column objects describing a table
	 *
	 * <code>print_r($connection->describeColumns("posts")); ?></code>
	 */
	public function describeColumns(string! table, string schema = null) -> <Column[]>
	{
		var columns, oldColumn, field, definition, columnSize,
			columnPrecision, columnScale, columnType, columnName;

		let columns = [];

		/**
		 *  0:column_name, 1:data_type, 2:data_length, 3:data_precision, 4:data_scale, 5:nullable, 6:constraint_type, 7:default, 8:position;
		 */
		let oldColumn = null;
		for field in this->fetchAll(this->_dialect->describeColumns(table, schema), \Phalcon\Db::FETCH_NUM) {

			let definition = ["bindType" : 2];

			let columnSize = field[2],
				columnPrecision = field[3],
				columnScale = field[4],
				columnType = field[1];

			loop {

				/**
				 * Check the column type to get the correct Phalcon type
				 */
				if memstr(columnType, "NUMBER") {
					let definition["type"]      = Column::TYPE_DECIMAL,
						definition["isNumeric"] = true,
						definition["size"]      = columnPrecision,
						definition["scale"]     = columnScale,
						definition["bindType"]  = 32;
					break;
				}

				if memstr(columnType, "INTEGER") {
					let definition["type"]       = Column::TYPE_INTEGER,
						definition["isNumeric"]  = true,
						definition["size"]       = columnPrecision,
						definition["bindType"]   = 1;
					break;
				}

				if memstr(columnType, "VARCHAR2") {
					let definition["type"] = Column::TYPE_VARCHAR,
						definition["size"] = columnSize;
						break;
				}

				if memstr(columnType, "FLOAT") {
					let definition["type"]      = Column::TYPE_FLOAT,
						definition["isNumeric"] = true,
						definition["size"]      = columnSize,
						definition["scale"]     = columnScale,
						definition["bindType"]  = 32;
					break;
				}

				if memstr(columnType, "TIMESTAMP") {
					let definition["type"] = Column::TYPE_TIMESTAMP;
					break;
				}

				if memstr(columnType, "RAW") {
					let definition["type"] = Column::TYPE_TEXT;
					break;
				}

				if memstr(columnType, "BLOB") {
					let definition["type"] = Column::TYPE_TEXT;
					break;
				}

				if memstr(columnType, "CLOB") {
					let definition["type"] = Column::TYPE_TEXT;
					break;
				}

				if memstr(columnType, "CHAR") {
					let definition["type"] = Column::TYPE_CHAR,
						definition["size"] = columnSize;
					break;
				}

				let definition["type"] = Column::TYPE_TEXT;
				break;
			}

			if oldColumn === null {
				let definition["first"] = true;
			} else {
				let definition["after"] = oldColumn;<commit_msg>Updated Oracle PDO Adapter to describe DATE column<commit_after>
/*
 +------------------------------------------------------------------------+
 | Phalcon Framework                                                      |
 +------------------------------------------------------------------------+
 | Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com)       |
 +------------------------------------------------------------------------+
 | This source file is subject to the New BSD License that is bundled     |
 | with this package in the file docs/LICENSE.txt.                        |
 |                                                                        |
 | If you did not receive a copy of the license and are unable to         |
 | obtain it through the world-wide-web, please send an email             |
 | to <EMAIL> so we can send you a copy immediately.       |
 +------------------------------------------------------------------------+
 | Authors: <NAME> <<EMAIL>>                      |
 |          <NAME> <<EMAIL>>                         |
 |          <NAME> <<EMAIL>>                        |
 +------------------------------------------------------------------------+
 */

namespace Phalcon\Db\Adapter\Pdo;

use Phalcon\Db\Column;
use Phalcon\Db\RawValue;
use Phalcon\Db\AdapterInterface;
use Phalcon\Db\Adapter\Pdo as PdoAdapter;

/**
 * Phalcon\Db\Adapter\Pdo\Oracle
 *
 * Specific functions for the Oracle database system
 * <code>
 *
 * $config = array(
 *  "dbname" => "//localhost/dbname",
 *  "username" => "oracle",
 *  "password" => "<PASSWORD>"
 * );
 *
 * $connection = new \Phalcon\Db\Adapter\Pdo\Oracle($config);
 *
 * </code>
 */
class Oracle extends PdoAdapter implements AdapterInterface
{

	protected _type = "oci";

	protected _dialectType = "oracle";

	/**
	 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
	 * Call it when you need to restore a database connection.
	 *
	 * @param array descriptor
	 * @return boolean
	 */
	public function connect(descriptor = null) -> boolean
	{
		var startup, value, status;

		if !descriptor {
			let descriptor = this->_descriptor;
		}

		let status = parent::connect(descriptor);

		/**
		 * Database session settings initiated with each HTTP request. Oracle behaviour depends on particular NLS* parameter. Check if the developer has defined custom startup or create one from scratch
		 */
		if fetch startup, descriptor["startup"] {
			if typeof startup == "array" {
				for value in startup {
					this->execute(value);
				}
			}
		}

		return status;
	}

	/**
	 * Returns an array of Phalcon\Db\Column objects describing a table
	 *
	 * <code>print_r($connection->describeColumns("posts")); ?></code>
	 */
	public function describeColumns(string! table, string schema = null) -> <Column[]>
	{
		var columns, oldColumn, field, definition, columnSize,
			columnPrecision, columnScale, columnType, columnName;

		let columns = [];

		/**
		 *  0:column_name, 1:data_type, 2:data_length, 3:data_precision, 4:data_scale, 5:nullable, 6:constraint_type, 7:default, 8:position;
		 */
		let oldColumn = null;
		for field in this->fetchAll(this->_dialect->describeColumns(table, schema), \Phalcon\Db::FETCH_NUM) {

			let definition = ["bindType" : 2];

			let columnSize = field[2],
				columnPrecision = field[3],
				columnScale = field[4],
				columnType = field[1];

			loop {

				/**
				 * Check the column type to get the correct Phalcon type
				 */
				if memstr(columnType, "NUMBER") {
					let definition["type"]      = Column::TYPE_DECIMAL,
						definition["isNumeric"] = true,
						definition["size"]      = columnPrecision,
						definition["scale"]     = columnScale,
						definition["bindType"]  = 32;
					break;
				}

				if memstr(columnType, "INTEGER") {
					let definition["type"]       = Column::TYPE_INTEGER,
						definition["isNumeric"]  = true,
						definition["size"]       = columnPrecision,
						definition["bindType"]   = 1;
					break;
				}

				if memstr(columnType, "VARCHAR2") {
					let definition["type"] = Column::TYPE_VARCHAR,
						definition["size"] = columnSize;
						break;
				}

				if memstr(columnType, "FLOAT") {
					let definition["type"]      = Column::TYPE_FLOAT,
						definition["isNumeric"] = true,
						definition["size"]      = columnSize,
						definition["scale"]     = columnScale,
						definition["bindType"]  = 32;
					break;
				}

				if memstr(columnType, "TIMESTAMP") {
					let definition["type"] = Column::TYPE_TIMESTAMP;
					break;
				}

				if memstr(columnType, "DATE") {
					let definition["type"] = Column::TYPE_DATE;
					break;
				}

				if memstr(columnType, "RAW") {
					let definition["type"] = Column::TYPE_TEXT;
					break;
				}

				if memstr(columnType, "BLOB") {
					let definition["type"] = Column::TYPE_TEXT;
					break;
				}

				if memstr(columnType, "CLOB") {
					let definition["type"] = Column::TYPE_TEXT;
					break;
				}

				if memstr(columnType, "CHAR") {
					let definition["type"] = Column::TYPE_CHAR,
						definition["size"] = columnSize;
					break;
				}

				let definition["type"] = Column::TYPE_TEXT;
				break;
			}

			if oldColumn === null {
				let definition["first"] = true;
			} else {
				let definition["after"] = oldColumn;
{'fraction_non_alphanumeric': 0.18922293727787917, 'fraction_numerical': 0.005378926135817885, 'mean_word_length': 1.9876614060258249, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1536457', 'n_tokens_mistral': 3558, 'n_tokens_neox': 2842, 'n_words': 759}