Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for ToSQL (0.01 sec)

  1. tests/sql_builder_test.go

    	// after model changed
    	if DB.Statement.DryRun || DB.DryRun {
    		t.Fatal("Failed expect DB.DryRun and DB.Statement.ToSQL to be false")
    	}
    
    	if DB.Statement.SQL.String() != "" {
    		t.Fatal("Failed expect DB.Statement.SQL to be empty")
    	}
    
    	// first
    	sql = DB.ToSQL(func(tx *gorm.DB) *gorm.DB {
    		return tx.Model(&User{}).Where(&User{Name: "foo", Age: 20}).Limit(10).Offset(5).Order("name ASC").First(&User{})
    	})
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Fri Jan 12 08:42:21 UTC 2024
    - 16.7K bytes
    - Viewed (0)
  2. gorm.go

    		return err
    	}
    	db.Plugins[name] = plugin
    	return nil
    }
    
    // ToSQL for generate SQL string.
    //
    //	db.ToSQL(func(tx *gorm.DB) *gorm.DB {
    //			return tx.Model(&User{}).Where(&User{Name: "foo", Age: 20})
    //				.Limit(10).Offset(5)
    //				.Order("name ASC")
    //				.First(&User{})
    //	})
    func (db *DB) ToSQL(queryFn func(tx *DB) *DB) string {
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Wed Oct 09 11:29:48 UTC 2024
    - 12.1K bytes
    - Viewed (0)
  3. tests/table_test.go

    }
    
    func TestTableWithNamer(t *testing.T) {
    	db, _ := gorm.Open(tests.DummyDialector{}, &gorm.Config{
    		NamingStrategy: schema.NamingStrategy{
    			TablePrefix: "t_",
    		},
    	})
    
    	sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
    		return tx.Model(&UserWithTableNamer{}).Find(&UserWithTableNamer{})
    	})
    
    	if !regexp.MustCompile("SELECT \\* FROM `t_users`").MatchString(sql) {
    		t.Errorf("Table with namer, got %v", sql)
    Registered: Sun Nov 03 09:35:10 UTC 2024
    - Last Modified: Sat Mar 09 09:31:28 UTC 2024
    - 10.6K bytes
    - Viewed (0)
Back to top