rennnosuke
e03ecdfeee
fix to add session.statement.IsForUpdate check in Session.queryRows()
...
# 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 { ... };
has, err := s.Get(&user); // executed to slave DB node.
...
```
2021-10-28 16:38:22 +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
Lunny Xiao
c29b9649a9
Add dameng support ( #2007 )
...
driver: https://gitee.com/travelliu/dm
docker: https://download.dameng.com/eco/dm8/dm8_docker.tar
fix #1837
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2007
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-24 13:46:08 +08:00
yedf
7cd6a74c9f
expose sql.Tx ( #2036 )
...
Co-authored-by: yedongfu <dongfuye@163.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2036
Co-authored-by: yedf <yedf@noreply.gitea.io>
Co-committed-by: yedf <yedf@noreply.gitea.io>
2021-08-21 11:30:31 +08:00
Lunny Xiao
7d458b4fcf
refactor create table for postgres ( #2034 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2034
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-14 10:57:47 +08:00
Lunny Xiao
dbc2de380b
Refactor find ( #2031 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2031
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-11 21:17:23 +08:00
Lunny Xiao
289c27ebec
add changelog for 1.2.2
2021-08-11 09:29:27 +08:00
Lunny Xiao
cace6862e2
Move convert back to xorm.io/xorm/convert ( #2030 )
...
Since `conversion.Conversion` has been referenced by external package, it should not be moved as internal package.
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2030
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-10 23:20:53 +08:00
Lunny Xiao
fae164488c
Fix problem on README ( #2028 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2028
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-08 15:35:44 +08:00
Lunny Xiao
3a8ae761c5
Add changelog for v1.2.1
2021-08-08 11:01:02 +08:00
Lunny Xiao
ad1a386b5e
Fix wrong comment ( #2027 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2027
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-08 11:00:11 +08:00
Lunny Xiao
4499c8c5b5
Fix import file bug ( #2025 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2025
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-06 11:26:22 +08:00
Lunny Xiao
bd1ca33ea5
Update docs for pgx ( #2024 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2024
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-05 14:47:25 +08:00
Lunny Xiao
0b3cc25a10
Add pgx driver support ( #1795 )
...
Fix #858
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1795
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-05 14:04:11 +08:00
Lunny Xiao
42c2f158e8
Fix timesatmp ( #2021 )
...
Now `Datetime` support `Datime(6)` to indicate the time scale. For different database , the max scale is not different.
`Datetime` means `Datetime(0)`.
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2021
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-04 16:12:10 +08:00
Lunny Xiao
f22b0cc369
Update changelog for 1.2.0
2021-08-04 09:20:54 +08:00
Lunny Xiao
2afa222871
Fix deleted column ( #2014 )
...
Fix #2013
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2014
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-29 19:51:10 +08:00
Lunny Xiao
aeed22016f
Support batch insert map ( #2019 )
...
Fix #1767
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2019
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-29 16:12:09 +08:00
Lunny Xiao
4383669bcd
Fix DBMetas returned unsigned tinyint ( #2017 )
...
Fix #2011
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2017
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-29 11:04:43 +08:00
Lunny Xiao
5240459858
Move assign functions to convert package ( #2015 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2015
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-28 15:15:35 +08:00
Lunny Xiao
eb6d3b1637
Make drone faster ( #2008 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2008
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-28 11:41:58 +08:00
Lunny Xiao
c02a1bf00c
Fix postgres driver datasource name parse ( #2012 )
...
Fix #2010
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2012
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-28 10:03:09 +08:00
Andrew Thornton
d973423802
Fix issue with byte representation in MSSQL ( #1957 )
...
There is a missing cast to string in BuildUpdates which leads to a failure
to call str2ucs and ucs2str for converts on MSSQL.
Ref: https://github.com/go-gitea/gitea/issues/16252
Signed-off-by: Andrew Thornton <art27@cantab.net>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1957
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2021-07-23 09:01:49 +08:00
Andrew Thornton
ad4830f531
Remove default length of 50 for Blob ( #1959 )
...
There is an odd inconsistency with default blob sizes - this PR only sets the
default size for bytea and binary.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1959
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2021-07-23 08:59:53 +08:00
Lunny Xiao
6f79e06376
Fix master/slave bug ( #2004 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2004
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-22 11:07:53 +08:00
Lunny Xiao
47cfe0347f
Add test for limit with query ( #1787 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1787
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-21 21:13:15 +08:00
Lunny Xiao
0f3f4ea7fb
Update docs ( #2003 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2003
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-21 19:17:50 +08:00
Lunny Xiao
107bee4eb4
refactor conversion ( #2001 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2001
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-21 11:46:41 +08:00
Lunny Xiao
e323971011
refactor some code ( #2000 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2000
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-21 00:12:20 +08:00
Lunny Xiao
a7e010df2d
refactor insert condition generation ( #1998 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1998
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-20 13:46:24 +08:00
Lunny Xiao
86775af2ec
refactor and add setjson function ( #1997 )
...
Fix #1992
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1997
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-19 13:43:53 +08:00
raizen666
5950824e37
Support build flag go-json to replace default json ( #1982 )
...
`go build -tags=gojson` to use `github.com/goccy/go-json` as default json handler
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1982
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: raizen666 <raizen666@noreply.gitea.io>
Co-committed-by: raizen666 <raizen666@noreply.gitea.io>
2021-07-19 12:49:50 +08:00
Lunny Xiao
aaa2111e8f
Refactor asbytes ( #1995 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1995
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-19 00:21:46 +08:00
Lunny Xiao
779a74ccff
Remove duplicated code ( #1991 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1991
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-15 07:06:15 +08:00
Lunny Xiao
69a7db5312
improve uint tests ( #1990 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1990
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-14 17:06:53 +08:00
Lunny Xiao
b296c8f1d7
Exec with time arg now will obey time zone settings on engine ( #1989 )
...
Fix #1770
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1989
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-14 12:20:26 +08:00
andreasgerstmayr
147328f629
fix possible null dereference in internal/statements/query.go ( #1988 )
...
Make sure that pLimitN is not `nil` before dereferencing the pointer.
Co-authored-by: Andreas Gerstmayr <agerstmayr@redhat.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1988
Co-authored-by: andreasgerstmayr <andreasgerstmayr@noreply.gitea.io>
Co-committed-by: andreasgerstmayr <andreasgerstmayr@noreply.gitea.io>
2021-07-12 23:51:50 +08:00
Lunny Xiao
394c4e1f17
Replace #1044 ( #1935 )
...
Fix #1372 , #765
TODO:
- [x] Add tests
Co-authored-by: MURAOKA Taro <koron.kaoriya@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1935
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-11 21:33:01 +08:00