MCPcopy Create free account
hub / github.com/temporalio/temporal / buildDSNAttr

Function buildDSNAttr

common/persistence/sql/sqlplugin/sqlite/plugin.go:181–210  ·  view source on GitHub ↗
(cfg *config.SQL)

Source from the content-addressed store, hash-verified

179}
180
181func buildDSNAttr(cfg *config.SQL) (url.Values, error) {
182 parameters := url.Values{}
183
184 // sort ConnectAttributes to get a deterministic order
185 keys := expmaps.Keys(cfg.ConnectAttributes)
186 sort.Strings(keys)
187
188 for _, k := range keys {
189 key := strings.TrimSpace(k)
190 value := strings.TrimSpace(cfg.ConnectAttributes[k])
191 if parameters.Get(key) != "" {
192 return nil, fmt.Errorf("duplicate connection attr: %v:%v, %v:%v",
193 key,
194 parameters.Get(key),
195 key, value,
196 )
197 }
198
199 if _, isValidQueryParameter := queryParameters[key]; isValidQueryParameter {
200 parameters.Set(key, value)
201 continue
202 }
203
204 // assume pragma
205 parameters.Add("_pragma", fmt.Sprintf("%s=%s", key, value))
206 }
207 // set time format
208 parameters.Add("_time_format", "sqlite")
209 return parameters, nil
210}

Callers 1

buildDSNFunction · 0.70

Calls 4

GetMethod · 0.65
AddMethod · 0.65
ErrorfMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected