Commit Graph

62 Commits

Author SHA1 Message Date
datbeohbbh 6dd92ce6f2 (fix) remove hacks in `session_insert` `(*Session) insertStruct` 2023-10-02 13:30:29 +07:00
datbeohbbh 8c5508fa79 squash all ydb-support commit history
(temp fix) ignore secure connection test

- use `ydb` as hostname

fix go vet

fix CI

update ydb-go-sdk to v3.52.1

fix `GetTables`
2023-09-24 17:13:12 +07:00
CyJaySong 94882e39df Fix deleted tag attribute zeroTime is not DatabaseTZ (#2299)
Co-authored-by: CyJay <cyjay@MacBook-Pro.lan>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2299
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: CyJaySong <CyJaySong@gmail.com>
Co-committed-by: CyJaySong <CyJaySong@gmail.com>
2023-08-07 04:28:55 +00:00
Lunny Xiao 6c29ab378e refactor write insert sql (#2302)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2302
2023-07-22 15:24:19 +00:00
brookechen 190384b4cd AutoIncrement列带ID插入数据时没有Commit (#2264)
业务场景中,需要预留(1 ~ 100)的ID给系统规则使用。所以会先使用插入将AutoIncrement列的id偏移到一个特定的值(如:100),然后“带ID调用Insert插入系统规则”。 当带ID插入时,由于没有commit,会被rollback掉。

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2264
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: brookechen <brookechen@noreply.gitea.io>
Co-committed-by: brookechen <brookechen@noreply.gitea.io>
2023-05-17 15:20:40 +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 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 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 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 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 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 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 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 a5030dc7a4 refactor get (#1967)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1967
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-06 16:06:04 +08:00
Lunny Xiao 962962bb64 Fix #929 (#1936)
sql server doesn't accept to insert a blank datetime like `0001-01-01 00:00:00`. So that we have a break change here that deleted column should not have a notnull tag.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1936
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-03 20:26:49 +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 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 2ac051f075 Improve insert map generating SQL (#1634)
Fix writeArg

Improve insert map generating SQL

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1634
2020-03-27 03:13:25 +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
joelBai c2bf301bdb fix batch insert interface slice be panic (#1598)
fix batch insert []interface{*struct, ...} be panic;add TestInsertMulti2Interface testcase

Co-authored-by: baijinping <baikkp@126.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1598
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-03-12 12:05:26 +00:00
Lunny Xiao 67cf42799c Remove duplicated code (#1588)
Remove duplicated code

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1588
2020-03-10 01:03:33 +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 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 ccf65397e8 Improve dialect interface (#1579)
Fix bug

Improve dialect interface

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1579
2020-03-07 10:00:05 +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 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 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 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 2513e09caa Add test for second insert error (#1527)
Add test for second insert error

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1527
2020-02-20 07:52:44 +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 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 691f6e7698
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
2019-09-25 16:42:24 +08:00
Lunny Xiao 59ed80ce1a
fix insert where with bool bug on mssql (#1432) 2019-09-24 16:05:35 +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
Lunny Xiao 17592d96b3
Add insert select where support (#1401) 2019-08-22 23:40:23 +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
Lunny Xiao 17b9cc7330
Add mssql ci test (#1203)
* add mssql ci test

* fix mssql ci

* check test databases

* fix ci

* fix postgres schema tests

* fix ci on postgres

* fix insert map bug

* fix insert map bug

* fix bug

* fix insert map bug

* fix create schema on tests

* fix mssql tests

* fix insert return id bugs on mssql

* add head comments
2019-01-22 23:59:58 +08:00
Lunny Xiao 5271caa592
Add insert map support (#940)
* add insert map

* fix insert map bug when cache enabled
2019-01-20 12:16:16 +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
Lunny Xiao ad69f7d8f0
performance improvement via string builder (#1036) 2018-07-11 08:59:00 +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 bfdf773629
fix tablename bug (#887)
* fix tablename bug

* fix test
2018-04-11 18:09:16 +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