Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compatible with pg #1683

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ CREATE TABLE alert_subscribe (
cluster varchar(128) not null,
rule_id bigint not null default 0,
severities varchar(32) not null default '',
tags varchar(4096) not null default '' ,
tags varchar(4096) not null default '[]',
redefine_severity smallint default 0 ,
new_severity smallint not null ,
redefine_channels smallint default 0 ,
Expand Down
1 change: 1 addition & 0 deletions etc/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ RSAPassWord = ""

[DB]
# postgres: host=%s port=%s user=%s dbname=%s password=%s sslmode=%s
# postgres: DSN="host=127.0.0.1 port=5432 user=root dbname=n9e_v6 password=1234 sslmode=disable"
DSN="root:1234@tcp(127.0.0.1:3306)/n9e_v6?charset=utf8mb4&parseTime=True&loc=Local&allowNativePasswords=true"
# enable debug mode or not
Debug = false
Expand Down
8 changes: 7 additions & 1 deletion pkg/ormx/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ func (j *JSONObj) UnmarshalJSON(data []byte) error {
func (j *JSONArr) Scan(value interface{}) error {
bytes, ok := value.([]byte)
if !ok {
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
// 判断是不是string类型 Postgres的varchar scan出来是string类型
strings, ok := value.(string)
if !ok {
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
}
// string类型转byte[]
bytes = []byte(strings)
}

result := json.RawMessage{}
Expand Down