Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

reverse Sqlite3 error , reverse.go:179 Unknown col "GroupGID" in index "IX_..." #41

Open
@zwq000

Description

use a exist sqlite database, index sql like

CREATE  INDEX "IX_Users_GroupGID" ON "Users" ("GroupGID")

DbMetas() func throw a error Unknown col "GroupGID", because at dialect_sqlite3.go func GetIndexes()
get column name is "GroupGID" ,it's include quotation.

索引定义中表名和字段名包含引号,这个数据库是其他程序生成的,所以 在获取数据库元数据时发生了异常.
无法找到对应的字段名.

目前的解决办法是 在 dialect_sqlite3.go 中增加一个 normalizeName 方法,去掉两边的引号和中间的空格

//normalize tabale/index/col name remove quotation
func normalizeName(name string) string {
	if name[0] == '"' {
		name = name[1:]
	}
	l := len(name)
	if name[l-1] == '"' {
		name = name[:l-1]
	}
	spaceIndex := strings.Index(name, " ")
	if spaceIndex > 1 { //name include space,Use firse token
		return name[:spaceIndex]
	}
	return name
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions