From 18d200682ae09bb6d52f97c7d8d6f9ade04ec553 Mon Sep 17 00:00:00 2001 From: ma91n Date: Wed, 28 Feb 2024 15:37:11 +0900 Subject: [PATCH] bugfi --- cli/dump.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/dump.go b/cli/dump.go index 0e75e85..17d8e9a 100644 --- a/cli/dump.go +++ b/cli/dump.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/jackc/pgtype" "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/pgxpool" "github.com/xuri/excelize/v2" @@ -37,6 +38,8 @@ var query = `SELECT tab.relname AS table_name ON tab.relid = coldesc.objoid AND col.ordinal_position = coldesc.objsubid WHERE exists(select 1 FROM tmp_exceltesting_dump_table_name WHERE tab.relname = name) + AND tab.schemaname = current_schema() + AND col.table_schema = current_schema() ORDER BY tab.relname , col.ordinal_position ; @@ -59,6 +62,9 @@ var queryAll = `SELECT tab.relname AS table_name LEFT OUTER JOIN pg_description coldesc ON tab.relid = coldesc.objoid AND col.ordinal_position = coldesc.objsubid + WHERE + tab.schemaname = current_schema() + AND col.table_schema = current_schema() ORDER BY tab.relname , col.ordinal_position ; @@ -343,6 +349,12 @@ func fmtCell(a any) string { switch v := a.(type) { case time.Time: return v.Format("2006-01-02 15:04:05") + case pgtype.Numeric: + var s string + if err := v.AssignTo(&s); err != nil { + return fmt.Sprintf("%v (fmtCell): %v", v, err) + } + return s default: return fmt.Sprint(v) }