Commit Graph

1672 Commits

Author SHA1 Message Date
Lunny Xiao fd823ae5bd more refactors 2022-05-30 18:38:09 +08:00
Lunny Xiao 274bba2d0b Fix bug 2022-05-30 18:38:09 +08:00
Lunny Xiao e2f9dffe4a refactor query 2022-05-30 18:38:09 +08:00
Lunny Xiao a0f42c421a Fix bug 2022-05-30 18:38:09 +08:00
Lunny Xiao ee2b5ef320 more refactor 2022-05-30 18:38:09 +08:00
Lunny Xiao 4e3ac37291 function parameter 2022-05-30 18:38:09 +08:00
Lunny Xiao ec7b41fd88 Refactor orderby and support arguments 2022-05-30 18:38:09 +08:00
Andrew Thornton eeb7fcf22c Add ORDER BY SEQ_IN_INDEX to MySQL GetIndexes to Fix IndexTests (#2152)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2152
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-05-30 18:36:23 +08:00
Andrew Thornton 60540cbabe Remove const insertSelectPlaceholder and associated dead code (#2151)
`insertSelectPlaceholder` is an unexported const set at true. No code changes this nor can any build environment change it.

Therefore we should remove it and the associated dead code.

Close #2146

Signed-off-by: Andrew Thornton <art27@cantab.net>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2151
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-05-30 00:29:03 +08:00
Andrew Thornton 26d291bbc3 Add interface to allow structs to provide specific index information (#2137)
The current mechanism for adding information about indices cannot express the ordering
of the columns in the index or add sorting information.

Here we add a new interface TableIndices which a struct would implement to provide
a slice of *schema.Index to provide additional indices to that gleaned from the tags.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2137
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-04-24 19:34:27 +08:00
Lunny Xiao f7e9fb74ac return a clear error for set TEXT type as compare condition (#2062)
Fix #523

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2062
2022-04-23 17:19:37 +08:00
Lunny Xiao 2c064b6da6 Add test for find date (#2121)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2121
2022-04-22 14:56:26 +08:00
Pierre-Louis Bonicoli e1d4365667 MySQL/MariaDB: return max length for text columns (#2133)
MySQL/MariaDB: return max length for text columns using `CHARACTER_MAXIMUM_LENGTH`.

 Tests:
 * add an integration test: `TestGetColumnsLength`
 * update `TestSyncTable3` since `TableInfo` isn't able to provide the column size

Co-authored-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2133
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
Co-committed-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
2022-04-22 10:48:53 +08:00
Lunny Xiao 8f2596bf64 some improvement (#2136)
Fix #2134 and replace #2135

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2136
2022-04-22 10:16:35 +08:00
Pierre-Louis Bonicoli ea9bba0d14 PostgreSQL: enable comment on column (#2131)
The [oldest unsupported version documentation](https://www.postgresql.org/docs/7.1/sql-comment.html) states that comment on a column is supported.

Update `TestGetColumnsComment` in order to check both MySQL/MariaDB and PostgreSQL.

Co-authored-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2131
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
Co-committed-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
2022-04-17 18:03:29 +08:00
Lunny Xiao e858b75756
Update changelog for 1.3.0 2022-04-14 10:12:39 +08:00
getsu b3f9c53d8a oracle数据库不再拼接AS (#2109)
修复 #2108

Co-authored-by: chendy <acrhwfy@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2109
Co-authored-by: getsu <getsu@noreply.gitea.io>
Co-committed-by: getsu <getsu@noreply.gitea.io>
2022-03-31 23:57:40 +08:00
finelog d195040cb9 fix session context overwrite when logSessionId not set (#2115)
ref pr https://gitea.com/xorm/xorm/pulls/2053

i think the previous fix has some issue
for example, i'm using session like this:

```go
// logSessionID == false
engine := NewEngine()

// use ctx.SessionId to distinguish uniq request id
cxt := context.WithValue(parent, log.SessionIDKey, "some unique request id")
session := engine.NewSession().Context(ctx)
```
however, with pr 2053, `session.Context` can't get SessionId from ctx.

this pr fix abrove issue, overwrite `session.Context()` only when `engine.logSessionID  == true`

please check it out,thanks!

Co-authored-by: finelog <kaicltw@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2115
Co-authored-by: finelog <finelog@noreply.gitea.io>
Co-committed-by: finelog <finelog@noreply.gitea.io>
2022-03-31 17:20:29 +08:00
Pierre-Louis Bonicoli 79a21b68aa replace GitHub links: xorm has been moved to gitea.com (#2126)
Co-authored-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2126
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
Co-committed-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
2022-03-31 14:26:05 +08:00
fuge 3180c418c2 bugfix :Oid It's a special index. You can't put it in (#2105)
Co-authored-by: fuge <8342337@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2105
Co-authored-by: fuge <fuge@noreply.gitea.io>
Co-committed-by: fuge <fuge@noreply.gitea.io>
2022-01-25 13:28:46 +08:00
finelog 7802393d01 fix reset colmap when counting distinct cols (#2096)
when using distinct cols with FindAndCount, reset statement.ColumnMap will make the counting sql an syntax error, this pr try fix this.
is this pr ok for merge?

error sql logging:
```sql
[SQL] SELECT DISTINCT `Fid` FROM `table_demo` WHERE Fkey = ? [val]

[SQL] SELECT count(DISTINCT ) FROM `table_demo` WHERE Fkey = ? [val]
```

after fix:
```sql
[SQL] SELECT DISTINCT `Fid` FROM `table_demo` WHERE Fkey = ? [val]

[SQL] SELECT count(DISTINCT `Fid`) FROM `table_demo` WHERE Fkey = ? [val]
```

Co-authored-by: finelog <kaicltw@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2096
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: finelog <finelog@noreply.gitea.io>
Co-committed-by: finelog <finelog@noreply.gitea.io>
2022-01-25 11:09:41 +08:00
appleboy e4e830bc78 chore(lint): remove revive and misspell command from makefile (#2088)
replace revive and misspell with golangci lint

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2088
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2022-01-16 19:04:15 +08:00
fuge d13b607d75 oracle分页,start 为 0 的bug (#2098)
删除前面判断即可。

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2098
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: fuge <fuge@noreply.gitea.io>
Co-committed-by: fuge <fuge@noreply.gitea.io>
2022-01-16 18:04:24 +08:00
jixianlqb 3d1c9fb761 对 DATE格式进行转换 (#2093)
对 DATE格式进行转换

Co-authored-by: laiqiangbin <laiqiangbin@chandashi.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2093
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: jixianlqb <jixianlqb@noreply.gitea.io>
Co-committed-by: jixianlqb <jixianlqb@noreply.gitea.io>
2022-01-16 16:36:07 +08:00
Andrew Thornton cd36b112ae Escape string and blob results from dump more correctly (#2091)
dumpTables currently badly handles BLOB and TEXT data containing control
characters:

* MySQL will interpret and unescape string literals e.g.`\r` will become
carriage return.

* Postgres will not allow string literals to contain NUL nor will
SQLite so BLOBs will not dump correctly.

* Schemas should not be set on the destination dump

* MSSQL needs the N prefix to correctly ensure that UTF-8 data is
correctly transferred.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2091
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-01-07 16:04:01 +08:00
Lunny Xiao 2fa7130704 Improve find interface (#2092)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2092
2022-01-06 19:43:06 +08:00
Andrew Thornton 470807151d fix cross db dumping of bools (#2089)
When dumping booleans these need to be converted from the original DB representation
to the new db representation. In the case of most DBs this is simply to 0 or 1 but
for postgres these have to be false or true.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2089
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-01-05 09:37:18 +08:00
satorunooshie 57365108ae Fix insertMultipleStruct to insert null value under certain circumstances (#2077)
The behavior of multi insertion of null differs from that of single insertion.
On the other hand, behavior between single and bulk insertion of null using pointer of struct field is identical.
Please see the example below.
```go
s := engineGroup.NewSession()

type User struct {
    ID   int    `xorm:"not null pk autoincr INT(10)"`
    Name string `xorm:"not null VARCHAR(191)"`
    Age  int64  `xorm:"null BIGINT(20)"`
}
list := []*User{
    {
        Name: "John",
    },
    {
    	Name: "Wick",
    },
}
s.Nullable("age")

// Single insertion works
_, err := s.Insert(list[0]) // [table] `user` INSERT INTO `user` (`name`,`age`) VALUES (?, ?) [John <nil>]

s.Nullable("age")
// Bulk insertion does not work
_, err := s.Insert(list) // [table] `user` INSERT INTO `user` (`name,`age`) VALUES (?, ?),(?, ?) [John, 0, Wick, 0]

//---------------------------------
//Using pointer, which is nullable, the generated sql has no difference.
//---------------------------------

type User struct {
    ID   int    `xorm:"not null pk autoincr INT(10)"`
    Name string `xorm:"not null VARCHAR(191)"`
    Age  *int64 `xorm:"null BIGINT(20)"`
}
list := []*User{
    {
        Name: "John",
    },
    {
    	Name: "Wick",
    },
}
s.Nullable("age")
// Single insertion works
_, err := s.Insert(list[0]) // [table] `user` INSERT INTO `user` (`name`,`age`) VALUES (?, ?) [John <nil>]

s.Nullable("age")
// Bulk insertion does not work
_, err := s.Insert(list) // [table] `user` INSERT INTO `user` (`name,`age`) VALUES (?, ?),(?, ?) [John, <nil>, Wick, <nil>]
```

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2077
Co-authored-by: satorunooshie <satorunooshie@noreply.gitea.io>
Co-committed-by: satorunooshie <satorunooshie@noreply.gitea.io>
2021-12-27 10:11:44 +08:00
Lunny Xiao a2d3669edf Add README and fix some lints (#2079)
as title.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2079
2021-12-14 09:00:35 +08:00
Lunny Xiao 303b1aeb77 Upgrade dependencies modules (#2078)
- github.com/goccy/go-json v0.7.4 -> v0.8.1
- github.com/json-iterator/go v1.1.11 -> v1.1.12
- github.com/mattn/go-sqlite3 v1.14.8 -> v1.14.9
- modernc.org/sqlite v1.11.2 -> v1.14.2

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2078
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-06 13:13:47 +08:00
linbaozhong 4f8f829913 exist方法sql语句优化 (#2075)
本地没有mssql和oracle,所以没法测试,但是,mysql 使用select 1 from TABLENAME where CONDITION limit 1可能更好

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2075
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: linbaozhong <linbaozhong@noreply.gitea.io>
Co-committed-by: linbaozhong <linbaozhong@noreply.gitea.io>
2021-12-01 13:54:47 +08:00
RenKanai 885f582677 Fix to add session.statement.IsForUpdate check in Session.queryRows() (#2064)
# Issue
The 'for-update' query is executed to slave DB node.

# Example

```go
s := engineGroup.NewSession(); // create session from EngineGroup.
...

s.ForUpdate();

type User struct { ... };
var user User;
has, err := s.Get(&user); // executed to slave DB node.
...
```

Co-authored-by: rennnosuke <rennnosuke@noreply.gitea.io>
Co-authored-by: RenKanai <turutekab@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2064
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: RenKanai <rennnosuke@noreply.gitea.io>
Co-committed-by: RenKanai <rennnosuke@noreply.gitea.io>
2021-11-24 10:29:39 +08:00
Lunny Xiao f35ff7c2eb Make SQLType2Type support uint (#2071)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2071
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-19 12:32:55 +08:00
fanybook aea91cc7de add table & column comment for postgres(add table comment for mysql) (#2067)
让 postgres 支持字段注释,只在 v1.2.5 上测试过(不知道怎么 import master)

发现 master 分支好像大改了?模式表名带 schema 了

使用方式和 mysql 相同
```go
	type User struct {
		Id int64	`xorm:"pk autoincr"`
		Name string `json:"name" xorm:"not null default '' varchar(50) index(name_age) comment('用户 (it''s) 1; 名')"`
		Salt string
		Age int		`json:"age" xorm:"not null default 0 int(10) index(name_age) comment('年龄')"`
		Passwd string `xorm:"varchar(200)"`
		CreatedAt time.Time `xorm:"created"`
		UpdatedAt time.Time `xorm:"updated"`
	}

	_ = engine.Sync(new(User))

    func (model User) TableComment() string {
    	return "表注释"
    }
```

Co-authored-by: fanybook <fanybook@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2067
Co-authored-by: fanybook <fanybook@noreply.gitea.io>
Co-committed-by: fanybook <fanybook@noreply.gitea.io>
2021-11-12 20:58:05 +08:00
stepbystep2 a22f5dce83 少了个`.` (#2068)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2068
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: stepbystep2 <stepbystep2@noreply.gitea.io>
Co-committed-by: stepbystep2 <stepbystep2@noreply.gitea.io>
2021-11-09 17:55:37 +08:00
RenKanai 5feff03a17 Fix README.md: Sync2 -> Sync (#2065)
Co-authored-by: rennnosuke <rennnosuke@noreply.gitea.io>
Co-authored-by: RenKanai <turutekab@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2065
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: RenKanai <rennnosuke@noreply.gitea.io>
Co-committed-by: RenKanai <rennnosuke@noreply.gitea.io>
2021-10-29 17:31:07 +08:00
rennnosuke 26f9d619cc Fix new-lined query execution in master DB node. (#2066)
# Issue
Such a following query is executed in master DB node with EngineGroup.

```go
s := engineGroup.NewSession(); // create session from EngineGroup.

sql := `
SELECT * FROM USER;
`;

type User struct { ... };
var users []User;
err := s.Sql(sql).Find(&users); // executed to master DB node.

```

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2066
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: rennnosuke <rennnosuke@noreply.gitea.io>
Co-committed-by: rennnosuke <rennnosuke@noreply.gitea.io>
2021-10-28 21:21:38 +08:00
Lunny Xiao 40a135948b New Prepare useage (#2061)
Fix #2060, Three ways to use the `Prepare`.

The first

```go
engine.Prepare().Where().Get()
```

The second

```go
sess := engine.NewSession()
defer sess.Close()

sess.Prepare().Where().Get()

sess.Prepare().Where().Get()
```

The third
```go
sess := engine.NewSession()
defer sess.Close()

sess.Begin()

sess.Prepare().Where().Get()

sess.Prepare().Where().Get()

sess.Commit()
```

Or

```go
sess := engine.NewSession()
defer sess.Close()

sess.Begin()

sess.Prepare().Insert()

sess.Prepare().Insert()

sess.Commit()
```

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2061
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-10-20 08:53:30 +08:00
Lunny Xiao b350c289f8 Fix missing quote on modifycolumnSQL (#2058)
Fix #2054

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2058
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-29 20:07:55 +08:00
Lunny Xiao bd5cd8cab7 Fix bug of dameng scan (#2056)
Fix #2055

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2056
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-24 21:45:47 +08:00
undefined_ss 0de285680b fix ctx override bug (#2053)
详情请参考工单:https://gitea.com/xorm/xorm/issues/2052

Co-authored-by: undefined_ss <sununiq@163.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2053
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: undefined_ss <undefined_ss@noreply.gitea.io>
Co-committed-by: undefined_ss <undefined_ss@noreply.gitea.io>
2021-09-23 20:22:14 +08:00
Lunny Xiao fd26f415ca Add test for mysql tls (#2049)
Fix #1495

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2049
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-17 18:47:30 +08:00
Lunny Xiao 6761699036 Fix bug of Rows (#2048)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2048
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-16 23:59:36 +08:00
Lunny Xiao 4656a87f2f Fix bug (#2046)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2046
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-13 15:19:59 +08:00
Lunny Xiao 16cf2442f6 Some performance optimization for get (#2043)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2043
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-07 16:03:08 +08:00
daisuzu 78309606d4 fix panic when `Iterate()` fails (#2040)
not to call `rows.Err()`

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2040
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: daisuzu <daisuzu@noreply.gitea.io>
Co-committed-by: daisuzu <daisuzu@noreply.gitea.io>
2021-09-07 09:23:16 +08:00
Lunny Xiao 045abb07df Expose ScanString / ScanInterface and etc (#2039)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2039
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-27 17:10:16 +08:00
finelog e5c89cf55e fix panic when convert sql and args with nil time.Time pointer (#2038)
this pr fix a panic, when using nil time.Time pointer for input.
not sure if there are others similar code.
please review it, thanks!

Co-authored-by: finelog <kaicltw@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2038
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: finelog <finelog@noreply.gitea.io>
Co-committed-by: finelog <finelog@noreply.gitea.io>
2021-08-26 00:03:18 +08:00
Lunny Xiao 0a429a241d Drop sync function and rename sync2 to sync (#2018)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2018
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-24 17:13:17 +08:00
Lunny Xiao d92fb412ee Make Get and Rows.Scan accept multiple parameters (#2029)
Now the below behaviours are allowed.

```Go
var id int64
var name string
has, err := engine.Table(&user).Cols("id", "name").Get(&id, &name)
// SELECT id, name FROM user LIMIT 1
```

```Go
rows, err := engine.Cols("name", "age").Rows(&User{Name:name})
// SELECT * FROM user
defer rows.Close()
for rows.Next() {
    var name string
    var age int
    err = rows.Scan(&name, &age)
}
```

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2029
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-24 15:42:34 +08:00