Revision 46464 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CountOperation.java

View differences:

CountOperation.java
96 96
        List<ExpressionBuilder.Value> valuesToRemoveFeatureType = new ArrayList<>();
97 97
        List<String> extraColumnNames = new ArrayList<>();
98 98

  
99
        if (this.query != null && this.query.hasGroupByColumns()) {
99
        if (this.query != null && (query.hasGroupByColumns() || query.hasAggregateFunctions())) {
100 100
            JDBCSQLBuilderBase subsqlbuilder = this.createSQLBuilder();
101 101
            SelectBuilder subselect = subsqlbuilder.select();
102 102
            
......
112 112
                            FeatureAttributeEmulatorExpression x = (FeatureAttributeEmulatorExpression) attrEmulator;
113 113
                            Expression exp = x.getExpression();
114 114

  
115
                            if (query != null && query.hasGroupByColumns()) {
115
//                            if (query != null && (query.hasGroupByColumns() || query.hasAggregateFunctions())) {
116 116
                                String aggregate = query.getAggregate(this.table.getTable(), attr.getName());
117 117
                                if (this.query.isAGroupByColumn(attr.getName())) {
118 118
                                    if (!subselect.has_column(attr.getName())) {
......
129 129
                                    }
130 130
                                
131 131
                                }
132
                            } else {
133
                                if (exp != null && !exp.isEmpty() && this.helper.supportExpression(this.featureType, exp.getPhrase())) {
134
                                    Code code = exp.getCode();
135
                                    subselect.column()
136
                                            .value(code.toValue(expbuilder))
137
                                            .as(attr.getName());
138
                                
139
                                }
140

  
141
                            }
132
//                            } else {
133
//                                if (exp != null && !exp.isEmpty() && this.helper.supportExpression(this.featureType, exp.getPhrase())) {
134
//                                    Code code = exp.getCode();
135
//                                    subselect.column()
136
//                                            .value(code.toValue(expbuilder))
137
//                                            .as(attr.getName());
138
//                                
139
//                                }
140
//
141
//                            }
142 142
                        }
143 143
                    }
144 144
                }
......
157 157
                }
158 158
            }
159 159
            
160
            if (this.query.hasGroupByColumns()) {
160
            if (this.query.hasGroupByColumns() || query.hasAggregateFunctions()) {
161 161
                subselect.from().table()
162 162
                        .database(this.table.getDatabase())
163 163
                        .schema(this.table.getSchema())

Also available in: Unified diff