gitee.com/eden-framework/sqlx@v0.0.3/builder/stmt_update_test.go (about)

     1  package builder_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	. "gitee.com/eden-framework/sqlx/builder"
     7  	. "gitee.com/eden-framework/sqlx/builder/buidertestingutils"
     8  	"github.com/onsi/gomega"
     9  )
    10  
    11  func TestStmtUpdate(t *testing.T) {
    12  	table := T("T")
    13  
    14  	t.Run("update", func(t *testing.T) {
    15  		gomega.NewWithT(t).Expect(
    16  			Update(table).
    17  				Set(
    18  					Col("F_a").ValueBy(1),
    19  					Col("F_b").ValueBy(2),
    20  				).
    21  				Where(
    22  					Col("F_a").Eq(1),
    23  					Comment("Comment"),
    24  				),
    25  		).To(BeExpr(`
    26  UPDATE T SET f_a = ?, f_b = ?
    27  WHERE f_a = ?
    28  /* Comment */`, 1, 2, 1))
    29  	})
    30  }