Giter Club home page Giter Club logo

Comments (1)

dosubot avatar dosubot commented on August 26, 2024 2

Hey @klemen-df! I'm here to help you with any bugs, questions, or contributions you have for the project. Let me know how I can assist you!

To resolve the error "Data too long for column 'component' at row 209" encountered during the SonarQube scraping process in version v1.0.0-beta10, you need to modify the length of the 'component' column in the relevant tables. The provided migration script 20231007_modify_component_length.go changes the column type to varchar(500) for the component field in the _tool_sonarqube_hotspots, _tool_sonarqube_issue_code_blocks, and _tool_sonarqube_issues tables.

Here is the relevant migration script:

package migrationscripts

import (
	"github.com/apache/incubator-devlake/core/context"
	"github.com/apache/incubator-devlake/core/dal"
	"github.com/apache/incubator-devlake/core/errors"
	"github.com/apache/incubator-devlake/core/plugin"
	"github.com/apache/incubator-devlake/helpers/migrationhelper"
)

var _ plugin.MigrationScript = (*modifyComponentLength)(nil)

type modifyComponentLength struct{}

type sonarqubeHotspot20231007 struct {
	Component string `gorm:"index;type:varchar(500)"`
}

func (sonarqubeHotspot20231007) TableName() string {
	return "_tool_sonarqube_hotspots"
}

type sonarqubeIssueCodeBlock20231007 struct {
	Component string `gorm:"index;type:varchar(500)"`
}

func (sonarqubeIssueCodeBlock20231007) TableName() string {
	return "_tool_sonarqube_issue_code_blocks"
}

type sonarqubeIssue20231007 struct {
	Component string `gorm:"index;type:varchar(500)"`
}

func (sonarqubeIssue20231007) TableName() string {
	return "_tool_sonarqube_issues"
}

func (script *modifyComponentLength) Up(basicRes context.BasicRes) errors.Error {
	db := basicRes.GetDal()
	err := migrationhelper.ChangeColumnsType[sonarqubeHotspot20231007](
		basicRes,
		script,
		sonarqubeHotspot20231007{}.TableName(),
		[]string{"component"},
		func(tmpColumnParams []interface{}) errors.Error {
			return db.UpdateColumn(
				&sonarqubeHotspot20231007{},
				"component",
				dal.DalClause{Expr: " ? ", Params: tmpColumnParams},
				dal.Where("? != '' ", tmpColumnParams...),
			)
		},
	)
	if err != nil {
		return err
	}

	err = migrationhelper.ChangeColumnsType[sonarqubeIssueCodeBlock20231007](
		basicRes,
		script,
		sonarqubeIssueCodeBlock20231007{}.TableName(),
		[]string{"component"},
		func(tmpColumnParams []interface{}) errors.Error {
			return db.UpdateColumn(
				&sonarqubeIssueCodeBlock20231007{},
				"component",
				dal.DalClause{Expr: " ? ", Params: tmpColumnParams},
				dal.Where("? != '' ", tmpColumnParams...),
			)
		},
	)
	if err != nil {
		return err
	}

	err = migrationhelper.ChangeColumnsType[sonarqubeIssue20231007](
		basicRes,
		script,
		sonarqubeIssue20231007{}.TableName(),
		[]string{"component"},
		func(tmpColumnParams []interface{}) errors.Error {
			return db.UpdateColumn(
				&sonarqubeIssue20231007{},
				"component",
				dal.DalClause{Expr: " ? ", Params: tmpColumnParams},
				dal.Where("? != '' ", tmpColumnParams...),
			)
		},
	)
	if err != nil {
		return err
	}

	return nil
}

func (*modifyComponentLength) Version() uint64 {
	return 20231007145127
}

func (*modifyComponentLength) Name() string {
	return "modify component type to varchar(500)"
}

This script increases the length of the component column to 500 characters, which should resolve the "Data too long for column 'component'" error. Additionally, if you encounter similar issues with other columns or tables, you can refer to the Configuration and Blueprint Troubleshooting documentation for more detailed solutions and workarounds [1][2].

To continue talking to Dosu, mention @dosu.

from incubator-devlake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.