From a50ce8d984a8938f7bd6ee3ad61ac688a709b8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=95=86=E8=AE=AF=E5=9C=A8=E7=BA=BF?= Date: Wed, 19 Feb 2014 22:01:02 +0800 Subject: [PATCH 1/4] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 商讯在线 --- CONTRIBUTING.md | 7 +++++-- README.md | 2 ++ README_CN.md | 2 ++ mysql.go | 3 ++- session.go | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c7fde071..6f65c2ae 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,14 +1,17 @@ ## Contributing to xorm -`xorm` has a backlog of pull requests, but contributions are still very +`xorm` has a backlog of [pull requests](https://help.github.com/articles/using-pull-requests), but contributions are still very much welcome. You can help with patch review, submitting bug reports, or adding new functionality. There is no formal style guide, but please conform to the style of existing code and general Go formatting conventions when submitting patches. +* [fork a repo](https://help.github.com/articles/fork-a-repo) +* [creating a pull request ](https://help.github.com/articles/creating-a-pull-request) + ### Patch review -Help review existing open pull requests by commenting on the code or +Help review existing open [pull requests](https://help.github.com/articles/using-pull-requests) by commenting on the code or proposed functionality. ### Bug reports diff --git a/README.md b/README.md index 85e5d46c..c5fb4ca7 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,8 @@ Or * [Gowalker](http://gowalker.org) - [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker) +* [Gobuild.io](http://gobuild.io) - [github.com/shxsun/gobuild](http://github.com/shxsun/gobuild) + * [Sudo China](http://sudochina.com) - [github.com/insionng/toropress](http://github.com/insionng/toropress) * [Godaily](http://godaily.org) - [github.com/govc/godaily](http://github.com/govc/godaily) diff --git a/README_CN.md b/README_CN.md index 8088f423..d7e8de80 100644 --- a/README_CN.md +++ b/README_CN.md @@ -81,6 +81,8 @@ xorm是一个简单而强大的Go语言ORM库. 通过它可以使数据库操作 * [Gowalker](http://gowalker.org) - [github.com/Unknwon/gowalker](http://github.com/Unknwon/gowalker) +* [Gobuild.io](http://gobuild.io) - [github.com/shxsun/gobuild](http://github.com/shxsun/gobuild) + * [Sudo China](http://sudochina.com) - [github.com/insionng/toropress](http://github.com/insionng/toropress) * [Godaily](http://godaily.org) - [github.com/govc/godaily](http://github.com/govc/godaily) diff --git a/mysql.go b/mysql.go index aff13333..23b53641 100644 --- a/mysql.go +++ b/mysql.go @@ -111,6 +111,7 @@ func (db *mysql) SqlType(c *Column) string { switch t := c.SQLType.Name; t { case Bool: res = TinyInt + c.Length = 1 case Serial: c.IsAutoIncrement = true c.IsPrimaryKey = true @@ -259,7 +260,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*Column, err if col.SQLType.IsText() { if col.Default != "" { col.Default = "'" + col.Default + "'" - }else{ + } else { if col.DefaultIsEmpty { col.Default = "''" } diff --git a/session.go b/session.go index 75570fcd..825acc46 100644 --- a/session.go +++ b/session.go @@ -2627,7 +2627,7 @@ func (session *Session) innerInsert(bean interface{}) (int64, error) { // Method InsertOne insert only one struct into database as a record. // The in parameter bean must a struct or a point to struct. The return -// parameter is lastInsertId and error +// parameter is inserted and error func (session *Session) InsertOne(bean interface{}) (int64, error) { err := session.newDb() if err != nil { From 69c057be1c39bedec01c0e13c73495c356bddae7 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 12 Apr 2014 21:59:43 +0800 Subject: [PATCH 2/4] bug fixed --- session.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/session.go b/session.go index a6c6e54f..2298e839 100644 --- a/session.go +++ b/session.go @@ -2911,7 +2911,7 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6 var sqlStr, inSql string var inArgs []interface{} doIncVer := false - var verValue *reflect.Value + var verValue reflect.Value if table.Version != "" && session.Statement.checkVersion { if condition != "" { condition = fmt.Sprintf("WHERE (%v) AND %v = ?", condition, @@ -2934,10 +2934,10 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6 session.Engine.Quote(table.Version)+" = "+session.Engine.Quote(table.Version)+" + 1", condition) - verValue, err = table.VersionColumn().ValueOf(bean) - if err != nil { - return 0, err - } + verValue = table.VersionColumn().ValueOf(bean) + //if err != nil { + // return 0, err + //} condiArgs = append(condiArgs, verValue.Interface()) doIncVer = true From 68c59188e947d3c87859d38e83249cfcc93e5a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=95=86=E8=AE=AF=E5=9C=A8=E7=BA=BF?= Date: Sun, 13 Apr 2014 10:03:07 +0800 Subject: [PATCH 3/4] fix bug #53 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 商讯在线 --- statement.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/statement.go b/statement.go index 773dd378..713e8637 100644 --- a/statement.go +++ b/statement.go @@ -523,6 +523,9 @@ func (statement *Statement) Cols(columns ...string) *Statement { statement.columnMap[strings.ToLower(nc)] = true } statement.ColumnStr = statement.Engine.Quote(strings.Join(newColumns, statement.Engine.Quote(", "))) + if strings.Contains(statement.ColumnStr, ".") { + statement.ColumnStr = strings.Replace(statement.ColumnStr, ".", statement.Engine.Quote("."), -1) + } return statement } From 855c53337a8ea26391fb45c851d1ef0d3cc07af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=95=86=E8=AE=AF=E5=9C=A8=E7=BA=BF?= Date: Sun, 13 Apr 2014 10:21:29 +0800 Subject: [PATCH 4/4] bug fixed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 商讯在线 --- engine.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/engine.go b/engine.go index 2499d494..6f7c3a32 100644 --- a/engine.go +++ b/engine.go @@ -481,7 +481,9 @@ func (engine *Engine) mapType(v reflect.Value) *Table { table := engine.newTable() method := v.MethodByName("TableName") if !method.IsValid() { - method = v.Addr().MethodByName("TableName") + if v.CanAddr() { + method = v.Addr().MethodByName("TableName") + } } if method.IsValid() { params := []reflect.Value{}