@@ -26,11 +26,8 @@ import (
26
26
gelerrint "github.com/geldata/gel-go/internal/gelerr"
27
27
)
28
28
29
- // WithTxOptions returns a shallow copy of the client
30
- // with the TxOptions set to opts.
31
- func (c Client ) WithTxOptions (
32
- opts gelcfg.TxOptions ,
33
- ) * Client { // nolint:gocritic
29
+ // WithTxOptions returns a copy of c with the [gelcfg.TxOptions] set to opts.
30
+ func (c Client ) WithTxOptions (opts gelcfg.TxOptions ) * Client { //nolint:gocritic,lll
34
31
if ! opts .IsValid () {
35
32
panic ("TxOptions not created with NewTxOptions() are not valid" )
36
33
}
@@ -40,11 +37,9 @@ func (c Client) WithTxOptions(
40
37
return & c
41
38
}
42
39
43
- // WithRetryOptions returns a shallow copy of the client
40
+ // WithRetryOptions returns a copy of c
44
41
// with the RetryOptions set to opts.
45
- func (c Client ) WithRetryOptions ( // nolint:gocritic
46
- opts gelcfg.RetryOptions ,
47
- ) * Client {
42
+ func (c Client ) WithRetryOptions (opts gelcfg.RetryOptions ) * Client { //nolint:gocritic,lll
48
43
if ! opts .IsValid () {
49
44
panic ("RetryOptions not created with NewRetryOptions() are not valid" )
50
45
}
@@ -62,15 +57,13 @@ func (c *Client) copyPool() {
62
57
c .pool = & pool
63
58
}
64
59
65
- // WithConfig returns a shallow copy of the client
60
+ // WithConfig returns a copy of c
66
61
// with configuration values set to cfg.
67
- // Equivalent to using the edgeql configure session command.
68
- // For available configuration parameters refer to the [Config documentation].
62
+ // This is equivalent to using the edgeql configure session command.
63
+ // For available configuration parameters refer to the [config documentation].
69
64
//
70
- // [Config documentation]: https://docs.geldata.com/reference/stdlib/cfg#ref-std-cfg
71
- func (c Client ) WithConfig ( // nolint:gocritic
72
- cfg map [string ]interface {},
73
- ) * Client {
65
+ // [config documentation]: https://docs.geldata.com/reference/stdlib/cfg#ref-std-cfg
66
+ func (c Client ) WithConfig (cfg map [string ]interface {}) * Client { //nolint:gocritic,lll
74
67
state := gel .CopyState (c .pool .State )
75
68
76
69
var config map [string ]interface {}
@@ -90,8 +83,7 @@ func (c Client) WithConfig( // nolint:gocritic
90
83
return & c
91
84
}
92
85
93
- // WithoutConfig returns a shallow copy of the client
94
- // with keys unset from the configuration.
86
+ // WithoutConfig returns a copy of c with keys unset from the configuration.
95
87
func (c Client ) WithoutConfig (key ... string ) * Client { // nolint:gocritic
96
88
state := gel .CopyState (c .pool .State )
97
89
@@ -107,11 +99,9 @@ func (c Client) WithoutConfig(key ...string) *Client { // nolint:gocritic
107
99
return & c
108
100
}
109
101
110
- // WithModuleAliases returns a shallow copy of the client
111
- // with module name aliases set to aliases.
112
- func (c Client ) WithModuleAliases ( // nolint:gocritic
113
- aliases ... gelcfg.ModuleAlias ,
114
- ) * Client {
102
+ // WithModuleAliases returns a copy of c with module name aliases set to
103
+ // aliases.
104
+ func (c Client ) WithModuleAliases (aliases ... gelcfg.ModuleAlias ) * Client { //nolint:gocritic,lll
115
105
state := gel .CopyState (c .pool .State )
116
106
117
107
var a []interface {}
@@ -129,11 +119,8 @@ func (c Client) WithModuleAliases( // nolint:gocritic
129
119
return & c
130
120
}
131
121
132
- // WithoutModuleAliases returns a shallow copy of the client
133
- // with aliases unset.
134
- func (c Client ) WithoutModuleAliases ( // nolint:gocritic
135
- aliases ... string ,
136
- ) * Client {
122
+ // WithoutModuleAliases returns a copy of c with aliases unset.
123
+ func (c Client ) WithoutModuleAliases (aliases ... string ) * Client { //nolint:gocritic,lll
137
124
state := gel .CopyState (c .pool .State )
138
125
139
126
if a , ok := state ["aliases" ]; ok {
@@ -159,10 +146,12 @@ func (c Client) WithoutModuleAliases( // nolint:gocritic
159
146
return & c
160
147
}
161
148
162
- // WithGlobals sets values for global variables for the returned client.
163
- func (c Client ) WithGlobals ( // nolint:gocritic
164
- globals map [string ]interface {},
165
- ) * Client {
149
+ // WithGlobals returns a copy of c with its global variables updated from
150
+ // globals.
151
+ //
152
+ // WithGlobals does not remove variables that are not mentioned in globals.
153
+ // Instead use [Client.WithoutGlobals].
154
+ func (c Client ) WithGlobals (globals map [string ]interface {}) * Client { //nolint:gocritic,lll
166
155
state := gel .CopyState (c .pool .State )
167
156
168
157
var g map [string ]interface {}
@@ -182,8 +171,8 @@ func (c Client) WithGlobals( // nolint:gocritic
182
171
return & c
183
172
}
184
173
185
- // WithoutGlobals unsets values for global variables for the returned client .
186
- func (c Client ) WithoutGlobals (globals ... string ) * Client { // nolint:gocritic
174
+ // WithoutGlobals returns a copy of c with the specified global names unset .
175
+ func (c Client ) WithoutGlobals (globals ... string ) * Client { //nolint:gocritic
187
176
state := gel .CopyState (c .pool .State )
188
177
189
178
if c , ok := state ["globals" ]; ok {
@@ -198,31 +187,31 @@ func (c Client) WithoutGlobals(globals ...string) *Client { // nolint:gocritic
198
187
return & c
199
188
}
200
189
201
- // WithWarningHandler sets the warning handler for the returned client. If
202
- // warningHandler is nil gelcfg.LogWarnings is used.
203
- func (c Client ) WithWarningHandler ( // nolint:gocritic
204
- warningHandler gelcfg.WarningHandler ,
205
- ) * Client {
206
- if warningHandler == nil {
207
- warningHandler = gelcfg .LogWarnings
190
+ // WithWarningHandler returns a copy of c with its [gelcfg.WarningHandler] set
191
+ // to handler. If handler is nil, [gelcfg.LogWarnings] is used.
192
+ func (c Client ) WithWarningHandler (handler gelcfg.WarningHandler ) * Client { //nolint:gocritic,lll
193
+ if handler == nil {
194
+ handler = gelcfg .LogWarnings
208
195
}
209
196
210
197
c .copyPool ()
211
- c .pool .QueryConfig .WarningHandler = warningHandler
198
+ c .pool .QueryConfig .WarningHandler = handler
212
199
return & c
213
200
}
214
201
215
- // WithQueryOptions sets the [gelcfg.QueryOptions] for the returned Client.
216
- func (c Client ) WithQueryOptions (
217
- options gelcfg.QueryOptions ,
218
- ) * Client { // nolint:gocritic
202
+ // WithQueryOptions returns a copy of c with its gelcfg.Queryoptions set to
203
+ // opts.
204
+ func (c Client ) WithQueryOptions (opts gelcfg.QueryOptions ) * Client { //nolint:gocritic,lll
219
205
c .copyPool ()
220
- c .pool .QueryConfig .QueryOptions = options
206
+ c .pool .QueryConfig .QueryOptions = opts
221
207
return & c
222
208
}
223
209
224
- // WithQueryTag returns a copy of the client with the [sys::QueryStats] tag
225
- // set.
210
+ // WithQueryTag returns a copy of c with the [sys::QueryStats] tag set.
211
+ //
212
+ // sys::QueryStats only records the tag from the first time a query is run.
213
+ // Running the query again with a different tag will not change the tag in the
214
+ // sys::QueryStats entry.
226
215
//
227
216
// [sys::QueryStats]: https://docs.geldata.com/reference/stdlib/sys#type::sys::QueryStats
228
217
func (c Client ) WithQueryTag (tag string ) (* Client , error ) {
@@ -247,8 +236,7 @@ func (c Client) WithQueryTag(tag string) (*Client, error) {
247
236
return & c , nil
248
237
}
249
238
250
- // WithoutQueryTag returns a copy of the client with the [sys::QueryStats] tag
251
- // removed.
239
+ // WithoutQueryTag returns a copy of c with the [sys::QueryStats] tag removed.
252
240
//
253
241
// [sys::QueryStats]: https://docs.geldata.com/reference/stdlib/sys#type::sys::QueryStats
254
242
func (c Client ) WithoutQueryTag () * Client {
0 commit comments