| 917 | } |
| 918 | |
| 919 | func TestSelectWithVariables(t *testing.T) { |
| 920 | DB.Save(&User{Name: "select_with_variables"}) |
| 921 | |
| 922 | rows, _ := DB.Table("users").Where("name = ?", "select_with_variables").Select("? as fake", gorm.Expr("name")).Rows() |
| 923 | defer rows.Close() |
| 924 | |
| 925 | if !rows.Next() { |
| 926 | t.Errorf("Should have returned at least one row") |
| 927 | } else { |
| 928 | columns, _ := rows.Columns() |
| 929 | AssertEqual(t, columns, []string{"fake"}) |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | func TestSelectWithArrayInput(t *testing.T) { |
| 934 | DB.Save(&User{Name: "select_with_array", Age: 42}) |