@ragestudio/scylla-odm 0.22.2 → 0.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/batch/index.d.ts +3 -3
- package/batch/index.d.ts.map +1 -1
- package/client.d.ts +6 -5
- package/client.d.ts.map +1 -1
- package/client.js +7 -7
- package/client.js.map +1 -1
- package/cql_gen/create_table.d.ts +1 -1
- package/cql_gen/create_table.d.ts.map +1 -1
- package/document/index.d.ts +3 -3
- package/document/index.d.ts.map +1 -1
- package/driver/LICENSE.txt +177 -0
- package/driver/NOTICE.txt +67 -0
- package/driver/auth/index.d.ts +37 -0
- package/driver/auth/index.js +37 -0
- package/driver/auth/no-auth-provider.js +73 -0
- package/driver/auth/plain-text-auth-provider.js +81 -0
- package/driver/auth/provider.js +77 -0
- package/driver/client-options.js +442 -0
- package/driver/client.js +1267 -0
- package/driver/concurrent/index.d.ts +49 -0
- package/driver/concurrent/index.js +366 -0
- package/driver/connection.js +1034 -0
- package/driver/control-connection.js +1282 -0
- package/driver/encoder.js +2316 -0
- package/driver/errors.js +223 -0
- package/driver/execution-options.js +612 -0
- package/driver/execution-profile.js +274 -0
- package/driver/host-connection-pool.js +587 -0
- package/driver/host.js +699 -0
- package/driver/index.d.ts +387 -0
- package/driver/index.js +81 -0
- package/driver/mapping/cache.js +214 -0
- package/driver/mapping/doc-info-adapter.js +171 -0
- package/driver/mapping/index.d.ts +219 -0
- package/driver/mapping/index.js +57 -0
- package/driver/mapping/mapper.js +225 -0
- package/driver/mapping/mapping-handler.js +641 -0
- package/driver/mapping/model-batch-item.js +215 -0
- package/driver/mapping/model-batch-mapper.js +141 -0
- package/driver/mapping/model-mapper.js +315 -0
- package/driver/mapping/model-mapping-info.js +225 -0
- package/driver/mapping/object-selector.js +417 -0
- package/driver/mapping/q.js +156 -0
- package/driver/mapping/query-generator.js +556 -0
- package/driver/mapping/result-mapper.js +123 -0
- package/driver/mapping/result.js +139 -0
- package/driver/mapping/table-mappings.js +133 -0
- package/driver/mapping/tree.js +160 -0
- package/driver/metadata/aggregate.js +79 -0
- package/driver/metadata/client-state.js +119 -0
- package/driver/metadata/data-collection.js +182 -0
- package/driver/metadata/event-debouncer.js +174 -0
- package/driver/metadata/index.d.ts +276 -0
- package/driver/metadata/index.js +1156 -0
- package/driver/metadata/materialized-view.js +49 -0
- package/driver/metadata/schema-function.js +98 -0
- package/driver/metadata/schema-index.js +166 -0
- package/driver/metadata/schema-parser.js +1399 -0
- package/driver/metadata/table-metadata.js +77 -0
- package/driver/operation-state.js +206 -0
- package/driver/policies/address-resolution.js +145 -0
- package/driver/policies/index.d.ts +241 -0
- package/driver/policies/index.js +110 -0
- package/driver/policies/load-balancing.js +970 -0
- package/driver/policies/reconnection.js +166 -0
- package/driver/policies/retry.js +326 -0
- package/driver/policies/speculative-execution.js +150 -0
- package/driver/policies/timestamp-generation.js +176 -0
- package/driver/prepare-handler.js +347 -0
- package/driver/promise-utils.js +191 -0
- package/driver/readers.js +624 -0
- package/driver/request-execution.js +644 -0
- package/driver/request-handler.js +332 -0
- package/driver/requests.js +618 -0
- package/driver/stream-id-stack.js +209 -0
- package/driver/streams.js +745 -0
- package/driver/token.js +325 -0
- package/driver/tokenizer.js +631 -0
- package/driver/types/big-decimal.js +282 -0
- package/driver/types/duration.js +576 -0
- package/driver/types/index.d.ts +486 -0
- package/driver/types/index.js +733 -0
- package/driver/types/inet-address.js +262 -0
- package/driver/types/integer.js +818 -0
- package/driver/types/local-date.js +280 -0
- package/driver/types/local-time.js +299 -0
- package/driver/types/mutable-long.js +385 -0
- package/driver/types/protocol-version.js +391 -0
- package/driver/types/result-set.js +287 -0
- package/driver/types/result-stream.js +164 -0
- package/driver/types/row.js +85 -0
- package/driver/types/time-uuid.js +414 -0
- package/driver/types/tuple.js +103 -0
- package/driver/types/uuid.js +160 -0
- package/driver/types/vector.js +130 -0
- package/driver/types/version-number.js +153 -0
- package/driver/utils.js +1485 -0
- package/driver/writers.js +350 -0
- package/global.d.ts +1 -1
- package/global.d.ts.map +1 -1
- package/index.d.ts +6 -6
- package/index.d.ts.map +1 -1
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/migrate/index.d.ts +1 -1
- package/migrate/index.d.ts.map +1 -1
- package/migrate/index.js +1 -1
- package/migrate/index.js.map +1 -1
- package/model/index.d.ts +6 -6
- package/model/index.d.ts.map +1 -1
- package/model/index.js +10 -10
- package/model/index.js.map +1 -1
- package/operations/countAll.d.ts +1 -1
- package/operations/countAll.d.ts.map +1 -1
- package/operations/delete.d.ts +3 -4
- package/operations/delete.d.ts.map +1 -1
- package/operations/delete.js +1 -1
- package/operations/delete.js.map +1 -1
- package/operations/find.d.ts +2 -2
- package/operations/find.d.ts.map +1 -1
- package/operations/find.js +1 -1
- package/operations/find.js.map +1 -1
- package/operations/findOne.d.ts +2 -2
- package/operations/findOne.d.ts.map +1 -1
- package/operations/findOne.js +1 -1
- package/operations/findOne.js.map +1 -1
- package/operations/insert.d.ts +3 -3
- package/operations/insert.d.ts.map +1 -1
- package/operations/insert.js +2 -2
- package/operations/insert.js.map +1 -1
- package/operations/sync.d.ts +1 -1
- package/operations/sync.d.ts.map +1 -1
- package/operations/sync.js +1 -1
- package/operations/sync.js.map +1 -1
- package/operations/tableExists.d.ts +1 -1
- package/operations/tableExists.d.ts.map +1 -1
- package/operations/update.d.ts +3 -3
- package/operations/update.d.ts.map +1 -1
- package/operations/update.js +2 -2
- package/operations/update.js.map +1 -1
- package/package.json +4 -12
- package/schema/index.d.ts +1 -1
- package/schema/index.d.ts.map +1 -1
- package/types.d.ts +4 -4
- package/types.d.ts.map +1 -1
- package/utils/queryParser.d.ts +1 -1
- package/utils/queryParser.d.ts.map +1 -1
- package/utils/queryParser.js +1 -1
- package/utils/queryParser.js.map +1 -1
- package/utils/typeChecker.d.ts +1 -1
- package/utils/typeChecker.d.ts.map +1 -1
- package/utils/typeChecker.js +1 -1
- package/utils/typeChecker.js.map +1 -1
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import utils from "./utils.js"
|
|
20
|
+
import types from "./types/index.js"
|
|
21
|
+
import errors from "./errors.js"
|
|
22
|
+
|
|
23
|
+
const proxyExecuteKey = "ProxyExecute"
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A base class that represents a wrapper around the user provided query options with getter methods and proper
|
|
27
|
+
* default values.
|
|
28
|
+
* <p>
|
|
29
|
+
* Note that getter methods might return <code>undefined</code> when not set on the query options or default
|
|
30
|
+
* {@link Client} options.
|
|
31
|
+
* </p>
|
|
32
|
+
*/
|
|
33
|
+
class ExecutionOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new instance of {@link ExecutionOptions}.
|
|
36
|
+
*/
|
|
37
|
+
constructor() {}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Creates an empty instance, where all methods return undefined, used internally.
|
|
41
|
+
* @ignore
|
|
42
|
+
* @return {ExecutionOptions}
|
|
43
|
+
*/
|
|
44
|
+
static empty() {
|
|
45
|
+
return new ExecutionOptions()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Determines if the stack trace before the query execution should be maintained.
|
|
50
|
+
* @abstract
|
|
51
|
+
* @returns {Boolean}
|
|
52
|
+
*/
|
|
53
|
+
getCaptureStackTrace() {}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Gets the [Consistency level]{@link module:types~consistencies} to be used for the execution.
|
|
57
|
+
* @abstract
|
|
58
|
+
* @returns {Number}
|
|
59
|
+
*/
|
|
60
|
+
getConsistency() {}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Key-value payload to be passed to the server. On the server side, implementations of QueryHandler can use
|
|
64
|
+
* this data.
|
|
65
|
+
* @abstract
|
|
66
|
+
* @returns {Object}
|
|
67
|
+
*/
|
|
68
|
+
getCustomPayload() {}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Gets the amount of rows to retrieve per page.
|
|
72
|
+
* @abstract
|
|
73
|
+
* @returns {Number}
|
|
74
|
+
*/
|
|
75
|
+
getFetchSize() {}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* When a fixed host is set on the query options and the query plan for the load-balancing policy is not used, it
|
|
79
|
+
* gets the host that should handle the query.
|
|
80
|
+
* @returns {Host}
|
|
81
|
+
*/
|
|
82
|
+
getFixedHost() {}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Gets the type hints for parameters given in the query, ordered as for the parameters.
|
|
86
|
+
* @abstract
|
|
87
|
+
* @returns {Array|Array<Array>}
|
|
88
|
+
*/
|
|
89
|
+
getHints() {}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Determines whether the driver must retrieve the following result pages automatically.
|
|
93
|
+
* <p>
|
|
94
|
+
* This setting is only considered by the [Client#eachRow()]{@link Client#eachRow} method.
|
|
95
|
+
* </p>
|
|
96
|
+
* @abstract
|
|
97
|
+
* @returns {Boolean}
|
|
98
|
+
*/
|
|
99
|
+
isAutoPage() {}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Determines whether its a counter batch. Only valid for [Client#batch()]{@link Client#batch}, it will be ignored by
|
|
103
|
+
* other methods.
|
|
104
|
+
* @abstract
|
|
105
|
+
* @returns {Boolean} A <code>Boolean</code> value, it can't be <code>undefined</code>.
|
|
106
|
+
*/
|
|
107
|
+
isBatchCounter() {}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Determines whether the batch should be written to the batchlog. Only valid for
|
|
111
|
+
* [Client#batch()]{@link Client#batch}, it will be ignored by other methods.
|
|
112
|
+
* @abstract
|
|
113
|
+
* @returns {Boolean} A <code>Boolean</code> value, it can't be <code>undefined</code>.
|
|
114
|
+
*/
|
|
115
|
+
isBatchLogged() {}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Determines whether the query can be applied multiple times without changing the result beyond the initial
|
|
119
|
+
* application.
|
|
120
|
+
* @abstract
|
|
121
|
+
* @returns {Boolean}
|
|
122
|
+
*/
|
|
123
|
+
isIdempotent() {}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Determines whether the query must be prepared beforehand.
|
|
127
|
+
* @abstract
|
|
128
|
+
* @returns {Boolean} A <code>Boolean</code> value, it can't be <code>undefined</code>.
|
|
129
|
+
*/
|
|
130
|
+
isPrepared() {}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Determines whether query tracing is enabled for the execution.
|
|
134
|
+
* @abstract
|
|
135
|
+
* @returns {Boolean}
|
|
136
|
+
*/
|
|
137
|
+
isQueryTracing() {}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Gets the keyspace for the query when set at query options level.
|
|
141
|
+
* <p>
|
|
142
|
+
* Note that this method will return <code>undefined</code> when the keyspace is not set at query options level.
|
|
143
|
+
* It will only return the keyspace name when the user provided a different keyspace than the current
|
|
144
|
+
* {@link Client} keyspace.
|
|
145
|
+
* </p>
|
|
146
|
+
* @abstract
|
|
147
|
+
* @returns {String}
|
|
148
|
+
*/
|
|
149
|
+
getKeyspace() {}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Gets the load balancing policy used for this execution.
|
|
153
|
+
* @returns {LoadBalancingPolicy} A <code>LoadBalancingPolicy</code> instance, it can't be <code>undefined</code>.
|
|
154
|
+
*/
|
|
155
|
+
getLoadBalancingPolicy() {}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Gets the Buffer representing the paging state.
|
|
159
|
+
* @abstract
|
|
160
|
+
* @returns {Buffer}
|
|
161
|
+
*/
|
|
162
|
+
getPageState() {}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Internal method that gets the preferred host.
|
|
166
|
+
* @abstract
|
|
167
|
+
* @ignore
|
|
168
|
+
*/
|
|
169
|
+
getPreferredHost() {}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Gets the query options as provided to the execution method without setting the default values.
|
|
173
|
+
* @returns {QueryOptions}
|
|
174
|
+
*/
|
|
175
|
+
getRawQueryOptions() {}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Gets the timeout in milliseconds to be used for the execution per coordinator.
|
|
179
|
+
* <p>
|
|
180
|
+
* A value of <code>0</code> disables client side read timeout for the execution. Default: <code>undefined</code>.
|
|
181
|
+
* </p>
|
|
182
|
+
* @abstract
|
|
183
|
+
* @returns {Number}
|
|
184
|
+
*/
|
|
185
|
+
getReadTimeout() {}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Gets the [retry policy]{@link module:policies/retry} to be used.
|
|
189
|
+
* @abstract
|
|
190
|
+
* @returns {RetryPolicy} A <code>RetryPolicy</code> instance, it can't be <code>undefined</code>.
|
|
191
|
+
*/
|
|
192
|
+
getRetryPolicy() {}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Internal method to obtain the row callback, for "by row" results.
|
|
196
|
+
* @abstract
|
|
197
|
+
* @ignore
|
|
198
|
+
*/
|
|
199
|
+
getRowCallback() {}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Internal method to get or generate a timestamp for the request execution.
|
|
203
|
+
* @ignore
|
|
204
|
+
* @returns {object|null}
|
|
205
|
+
*/
|
|
206
|
+
getOrGenerateTimestamp() {}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Gets the index of the parameters that are part of the partition key to determine the routing.
|
|
210
|
+
* @abstract
|
|
211
|
+
* @ignore
|
|
212
|
+
* @returns {Array}
|
|
213
|
+
*/
|
|
214
|
+
getRoutingIndexes() {}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Gets the partition key(s) to determine which coordinator should be used for the query.
|
|
218
|
+
* @abstract
|
|
219
|
+
* @returns {Buffer|Array<Buffer>}
|
|
220
|
+
*/
|
|
221
|
+
getRoutingKey() {}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Gets the array of the parameters names that are part of the partition key to determine the
|
|
225
|
+
* routing. Only valid for non-prepared requests.
|
|
226
|
+
* @abstract
|
|
227
|
+
* @ignore
|
|
228
|
+
*/
|
|
229
|
+
getRoutingNames() {}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Gets the the consistency level to be used for the serial phase of conditional updates.
|
|
233
|
+
* @abstract
|
|
234
|
+
* @returns {Number}
|
|
235
|
+
*/
|
|
236
|
+
getSerialConsistency() {}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Gets the provided timestamp for the execution in microseconds from the unix epoch (00:00:00, January 1st, 1970).
|
|
240
|
+
* <p>When a timestamp generator is used, this method returns <code>undefined</code>.</p>
|
|
241
|
+
* @abstract
|
|
242
|
+
* @returns {number|object|undefined|null}
|
|
243
|
+
*/
|
|
244
|
+
getTimestamp() {}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @param {Array} hints
|
|
248
|
+
* @abstract
|
|
249
|
+
* @ignore
|
|
250
|
+
*/
|
|
251
|
+
setHints(hints) {}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Sets the keyspace for the execution.
|
|
255
|
+
* @ignore
|
|
256
|
+
* @abstract
|
|
257
|
+
* @param {String} keyspace
|
|
258
|
+
*/
|
|
259
|
+
setKeyspace(keyspace) {}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @abstract
|
|
263
|
+
* @ignore
|
|
264
|
+
*/
|
|
265
|
+
setPageState() {}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Internal method that sets the preferred host.
|
|
269
|
+
* @abstract
|
|
270
|
+
* @ignore
|
|
271
|
+
*/
|
|
272
|
+
setPreferredHost() {}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Sets the index of the parameters that are part of the partition key to determine the routing.
|
|
276
|
+
* @param {Array} routingIndexes
|
|
277
|
+
* @abstract
|
|
278
|
+
* @ignore
|
|
279
|
+
*/
|
|
280
|
+
setRoutingIndexes(routingIndexes) {}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Sets the routing key.
|
|
284
|
+
* @abstract
|
|
285
|
+
* @ignore
|
|
286
|
+
*/
|
|
287
|
+
setRoutingKey(value) {}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Internal implementation of {@link ExecutionOptions} that uses the value from the client options and execution
|
|
292
|
+
* profile into account.
|
|
293
|
+
* @ignore
|
|
294
|
+
*/
|
|
295
|
+
class DefaultExecutionOptions extends ExecutionOptions {
|
|
296
|
+
/**
|
|
297
|
+
* Creates a new instance of {@link ExecutionOptions}.
|
|
298
|
+
* @param {QueryOptions} queryOptions
|
|
299
|
+
* @param {Client} client
|
|
300
|
+
* @param {Function|null} rowCallback
|
|
301
|
+
*/
|
|
302
|
+
constructor(queryOptions, client, rowCallback) {
|
|
303
|
+
super()
|
|
304
|
+
|
|
305
|
+
this._queryOptions = queryOptions
|
|
306
|
+
this._rowCallback = rowCallback
|
|
307
|
+
this._routingKey = this._queryOptions.routingKey
|
|
308
|
+
this._hints = this._queryOptions.hints
|
|
309
|
+
this._keyspace = this._queryOptions.keyspace
|
|
310
|
+
this._routingIndexes = this._queryOptions.routingIndexes
|
|
311
|
+
this._pageState =
|
|
312
|
+
typeof this._queryOptions.pageState === "string"
|
|
313
|
+
? utils.allocBufferFromString(
|
|
314
|
+
this._queryOptions.pageState,
|
|
315
|
+
"hex",
|
|
316
|
+
)
|
|
317
|
+
: this._queryOptions.pageState
|
|
318
|
+
this._preferredHost = null
|
|
319
|
+
|
|
320
|
+
this._client = client
|
|
321
|
+
this._defaultQueryOptions = client.options.queryOptions
|
|
322
|
+
this._profile = client.profileManager.getProfile(
|
|
323
|
+
this._queryOptions.executionProfile,
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
// Build a custom payload object designed for DSE-specific functionality
|
|
327
|
+
this._customPayload = DefaultExecutionOptions.createCustomPayload(
|
|
328
|
+
this._queryOptions,
|
|
329
|
+
this._defaultQueryOptions,
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
if (!this._profile) {
|
|
333
|
+
throw new errors.ArgumentError(
|
|
334
|
+
`Execution profile "${this._queryOptions.executionProfile}" not found`,
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Creates a payload for given user.
|
|
341
|
+
* @param {QueryOptions} userOptions
|
|
342
|
+
* @param {QueryOptions} defaultQueryOptions
|
|
343
|
+
* @private
|
|
344
|
+
*/
|
|
345
|
+
static createCustomPayload(userOptions, defaultQueryOptions) {
|
|
346
|
+
let customPayload =
|
|
347
|
+
userOptions.customPayload || defaultQueryOptions.customPayload
|
|
348
|
+
const executeAs = userOptions.executeAs || defaultQueryOptions.executeAs
|
|
349
|
+
|
|
350
|
+
if (executeAs) {
|
|
351
|
+
if (!customPayload) {
|
|
352
|
+
customPayload = {}
|
|
353
|
+
customPayload[proxyExecuteKey] =
|
|
354
|
+
utils.allocBufferFromString(executeAs)
|
|
355
|
+
} else if (!customPayload[proxyExecuteKey]) {
|
|
356
|
+
// Avoid appending to the existing payload object
|
|
357
|
+
customPayload = utils.extend({}, customPayload)
|
|
358
|
+
customPayload[proxyExecuteKey] =
|
|
359
|
+
utils.allocBufferFromString(executeAs)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return customPayload
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Creates a new instance {@link ExecutionOptions}, based on the query options.
|
|
368
|
+
* @param {QueryOptions|null} queryOptions
|
|
369
|
+
* @param {Client} client
|
|
370
|
+
* @param {Function|null} [rowCallback]
|
|
371
|
+
* @ignore
|
|
372
|
+
* @return {ExecutionOptions}
|
|
373
|
+
*/
|
|
374
|
+
static create(queryOptions, client, rowCallback) {
|
|
375
|
+
if (!queryOptions || typeof queryOptions === "function") {
|
|
376
|
+
// queryOptions can be null/undefined and could be of type function when is an optional parameter
|
|
377
|
+
queryOptions = utils.emptyObject
|
|
378
|
+
}
|
|
379
|
+
return new DefaultExecutionOptions(queryOptions, client, rowCallback)
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
getCaptureStackTrace() {
|
|
383
|
+
return ifUndefined(
|
|
384
|
+
this._queryOptions.captureStackTrace,
|
|
385
|
+
this._defaultQueryOptions.captureStackTrace,
|
|
386
|
+
)
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
getConsistency() {
|
|
390
|
+
return ifUndefined3(
|
|
391
|
+
this._queryOptions.consistency,
|
|
392
|
+
this._profile.consistency,
|
|
393
|
+
this._defaultQueryOptions.consistency,
|
|
394
|
+
)
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
getCustomPayload() {
|
|
398
|
+
return this._customPayload
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
getFetchSize() {
|
|
402
|
+
return ifUndefined(
|
|
403
|
+
this._queryOptions.fetchSize,
|
|
404
|
+
this._defaultQueryOptions.fetchSize,
|
|
405
|
+
)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
getFixedHost() {
|
|
409
|
+
return this._queryOptions.host
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
getHints() {
|
|
413
|
+
return this._hints
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
isAutoPage() {
|
|
417
|
+
return ifUndefined(
|
|
418
|
+
this._queryOptions.autoPage,
|
|
419
|
+
this._defaultQueryOptions.autoPage,
|
|
420
|
+
)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
isBatchCounter() {
|
|
424
|
+
return ifUndefined(this._queryOptions.counter, false)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
isBatchLogged() {
|
|
428
|
+
return ifUndefined3(
|
|
429
|
+
this._queryOptions.logged,
|
|
430
|
+
this._defaultQueryOptions.logged,
|
|
431
|
+
true,
|
|
432
|
+
)
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
isIdempotent() {
|
|
436
|
+
return ifUndefined(
|
|
437
|
+
this._queryOptions.isIdempotent,
|
|
438
|
+
this._defaultQueryOptions.isIdempotent,
|
|
439
|
+
)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Determines if the query execution must be prepared beforehand.
|
|
444
|
+
* @return {Boolean}
|
|
445
|
+
*/
|
|
446
|
+
isPrepared() {
|
|
447
|
+
return ifUndefined(
|
|
448
|
+
this._queryOptions.prepare,
|
|
449
|
+
this._defaultQueryOptions.prepare,
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
isQueryTracing() {
|
|
454
|
+
return ifUndefined(
|
|
455
|
+
this._queryOptions.traceQuery,
|
|
456
|
+
this._defaultQueryOptions.traceQuery,
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
getKeyspace() {
|
|
461
|
+
return this._keyspace
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
getLoadBalancingPolicy() {
|
|
465
|
+
return this._profile.loadBalancing
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
getOrGenerateTimestamp() {
|
|
469
|
+
let result = this.getTimestamp()
|
|
470
|
+
|
|
471
|
+
if (result === undefined) {
|
|
472
|
+
const generator = this._client.options.policies.timestampGeneration
|
|
473
|
+
|
|
474
|
+
if (
|
|
475
|
+
types.protocolVersion.supportsTimestamp(
|
|
476
|
+
this._client.controlConnection.protocolVersion,
|
|
477
|
+
) &&
|
|
478
|
+
generator
|
|
479
|
+
) {
|
|
480
|
+
result = generator.next(this._client)
|
|
481
|
+
} else {
|
|
482
|
+
result = null
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return typeof result === "number"
|
|
487
|
+
? types.Long.fromNumber(result)
|
|
488
|
+
: result
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
getPageState() {
|
|
492
|
+
return this._pageState
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Gets the profile defined by the user or the default profile
|
|
497
|
+
* @internal
|
|
498
|
+
* @ignore
|
|
499
|
+
*/
|
|
500
|
+
getProfile() {
|
|
501
|
+
return this._profile
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
getRawQueryOptions() {
|
|
505
|
+
return this._queryOptions
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
getReadTimeout() {
|
|
509
|
+
return ifUndefined3(
|
|
510
|
+
this._queryOptions.readTimeout,
|
|
511
|
+
this._profile.readTimeout,
|
|
512
|
+
this._client.options.socketOptions.readTimeout,
|
|
513
|
+
)
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
getRetryPolicy() {
|
|
517
|
+
return ifUndefined3(
|
|
518
|
+
this._queryOptions.retry,
|
|
519
|
+
this._profile.retry,
|
|
520
|
+
this._client.options.policies.retry,
|
|
521
|
+
)
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
getRoutingIndexes() {
|
|
525
|
+
return this._routingIndexes
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
getRoutingKey() {
|
|
529
|
+
return this._routingKey
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
getRoutingNames() {
|
|
533
|
+
return this._queryOptions.routingNames
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Internal method to obtain the row callback, for "by row" results.
|
|
538
|
+
* @ignore
|
|
539
|
+
*/
|
|
540
|
+
getRowCallback() {
|
|
541
|
+
return this._rowCallback
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
getSerialConsistency() {
|
|
545
|
+
return ifUndefined3(
|
|
546
|
+
this._queryOptions.serialConsistency,
|
|
547
|
+
this._profile.serialConsistency,
|
|
548
|
+
this._defaultQueryOptions.serialConsistency,
|
|
549
|
+
)
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
getTimestamp() {
|
|
553
|
+
return this._queryOptions.timestamp
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Internal property to set the custom payload.
|
|
558
|
+
* @ignore
|
|
559
|
+
* @internal
|
|
560
|
+
* @param {Object} payload
|
|
561
|
+
*/
|
|
562
|
+
setCustomPayload(payload) {
|
|
563
|
+
this._customPayload = payload
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* @param {Array} hints
|
|
568
|
+
*/
|
|
569
|
+
setHints(hints) {
|
|
570
|
+
this._hints = hints
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @param {String} keyspace
|
|
575
|
+
*/
|
|
576
|
+
setKeyspace(keyspace) {
|
|
577
|
+
this._keyspace = keyspace
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @param {Buffer} pageState
|
|
582
|
+
*/
|
|
583
|
+
setPageState(pageState) {
|
|
584
|
+
this._pageState = pageState
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* @param {Array} routingIndexes
|
|
589
|
+
*/
|
|
590
|
+
setRoutingIndexes(routingIndexes) {
|
|
591
|
+
this._routingIndexes = routingIndexes
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
setRoutingKey(value) {
|
|
595
|
+
this._routingKey = value
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function ifUndefined(v1, v2) {
|
|
600
|
+
return v1 !== undefined ? v1 : v2
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
function ifUndefined3(v1, v2, v3) {
|
|
604
|
+
if (v1 !== undefined) {
|
|
605
|
+
return v1
|
|
606
|
+
}
|
|
607
|
+
return v2 !== undefined ? v2 : v3
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
export { ExecutionOptions, DefaultExecutionOptions, proxyExecuteKey }
|
|
611
|
+
|
|
612
|
+
export default { ExecutionOptions, DefaultExecutionOptions, proxyExecuteKey }
|