MCPcopy
hub / github.com/go-gorm/gorm / TestSelectWithVariables

Function TestSelectWithVariables

tests/query_test.go:919–931  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

917}
918
919func 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
933func TestSelectWithArrayInput(t *testing.T) {
934 DB.Save(&User{Name: "select_with_array", Age: 42})

Callers

nothing calls this directly

Calls 10

ExprFunction · 0.92
SaveMethod · 0.80
NextMethod · 0.80
RowsMethod · 0.65
SelectMethod · 0.65
WhereMethod · 0.65
TableMethod · 0.65
CloseMethod · 0.65
ColumnsMethod · 0.65
AssertEqualFunction · 0.50

Tested by

no test coverage detected