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

expected ';', found 'IDENT' string (and 1 more errors)-package model #23

Open
ghost opened this issue Sep 22, 2017 · 4 comments
Open

expected ';', found 'IDENT' string (and 1 more errors)-package model #23

ghost opened this issue Sep 22, 2017 · 4 comments
Labels

Comments

@ghost
Copy link

ghost commented Sep 22, 2017

>xorm reverse mysql root:@(127.0.0.1:3306)/nongji?charset=utf8 .\templates\goxorm
2017/09/22 12:07:41 [Error] reverse.go:298 16:17: expected ';', found 'IDENT' string (and 1 more errors)-package model





type MyInformation29 struct {

        Iid     int `xorm:"not null pk autoincr MEDIUMINT(7)"`
        Id      int `xorm:"not null default 0 index INT(10)"`
        Content string `xorm:"MEDIUMTEXT"`
        YumiOperationType       int `xorm:"not null default 0 TINYINT(1)"`
        PlotsType       int `xorm:"not null default 0 TINYINT(1)"`
        DateRangeEnd    string `xorm:"not null default 0.00 DECIMAL(10,2)"`
        DateRangeStart  string `xorm:"not null default 0.00 DECIMAL(10,2)"`
        Expected price  string `xorm:"not null default 0.00 DECIMAL(10,2)"`
        Address string `xorm:"not null VARCHAR(250)"`
        Area    string `xorm:"not null default 0.00 DECIMAL(10,2)"`
        Source  string `xorm:"not null VARCHAR(250)"`

}

如上,reverse 报这个错误。
已经删除了 go-xorm 所有代码并重新 go get ,并重新将 go-xorm/cmd/templates 重新拷贝到当前目录。还是报这个错误。

我检查下代码看看能不能找到原因。

@ghost
Copy link
Author

ghost commented Sep 22, 2017

找到原因,数据库字段存在空格时就挂了。
数据库有个expected price 字段,转换出来的go字段名是 Expected price ,直接挂了。

@lunny lunny added the bug label Sep 22, 2017
@ghost
Copy link
Author

ghost commented Sep 22, 2017

tpl 里面调用了 Mapper 转换字段名,替换掉 Mapper 函数将空格替换为 _ 。
go-xorm\cmd\xorm\go.go 文件设置了 tag,可以在这里增加指定字段名,当判断到 Mapper 后的和原始值不一致时强制指定字段名。

这样可以在cmd里面解决,但是感觉并不好,xorm 其他部分呢也有可能碰到这个问题。

预期 col.Name 是保存数据库原始字段名还是处理后的字段名?
我看到存在 col.FiedName ,这个计划是保存原始字段名?不过我测试mssql驱动下为空。

@iGitHubJ
Copy link

我也遇到了这个错误,请问大神们怎么解决?

@kelein
Copy link

kelein commented Aug 21, 2018

Met same question:

[Error] reverse.go:257 1085:159: expected ';', found 'IDENT' route (and 1 more errors)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants