@@ -109,7 +109,7 @@ func LoadFromEnvironment(prefix string) (*Config, error) {
109109 }
110110 if v := os .Getenv (prefix + "FORMAT_UPPERCASE_KEYWORDS" ); v != "" {
111111 if b , err := strconv .ParseBool (v ); err == nil {
112- config .Format .UppercaseKeywords = b
112+ config .Format .UppercaseKeywords = Bool ( b )
113113 }
114114 }
115115 if v := os .Getenv (prefix + "FORMAT_MAX_LINE_LENGTH" ); v != "" {
@@ -119,7 +119,7 @@ func LoadFromEnvironment(prefix string) (*Config, error) {
119119 }
120120 if v := os .Getenv (prefix + "FORMAT_COMPACT" ); v != "" {
121121 if b , err := strconv .ParseBool (v ); err == nil {
122- config .Format .Compact = b
122+ config .Format .Compact = Bool ( b )
123123 }
124124 }
125125
@@ -129,12 +129,12 @@ func LoadFromEnvironment(prefix string) (*Config, error) {
129129 }
130130 if v := os .Getenv (prefix + "VALIDATION_STRICT_MODE" ); v != "" {
131131 if b , err := strconv .ParseBool (v ); err == nil {
132- config .Validation .StrictMode = b
132+ config .Validation .StrictMode = Bool ( b )
133133 }
134134 }
135135 if v := os .Getenv (prefix + "VALIDATION_RECURSIVE" ); v != "" {
136136 if b , err := strconv .ParseBool (v ); err == nil {
137- config .Validation .Recursive = b
137+ config .Validation .Recursive = Bool ( b )
138138 }
139139 }
140140 if v := os .Getenv (prefix + "VALIDATION_PATTERN" ); v != "" {
@@ -152,29 +152,29 @@ func LoadFromEnvironment(prefix string) (*Config, error) {
152152 }
153153 if v := os .Getenv (prefix + "OUTPUT_VERBOSE" ); v != "" {
154154 if b , err := strconv .ParseBool (v ); err == nil {
155- config .Output .Verbose = b
155+ config .Output .Verbose = Bool ( b )
156156 }
157157 }
158158
159159 // Analyze settings
160160 if v := os .Getenv (prefix + "ANALYZE_SECURITY" ); v != "" {
161161 if b , err := strconv .ParseBool (v ); err == nil {
162- config .Analyze .Security = b
162+ config .Analyze .Security = Bool ( b )
163163 }
164164 }
165165 if v := os .Getenv (prefix + "ANALYZE_PERFORMANCE" ); v != "" {
166166 if b , err := strconv .ParseBool (v ); err == nil {
167- config .Analyze .Performance = b
167+ config .Analyze .Performance = Bool ( b )
168168 }
169169 }
170170 if v := os .Getenv (prefix + "ANALYZE_COMPLEXITY" ); v != "" {
171171 if b , err := strconv .ParseBool (v ); err == nil {
172- config .Analyze .Complexity = b
172+ config .Analyze .Complexity = Bool ( b )
173173 }
174174 }
175175 if v := os .Getenv (prefix + "ANALYZE_ALL" ); v != "" {
176176 if b , err := strconv .ParseBool (v ); err == nil {
177- config .Analyze .All = b
177+ config .Analyze .All = Bool ( b )
178178 }
179179 }
180180
@@ -217,7 +217,7 @@ func LoadFromEnvironment(prefix string) (*Config, error) {
217217 }
218218 if v := os .Getenv (prefix + "SERVER_METRICS_ENABLED" ); v != "" {
219219 if b , err := strconv .ParseBool (v ); err == nil {
220- config .Server .MetricsEnabled = b
220+ config .Server .MetricsEnabled = Bool ( b )
221221 }
222222 }
223223 if v := os .Getenv (prefix + "SERVER_SHUTDOWN_TIMEOUT" ); v != "" {
@@ -257,36 +257,32 @@ func Merge(configs ...*Config) *Config {
257257 return result
258258}
259259
260- // mergeInto merges src into dst, with non-zero values from src taking precedence.
261- //
262- // NOTE: Boolean fields are only merged when true. This is a known limitation that
263- // prevents setting booleans to false via environment variables to override a config
264- // file that has them set to true. A proper fix would require using *bool pointers
265- // for all boolean fields to distinguish between "not set" and "explicitly set to false".
266- // See: https://github.com/ajitpratap0/GoSQLX/issues/134 for tracking issue.
260+ // mergeInto merges src into dst, with non-nil/non-zero values from src taking precedence.
261+ // Boolean fields use *bool pointers to distinguish between "not set" (nil) and
262+ // "explicitly set to false" (*false), allowing proper override behavior.
267263func mergeInto (dst , src * Config ) {
268264 // Merge Format
269265 if src .Format .Indent != 0 {
270266 dst .Format .Indent = src .Format .Indent
271267 }
272- if src .Format .UppercaseKeywords {
268+ if src .Format .UppercaseKeywords != nil {
273269 dst .Format .UppercaseKeywords = src .Format .UppercaseKeywords
274270 }
275271 if src .Format .MaxLineLength != 0 {
276272 dst .Format .MaxLineLength = src .Format .MaxLineLength
277273 }
278- if src .Format .Compact {
274+ if src .Format .Compact != nil {
279275 dst .Format .Compact = src .Format .Compact
280276 }
281277
282278 // Merge Validation
283279 if src .Validation .Dialect != "" {
284280 dst .Validation .Dialect = src .Validation .Dialect
285281 }
286- if src .Validation .StrictMode {
282+ if src .Validation .StrictMode != nil {
287283 dst .Validation .StrictMode = src .Validation .StrictMode
288284 }
289- if src .Validation .Recursive {
285+ if src .Validation .Recursive != nil {
290286 dst .Validation .Recursive = src .Validation .Recursive
291287 }
292288 if src .Validation .Pattern != "" {
@@ -300,21 +296,21 @@ func mergeInto(dst, src *Config) {
300296 if src .Output .Format != "" {
301297 dst .Output .Format = src .Output .Format
302298 }
303- if src .Output .Verbose {
299+ if src .Output .Verbose != nil {
304300 dst .Output .Verbose = src .Output .Verbose
305301 }
306302
307303 // Merge Analyze
308- if src .Analyze .Security {
304+ if src .Analyze .Security != nil {
309305 dst .Analyze .Security = src .Analyze .Security
310306 }
311- if src .Analyze .Performance {
307+ if src .Analyze .Performance != nil {
312308 dst .Analyze .Performance = src .Analyze .Performance
313309 }
314- if src .Analyze .Complexity {
310+ if src .Analyze .Complexity != nil {
315311 dst .Analyze .Complexity = src .Analyze .Complexity
316312 }
317- if src .Analyze .All {
313+ if src .Analyze .All != nil {
318314 dst .Analyze .All = src .Analyze .All
319315 }
320316
@@ -345,7 +341,7 @@ func mergeInto(dst, src *Config) {
345341 if src .Server .LogFile != "" {
346342 dst .Server .LogFile = src .Server .LogFile
347343 }
348- if src .Server .MetricsEnabled {
344+ if src .Server .MetricsEnabled != nil {
349345 dst .Server .MetricsEnabled = src .Server .MetricsEnabled
350346 }
351347 if src .Server .ShutdownTimeout != 0 {
0 commit comments