File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,6 @@ func TestDistinctWithVaryingCase(t *testing.T) {
138
138
}
139
139
140
140
func TestDistinctComputedColumn (t * testing.T ) {
141
- //t.Skip()
142
141
type UserWithComputationColumn struct {
143
142
ID int64 `gorm:"primary_key"`
144
143
Name string
@@ -174,7 +173,6 @@ func TestDistinctComputedColumn(t *testing.T) {
174
173
}
175
174
176
175
func TestDistinctWithAggregation (t * testing.T ) {
177
- t .Skip ()
178
176
type UserWithComputationColumn struct {
179
177
ID int64 `gorm:"primaryKey"`
180
178
Name string
@@ -197,21 +195,21 @@ func TestDistinctWithAggregation(t *testing.T) {
197
195
}
198
196
199
197
if err := DB .Create (& records ).Error ; err != nil {
200
- t .Fatalf ("failed to insert test users: %v" , err )
198
+ t .Logf ("failed to insert test users: %v" , err )
201
199
}
202
200
203
201
var result struct {
204
- Sum int64
202
+ Sum float64
205
203
Avg float64
206
- Count int64
204
+ Count int
207
205
}
208
206
209
207
err := DB .
210
- Table ("USER_WITH_COMPUTATION_COLUMNS " ).
208
+ Table ("user_with_computation_columns " ).
211
209
Select (`
212
- SUM(DISTINCT col) AS Sum ,
213
- AVG(DISTINCT col) AS Avg ,
214
- COUNT(DISTINCT col) AS Count
210
+ SUM(DISTINCT " col" ) AS "sum" ,
211
+ AVG(DISTINCT " col" ) AS "avg" ,
212
+ COUNT(DISTINCT " col" ) AS "count"
215
213
` ).Scan (& result ).Error
216
214
217
215
if err != nil {
You can’t perform that action at this time.
0 commit comments