insert的时候支持单主键的递归转换。 #723

Closed
chenghuama wants to merge 1 commits from chenghuama/master into master
chenghuama commented 2017-09-14 06:20:22 +00:00 (Migrated from github.com)

外键递归转换,测试案例:
type TTA struct {
Id int64 xorm:"pk autoincr"
Aname string
}
type TTB struct {
ID *TTA xorm:"bigint pk"
Bname string
}
type TTC struct {
ID *TTB xorm:"bigint pk id"
Cname string
}

func TestD(t *testing.T) {
t.Log(db.DbRead.Sync2(new(TTA), new(TTB), new(TTC)))

a := TTA{Id: 78, Aname: "a"}
b := TTB{&a, "b"}
c := TTC{&b, "c"}  
_, err := db.DbRead.Insert(&a, &b, &c)
t.Log(err)

}

外键递归转换,测试案例: type TTA struct { Id int64 `xorm:"pk autoincr"` Aname string } type TTB struct { ID *TTA `xorm:"bigint pk"` Bname string } type TTC struct { ID *TTB `xorm:"bigint pk id"` Cname string } func TestD(t *testing.T) { t.Log(db.DbRead.Sync2(new(TTA), new(TTB), new(TTC))) a := TTA{Id: 78, Aname: "a"} b := TTB{&a, "b"} c := TTC{&b, "c"} _, err := db.DbRead.Insert(&a, &b, &c) t.Log(err) }
codecov-io commented 2017-09-14 06:30:23 +00:00 (Migrated from github.com)

Codecov Report

Merging #723 into master will decrease coverage by 0.01%.
The diff coverage is 47.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #723      +/-   ##
==========================================
- Coverage   52.41%   52.39%   -0.02%     
==========================================
  Files          35       35              
  Lines        8225     8237      +12     
==========================================
+ Hits         4311     4316       +5     
- Misses       3431     3436       +5     
- Partials      483      485       +2
Impacted Files Coverage Δ
session_convert.go 21.06% <47.36%> (+0.43%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c29485f...20eef8e. Read the comment docs.

# [Codecov](https://codecov.io/gh/go-xorm/xorm/pull/723?src=pr&el=h1) Report > Merging [#723](https://codecov.io/gh/go-xorm/xorm/pull/723?src=pr&el=desc) into [master](https://codecov.io/gh/go-xorm/xorm/commit/c29485f954ed6495861c0098f9a1642a467299c8?src=pr&el=desc) will **decrease** coverage by `0.01%`. > The diff coverage is `47.36%`. [![Impacted file tree graph](https://codecov.io/gh/go-xorm/xorm/pull/723/graphs/tree.svg?height=150&width=650&token=yB5nO1krEe&src=pr)](https://codecov.io/gh/go-xorm/xorm/pull/723?src=pr&el=tree) ```diff @@ Coverage Diff @@ ## master #723 +/- ## ========================================== - Coverage 52.41% 52.39% -0.02% ========================================== Files 35 35 Lines 8225 8237 +12 ========================================== + Hits 4311 4316 +5 - Misses 3431 3436 +5 - Partials 483 485 +2 ``` | [Impacted Files](https://codecov.io/gh/go-xorm/xorm/pull/723?src=pr&el=tree) | Coverage Δ | | |---|---|---| | [session\_convert.go](https://codecov.io/gh/go-xorm/xorm/pull/723/diff?src=pr&el=tree#diff-c2Vzc2lvbl9jb252ZXJ0Lmdv) | `21.06% <47.36%> (+0.43%)` | :arrow_up: | ------ [Continue to review full report at Codecov](https://codecov.io/gh/go-xorm/xorm/pull/723?src=pr&el=continue). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta) > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://codecov.io/gh/go-xorm/xorm/pull/723?src=pr&el=footer). Last update [c29485f...20eef8e](https://codecov.io/gh/go-xorm/xorm/pull/723?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Please add tests on codes.

Please add tests on codes.

outdated.

outdated.
lunny closed this pull request 2023-07-22 15:13:00 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.