From 41b25e94b084e76146806f893e4c7c525fa359c0 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Tue, 4 Aug 2015 11:58:41 +0200 Subject: [PATCH] improved parameter naming and documentation of schemabuilder changes according to #9191 close #9191 --- framework/db/ColumnSchemaBuilder.php | 4 +-- framework/db/SchemaBuilderTrait.php | 66 ++++++++++++++---------------------- 2 files changed, 27 insertions(+), 43 deletions(-) diff --git a/framework/db/ColumnSchemaBuilder.php b/framework/db/ColumnSchemaBuilder.php index fe2f2bb..ad35ec2 100644 --- a/framework/db/ColumnSchemaBuilder.php +++ b/framework/db/ColumnSchemaBuilder.php @@ -140,7 +140,7 @@ class ColumnSchemaBuilder extends Object */ protected function buildNotNullString() { - return $this->isNotNull === true ? ' NOT NULL' : ''; + return $this->isNotNull ? ' NOT NULL' : ''; } /** @@ -149,7 +149,7 @@ class ColumnSchemaBuilder extends Object */ protected function buildUniqueString() { - return $this->isUnique === true ? ' UNIQUE' : ''; + return $this->isUnique ? ' UNIQUE' : ''; } /** diff --git a/framework/db/SchemaBuilderTrait.php b/framework/db/SchemaBuilderTrait.php index a6783f3..3bfa404 100644 --- a/framework/db/SchemaBuilderTrait.php +++ b/framework/db/SchemaBuilderTrait.php @@ -125,51 +125,35 @@ trait SchemaBuilderTrait /** * Creates a float column. - * @param integer $precision column value precision. First parameter passed to the column type, e.g. FLOAT(precision, scale). - * This parameter will be ignored if not supported by the DBMS. - * @param integer $scale column value scale. Second parameter passed to the column type, e.g. FLOAT(precision, scale). + * @param integer $precision column value precision. First parameter passed to the column type, e.g. FLOAT(precision). * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6 */ - public function float($precision = null, $scale = null) + public function float($precision = null) { - $length = []; - if ($precision !== null) { - $length[] = $precision; - } - if ($scale !== null) { - $length[] = $scale; - } - return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_FLOAT, $length); + return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_FLOAT, $precision); } /** * Creates a double column. - * @param integer $precision column value precision. First parameter passed to the column type, e.g. DOUBLE(precision, scale). - * This parameter will be ignored if not supported by the DBMS. - * @param integer $scale column value scale. Second parameter passed to the column type, e.g. DOUBLE(precision, scale). + * @param integer $precision column value precision. First parameter passed to the column type, e.g. DOUBLE(precision). * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6 */ - public function double($precision = null, $scale = null) + public function double($precision = null) { - $length = []; - if ($precision !== null) { - $length[] = $precision; - } - if ($scale !== null) { - $length[] = $scale; - } - return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DOUBLE, $length); + return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DOUBLE, $precision); } /** * Creates a decimal column. - * @param integer $precision column value precision. First parameter passed to the column type, e.g. DECIMAL(precision, scale). + * @param integer $precision column value precision, which is usually the total number of digits. + * First parameter passed to the column type, e.g. DECIMAL(precision, scale). * This parameter will be ignored if not supported by the DBMS. - * @param integer $scale column value scale. Second parameter passed to the column type, e.g. DECIMAL(precision, scale). + * @param integer $scale column value scale, which is usually the number of digits after the decimal point. + * Second parameter passed to the column type, e.g. DECIMAL(precision, scale). * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6 @@ -188,38 +172,38 @@ trait SchemaBuilderTrait /** * Creates a datetime column. - * @param integer $length column size or precision definition. + * @param integer $precision column value precision. First parameter passed to the column type, e.g. DATETIME(precision). * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6 */ - public function dateTime($length = null) + public function dateTime($precision = null) { - return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DATETIME, $length); + return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_DATETIME, $precision); } /** * Creates a timestamp column. - * @param integer $length column size or precision definition. + * @param integer $precision column value precision. First parameter passed to the column type, e.g. TIMESTAMP(precision). * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6 */ - public function timestamp($length = null) + public function timestamp($precision = null) { - return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TIMESTAMP, $length); + return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TIMESTAMP, $precision); } /** * Creates a time column. - * @param integer $length column size or precision definition. + * @param integer $precision column value precision. First parameter passed to the column type, e.g. TIME(precision). * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6 */ - public function time($length = null) + public function time($precision = null) { - return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TIME, $length); + return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_TIME, $precision); } /** @@ -246,21 +230,21 @@ trait SchemaBuilderTrait /** * Creates a boolean column. - * @param integer $length column size or precision definition. - * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6 */ - public function boolean($length = null) + public function boolean() { - return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BOOLEAN, $length); + return $this->getDb()->getSchema()->createColumnSchemaBuilder(Schema::TYPE_BOOLEAN); } /** * Creates a money column. - * @param integer $precision column value precision. First parameter passed to the column type, e.g. MONEY(precision, scale). + * @param integer $precision column value precision, which is usually the total number of digits. + * First parameter passed to the column type, e.g. DECIMAL(precision, scale). * This parameter will be ignored if not supported by the DBMS. - * @param integer $scale column value scale. Second parameter passed to the column type, e.g. MONEY(precision, scale). + * @param integer $scale column value scale, which is usually the number of digits after the decimal point. + * Second parameter passed to the column type, e.g. DECIMAL(precision, scale). * This parameter will be ignored if not supported by the DBMS. * @return ColumnSchemaBuilder the column instance which can be further customized. * @since 2.0.6