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

Open
opened 2017-09-22 04:12:31 +00:00 by lunny · 4 comments
Owner

Author: @GameXG

>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 重新拷贝到当前目录。还是报这个错误。

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

Author: @GameXG ``` >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 重新拷贝到当前目录。还是报这个错误。 我检查下代码看看能不能找到原因。
Author
Owner

Author: @GameXG

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

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

Author: @GameXG

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

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

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

Author: @GameXG tpl 里面调用了 Mapper 转换字段名,替换掉 Mapper 函数将空格替换为 _ 。 go-xorm\cmd\xorm\go.go 文件设置了 tag,可以在这里增加指定字段名,当判断到 Mapper 后的和原始值不一致时强制指定字段名。 这样可以在cmd里面解决,但是感觉并不好,xorm 其他部分呢也有可能碰到这个问题。 预期 col.Name 是保存数据库原始字段名还是处理后的字段名? 我看到存在 col.FiedName ,这个计划是保存原始字段名?不过我测试mssql驱动下为空。
Author
Owner

Author: @iGitHubJ

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

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

Author: @Keleir

Met same question:

[Error] reverse.go:257 1085:159: expected ';', found 'IDENT' route (and 1 more errors)
Author: @Keleir Met same question: ``` [Error] reverse.go:257 1085:159: expected ';', found 'IDENT' route (and 1 more errors) ```
This repo is archived. You cannot comment on issues.
No Milestone
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/cmd#23
No description provided.