Commit Graph

1740 Commits

Author SHA1 Message Date
Lunny Xiao caa8a029c6 some optimzation (#2272)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2272
2023-06-02 14:16:30 +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
Zettat123 57f7d69f1b Fix test-cockroach workflow (#2269)
The image has already specified the entrypoint so we don't need to call `/cockroach/cockroach` in `cmd`.
![image](/attachments/669496c1-5673-4609-abc7-f42846e4d479)

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2269
Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-committed-by: Zettat123 <zettat123@gmail.com>
2023-05-29 13:01:43 +00:00
Lunny Xiao 04d36cfa81 Use actions instead of drone (#2258)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2258
2023-05-25 18:15:09 +08: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
Martin Viggiano e6907e9a62 oracle: Fix quotes on DropTableSQL function, add IsSequenceExist function. (#2265)
- Fixed quotes on drop table SQL statement.
- Implemented IsSequenceExists function for oracle dialect.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2265
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Martin Viggiano <martinvigg@gmail.com>
Co-committed-by: Martin Viggiano <martinvigg@gmail.com>
2023-05-17 09:04:00 +08:00
Abei1uo 23be940bad Fix session insert interface slice commit panic(#2259) (#2260)
Fix session insert interface slice commit panic(#2259)
-- TestInsertMulti2InterfaceTransaction is the test case

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2260
Co-authored-by: Abei1uo <2676567028@qq.com>
Co-committed-by: Abei1uo <2676567028@qq.com>
2023-05-12 14:58:38 +08:00
Alberto Garcia 94fcec7f65 parse timestamp with milliseconds in tz format (#2246)
This pr fixes a bug caused when a timestmap in TZ format with milliseconds (`2023-04-05T15:50:48.256816Z` or `2023-04-05T15:50:48.256816+08:00`) is being parsed.

- The bug is happens in the function `String2Time` in `convert/time.go`
- if the timestamp contains milliseconds a layout with the structure `2006-01-02 15:04:05.` is used to parse it
- This layout contains an space between the date and the hour, if the timestamp returned by the db contains a `T` the parser fails and an error is returned

This pr adds a check for the `T` and milliseconds in the timestamp, if both conditions are present the date is parsed using the RFC3339 layout

Added test cases to check timestamps in this format

Solves [#2244](https://gitea.com/xorm/xorm/issues/2244)

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2246
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Alberto Garcia <agarcia@circutor.com>
Co-committed-by: Alberto Garcia <agarcia@circutor.com>
2023-04-06 21:47:59 +08:00
datbeohbbh d485abba57 add `(*Engine) SetConnMaxIdleTime` (#2229)
issue: https://gitea.com/xorm/xorm/issues/2228
Co-authored-by: datbeohbbh <phongtomfapp@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2229
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: datbeohbbh <datbeohbbh@noreply.gitea.io>
Co-committed-by: datbeohbbh <datbeohbbh@noreply.gitea.io>
2023-03-06 18:55:33 +08:00
fanshengshuai 914f2db9ea mysql字段为UNSIGNED时,会导致字段类型无法识别,返回RawBytes,JSON 字段映射为String (#2225)
如题

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2225
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: fanshengshuai <fanshengshuai@noreply.gitea.io>
Co-committed-by: fanshengshuai <fanshengshuai@noreply.gitea.io>
2023-02-28 23:42:42 +08:00
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
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
jamlacey 0c9963c637 Add support for go-ora driver (#2215)
Co-authored-by: James Lacey <jamlacey@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2215
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: jamlacey <jamlacey@noreply.gitea.io>
Co-committed-by: jamlacey <jamlacey@noreply.gitea.io>
2023-02-04 21:24:29 +08:00
datbeohbbh 7dc2a18876 Bug fix: `Rows` must be closed after used (#2214)
Issue: [#2213](https://gitea.com/xorm/xorm/issues/2213#issue-132724)
Co-authored-by: datbeohbbh <phongtomfapp@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2214
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-03 17:24:16 +08:00
tamalsaha 5fafa00043 fix: Correctly parse jsonb column tag (#2206)
Signed-off-by: Tamal Saha <tamal@appscode.com>
Co-authored-by: Tamal Saha <tamal@appscode.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2206
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: tamalsaha <tamalsaha@noreply.gitea.io>
Co-committed-by: tamalsaha <tamalsaha@noreply.gitea.io>
2023-01-09 13:19:29 +08:00
Dmitry Narizhnykh 71270edfcc add delimiters between COMMENT ON COLUMN... for Postgres (#2156)
Fix bug: CreateTableSQL func generates invalid SQL without ";" delimiters.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2156
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Dmitry Narizhnykh <slotix@noreply.gitea.io>
Co-committed-by: Dmitry Narizhnykh <slotix@noreply.gitea.io>
2022-12-12 18:35:40 +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
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
stevefan1999 3acabdaf26 Fix Oracle Table creation default value (#2190)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2190
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: stevefan1999 <stevefan1999@noreply.gitea.io>
Co-committed-by: stevefan1999 <stevefan1999@noreply.gitea.io>
2022-10-24 11:29:54 +08:00
Lunny Xiao bd58520020
add changelog for 1.3.2 2022-09-03 15:14:19 +08:00
Andrew Thornton c900ecc87f Prevent Sync failure with non-regular indexes on Postgres (#2174)
When dropping indexes in Postgres if the index is non-regular we
should not attempt to regularise the index name as it is already correct.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2174
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-09-03 10:12:17 +08:00
Andrew Thornton c3bce55620 Change schemas.Column to use int64 (#2160)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2160
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-07-14 13:55:24 +08:00
Lunny Xiao f469d88166
Update changelog for 1.3.1 2022-06-03 17:44:49 +08:00
Lunny Xiao c98930f8f2 Fix oid index for postgres (#2154)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2154
2022-06-03 15:24:24 +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
Andrew Thornton eeb7fcf22c Add ORDER BY SEQ_IN_INDEX to MySQL GetIndexes to Fix IndexTests (#2152)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2152
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-05-30 18:36:23 +08:00
Andrew Thornton 60540cbabe Remove const insertSelectPlaceholder and associated dead code (#2151)
`insertSelectPlaceholder` is an unexported const set at true. No code changes this nor can any build environment change it.

Therefore we should remove it and the associated dead code.

Close #2146

Signed-off-by: Andrew Thornton <art27@cantab.net>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2151
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-05-30 00:29:03 +08:00
Andrew Thornton 26d291bbc3 Add interface to allow structs to provide specific index information (#2137)
The current mechanism for adding information about indices cannot express the ordering
of the columns in the index or add sorting information.

Here we add a new interface TableIndices which a struct would implement to provide
a slice of *schema.Index to provide additional indices to that gleaned from the tags.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2137
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-04-24 19:34:27 +08:00
Lunny Xiao f7e9fb74ac return a clear error for set TEXT type as compare condition (#2062)
Fix #523

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2062
2022-04-23 17:19:37 +08:00
Lunny Xiao 2c064b6da6 Add test for find date (#2121)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2121
2022-04-22 14:56:26 +08:00
Pierre-Louis Bonicoli e1d4365667 MySQL/MariaDB: return max length for text columns (#2133)
MySQL/MariaDB: return max length for text columns using `CHARACTER_MAXIMUM_LENGTH`.

 Tests:
 * add an integration test: `TestGetColumnsLength`
 * update `TestSyncTable3` since `TableInfo` isn't able to provide the column size

Co-authored-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2133
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
Co-committed-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
2022-04-22 10:48:53 +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
Pierre-Louis Bonicoli ea9bba0d14 PostgreSQL: enable comment on column (#2131)
The [oldest unsupported version documentation](https://www.postgresql.org/docs/7.1/sql-comment.html) states that comment on a column is supported.

Update `TestGetColumnsComment` in order to check both MySQL/MariaDB and PostgreSQL.

Co-authored-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2131
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
Co-committed-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
2022-04-17 18:03:29 +08:00
Lunny Xiao e858b75756
Update changelog for 1.3.0 2022-04-14 10:12:39 +08:00
getsu b3f9c53d8a oracle数据库不再拼接AS (#2109)
修复 #2108

Co-authored-by: chendy <acrhwfy@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2109
Co-authored-by: getsu <getsu@noreply.gitea.io>
Co-committed-by: getsu <getsu@noreply.gitea.io>
2022-03-31 23:57:40 +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
Pierre-Louis Bonicoli 79a21b68aa replace GitHub links: xorm has been moved to gitea.com (#2126)
Co-authored-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2126
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
Co-committed-by: Pierre-Louis Bonicoli <pilou@noreply.gitea.io>
2022-03-31 14:26:05 +08:00
fuge 3180c418c2 bugfix :Oid It's a special index. You can't put it in (#2105)
Co-authored-by: fuge <8342337@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2105
Co-authored-by: fuge <fuge@noreply.gitea.io>
Co-committed-by: fuge <fuge@noreply.gitea.io>
2022-01-25 13:28:46 +08:00
finelog 7802393d01 fix reset colmap when counting distinct cols (#2096)
when using distinct cols with FindAndCount, reset statement.ColumnMap will make the counting sql an syntax error, this pr try fix this.
is this pr ok for merge?

error sql logging:
```sql
[SQL] SELECT DISTINCT `Fid` FROM `table_demo` WHERE Fkey = ? [val]

[SQL] SELECT count(DISTINCT ) FROM `table_demo` WHERE Fkey = ? [val]
```

after fix:
```sql
[SQL] SELECT DISTINCT `Fid` FROM `table_demo` WHERE Fkey = ? [val]

[SQL] SELECT count(DISTINCT `Fid`) FROM `table_demo` WHERE Fkey = ? [val]
```

Co-authored-by: finelog <kaicltw@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2096
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: finelog <finelog@noreply.gitea.io>
Co-committed-by: finelog <finelog@noreply.gitea.io>
2022-01-25 11:09:41 +08:00
appleboy e4e830bc78 chore(lint): remove revive and misspell command from makefile (#2088)
replace revive and misspell with golangci lint

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2088
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2022-01-16 19:04:15 +08:00
fuge d13b607d75 oracle分页,start 为 0 的bug (#2098)
删除前面判断即可。

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2098
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: fuge <fuge@noreply.gitea.io>
Co-committed-by: fuge <fuge@noreply.gitea.io>
2022-01-16 18:04:24 +08:00
jixianlqb 3d1c9fb761 对 DATE格式进行转换 (#2093)
对 DATE格式进行转换

Co-authored-by: laiqiangbin <laiqiangbin@chandashi.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2093
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: jixianlqb <jixianlqb@noreply.gitea.io>
Co-committed-by: jixianlqb <jixianlqb@noreply.gitea.io>
2022-01-16 16:36:07 +08:00
Andrew Thornton cd36b112ae Escape string and blob results from dump more correctly (#2091)
dumpTables currently badly handles BLOB and TEXT data containing control
characters:

* MySQL will interpret and unescape string literals e.g.`\r` will become
carriage return.

* Postgres will not allow string literals to contain NUL nor will
SQLite so BLOBs will not dump correctly.

* Schemas should not be set on the destination dump

* MSSQL needs the N prefix to correctly ensure that UTF-8 data is
correctly transferred.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2091
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-01-07 16:04:01 +08:00
Lunny Xiao 2fa7130704 Improve find interface (#2092)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2092
2022-01-06 19:43:06 +08:00
Andrew Thornton 470807151d fix cross db dumping of bools (#2089)
When dumping booleans these need to be converted from the original DB representation
to the new db representation. In the case of most DBs this is simply to 0 or 1 but
for postgres these have to be false or true.

Signed-off-by: Andrew Thornton <art27@cantab.net>

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2089
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2022-01-05 09:37:18 +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 303b1aeb77 Upgrade dependencies modules (#2078)
- github.com/goccy/go-json v0.7.4 -> v0.8.1
- github.com/json-iterator/go v1.1.11 -> v1.1.12
- github.com/mattn/go-sqlite3 v1.14.8 -> v1.14.9
- modernc.org/sqlite v1.11.2 -> v1.14.2

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2078
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-06 13:13:47 +08:00
linbaozhong 4f8f829913 exist方法sql语句优化 (#2075)
本地没有mssql和oracle,所以没法测试,但是,mysql 使用select 1 from TABLENAME where CONDITION limit 1可能更好

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2075
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: linbaozhong <linbaozhong@noreply.gitea.io>
Co-committed-by: linbaozhong <linbaozhong@noreply.gitea.io>
2021-12-01 13:54:47 +08:00
RenKanai 885f582677 Fix to add session.statement.IsForUpdate check in Session.queryRows() (#2064)
# 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 { ... };
var user User;
has, err := s.Get(&user); // executed to slave DB node.
...
```

Co-authored-by: rennnosuke <rennnosuke@noreply.gitea.io>
Co-authored-by: RenKanai <turutekab@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2064
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: RenKanai <rennnosuke@noreply.gitea.io>
Co-committed-by: RenKanai <rennnosuke@noreply.gitea.io>
2021-11-24 10:29:39 +08:00