protected function getColumnDefinitionSql(Column $col) { $type = $this->getDatabaseType($col->getType()); $limit = $col->getLimit(); $sql = strtoupper($type['name']); if (array_key_exists('limit', $type)) { $sql .= sprintf('(%u)', $limit === NULL ? $type['limit'] : min($limit, $type['limit'])); } if (!empty($type['unsigned']) || array_key_exists('unsigned', $type) && $col->isUnsigned()) { $sql .= ' UNSIGNED'; } $sql .= $col->isNullable() ? ' NULL' : ' NOT NULL'; if ($col->hasDefault()) { $sql .= $this->getDefaultValueSql($col->getDefault()); } if ($col->isPrimaryKey() && $col->isIdentity()) { $sql .= ' AUTO_INCREMENT'; } return $sql; }
protected function getColumnDefinitionSql(Column $col) { $type = $this->getDatabaseType($col->getType()); $limit = $col->getLimit(); if ($col->isIdentity()) { $sql = 'SERIAL'; } else { $sql = strtoupper($type['name']); if (array_key_exists('limit', $type)) { $sql .= sprintf('(%u)', $limit === NULL ? $type['limit'] : min($limit, $type['limit'])); } if (!empty($type['unsigned']) || array_key_exists('unsigned', $type) && $col->isUnsigned()) { if ($col->isNullable()) { $sql .= sprintf(' CHECK (%s IS NULL OR %s >= 0)', $this->conn->quoteIdentifier($col->getName()), $this->conn->quoteIdentifier($col->getName())); } else { $sql .= sprintf(' CHECK (%s >= 0)', $this->conn->quoteIdentifier($col->getName())); } } } $sql .= $col->isNullable() ? ' NULL' : ' NOT NULL'; if ($col->hasDefault()) { $sql .= $this->getDefaultValueSql($col->getDefault()); } return $sql; }