From 1f76a7d6d41c665ca47b282be4363670c1c18b62 Mon Sep 17 00:00:00 2001 From: ZPascal Date: Sun, 12 Jul 2026 10:04:57 +0200 Subject: [PATCH] fix: Adjust the PostgresConfig JSON/YAML tags to snake_case (max_conns, connect_timeout, prepare_threshold, ssl_mode) matching the CUE schema in sql_patch.cue Signed-off-by: ZPascal --- go/datasource/proxy/sql/sql.go | 8 ++++---- go/datasource/proxy/sql/sql_test.go | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/go/datasource/proxy/sql/sql.go b/go/datasource/proxy/sql/sql.go index 4bf7b7c..190d830 100644 --- a/go/datasource/proxy/sql/sql.go +++ b/go/datasource/proxy/sql/sql.go @@ -53,13 +53,13 @@ type MySQLConfig struct { type PostgresConfig struct { // MaxConns is the maximum size of the pool - MaxConns int32 `json:"maxConns,omitempty" yaml:"maxConns,omitempty"` + MaxConns int32 `json:"max_conns,omitempty" yaml:"max_conns,omitempty"` // ConnectTimeout the timeout value used for socket connect operations. - ConnectTimeout common.DurationString `json:"connectTimeout,omitempty" yaml:"connectTimeout,omitempty"` + ConnectTimeout common.DurationString `json:"connect_timeout,omitempty" yaml:"connect_timeout,omitempty"` // PrepareThreshold specifies the number of PreparedStatement executions that must occur before the driver begins using server-side prepared statements. - PrepareThreshold *int `json:"prepareThreshold,omitempty" yaml:"prepareThreshold,omitempty"` + PrepareThreshold *int `json:"prepare_threshold,omitempty" yaml:"prepare_threshold,omitempty"` // SSLMode to use when connecting to postgres - SSLMode SSLMode `json:"sslMode,omitempty" yaml:"sslMode,omitempty"` + SSLMode SSLMode `json:"ssl_mode,omitempty" yaml:"ssl_mode,omitempty"` // Options specifies command-line options to send to the server at connection start Options string `json:"options,omitempty" yaml:"options,omitempty"` } diff --git a/go/datasource/proxy/sql/sql_test.go b/go/datasource/proxy/sql/sql_test.go index 87fa2df..c454497 100644 --- a/go/datasource/proxy/sql/sql_test.go +++ b/go/datasource/proxy/sql/sql_test.go @@ -36,7 +36,7 @@ func TestUnmarshalJSONConfig(t *testing.T) { "host": "localhost:5432", "database": "test", "postgres": { - "sslMode": "disable" + "ssl_mode": "disable" } } `, @@ -161,10 +161,10 @@ func TestUnmarshalJSONConfig(t *testing.T) { "host": "localhost:5432", "database": "test", "postgres": { - "maxConns": 50, - "connectTimeout": "5m", - "prepareThreshold": 5, - "sslMode": "require", + "max_conns": 50, + "connect_timeout": "5m", + "prepare_threshold": 5, + "ssl_mode": "require", "options": "-c search_path=myschema" } } @@ -190,7 +190,7 @@ func TestUnmarshalJSONConfig(t *testing.T) { "host": "localhost:5432", "database": "test", "postgres": { - "sslMode": "notreal" + "ssl_mode": "notreal" } } `, @@ -266,7 +266,7 @@ driver: postgres host: localhost:5432 database: test postgres: - sslMode: disable + ssl_mode: disable `, result: Config{ Driver: DriverPostgreSQL, @@ -376,7 +376,7 @@ driver: postgres host: localhost:5432 database: test postgres: - sslMode: verify-full + ssl_mode: verify-full `, result: Config{ Driver: DriverPostgreSQL, @@ -394,7 +394,7 @@ driver: postgres host: localhost:5432 database: test postgres: - sslMode: invalid + ssl_mode: invalid `, expectErr: true, },