<commit_before><?php


	class QueryRewrite{
		private $sql = null;
		private $type = 0;
		
		const UNKNOWN     = 0;
		const SELECT      = 1;
		const DELETE      = 2;
		const INSERT      = 3;
		const UPDATE      = 4;
		const ALTER       = 5;
		const DROP        = 6;
		const CREATE      = 7;
		const DELETEMULTI = 8;
		const UNION		  = 9;
		
	// Valid Table Regex
		const TABLEREF = '`?[A-Za-z0-9_]+`?(\.`?[A-Za-z0-9_]+`?)?';
		
		public function __construct($sql) {
			$this->sql = trim($sql);
			$this->figureOutType();
		}
		
		function figureOutType(){
			if (preg_match('/^DELETE\s+FROM\s/', $this->sql))
				$this->type = self::DELETE;
			elseif (preg_match('/^DELETE\s+'.self::TABLEREF.'\s+FROM\s/', $this->sql))
				$this->type = self::DELETEMULTI;
			elseif (preg_match('/^INSERT\s+INTO\s/', $this->sql))
				$this->type = self::INSERT;
			elseif (preg_match('/^(.*)\s+UNION\s+(.*)$/', $this->sql))
				$this->type = self::UNION;
			else
				$this->type = self::UNKNOWN;
		}
		
		function toSelect() {
			switch ($this->type) {
				case self::SELECT:
				case self::UNION:
					return $this->sql;
				case self::DELETE:
					return preg_replace('/^DELETE\s+FROM\s/', 'SELECT 0 FROM ', $this->sql);
				case self::DELETEMULTI:
					return preg_replace('/^DELETE\s+'.self::TABLEREF.'\s+FROM\s/', 'SELECT 0 FROM ', $this->sql);
			}
			return null;
		}<commit_msg>add in select regex<commit_after><?php


	class QueryRewrite{
		private $sql = null;
		private $type = 0;
		
		const UNKNOWN     = 0;
		const SELECT      = 1;
		const DELETE      = 2;
		const INSERT      = 3;
		const UPDATE      = 4;
		const ALTER       = 5;
		const DROP        = 6;
		const CREATE      = 7;
		const DELETEMULTI = 8;
		const UNION		  = 9;
		
	// Valid Table Regex
		const TABLEREF = '`?[A-Za-z0-9_]+`?(\.`?[A-Za-z0-9_]+`?)?';
		
		public function __construct($sql) {
			$this->sql = trim($sql);
			$this->figureOutType();
		}
		
		function figureOutType(){
			if (preg_match('/^SELECT\s/', $this->sql))
				$this->type = self::SELECT;
			elseif (preg_match('/^DELETE\s+FROM\s/', $this->sql))
				$this->type = self::DELETE;
			elseif (preg_match('/^DELETE\s+'.self::TABLEREF.'\s+FROM\s/', $this->sql))
				$this->type = self::DELETEMULTI;
			elseif (preg_match('/^INSERT\s+INTO\s/', $this->sql))
				$this->type = self::INSERT;
			elseif (preg_match('/^(.*)\s+UNION\s+(.*)$/', $this->sql))
				$this->type = self::UNION;
			else
				$this->type = self::UNKNOWN;
		}
		
		function toSelect() {
			switch ($this->type) {
				case self::SELECT:
				case self::UNION:
					return $this->sql;
				case self::DELETE:
					return preg_replace('/^DELETE\s+FROM\s/', 'SELECT 0 FROM ', $this->sql);
				case self::DELETEMULTI:
					return preg_replace('/^DELETE\s+'.self::TABLEREF.'\s+FROM\s/', 'SELECT 0 FROM ', $this->sql);
			}
			return null;
		}
{'fraction_non_alphanumeric': 0.20205237084217975, 'fraction_numerical': 0.012031139419674451, 'mean_word_length': 2.6906005221932117, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '4004114', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1090, 'n_words': 216}