Commit a46efe79 by Qiang Xue

Fixes #3469: Fixed the bug that `QueryBuilder::getColumnType()` may drop the…

Fixes #3469: Fixed the bug that `QueryBuilder::getColumnType()` may drop the provided column precision in certain cases
parent 50220cc9
......@@ -28,6 +28,7 @@ Yii Framework 2 Change Log
- Bug #3431: Allow using extended ErrorHandler class from the app namespace (cebe)
- Bug #3436: Fixed the issue that `ServiceLocator` still returns the old component after calling `set()` with a new definition (qiangxue)
- Bug #3458: Fixed the bug that the image rendered by `CaptchaAction` was using a wrong content type (MDMunir, qiangxue)
- Bug #3469: Fixed the bug that `QueryBuilder::getColumnType()` may drop the provided column precision in certain cases (qiangxue, Ragazzo)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue)
- Enh #2435: `yii\db\IntegrityException` is now thrown on database integrity errors instead of general `yii\db\Exception` (samdark)
......
......@@ -591,7 +591,13 @@ class QueryBuilder extends \yii\base\Object
return $this->typeMap[$type];
} elseif (preg_match('/^(\w+)\((.+?)\)(.*)$/', $type, $matches)) {
if (isset($this->typeMap[$matches[1]])) {
return preg_replace('/\(.+\)/', '(' . $matches[2] . ')', $this->typeMap[$matches[1]]) . $matches[3];
$ptype = $this->typeMap[$matches[1]];
if (strpos($ptype, '(') !== false) {
// replace the precision in $ptype with the actual one
return preg_replace('/\(.+\)/', '(' . $matches[2] . ')', $ptype) . $matches[3];
} else {
return "{$ptype}({$matches[2]}){$matches[3]}";
}
}
} elseif (preg_match('/^(\w+)\s+/', $type, $matches)) {
if (isset($this->typeMap[$matches[1]])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment