Prevent using cast column from alias __ctx_query
Fixes #1160 by keep the original name of the column and using it if the column type is date.
This commit is contained in:
parent
a614fb1ef6
commit
d1696425fd
@ -52,10 +52,18 @@ Numeric histogram:
|
||||
*/
|
||||
module.exports = class NumericHistogram extends BaseHistogram {
|
||||
_buildQuery (psql, override, callback) {
|
||||
let column = this.column;
|
||||
let query = this.query;
|
||||
// for date type we have to cast the column using an alias
|
||||
// and using that alias to prevent multiple calls to the cast
|
||||
if (this._columnType === 'date') {
|
||||
query = `(SELECT *, ${utils.columnCastTpl({ column })} as __cdb_cast_date FROM (${this.query}) __cdb_original_query)`;
|
||||
column = '__cdb_cast_date';
|
||||
}
|
||||
const histogramSql = this._buildQueryTpl({
|
||||
column: this._columnType === 'date' ? utils.columnCastTpl({ column: this.column }) : this.column,
|
||||
column,
|
||||
isFloatColumn: this._columnType === 'float',
|
||||
query: this.query,
|
||||
query,
|
||||
start: this._getBinStart(override),
|
||||
end: this._getBinEnd(override),
|
||||
bins: this._getBinsCount(override),
|
||||
|
Loading…
Reference in New Issue
Block a user