@@ -98,11 +98,37 @@ ON CONFLICT(""id"") DO UPDATE SET
9898 var lst = fsql . Select < tbiou02 > ( ) . Where ( a => new [ ] { 1 , 2 , 3 , 4 } . Contains ( a . id ) ) . ToList ( ) ;
9999 Assert . Equal ( 4 , lst . Where ( a => a . name == "00" + a . id ) . Count ( ) ) ;
100100 }
101+
101102 class tbiou02
102103 {
103104 public int id { get ; set ; }
104105 public string name { get ; set ; }
105106 }
107+
108+ [ Fact ]
109+ public void InsertOrUpdate_TempPrimary ( )
110+ {
111+ fsql . Delete < tbiou_temp > ( ) . Where ( "1=1" ) . ExecuteAffrows ( ) ;
112+ var iou = fsql . InsertOrUpdate < tbiou_temp > ( ) . SetSource ( new tbiou_temp { name = "01" , description = "testval" } , m => new { m . name } ) ;
113+ var sql = iou . ToSql ( ) ;
114+ Assert . Equal ( @"INSERT INTO ""tbiou_temp""(""name"", ""description"") VALUES('01', 'testval')
115+ ON CONFLICT(""name"") DO UPDATE SET
116+ ""description"" = EXCLUDED.""description""" , sql ) ;
117+ Assert . Equal ( 1 , iou . ExecuteAffrows ( ) ) ;
118+
119+ var iou2 = fsql . InsertOrUpdate < tbiou_temp > ( ) . SetSource ( new tbiou_temp { name = "01" , description = "testval2" } , m => new { m . name } ) . ExecuteAffrows ( ) ;
120+ Assert . Equal ( 1 , iou2 ) ;
121+
122+ }
123+ [ Index ( "uix_tbiou_temp_name" , "name" , true ) ]
124+ class tbiou_temp
125+ {
126+ [ Column ( IsPrimary = true , IsIdentity = true ) ]
127+ public int id { get ; set ; }
128+
129+ public string name { get ; set ; }
130+ public string description { get ; set ; }
131+ }
106132 [ Fact ]
107133 public void InsertOrUpdate_OnePrimaryAndIdentity ( )
108134 {
0 commit comments