File tree 1 file changed +39
-0
lines changed 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -741,3 +741,42 @@ func TestInsertMulti4(t *testing.T) {
741
741
assert .NoError (t , err )
742
742
assert .EqualValues (t , len (users ), cnt )
743
743
}
744
+
745
+ func TestAnonymousStruct (t * testing.T ) {
746
+ type PlainObject struct {
747
+ ID uint64 `json:"id,string" xorm:"'ID' pk autoincr"`
748
+ Desc string `json:"desc" xorm:"'DESC' notnull"`
749
+ }
750
+
751
+ type PlainFoo struct {
752
+ PlainObject `xorm:"extends"` // primary key defined in extends struct
753
+
754
+ Width uint32 `json:"width" xorm:"'WIDTH' notnull"`
755
+ Height uint32 `json:"height" xorm:"'HEIGHT' notnull"`
756
+
757
+ Ext struct {
758
+ F1 uint32 `json:"f1,omitempty"`
759
+ F2 uint32 `json:"f2,omitempty"`
760
+ } `json:"ext" xorm:"'EXT' json notnull"`
761
+ }
762
+
763
+ assert .NoError (t , prepareEngine ())
764
+ assertSync (t , new (PlainFoo ))
765
+
766
+ _ , err := testEngine .Insert (& PlainFoo {
767
+ PlainObject : PlainObject {
768
+ Desc : "test" ,
769
+ },
770
+ Width : 10 ,
771
+ Height : 20 ,
772
+
773
+ Ext : struct {
774
+ F1 uint32 `json:"f1,omitempty"`
775
+ F2 uint32 `json:"f2,omitempty"`
776
+ }{
777
+ F1 : 11 ,
778
+ F2 : 12 ,
779
+ },
780
+ })
781
+ assert .NoError (t , err )
782
+ }
You can’t perform that action at this time.
0 commit comments