Notealot
24ea0249fc
重构 json handler
2023-07-31 15:34:44 +08:00
洪坤安
73eee961cc
Performance Optimization: reduce slice2Bean calling times of strings.ToLower and map creation times ( #2255 )
...
1. 优化性能:减少func (session *Session) slice2Bean方法中的strings.ToLower调用次数以及减少map创建和访问次数(见工单 https://gitea.com/xorm/xorm/issues/2243)
2. 新增SetDefaultJSONHandler方法,用于用户自行设置DefaultJSONHandler(见工单 https://gitea.com/xorm/xorm/issues/2129)
优化前:
加载耗时=16.079s,总记录数=4028940
加载耗时=15.775s,总记录数=4028940
加载耗时=15.946s,总记录数=4028940
优化后:
加载耗时=10.863s,总记录数=4028940
加载耗时=11.257s,总记录数=4028940
加载耗时=11.155s,总记录数=4028940
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2255
Co-authored-by: 洪坤安 <wuzili1234@163.com>
Co-committed-by: 洪坤安 <wuzili1234@163.com>
2023-07-12 09:53:19 +00:00
Lunny Xiao
79a8bc804b
Fix join problem ( #2291 )
...
Fix #2284
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2291
2023-07-12 02:01:56 +00:00
Lunny Xiao
f1bfc5ce98
join support condition ( #2201 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2201
2022-12-09 23:37:26 +08:00
tylerthail2019
71a5939c65
add disable version check func ( #2197 )
...
Co-authored-by: tyler <tylerthail@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2197
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: tylerthail2019 <tylerthail2019@noreply.gitea.io>
Co-committed-by: tylerthail2019 <tylerthail2019@noreply.gitea.io>
2022-11-16 13:22:04 +08:00
Lunny Xiao
f9a6990ecb
Refactor orderby and support arguments ( #2150 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2150
2022-05-31 11:00:28 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Lunny Xiao
46fd8f58b3
Get struct and Find support big.Float ( #1976 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1976
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-07 15:46:21 +08:00
Lunny Xiao
54bbead2be
refactor slice2Bean 2 ( #1975 )
...
as title.
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1975
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-07 13:59:48 +08:00
Lunny Xiao
bece9a6373
refactor slice2Bean ( #1974 )
...
as title.
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1974
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-07 13:03:05 +08:00
Lunny Xiao
8f8195a86b
Improve get field value of bean ( #1961 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1961
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-29 14:32:29 +08:00
Lunny Xiao
4bfe6853f5
Fix some comments lint and bug ( #1888 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1888
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-10 10:57:36 +08:00
Lunny Xiao
beac298c02
Fix json tag with other type ( #1822 )
...
Fix json tag with other type
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1822
Co-Authored-By: Lunny Xiao <xiaolunwen@gmail.com>
Co-Committed-By: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-03 17:10:35 +08:00
appleboy
fe3bc3851e
chore: enable fmt check ( #1742 )
...
chore: enable fmt check
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1742
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-21 04:36:55 +00:00
Thomas_An
0fae64bb3b
Support get dataSourceName on ContextHook for monitor which DB executed SQL ( #1740 )
...
Merge branch 'log_context_add_db_info'
add session to context
Revert "accept lunny's suggestion"
This reverts commit 57fd669942
.
Merge branch 'master' of https://gitea.com/Thomas_An/thomasan_xorm
accept lunny's suggestion
Merge branch 'master' into master
add test code
session add Engine func
Used to monitor which DB executed this SQL
Co-authored-by: yong.an <yong.an@shopee.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1740
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-13 13:29:38 +00:00
limo.creed
34dc7f8791
Add Hook ( #1644 )
...
move hook to standalone package
add hook for engine
Co-authored-by: yuxiao.lu <yuxiao.lu@liulishuo.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1644
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-09 06:03:39 +00:00
Lunny Xiao
0a06dc204a
Move processor function into one file ( #1637 )
...
Move processor function into one file
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1637
2020-03-28 02:23:37 +00:00
Lunny Xiao
78bb4c711d
Improve codes ( #1630 )
...
Improve codes
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1630
2020-03-26 13:24:11 +00:00
Lunny Xiao
b78418daa5
Support session id ( #1632 )
...
small nit
Support session id
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1632
2020-03-26 12:31:08 +00:00
Lunny Xiao
5053c35701
Don't keep db on dialects ( #1623 )
...
don't keep db on dialects
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1623
2020-03-24 02:19:24 +00:00
Lunny Xiao
f238bb9d07
Improve insert ( #1583 )
...
Improve insert
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1583
2020-03-08 05:14:28 +00:00
Lunny Xiao
f51d28304a
Move some codes to statement sub package ( #1574 )
...
revert change for delete
refactor new engine
fix tests
Move some codes to statement sub package
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1574
2020-03-06 06:43:49 +00:00
Lunny Xiao
7278e2ab71
Improve tests ( #1572 )
...
fix test
Improve tests
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1572
2020-03-04 03:30:21 +00:00
Lunny Xiao
4e59597a49
Fix break session sql enable feature ( #1566 )
...
Fix break session sql enable feature
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1566
2020-03-01 03:05:26 +00:00
Lunny Xiao
41388c2f56
Use a new ContextLogger interface to implement logger ( #1557 )
...
Fix bug
Add log track on prepare & tx
Some improvements
remove unused codes
refactor logger
Fix bug
log context
add ContextLogger interface
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1557
2020-02-29 08:59:59 +00:00
Lunny Xiao
2b62dc5a51
Move statement as a sub package ( #1564 )
...
Fix test
Fix bug
Move statement as a sub package
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1564
2020-02-28 12:29:08 +00:00
Lunny Xiao
f63b42ff9b
Move maptype to tag parser ( #1561 )
...
Move maptype to tag parser
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1561
2020-02-28 02:00:21 +00:00
Lunny Xiao
e2f9100419
Move tag parser related codes as a standalone sub package ( #1547 )
...
Fix sliceEq
fix tests
Move tag parser related codes as a standalone sub package
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1547
2020-02-27 03:58:31 +00:00
Lunny Xiao
5a5375a170
Improve statement ( #1549 )
...
Fix cache bug
Improve statement
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1549
2020-02-27 00:34:16 +00:00
Lunny Xiao
390effb8a4
Move zero functions to a standalone package ( #1548 )
...
Remove depreciated functions and move some functions to schemas
Move zero functions to a standalone package
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1548
2020-02-26 12:45:10 +00:00
Lunny Xiao
bf25a77bca
Merge core package back into the main repository and split into serval sub packages. ( #1543 )
...
Fix test
Improve fmt
update go.mod
Move core as a sub package
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1543
2020-02-24 08:53:18 +00:00
Lunny Xiao
1735906dcc
Support local sql log ( #1338 )
2019-10-21 03:42:26 +00:00
Lunny Xiao
c9b14f9487
move depends package from github.com to customize domain ( #1327 )
2019-06-17 13:38:13 +08:00
Lunny Xiao
5ef12eab78
make json as interface ( #1248 )
2019-03-29 14:32:36 +08:00