Convert all SQL keywords to upper case

대소문자를 섞어서 쓰고 있던 SQL 키워드들을 모두 대문자로 통일
as, and, or, like, desc 등이 소문자였음
This commit is contained in:
Kijin Sung 2018-06-30 15:42:52 +09:00
parent 6070707941
commit 83362034cd
6 changed files with 15 additions and 20 deletions

View file

@ -46,7 +46,7 @@ class Condition
$this->column_name = $column_name; $this->column_name = $column_name;
$this->argument = $argument; $this->argument = $argument;
$this->operation = $operation; $this->operation = $operation;
$this->pipe = $pipe; $this->pipe = strtoupper($pipe);
} }
function getArgument() function getArgument()
@ -208,32 +208,27 @@ class Condition
case 'like_tail' : case 'like_tail' :
case 'like_prefix' : case 'like_prefix' :
case 'like' : case 'like' :
if(defined('__CUBRID_VERSION__') return $name . ' LIKE ' . $value;
&& __CUBRID_VERSION__ >= '8.4.1')
return $name . ' rlike ' . $value;
else
return $name . ' like ' . $value;
break;
case 'notlike_tail' : case 'notlike_tail' :
case 'notlike_prefix' : case 'notlike_prefix' :
case 'notlike' : case 'notlike' :
return $name . ' not like ' . $value; return $name . ' NOT LIKE ' . $value;
break; break;
case 'in' : case 'in' :
return $name . ' in ' . $value; return $name . ' IN ' . $value;
break; break;
case 'notin' : case 'notin' :
case 'not_in' : case 'not_in' :
return $name . ' not in ' . $value; return $name . ' NOT IN ' . $value;
break; break;
case 'notequal' : case 'notequal' :
return $name . ' <> ' . $value; return $name . ' <> ' . $value;
break; break;
case 'notnull' : case 'notnull' :
return $name . ' is not null'; return $name . ' IS NOT NULL ';
break; break;
case 'null' : case 'null' :
return $name . ' is null'; return $name . ' IS NULL ';
break; break;
case 'and' : case 'and' :
return $name . ' & ' . $value; return $name . ' & ' . $value;
@ -248,7 +243,7 @@ class Condition
return $name . ' ~ ' . $value; return $name . ' ~ ' . $value;
break; break;
case 'between' : case 'between' :
return $name . ' between ' . $value[0] . ' and ' . $value[1]; return $name . ' BETWEEN ' . $value[0] . ' AND ' . $value[1];
break; break;
} }
} }

View file

@ -68,7 +68,7 @@ class ConditionWithArgument extends Condition
$q = '?'; $q = '?';
} }
} }
return $this->pipe . ' ' . $this->getConditionPart($q); return strtoupper($this->pipe) . ' ' . $this->getConditionPart($q);
} }
/** /**

View file

@ -42,7 +42,7 @@ class SelectExpression extends Expression
*/ */
function getExpression() function getExpression()
{ {
return sprintf("%s%s", $this->column_name, $this->column_alias ? " as " . $this->column_alias : ""); return sprintf("%s%s", $this->column_name, $this->column_alias ? (' AS ' . $this->column_alias) : "");
} }
function show() function show()

View file

@ -37,7 +37,7 @@ class OrderByColumn
{ {
$result = $this->getColumnName(); $result = $this->getColumnName();
$result .= ' '; $result .= ' ';
$result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : $this->sort_order; $result .= is_a($this->sort_order, 'Argument') ? $this->sort_order->getValue() : strtoupper($this->sort_order);
return $result; return $result;
} }

View file

@ -41,9 +41,9 @@ class JoinTable extends Table
function toString($with_value = true) function toString($with_value = true)
{ {
$part = $this->join_type . ' ' . $this->name; $part = strtoupper($this->join_type) . ' ' . $this->name;
$part .= $this->alias ? ' as ' . $this->alias : ''; $part .= $this->alias ? (' AS ' . $this->alias) : '';
$part .= ' on '; $part .= ' ON ';
foreach($this->conditions as $conditionGroup) foreach($this->conditions as $conditionGroup)
{ {
$part .= $conditionGroup->toString($with_value); $part .= $conditionGroup->toString($with_value);

View file

@ -36,7 +36,7 @@ class Table
function toString() function toString()
{ {
//return $this->name; //return $this->name;
return sprintf("%s%s", $this->name, $this->alias ? ' as ' . $this->alias : ''); return sprintf("%s%s", $this->name, $this->alias ? (' AS ' . $this->alias) : '');
} }
function getName() function getName()