Commit Graph

8 Commits

Author SHA1 Message Date
Lunny Xiao 6e78cff477
Use any instead of interface{} 2023-10-28 17:48:25 +08:00
Lunny Xiao 82faf6c301 start v2 (#2350)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2350
2023-10-27 14:27:46 +00:00
6543 e5be0f4129 Remove dead code from session.SyncWithOptions() (#2323)
db7c264062/sync.go (L229-L231)

as oriIndex only is **not** nil if index.Equal(index2)

and index.Equal(index2) check if `oriIndex.Type == index.Type` ... so it always is false

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2323
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2023-09-16 14:41:02 +00:00
6543 db7c264062 Add Sync options to ignore constrains and indices (#2320)
needed for https://github.com/woodpecker-ci/woodpecker/pull/2117

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2320
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2023-08-09 03:28:52 +00:00
LinkinStars 9b71cb49cc The loadTableInfo function supports passing the context. (#2297)
## `loadTableInfo` add context parameter

### Main change
```diff
+++ func (engine *Engine) loadTableInfo(ctx context.Context, table *schemas.Table) error
--- func (engine *Engine) loadTableInfo(table *schemas.Table) error
```

### Situation
After #2200, I built custom dialect to control the SQL. I find that everything else is fine, except when the `SYNC` method executes with an exception.
The reason is that the `loadTableInfo` method calls the `GetIndexes` and `GetColumns` methods with the dialect during execution. **The context passed to these two methods are all `engine.defaultContext` not the current session's context.** So, I think the `loadTableInfo` method should add the context parameter to ensure that the correct context is used during execution.

### Review Note
1. dialect's `GetColumns` and `GetIndexes` methods are **only** used here, if the context here is incorrect, then the context parameter is invalid.
2. `loadTableInfo` method is only used in `SYNC` and `DBMetas` methods, `SYNC` should pass the session's context, while `DBMetas` has no problem passing `engine.defaultContext`.

All in all, I think this change should not affect other function.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/2297
Co-authored-by: LinkinStars <linkinstar@foxmail.com>
Co-committed-by: LinkinStars <linkinstar@foxmail.com>
2023-07-14 07:35:35 +00:00
brookechen 486c344ba3 In SQLite3, Sync doesn't support Modify Column:Error: near MODIFY: syntax error (#2267)
rebase

Co-authored-by: brookechen <brookechen@noreply.gitea.io>
Co-authored-by: brookechen <brookechen@tencent.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2267
Co-authored-by: brookechen <brookechen@noreply.gitea.com>
Co-committed-by: brookechen <brookechen@noreply.gitea.com>
2023-07-11 17:10:36 +00:00
Lunny Xiao 18f8e7a86c Default don't log warn for database extra columns when syncing (#2280)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2280
2023-06-23 15:00:31 +00:00
Lunny Xiao 068de8c0f8 Don't warn when database have extra columns which are not in struct (#2279)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2279
2023-06-23 08:48:37 +00:00