Fix: CSV export fails if it has sub query with filter

This commit is contained in:
Gabriel Herbert
2025-10-18 16:55:44 +02:00
parent 1b884f6763
commit ba9ade2ea5
3 changed files with 21 additions and 2 deletions

View File

@@ -106,7 +106,7 @@ func Handler(w http.ResponseWriter, r *http.Request) {
handler.AbortRequest(w, handler.ContextCsvDownload, err, handler.ErrGeneral)
return
}
var columns []types.Column
var columns []types.CsvExportColumn
if err := json.Unmarshal([]byte(columnsString), &columns); err != nil {
handler.AbortRequest(w, handler.ContextCsvDownload, err, handler.ErrGeneral)
return

8
types/types_csv.go Normal file
View File

@@ -0,0 +1,8 @@
package types
import "github.com/gofrs/uuid"
type CsvExportColumn struct {
AttributeId uuid.UUID `json:"attributeId"`
Captions CaptionMap `json:"captions"`
}

View File

@@ -142,6 +142,17 @@ export default {
clearInterval(this.cacheDenialTimeout);
},
computed:{
columnsCsv:(s) => {
let out = [];
for(const c of s.columnsSorted) {
// only keep relevant data
out.push({
attributeId:c.attributeId,
captions:c.captions
});
}
return out;
},
columnsSorted:(s) => {
let out = [];
for(const b of s.columnBatches) {
@@ -161,7 +172,7 @@ export default {
`timezone=${encodeURIComponent(s.timezone)}`,
`ignore_header=${s.hasHeader ? 'false' : 'true'}`,
`relation_id=${s.query.relationId}`,
`columns=${encodeURIComponent(JSON.stringify(s.columnsSorted))}`,
`columns=${encodeURIComponent(JSON.stringify(s.columnsCsv))}`,
`joins=${encodeURIComponent(JSON.stringify(s.joins))}`,
`expressions=${encodeURIComponent(JSON.stringify(s.expressions))}`,
`filters=${encodeURIComponent(JSON.stringify(s.filters))}`,