我是用了xorm工具反轉(zhuǎn)數(shù)據(jù)庫獲取表結構。得到結構體如下typeUserUserstruct{Idint`xorm:"notnullpkautoincrunique(id,sys_group_id,branch_id)INT(11)"`Nicknamestring`xorm:"default''comment('用戶名')VARCHAR(200)"`Emailstring`xorm:"default''comment('email')indexVARCHAR(64)"`EmailIsavalibleint`xorm:"notnulldefault0comment('email是否驗證')TINYINT(4)"`Mobilestring`xorm:"default''comment('手機號')indexCHAR(16)"`MobileIsavalibleint`xorm:"notnulldefault0comment('mobile是否驗證')TINYINT(4)"`Passwordstring`xorm:"notnulldefault''comment('密碼')CHAR(64)"`Isavalibleint`xorm:"notnulldefault0comment('是否可用')TINYINT(4)"`Customerkeystring`xorm:"notnulldefault''comment('用戶key,自動生成')CHAR(64)"`Createdatetime.Time`xorm:"notnulldefault'CURRENT_TIMESTAMP'indexTIMESTAMP"`Useripstring`xorm:"notnulldefault''VARCHAR(50)"`Levelint`xorm:"default0comment('0學員1員工')INT(11)"`SysGroupIdint`xorm:"comment('部門編號')unique(id,sys_group_id,branch_id)INT(11)"`CompanyIdint`xorm:"default0unique(id,sys_group_id,branch_id)INT(11)"`CreateUseridint`xorm:"INT(11)"`CreateFlagstring`xorm:"VARCHAR(255)"`CreateGroupint`xorm:"INT(11)"`Mobliephonefaceurlstring`xorm:"comment('app人臉圖片地址')VARCHAR(128)"`Mobliephonefacestatusstring`xorm:"default'0'comment('預留狀態(tài)0初始化1已預留2申請修改3審批通過(審批通過后并且預留通過后改為1狀態(tài))')CHAR(1)"`Mobliephonevoiceidstring`xorm:"comment('app聲紋信息id')VARCHAR(50)"`Mobliephonevoicestatusstring`xorm:"default'0'comment('預留狀態(tài)0初始化1已預留2申請修改3審批通過(審批通過后并且預留通過后改為1狀態(tài))')CHAR(1)"`Pcfaceurlstring`xorm:"comment('pc人臉圖片地址')VARCHAR(128)"`Pcfacestatusstring`xorm:"default'0'comment('預留狀態(tài)0初始化1已預留2申請修改3審批通過(審批通過后并且預留通過后改為1狀態(tài))')CHAR(1)"`Pcvoiceidstring`xorm:"comment('pc聲紋信息id')VARCHAR(64)"`Pcvoicestatusstring`xorm:"default'0'comment('預留狀態(tài)0初始化1已預留2申請修改3審批通過(審批通過后并且預留通過后改為1狀態(tài))')CHAR(1)"`Mobliephonefacebytestring`xorm:"TEXT"`Pcfacebytestring`xorm:"MEDIUMTEXT"`}```現(xiàn)在我進行數(shù)據(jù)庫查詢,語句如下engine,err=xorm.NewEngine("mysql","name:pwd@tcp(ip:port)/xxxxx?charset=utf8")users:=make([]model.UserUser,0)err=engine.Alias("t").Where("t.mobile=?","123").Find(&users)執(zhí)行時會報錯fieldIdtagunique(id,cannotmatch)charactor請問是哪里寫的有問題?
使用xorm反轉(zhuǎn)數(shù)據(jù)庫獲取表結構后,查詢失敗
溫溫醬
2019-07-06 23:37:07