more postgresql type fixes
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-04-20 16:35:23 +10:00
parent aa0d8099c7
commit 83bd4b2026
5 changed files with 56 additions and 7 deletions
+39
View File
@@ -0,0 +1,39 @@
package tasks
import (
"strings"
"testing"
"time"
)
func TestBuildCanonicalHourlySummaryUnionCastsInventoryIDToBigInt(t *testing.T) {
start := time.Unix(1700000000, 0).UTC()
end := start.Add(24 * time.Hour)
query := buildCanonicalHourlySummaryUnion(start, end)
if !strings.Contains(query, `CAST(NULL AS BIGINT) AS "InventoryId"`) {
t.Fatalf("expected InventoryId cast to BIGINT in canonical hourly union query")
}
if !strings.Contains(query, `CAST(NULL AS TEXT) AS "EventKey"`) {
t.Fatalf("expected EventKey cast to TEXT in canonical hourly union query")
}
if !strings.Contains(query, `CAST(NULL AS TEXT) AS "CloudId"`) {
t.Fatalf("expected CloudId cast to TEXT in canonical hourly union query")
}
}
func TestBuildCanonicalDailyRollupSummaryUnionCastsInventoryIDToBigInt(t *testing.T) {
start := time.Unix(1700000000, 0).UTC()
end := start.AddDate(0, 1, 0)
query := buildCanonicalDailyRollupSummaryUnion(start, end)
if !strings.Contains(query, `CAST(NULL AS BIGINT) AS "InventoryId"`) {
t.Fatalf("expected InventoryId cast to BIGINT in canonical daily rollup union query")
}
if !strings.Contains(query, `CAST(NULL AS TEXT) AS "EventKey"`) {
t.Fatalf("expected EventKey cast to TEXT in canonical daily rollup union query")
}
if !strings.Contains(query, `CAST(NULL AS TEXT) AS "CloudId"`) {
t.Fatalf("expected CloudId cast to TEXT in canonical daily rollup union query")
}
}
+3 -3
View File
@@ -313,12 +313,12 @@ func (c *CronTask) aggregateDailySummarySQLCanonical(ctx context.Context, daySta
func buildCanonicalHourlySummaryUnion(start, end time.Time) string {
return fmt.Sprintf(`
SELECT
NULL AS "InventoryId",
CAST(NULL AS BIGINT) AS "InventoryId",
COALESCE("Name",'') AS "Name",
COALESCE("Vcenter",'') AS "Vcenter",
COALESCE("VmId",'') AS "VmId",
NULL AS "EventKey",
NULL AS "CloudId",
CAST(NULL AS TEXT) AS "EventKey",
CAST(NULL AS TEXT) AS "CloudId",
COALESCE("CreationTime",0) AS "CreationTime",
COALESCE("DeletionTime",0) AS "DeletionTime",
COALESCE("ResourcePool",'') AS "ResourcePool",
+3 -3
View File
@@ -769,12 +769,12 @@ WHERE "Date" >= %d AND "Date" < %d
func buildCanonicalDailyRollupSummaryUnion(start, end time.Time) string {
return fmt.Sprintf(`
SELECT
NULL AS "InventoryId",
CAST(NULL AS BIGINT) AS "InventoryId",
COALESCE("Name",'') AS "Name",
COALESCE("Vcenter",'') AS "Vcenter",
COALESCE("VmId",'') AS "VmId",
NULL AS "EventKey",
NULL AS "CloudId",
CAST(NULL AS TEXT) AS "EventKey",
CAST(NULL AS TEXT) AS "CloudId",
COALESCE("CreationTime",0) AS "CreationTime",
COALESCE("DeletionTime",0) AS "DeletionTime",
COALESCE("LastResourcePool",'') AS "ResourcePool",