Comments (8)
自己跟踪发现是下面这个函数里报的错:
func (session *Session) row2Bean(rows *sql.Rows, fields []string, fieldsCount int, bean interface{})
字段是字符串类型就会报错,
fieldType.Kind()
rawValueType.Kind()
这两个的类型不一致,导致会到 bytes2Value 里处理,然后出错。
from xorm.
能否将你的数据库结构贴一下?我测试了你的代码是正常的。
fmt.Sprintf("%v:%v@tcp(%v:3306)/%v? charset=utf8"
这个代码中在?和charset之间的空格应去掉。
另NewEngine返回的第二个参数err应检查是否不为nil
from xorm.
能否将你的数据库结构贴一下?我测试了你的代码是正常的。
fmt.Sprintf("%v:%v@tcp(%v:3306)/%v? charset=utf8"
这个代码中在?和charset之间的空格应去掉。
另NewEngine返回的第二个参数err应检查是否不为nil
from xorm.
能否将你的数据库结构贴一下?我测试了你的代码是正常的。
fmt.Sprintf("%v:%v@tcp(%v:3306)/%v? charset=utf8"
这个代码中在?和charset之间的空格应去掉。
另NewEngine返回的第二个参数err应检查是否不为nil
from xorm.
谢谢lunny回复,真实代码里没有没有空格,数据连接没有问题,我测过,如果只返回一个整数字段时是没有问题的,
表结构如下:
CREATE TABLE IF NOT EXISTS User
(
Id
bigint(20) NOT NULL AUTO_INCREMENT,
UserName
varchar(255) DEFAULT NULL,
FullName
varchar(255) DEFAULT NULL,
Created
datetime DEFAULT NULL,
PRIMARY KEY (Id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
from xorm.
lunny是否理解有误,我是说,数据库的连接是正常的,如果结果集只返回一个整数字段时是没有问题的,如果有string字段时,查询依然报错。
type User struct {
Id int32
UserName string
}
from xorm.
再更新下看看好了没有?你用的是SameMapper?
from xorm.
已更新,解决了,多谢,用的是SameMapper。
from xorm.
Related Issues (20)
- sync2不支持同步mysql中MEMORY引擎的数据表V0.7.0
- Invalid object name 'SYS.INDEXES' on SQL Server case sensitive collate HOT 1
- CTE (Common Table Expression) with aliases support
- 事务无法执行afterClosure HOT 1
- go mod download get stuck at xorm.io/core HOT 2
- lost table name with session when insert multiple Slice
- xorm mock CURD HOT 2
- [xorm.NewEngine] I gave wrong 'dataSourceName' but can't panic the error HOT 2
- 文档的问题 HOT 1
- SQLite to mssql dump
- undefined: builder.StringBuilder HOT 3
- Oracle Dialect Quote Brackets HOT 1
- Mysql split-table HOT 2
- driver.Valuer not checked on Insert() HOT 1
- Add support for vertica
- Avoid varargs for batch operations HOT 1
- go fmt go file warning HOT 1
- how to use force index when construct session HOT 2
- mysql5.7版本中json类型的数据插入空数组,数据为null
- how to open session autoclose flag with xorm.engine HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xorm.