@@ -27,36 +27,36 @@ |
||
| 27 | 27 | * @since 12.0.0 |
| 28 | 28 | */ |
| 29 | 29 | interface IFunctionBuilder { |
| 30 | - /** |
|
| 31 | - * Calculates the MD5 hash of a given input |
|
| 32 | - * |
|
| 33 | - * @param mixed $input The input to be hashed |
|
| 34 | - * |
|
| 35 | - * @return IQueryFunction |
|
| 36 | - * @since 12.0.0 |
|
| 37 | - */ |
|
| 38 | - public function md5($input); |
|
| 30 | + /** |
|
| 31 | + * Calculates the MD5 hash of a given input |
|
| 32 | + * |
|
| 33 | + * @param mixed $input The input to be hashed |
|
| 34 | + * |
|
| 35 | + * @return IQueryFunction |
|
| 36 | + * @since 12.0.0 |
|
| 37 | + */ |
|
| 38 | + public function md5($input); |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Combines two input strings |
|
| 42 | - * |
|
| 43 | - * @param mixed $x The first input string |
|
| 44 | - * @param mixed $y The seccond input string |
|
| 45 | - * |
|
| 46 | - * @return IQueryFunction |
|
| 47 | - * @since 12.0.0 |
|
| 48 | - */ |
|
| 49 | - public function concat($x, $y); |
|
| 40 | + /** |
|
| 41 | + * Combines two input strings |
|
| 42 | + * |
|
| 43 | + * @param mixed $x The first input string |
|
| 44 | + * @param mixed $y The seccond input string |
|
| 45 | + * |
|
| 46 | + * @return IQueryFunction |
|
| 47 | + * @since 12.0.0 |
|
| 48 | + */ |
|
| 49 | + public function concat($x, $y); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Takes a substring from the input string |
|
| 53 | - * |
|
| 54 | - * @param mixed $input The input string |
|
| 55 | - * @param mixed $start The start of the substring, note that counting starts at 1 |
|
| 56 | - * @param mixed $length The length of the substring |
|
| 57 | - * |
|
| 58 | - * @return IQueryFunction |
|
| 59 | - * @since 12.0.0 |
|
| 60 | - */ |
|
| 61 | - public function substring($input, $start, $length = null); |
|
| 51 | + /** |
|
| 52 | + * Takes a substring from the input string |
|
| 53 | + * |
|
| 54 | + * @param mixed $input The input string |
|
| 55 | + * @param mixed $start The start of the substring, note that counting starts at 1 |
|
| 56 | + * @param mixed $length The length of the substring |
|
| 57 | + * |
|
| 58 | + * @return IQueryFunction |
|
| 59 | + * @since 12.0.0 |
|
| 60 | + */ |
|
| 61 | + public function substring($input, $start, $length = null); |
|
| 62 | 62 | } |
@@ -27,24 +27,24 @@ |
||
| 27 | 27 | namespace OC\DB; |
| 28 | 28 | |
| 29 | 29 | class AdapterOCI8 extends Adapter { |
| 30 | - public function lastInsertId($table) { |
|
| 31 | - if (is_null($table)) { |
|
| 32 | - throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()'); |
|
| 33 | - } |
|
| 34 | - if ($table !== null) { |
|
| 35 | - $suffix = '_SEQ'; |
|
| 36 | - $table = '"' . $table . $suffix . '"'; |
|
| 37 | - } |
|
| 38 | - return $this->conn->realLastInsertId($table); |
|
| 39 | - } |
|
| 30 | + public function lastInsertId($table) { |
|
| 31 | + if (is_null($table)) { |
|
| 32 | + throw new \InvalidArgumentException('Oracle requires a table name to be passed into lastInsertId()'); |
|
| 33 | + } |
|
| 34 | + if ($table !== null) { |
|
| 35 | + $suffix = '_SEQ'; |
|
| 36 | + $table = '"' . $table . $suffix . '"'; |
|
| 37 | + } |
|
| 38 | + return $this->conn->realLastInsertId($table); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400"; |
|
| 41 | + const UNIX_TIMESTAMP_REPLACEMENT = "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400"; |
|
| 42 | 42 | |
| 43 | - public function fixupStatement($statement) { |
|
| 44 | - $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement); |
|
| 45 | - $statement = str_replace('`', '"', $statement); |
|
| 46 | - $statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement); |
|
| 47 | - $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement); |
|
| 48 | - return $statement; |
|
| 49 | - } |
|
| 43 | + public function fixupStatement($statement) { |
|
| 44 | + $statement = preg_replace('/`(\w+)` ILIKE \?/', 'REGEXP_LIKE(`$1`, \'^\' || REPLACE(?, \'%\', \'.*\') || \'$\', \'i\')', $statement); |
|
| 45 | + $statement = str_replace('`', '"', $statement); |
|
| 46 | + $statement = str_ireplace('NOW()', 'CURRENT_TIMESTAMP', $statement); |
|
| 47 | + $statement = str_ireplace('UNIX_TIMESTAMP()', self::UNIX_TIMESTAMP_REPLACEMENT, $statement); |
|
| 48 | + return $statement; |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -33,139 +33,139 @@ |
||
| 33 | 33 | |
| 34 | 34 | class OCIExpressionBuilder extends ExpressionBuilder { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param mixed $column |
|
| 38 | - * @param mixed|null $type |
|
| 39 | - * @return array|IQueryFunction|string |
|
| 40 | - */ |
|
| 41 | - protected function prepareColumn($column, $type) { |
|
| 42 | - if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
| 43 | - $column = $this->castColumn($column, $type); |
|
| 44 | - } else { |
|
| 45 | - $column = $this->helper->quoteColumnNames($column); |
|
| 46 | - } |
|
| 47 | - return $column; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @inheritdoc |
|
| 52 | - */ |
|
| 53 | - public function comparison($x, $operator, $y, $type = null) { |
|
| 54 | - $x = $this->prepareColumn($x, $type); |
|
| 55 | - $y = $this->prepareColumn($y, $type); |
|
| 56 | - |
|
| 57 | - return $this->expressionBuilder->comparison($x, $operator, $y); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @inheritdoc |
|
| 62 | - */ |
|
| 63 | - public function eq($x, $y, $type = null) { |
|
| 64 | - $x = $this->prepareColumn($x, $type); |
|
| 65 | - $y = $this->prepareColumn($y, $type); |
|
| 66 | - |
|
| 67 | - return $this->expressionBuilder->eq($x, $y); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @inheritdoc |
|
| 72 | - */ |
|
| 73 | - public function neq($x, $y, $type = null) { |
|
| 74 | - $x = $this->prepareColumn($x, $type); |
|
| 75 | - $y = $this->prepareColumn($y, $type); |
|
| 76 | - |
|
| 77 | - return $this->expressionBuilder->neq($x, $y); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @inheritdoc |
|
| 82 | - */ |
|
| 83 | - public function lt($x, $y, $type = null) { |
|
| 84 | - $x = $this->prepareColumn($x, $type); |
|
| 85 | - $y = $this->prepareColumn($y, $type); |
|
| 86 | - |
|
| 87 | - return $this->expressionBuilder->lt($x, $y); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @inheritdoc |
|
| 92 | - */ |
|
| 93 | - public function lte($x, $y, $type = null) { |
|
| 94 | - $x = $this->prepareColumn($x, $type); |
|
| 95 | - $y = $this->prepareColumn($y, $type); |
|
| 96 | - |
|
| 97 | - return $this->expressionBuilder->lte($x, $y); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * @inheritdoc |
|
| 102 | - */ |
|
| 103 | - public function gt($x, $y, $type = null) { |
|
| 104 | - $x = $this->prepareColumn($x, $type); |
|
| 105 | - $y = $this->prepareColumn($y, $type); |
|
| 106 | - |
|
| 107 | - return $this->expressionBuilder->gt($x, $y); |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @inheritdoc |
|
| 112 | - */ |
|
| 113 | - public function gte($x, $y, $type = null) { |
|
| 114 | - $x = $this->prepareColumn($x, $type); |
|
| 115 | - $y = $this->prepareColumn($y, $type); |
|
| 116 | - |
|
| 117 | - return $this->expressionBuilder->gte($x, $y); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @inheritdoc |
|
| 122 | - */ |
|
| 123 | - public function in($x, $y, $type = null) { |
|
| 124 | - $x = $this->prepareColumn($x, $type); |
|
| 125 | - $y = $this->prepareColumn($y, $type); |
|
| 126 | - |
|
| 127 | - return $this->expressionBuilder->in($x, $y); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @inheritdoc |
|
| 132 | - */ |
|
| 133 | - public function notIn($x, $y, $type = null) { |
|
| 134 | - $x = $this->prepareColumn($x, $type); |
|
| 135 | - $y = $this->prepareColumn($y, $type); |
|
| 136 | - |
|
| 137 | - return $this->expressionBuilder->notIn($x, $y); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Returns a IQueryFunction that casts the column to the given type |
|
| 142 | - * |
|
| 143 | - * @param string $column |
|
| 144 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 145 | - * @return IQueryFunction |
|
| 146 | - */ |
|
| 147 | - public function castColumn($column, $type) { |
|
| 148 | - if ($type === IQueryBuilder::PARAM_STR) { |
|
| 149 | - $column = $this->helper->quoteColumnName($column); |
|
| 150 | - return new QueryFunction('to_char(' . $column . ')'); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - return parent::castColumn($column, $type); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * @inheritdoc |
|
| 158 | - */ |
|
| 159 | - public function like($x, $y, $type = null) { |
|
| 160 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * @inheritdoc |
|
| 165 | - */ |
|
| 166 | - public function iLike($x, $y, $type = null) { |
|
| 167 | - $x = $this->helper->quoteColumnName($x); |
|
| 168 | - $y = $this->helper->quoteColumnName($y); |
|
| 169 | - return new QueryFunction('REGEXP_LIKE('.$x.', \'^\' || REPLACE('.$y.', \'%\', \'.*\') || \'$\', \'i\')'); |
|
| 170 | - } |
|
| 36 | + /** |
|
| 37 | + * @param mixed $column |
|
| 38 | + * @param mixed|null $type |
|
| 39 | + * @return array|IQueryFunction|string |
|
| 40 | + */ |
|
| 41 | + protected function prepareColumn($column, $type) { |
|
| 42 | + if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
| 43 | + $column = $this->castColumn($column, $type); |
|
| 44 | + } else { |
|
| 45 | + $column = $this->helper->quoteColumnNames($column); |
|
| 46 | + } |
|
| 47 | + return $column; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @inheritdoc |
|
| 52 | + */ |
|
| 53 | + public function comparison($x, $operator, $y, $type = null) { |
|
| 54 | + $x = $this->prepareColumn($x, $type); |
|
| 55 | + $y = $this->prepareColumn($y, $type); |
|
| 56 | + |
|
| 57 | + return $this->expressionBuilder->comparison($x, $operator, $y); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @inheritdoc |
|
| 62 | + */ |
|
| 63 | + public function eq($x, $y, $type = null) { |
|
| 64 | + $x = $this->prepareColumn($x, $type); |
|
| 65 | + $y = $this->prepareColumn($y, $type); |
|
| 66 | + |
|
| 67 | + return $this->expressionBuilder->eq($x, $y); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @inheritdoc |
|
| 72 | + */ |
|
| 73 | + public function neq($x, $y, $type = null) { |
|
| 74 | + $x = $this->prepareColumn($x, $type); |
|
| 75 | + $y = $this->prepareColumn($y, $type); |
|
| 76 | + |
|
| 77 | + return $this->expressionBuilder->neq($x, $y); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @inheritdoc |
|
| 82 | + */ |
|
| 83 | + public function lt($x, $y, $type = null) { |
|
| 84 | + $x = $this->prepareColumn($x, $type); |
|
| 85 | + $y = $this->prepareColumn($y, $type); |
|
| 86 | + |
|
| 87 | + return $this->expressionBuilder->lt($x, $y); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @inheritdoc |
|
| 92 | + */ |
|
| 93 | + public function lte($x, $y, $type = null) { |
|
| 94 | + $x = $this->prepareColumn($x, $type); |
|
| 95 | + $y = $this->prepareColumn($y, $type); |
|
| 96 | + |
|
| 97 | + return $this->expressionBuilder->lte($x, $y); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @inheritdoc |
|
| 102 | + */ |
|
| 103 | + public function gt($x, $y, $type = null) { |
|
| 104 | + $x = $this->prepareColumn($x, $type); |
|
| 105 | + $y = $this->prepareColumn($y, $type); |
|
| 106 | + |
|
| 107 | + return $this->expressionBuilder->gt($x, $y); |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @inheritdoc |
|
| 112 | + */ |
|
| 113 | + public function gte($x, $y, $type = null) { |
|
| 114 | + $x = $this->prepareColumn($x, $type); |
|
| 115 | + $y = $this->prepareColumn($y, $type); |
|
| 116 | + |
|
| 117 | + return $this->expressionBuilder->gte($x, $y); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @inheritdoc |
|
| 122 | + */ |
|
| 123 | + public function in($x, $y, $type = null) { |
|
| 124 | + $x = $this->prepareColumn($x, $type); |
|
| 125 | + $y = $this->prepareColumn($y, $type); |
|
| 126 | + |
|
| 127 | + return $this->expressionBuilder->in($x, $y); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @inheritdoc |
|
| 132 | + */ |
|
| 133 | + public function notIn($x, $y, $type = null) { |
|
| 134 | + $x = $this->prepareColumn($x, $type); |
|
| 135 | + $y = $this->prepareColumn($y, $type); |
|
| 136 | + |
|
| 137 | + return $this->expressionBuilder->notIn($x, $y); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Returns a IQueryFunction that casts the column to the given type |
|
| 142 | + * |
|
| 143 | + * @param string $column |
|
| 144 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 145 | + * @return IQueryFunction |
|
| 146 | + */ |
|
| 147 | + public function castColumn($column, $type) { |
|
| 148 | + if ($type === IQueryBuilder::PARAM_STR) { |
|
| 149 | + $column = $this->helper->quoteColumnName($column); |
|
| 150 | + return new QueryFunction('to_char(' . $column . ')'); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + return parent::castColumn($column, $type); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * @inheritdoc |
|
| 158 | + */ |
|
| 159 | + public function like($x, $y, $type = null) { |
|
| 160 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * @inheritdoc |
|
| 165 | + */ |
|
| 166 | + public function iLike($x, $y, $type = null) { |
|
| 167 | + $x = $this->helper->quoteColumnName($x); |
|
| 168 | + $y = $this->helper->quoteColumnName($y); |
|
| 169 | + return new QueryFunction('REGEXP_LIKE('.$x.', \'^\' || REPLACE('.$y.', \'%\', \'.*\') || \'$\', \'i\')'); |
|
| 170 | + } |
|
| 171 | 171 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | public function castColumn($column, $type) { |
| 148 | 148 | if ($type === IQueryBuilder::PARAM_STR) { |
| 149 | 149 | $column = $this->helper->quoteColumnName($column); |
| 150 | - return new QueryFunction('to_char(' . $column . ')'); |
|
| 150 | + return new QueryFunction('to_char('.$column.')'); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return parent::castColumn($column, $type); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @inheritdoc |
| 158 | 158 | */ |
| 159 | 159 | public function like($x, $y, $type = null) { |
| 160 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 160 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -29,10 +29,10 @@ |
||
| 29 | 29 | use OCP\DB\QueryBuilder\IQueryFunction; |
| 30 | 30 | |
| 31 | 31 | class SqliteExpressionBuilder extends ExpressionBuilder { |
| 32 | - /** |
|
| 33 | - * @inheritdoc |
|
| 34 | - */ |
|
| 35 | - public function like($x, $y, $type = null) { |
|
| 36 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 37 | - } |
|
| 32 | + /** |
|
| 33 | + * @inheritdoc |
|
| 34 | + */ |
|
| 35 | + public function like($x, $y, $type = null) { |
|
| 36 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -33,6 +33,6 @@ |
||
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | 35 | public function like($x, $y, $type = null) { |
| 36 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 36 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
| 37 | 37 | } |
| 38 | 38 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | use OC\DB\QueryBuilder\QueryFunction; |
| 25 | 25 | |
| 26 | 26 | class OCIFunctionBuilder extends FunctionBuilder { |
| 27 | - public function md5($input) { |
|
| 28 | - return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 29 | - } |
|
| 27 | + public function md5($input) { |
|
| 28 | + return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | class OCIFunctionBuilder extends FunctionBuilder { |
| 27 | 27 | public function md5($input) { |
| 28 | - return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw(' . $this->helper->quoteColumnName($input) .')))'); |
|
| 28 | + return new QueryFunction('LOWER(DBMS_OBFUSCATION_TOOLKIT.md5 (input => UTL_RAW.cast_to_raw('.$this->helper->quoteColumnName($input).')))'); |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -26,31 +26,31 @@ |
||
| 26 | 26 | use OCP\DB\QueryBuilder\IFunctionBuilder; |
| 27 | 27 | |
| 28 | 28 | class FunctionBuilder implements IFunctionBuilder { |
| 29 | - /** @var QuoteHelper */ |
|
| 30 | - protected $helper; |
|
| 29 | + /** @var QuoteHelper */ |
|
| 30 | + protected $helper; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * ExpressionBuilder constructor. |
|
| 34 | - * |
|
| 35 | - * @param QuoteHelper $helper |
|
| 36 | - */ |
|
| 37 | - public function __construct(QuoteHelper $helper) { |
|
| 38 | - $this->helper = $helper; |
|
| 39 | - } |
|
| 32 | + /** |
|
| 33 | + * ExpressionBuilder constructor. |
|
| 34 | + * |
|
| 35 | + * @param QuoteHelper $helper |
|
| 36 | + */ |
|
| 37 | + public function __construct(QuoteHelper $helper) { |
|
| 38 | + $this->helper = $helper; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - public function md5($input) { |
|
| 42 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 43 | - } |
|
| 41 | + public function md5($input) { |
|
| 42 | + return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function concat($x, $y) { |
|
| 46 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 47 | - } |
|
| 45 | + public function concat($x, $y) { |
|
| 46 | + return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function substring($input, $start, $length = null) { |
|
| 50 | - if ($length) { |
|
| 51 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 52 | - } else { |
|
| 53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 54 | - } |
|
| 55 | - } |
|
| 49 | + public function substring($input, $start, $length = null) { |
|
| 50 | + if ($length) { |
|
| 51 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 52 | + } else { |
|
| 53 | + return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -39,18 +39,18 @@ |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function md5($input) { |
| 42 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
| 42 | + return new QueryFunction('MD5('.$this->helper->quoteColumnName($input).')'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function concat($x, $y) { |
| 46 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
| 46 | + return new QueryFunction('CONCAT('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function substring($input, $start, $length = null) { |
| 50 | 50 | if ($length) { |
| 51 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
| 51 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).', '.$this->helper->quoteColumnName($length).')'); |
|
| 52 | 52 | } else { |
| 53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
| 53 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).')'); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | use OC\DB\QueryBuilder\QueryFunction; |
| 25 | 25 | |
| 26 | 26 | class SqliteFunctionBuilder extends FunctionBuilder { |
| 27 | - public function concat($x, $y) { |
|
| 28 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y)); |
|
| 29 | - } |
|
| 27 | + public function concat($x, $y) { |
|
| 28 | + return new QueryFunction($this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y)); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | class SqliteFunctionBuilder extends FunctionBuilder { |
| 27 | 27 | public function concat($x, $y) { |
| 28 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y)); |
|
| 28 | + return new QueryFunction($this->helper->quoteColumnName($x).' || '.$this->helper->quoteColumnName($y)); |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | use OC\DB\QueryBuilder\QueryFunction; |
| 25 | 25 | |
| 26 | 26 | class PgSqlFunctionBuilder extends FunctionBuilder { |
| 27 | - public function concat($x, $y) { |
|
| 28 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y)); |
|
| 29 | - } |
|
| 27 | + public function concat($x, $y) { |
|
| 28 | + return new QueryFunction($this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y)); |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -25,6 +25,6 @@ |
||
| 25 | 25 | |
| 26 | 26 | class PgSqlFunctionBuilder extends FunctionBuilder { |
| 27 | 27 | public function concat($x, $y) { |
| 28 | - return new QueryFunction($this->helper->quoteColumnName($x) . ' || ' . $this->helper->quoteColumnName($y)); |
|
| 28 | + return new QueryFunction($this->helper->quoteColumnName($x).' || '.$this->helper->quoteColumnName($y)); |
|
| 29 | 29 | } |
| 30 | 30 | } |
@@ -29,41 +29,41 @@ |
||
| 29 | 29 | use Doctrine\Common\EventSubscriber; |
| 30 | 30 | |
| 31 | 31 | class SQLiteSessionInit implements EventSubscriber { |
| 32 | - /** |
|
| 33 | - * @var bool |
|
| 34 | - */ |
|
| 35 | - private $caseSensitiveLike; |
|
| 32 | + /** |
|
| 33 | + * @var bool |
|
| 34 | + */ |
|
| 35 | + private $caseSensitiveLike; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - private $journalMode; |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + private $journalMode; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Configure case sensitive like for each connection |
|
| 44 | - * |
|
| 45 | - * @param bool $caseSensitiveLike |
|
| 46 | - * @param string $journalMode |
|
| 47 | - */ |
|
| 48 | - public function __construct($caseSensitiveLike, $journalMode) { |
|
| 49 | - $this->caseSensitiveLike = $caseSensitiveLike; |
|
| 50 | - $this->journalMode = $journalMode; |
|
| 51 | - } |
|
| 42 | + /** |
|
| 43 | + * Configure case sensitive like for each connection |
|
| 44 | + * |
|
| 45 | + * @param bool $caseSensitiveLike |
|
| 46 | + * @param string $journalMode |
|
| 47 | + */ |
|
| 48 | + public function __construct($caseSensitiveLike, $journalMode) { |
|
| 49 | + $this->caseSensitiveLike = $caseSensitiveLike; |
|
| 50 | + $this->journalMode = $journalMode; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @param ConnectionEventArgs $args |
|
| 55 | - * @return void |
|
| 56 | - */ |
|
| 57 | - public function postConnect(ConnectionEventArgs $args) { |
|
| 58 | - $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; |
|
| 59 | - $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
| 60 | - $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
| 61 | - /** @var \PDO $pdo */ |
|
| 62 | - $pdo = $args->getConnection()->getWrappedConnection(); |
|
| 63 | - $pdo->sqliteCreateFunction('md5', 'md5', 1); |
|
| 64 | - } |
|
| 53 | + /** |
|
| 54 | + * @param ConnectionEventArgs $args |
|
| 55 | + * @return void |
|
| 56 | + */ |
|
| 57 | + public function postConnect(ConnectionEventArgs $args) { |
|
| 58 | + $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; |
|
| 59 | + $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
| 60 | + $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
| 61 | + /** @var \PDO $pdo */ |
|
| 62 | + $pdo = $args->getConnection()->getWrappedConnection(); |
|
| 63 | + $pdo->sqliteCreateFunction('md5', 'md5', 1); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function getSubscribedEvents() { |
|
| 67 | - return array(Events::postConnect); |
|
| 68 | - } |
|
| 66 | + public function getSubscribedEvents() { |
|
| 67 | + return array(Events::postConnect); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -56,8 +56,8 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | public function postConnect(ConnectionEventArgs $args) { |
| 58 | 58 | $sensitive = ($this->caseSensitiveLike) ? 'true' : 'false'; |
| 59 | - $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive); |
|
| 60 | - $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode); |
|
| 59 | + $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = '.$sensitive); |
|
| 60 | + $args->getConnection()->executeUpdate('PRAGMA journal_mode = '.$this->journalMode); |
|
| 61 | 61 | /** @var \PDO $pdo */ |
| 62 | 62 | $pdo = $args->getConnection()->getWrappedConnection(); |
| 63 | 63 | $pdo->sqliteCreateFunction('md5', 'md5', 1); |