KN4CK3R
056cecc97e
Add Truncate
method ( #2220 )
...
This PR adds a `Truncate` method which allows to delete all existing rows in a table. The current `Delete` implementation enforces conditions to prevent accidental data deletion.
Co-authored-by: KN4CK3R <admin@oldschoolhack.me >
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com >
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2220
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com >
Co-authored-by: KN4CK3R <kn4ck3r@noreply.gitea.io >
Co-committed-by: KN4CK3R <kn4ck3r@noreply.gitea.io >
2023-02-20 07:17:35 +08: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
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
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
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
c433fd51cb
Nil ptr is nullable ( #1919 )
...
replace #661
Co-authored-by: Jim Salem <jim@komand.com >
Co-authored-by: Oleh Herych <diesel.draft@gmail.com >
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1919
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com >
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com >
2021-07-06 23:20:17 +08:00
Lunny Xiao
8f64a78cd4
Support delete with no bean ( #1926 )
...
Now you can use delete like this:
```
orm.Table("my_table").Where("id=?",1).Delete()
```
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1926
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com >
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com >
2021-07-06 17:11:45 +08:00
Lunny Xiao
7fd6356a85
Add DBVersion ( #1723 )
...
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1723
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com >
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com >
2021-06-12 15:06:05 +08:00
clannadxr
407da9ddd8
export tag identifier ( #1865 )
...
#1864 Export tag identifier so we can change that form `xorm` to others
This will be useful when in some migration scenarios such as migrate `sqlx` to `xorm`, the former uses `db` as the identifier and has a very simple rule which can be covered by xorm parser rules
Co-authored-by: clannadxr <clannadxr@hotmail.com >
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1865
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com >
Co-authored-by: clannadxr <clannadxr@noreply.gitea.io >
Co-committed-by: clannadxr <clannadxr@noreply.gitea.io >
2021-02-09 15:20:54 +08: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
b7b2b21a40
Fix dump/import bug ( #1603 )
...
Fix bug
Fix mssql
Fix postgres
Fix import test
Fix dump/import bug
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1603
2020-03-15 02:02:37 +00:00
Lunny Xiao
94fd254638
Support count with cols ( #1595 )
...
Support count with cols
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1595
2020-03-11 03:29:43 +00:00
Lunny Xiao
7455014823
Improve quote policy ( #1567 )
...
names with upper charactor on postgres will need quotes
Fix bug
Add new quote parameter on tests
Fix bug
Fix tests
Fix quotes
fix test
Improve quote policy
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1567
2020-03-06 07:48:32 +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
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
aa522f7d98
Improve code ( #1552 )
...
Change filters
Fix test
add more tests on drone
add more tests on drone
Improve code
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1552
2020-02-27 03:33:40 +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
bd20ffba3b
fix update map with version ( #1448 )
...
fix test
fix update map with version
SetExpr support more go types (#1499 )
Improve tests
SetExpr support more go types
fix vet
fix drone lint
remove go1.10 test on drone
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1499
fix vet
fix drone lint
remove go1.10 test on drone
Fix update with Alias (#1455 )
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1448
2020-01-20 05:24:12 +00:00
Lunny Xiao
6d11913765
Add support subquery on SetExpr ( #1428 )
...
* add support subquery on SetExpr
* fix tests
2019-09-23 23:34:26 +08:00
Lunny Xiao
c9b14f9487
move depends package from github.com to customize domain ( #1327 )
2019-06-17 13:38:13 +08:00
Masaki.Yamamoto
8a61b3a8a9
Fix spelling inconsistency ( #1317 )
2019-06-06 10:55:52 +08:00
Lunny Xiao
5750e3f90a
Add context support ( #1193 )
...
* add context support
* improve pingcontext tests
2019-01-20 11:01:14 +08:00
Lunny Xiao
270035c70f
Add more methods for EngineInterface ( #1091 )
...
* add more methods for EngineInterface
* more interfaces
2018-09-07 11:01:18 +08:00
Lunny Xiao
4ce90f9a62
Exec support builder ( #1064 )
2018-08-09 13:09:54 +08:00
Lunny Xiao
636ccefbc7
fix update map with table name ( #888 )
...
* fix update map with table name
* fix bug update map when cache enabled
* refactor cacheInsert
* fix cache test
2018-04-11 23:09:46 +08:00
Lunny Xiao
5c2af83817
add test and remove unused warn log ( #886 )
2018-04-11 15:39:04 +08:00
Lunny Xiao
bd20c37bfb
Add SetSchema for engine ( #876 )
...
* add SetSchema for engine
* fix user
* fix postgres with schema
* fix test
* fix test
* fix test
* fix tablename
* refactor tableName
* fix schema support
* improve the interface of EngineInterface
2018-04-10 09:50:29 +08:00
Lunny Xiao
430fbe866a
add FindAndCount method ( #842 )
2018-02-07 07:06:13 -06:00
Lunny Xiao
a6cc098689
QueryString and QueryInterface supports composite conditions ( #784 )
2017-11-20 16:14:27 +08:00
Lunny Xiao
de4b2f9c8e
Query now could work with Where, In, SQL and other condition methods ( #776 )
2017-11-15 11:34:59 +08:00
Lunny Xiao
109cb1a7d0
Add support Engine Group ( #748 )
...
* add support group engine
* revert code
* add NewGroup function
* add engine group policy
* rename file name
* modify policy interface
* remove Init function from policy interface
* refactor Group Policy
* rename and comments
* rename and bug fix for WeightRoundRobinPolicy
* modify Slave function
* modify Slave function and add LeastConnPolicy
* use original Engine and Session
* remove unused count variables
* fix bug on NewEngineGroup
* remove unused method
* improve range and refactor
* add some comments and refactor
* implement GroupPolicy of GroupPolicyHandler
* refactor
* simple code
* add tests support for EngineGroup & fix some bugs
* improve the NewEngineGroup interface
* change the default policy of engine group
* fix some tests
2017-10-16 15:28:13 +08:00