Browse Source

Fixes #3469: Fixed the bug that `QueryBuilder::getColumnType()` may drop the provided column precision in certain cases

tags/2.0.0-rc
Qiang Xue 11 years ago
parent
commit
a46efe79c6
  1. 1
      framework/CHANGELOG.md
  2. 8
      framework/db/QueryBuilder.php

1
framework/CHANGELOG.md

@ -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)

8
framework/db/QueryBuilder.php

@ -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]])) {

Loading…
Cancel
Save