Commit Graph

61 Commits

Author SHA1 Message Date
Lunny Xiao 15bc47712e
Fix update 2023-07-25 15:56:15 +08:00
Lunny Xiao a13564976c refactor write update sql (#2304)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2304
2023-07-24 07:57:05 +00:00
Lunny Xiao 2df56f033a Some refactors (#2293)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2293
2023-07-20 14:45:31 +00:00
LinkinStars cb851a2f95 Filter support passing context (#2200) (#2270)
```diff
// Filter is an interface to filter SQL
type Filter interface {
---	Do(sql string) string
+++	Do(ctx context.Context, sql string) string
}
```

### Adds a `Context` parameter to the `Do` method of the Filter interface.

Developers can rewrite SQL through the `Filter` `Do` method and **need to get the necessary data from the Context** to assist.

For example, get user information through `Context`, so that different users can use different tables. Another example is to get the flags through `Context` to add annotations to the SQL, and use the annotations to let the subsequent `DB-Proxy` to achieve read/write separation.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2270
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: LinkinStars <linkinstar@foxmail.com>
Co-committed-by: LinkinStars <linkinstar@foxmail.com>
2023-05-31 01:43:24 +00:00
datbeohbbh 52855dae32 update go version to v1.17 in .drone.yml (#2219)
issue: #2218
Co-authored-by: datbeohbbh <phongtomfapp@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2219
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: datbeohbbh <datbeohbbh@noreply.gitea.io>
Co-committed-by: datbeohbbh <datbeohbbh@noreply.gitea.io>
2023-02-12 11:16:53 +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 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 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
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 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 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 5a58a272bc fix lint (#1953)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1953
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-15 20:28:49 +08:00
Lunny Xiao 8e22bad304 Fix bug didn't reset statement on update (#1939)
Fix #1900

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1939
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-12 11:43:45 +08:00
Lunny Xiao 7864cb5ae6 refactor exprParam (#1825)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1825
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-09 09:05:50 +08:00
Lunny Xiao 26b248c569 Fix update bug (#1823)
Fix #1821

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1823
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-05 10:55:36 +08:00
getsu 677c0d7411 fix invalid date when update for oracle (#1694)
Merge branch 'master' into master

Merge branch 'master' into master

Merge branch 'master' into master

fix invalid date when update for oracle

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: chendy <dengyue.chen@ebaotech.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1694
2020-07-03 08:10:09 +00:00
Lunny Xiao 9500b23395 Fix pk bug (#1602)
Fix pk bug

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1602
2020-03-13 08:57:34 +00:00
Lunny Xiao 188da20272 Move value2interface from session to statement package (#1587)
Fix zero

Fix tests

Move value2interface from session to statement package

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1587
2020-03-09 08:03:59 +00:00
Lunny Xiao 3617ee736f Only replace quotes when necessary (#1584)
fix test

improve code

improve code

improve code

improve code

Fix replace quote

fix test

Only replace quotes when necessary

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1584
2020-03-09 02:17:37 +00:00
Lunny Xiao 7f22948be9 Improve dialect interface (#1578)
Improve dialect interface

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1578
2020-03-07 08:51:30 +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 02c8a4b25d Move caches to manager (#1553)
Move caches to manager

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1553
2020-02-27 03:12:25 +00:00
Lunny Xiao a421331cf9 Improve some codes (#1551)
Improve code

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1551
2020-02-27 01:30:06 +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 eabfb48b5d Fix int time deleted bug (#1539)
Fix panic

Fix test

Fix test for mssql time

Add sql type check on deleted cond

Fix int time deleted bug

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1539
2020-02-21 12:17:40 +00:00
Lunny Xiao 062d9960b2 For nullable columns, store nil values as NULL (#531)
Merge branch 'master' into jcsalem/fix/nil_ptr_is_nullable

fix bug when buffersize with iterate (#941)

Merge branch 'master' into lunny/fix_buffer_iterate

Exclude schema from index name (#1505)

Merge branch 'master' into fix-schema-idx

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

Exclude schema from the index name

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1505

fix test

fix bug

fix bug when buffersize with iterate

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)

Co-authored-by: Guillermo Prandi <guillep2k@noreply.gitea.io>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/941

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

Exclude schema from index name (#1505)

Merge branch 'master' into fix-schema-idx

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

Exclude schema from the index name

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1505

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

For nullable columns, store nil values as NULL

fix vet

fix drone lint

remove go1.10 test on drone

Fix update with Alias (#1455)

Improve ci tests (#1477)

Rewrite Engine.QuoteTo() to accept multi-part identifiers (#1476)

Support local sql log (#1338)

Fix go mod and update version (#1460)

Move github.com/go-xorm/xorm to xorm.io/xorm (#1459)

add support custom type Nullfloat64 (#1450)

fix bug when query map condtion with no quote (#1449)

Don't warn when bool column default is 1 but not true (#1447)

* don't warn when bool column default is 1 but not true

* fix default case sensitive

Fix sync2 with custom table name (#1445)

* fix sync2 with custom table name

* fix bug on postgres

* fix bug on postgres

fix bug when update with setexpr (#1446)

add tidb tests on drone ci (#1444)

improve sync2 (#1443)

Fix wrong dbmetas (#1442)

* add tests for db metas

* add more tests

* fix bug on mssql

Fix default value parse bugs (#1437)

* fix default value

* fix default value tags

* fix postgres default

* fix default on postgres

* fix default on postgres

* fix mssql default

fix arg conversion (#1441)

* fix arg conversion

* fix bugs

* fix bug on postgres

* use traditional positional parameters on insert into select

* remove unnecessary tests

upgrade core (#1440)

add tests (#1439)

add go1.13 tests on drone (#1416)

Fix bug on insert where (#1436)

* fix bug on insert where

* fix bug

* fix lint

fix bug when insert multiple slices with customize table name (#1433)

* fix bug when insert multiple slices with customize table name

* fix tests on mssql

* fix tests

fix insert where with bool bug on mssql (#1432)

fix setexpr missing big quotes (#1431)

* fix setexpr missing big quotes

* fix tests

* fix tests

Add support subquery on SetExpr (#1428)

* add support subquery on SetExpr

* fix tests

fix go mod (#1427)

fix tests (#1429)

Use strings.Builder instead of builder.StringBuilder (#1417)

* use strings.Builder instead of builder.StringBuilder

* fix dependency

* fix dependency

Remove unuse get cols code (#1413)

Add mssql ci test (#1410)

* add mssql ci test

* fix drone test

Add insert select where support (#1401)

Use drone new format (#1388)

* use drone new format
fix get customize type bug (#1382)

fix bugs (#1375)

update drone (#1374)

Add tests for get var (#1305)

* add test for SQL get
* fix tests

fix error when get null var (#890)

* fix error when get null var
* add support get for null var
* fix bug

Remove quotestr totally (#1366)

* remove QuoteStr() totally

* update xorm.core -> v0.7.0

* update dialect Quote

remove QuoteStr() usage in dialects (#1364)

document of FindAndCount() (#1365)

remove QuoteStr() usage (#1360)

make sure timeout in context timeout t...

Co-authored-by: Guillermo Prandi <guillep2k@noreply.gitea.io>
Co-authored-by: Jim Salem <jim@komand.com>
Co-authored-by: Guillermo Prandi <guillep2k@noreply@gitea.io>
Co-authored-by: yudppp <yu.d.ppp@gmail.com>
Co-authored-by: BetaCat <outman99@hotmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/531
2020-01-20 08:25:21 +00:00
Lunny Xiao 6dfe337869 fix statement.LimitN(0) will delete or update all data (#1119)
fix test

fix nil pointer

fix statement.Limit(0) will update or delete all data

fix bug when buffersize with iterate (#941)

Merge branch 'master' into lunny/fix_buffer_iterate

Exclude schema from index name (#1505)

Merge branch 'master' into fix-schema-idx

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

Exclude schema from the index name

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1505

fix test

fix bug

fix bug when buffersize with iterate

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)

Co-authored-by: Guillermo Prandi <guillep2k@noreply.gitea.io>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/941

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

Exclude schema from index name (#1505)

Merge branch 'master' into fix-schema-idx

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

Exclude schema from the index name

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1505

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)

Improve ci tests (#1477)

Rewrite Engine.QuoteTo() to accept multi-part identifiers (#1476)

Support local sql log (#1338)

Fix go mod and update version (#1460)

Move github.com/go-xorm/xorm to xorm.io/xorm (#1459)

add support custom type Nullfloat64 (#1450)

fix bug when query map condtion with no quote (#1449)

Don't warn when bool column default is 1 but not true (#1447)

* don't warn when bool column default is 1 but not true

* fix default case sensitive

Fix sync2 with custom table name (#1445)

* fix sync2 with custom table name

* fix bug on postgres

* fix bug on postgres

fix bug when update with setexpr (#1446)

add tidb tests on drone ci (#1444)

improve sync2 (#1443)

Fix wrong dbmetas (#1442)

* add tests for db metas

* add more tests

* fix bug on mssql

Fix default value parse bugs (#1437)

* fix default value

* fix default value tags

* fix postgres default

* fix default on postgres

* fix default on postgres

* fix mssql default

fix arg conversion (#1441)

* fix arg conversion

* fix bugs

* fix bug on postgres

* use traditional positional parameters on insert into select

* remove unnecessary tests

upgrade core (#1440)

add tests (#1439)

add go1.13 tests on drone (#1416)

Fix bug on insert where (#1436)

* fix bug on insert where

* fix bug

* fix lint

fix bug when insert multiple slices with customize table name (#1433)

* fix bug when insert multiple slices with customize table name

* fix tests on mssql

* fix tests

fix insert where with bool bug on mssql (#1432)

fix setexpr missing big quotes (#1431)

* fix setexpr missing big quotes

* fix tests

* fix tests

Add support subquery on SetExpr (#1428)

* add support subquery on SetExpr

* fix tests

fix go mod (#1427)

fix tests (#1429)

Use strings.Builder instead of builder.StringBuilder (#1417)

* use strings.Builder instead of builder.StringBuilder

* fix dependency

* fix dependency

Remove unuse get cols code (#1413)

Add mssql ci test (#1410)

* add mssql ci test

* fix drone test

Add insert select where support (#1401)

Use drone new format (#1388)

* use drone new format
fix get customize type bug (#1382)

fix bugs (#1375)

update drone (#1374)

Add tests for get var (#1305)

* add test for SQL get
* fix tests

fix error when get null var (#890)

* fix error when get null var
* add support get for null var
* fix bug

Remove quotestr totally (#1366)

* remove QuoteStr() totally

* update xorm.core -> v0.7.0

* update dialect Quote

remove QuoteStr() usage in dialects (#1364)

document of FindAndCount() (#1365)

remove QuoteStr() usage (#1360)

Co-authored-by: yifhao <yifhao@tencent.com>
Co-authored-by: yifhao <1124210681@qq.com>
Co-authored-by: Guillermo Prandi <guillep2k@noreply.gitea.io>
Co-authored-by: Guillermo Prandi <guillep2k@noreply@gitea.io>
Co-authored-by: yudppp <yu.d.ppp@gmail.com>
Co-authored-by: BetaCat <outman99@hotmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1119
2020-01-20 08:22:06 +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 a18e35f7f5 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
2020-01-19 09:36:06 +00:00
Lunny Xiao c349d36e95 Fix update with Alias (#1455) 2019-11-14 06:49:43 +00:00
Lunny Xiao 2fbb9cd8de
fix setexpr missing big quotes (#1431)
* fix setexpr missing big quotes

* fix tests

* fix tests
2019-09-24 12:58:25 +08: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
BetaCat 18b32486cf remove QuoteStr() usage (#1360) 2019-07-24 09:41:06 +08:00
Lunny Xiao c9b14f9487
move depends package from github.com to customize domain (#1327) 2019-06-17 13:38:13 +08:00
Wendell Sun 1c2d47e0da add deleted condition for Update operation (#1249) 2019-03-13 19:02:41 +08:00
Lunny Xiao c68531db53
Add lasterror on statement to return errors when chain operations (#1151)
* add lasterror on statement to return errors when chain operations

* add tests for last error

* refactor error
2019-01-20 11:45:42 +08:00
mars 3add351809 Add version uint type support (#1125)
* fix panic when use version with uint32 type

* fix panic when use version with uint32 type

* Code refactoring
2018-10-27 21:20:00 +08:00
陈文强 4b224e8823 Fix genUpdateColumns() should not ignore soft delete column when unscoped (#1051) 2018-07-26 20:05:25 +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 6542364944
refactor buildUpdates (#884) 2018-04-11 12:57:13 +08:00
Lunny Xiao fd4a80bcad
fix id condition not used bug (#882) 2018-04-11 11:52:16 +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 865979f716
add support for map[string]interface{} as condition on Update and Where (#764) 2017-10-30 11:07:56 +08:00
Lunny Xiao 7dc8e7623c fix time tag utc (#742)
* fix time tag utc

* rename NowTime -> nowTime
2017-09-30 08:59:13 +08:00
Lunny Xiao 3101e3bc44 fix conflicts between Cols and updated (#725) 2017-09-15 09:51:15 +08:00