You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is meant to be much easier to discover than the current approach of directly invoking `Executor` methods.
In addition, I'm improving documentation for the `query*()` functions across the board.
/// SQL query that will map its results to owned Rust types.
24
+
/// A single SQL query that will map its results to an owned Rust type.
25
+
///
26
+
/// Executes as a prepared statement.
25
27
///
26
28
/// Returned by [`Query::try_map`], `query!()`, etc. Has most of the same methods as [`Query`] but
27
29
/// the return types are changed to reflect the mapping. However, there is no equivalent of
@@ -96,6 +98,8 @@ where
96
98
/// matching the one with the flag will use the cached statement until the
97
99
/// cache is cleared.
98
100
///
101
+
/// If `false`, the prepared statement will be closed after execution.
102
+
///
99
103
/// Default: `true`.
100
104
pubfnpersistent(mutself,value:bool) -> Self{
101
105
self.persistent = value;
@@ -155,6 +159,7 @@ where
155
159
156
160
/// Execute multiple queries and return the rows affected from each query, in a stream.
157
161
#[inline]
162
+
#[deprecated = "Only the SQLite driver supports multiple statements in one prepared statement and that behavior is deprecated. Use `sqlx::raw_sql()` instead."]
158
163
pubasyncfnexecute_many<'e,'c:'e,E>(
159
164
self,
160
165
executor:E,
@@ -178,9 +183,13 @@ where
178
183
executor.fetch(self)
179
184
}
180
185
181
-
/// Execute multiple queries and return the generated results as a stream
182
-
/// from each query, in a stream.
186
+
/// Execute multiple queries and return the generated results as a stream.
187
+
///
188
+
/// For each query in the stream, any generated rows are returned first,
189
+
/// then the `QueryResult` with the number of rows affected.
183
190
#[inline]
191
+
#[deprecated = "Only the SQLite driver supports multiple statements in one prepared statement and that behavior is deprecated. Use `sqlx::raw_sql()` instead."]
192
+
// TODO: we'll probably still want a way to get the `DB::QueryResult` at the end of a `fetch()` stream.
184
193
pubfnfetch_many<'e,'c:'e,E>(
185
194
self,
186
195
executor:E,
@@ -193,7 +202,13 @@ where
193
202
executor.fetch_many(self)
194
203
}
195
204
196
-
/// Execute the query and return all the generated results, collected into a [`Vec`].
205
+
/// Execute the query and return all the resulting rows collected into a [`Vec`].
206
+
///
207
+
/// ### Note: beware result set size.
208
+
/// This will attempt to collect the full result set of the query into memory.
209
+
///
210
+
/// To avoid exhausting available memory, ensure the result set has a known upper bound,
// FIXME: this should have used `executor.fetch()` but that's a breaking change
348
+
// because this technically allows multiple statements in one query string.
349
+
#[allow(deprecated)]
310
350
self.fetch_many(executor)
311
351
.try_filter_map(|step| asyncmove{
312
352
Ok(match step {
@@ -319,6 +359,7 @@ where
319
359
320
360
/// Execute multiple queries and return the generated results as a stream
321
361
/// from each query, in a stream.
362
+
#[deprecated = "Only the SQLite driver supports multiple statements in one prepared statement and that behavior is deprecated. Use `sqlx::raw_sql()` instead."]
322
363
pubfnfetch_many<'e,'c:'e,E>(
323
364
mutself,
324
365
executor:E,
@@ -346,7 +387,13 @@ where
346
387
})
347
388
}
348
389
349
-
/// Execute the query and return all the generated results, collected into a [`Vec`].
390
+
/// Execute the query and return all the resulting rows collected into a [`Vec`].
391
+
///
392
+
/// ### Note: beware result set size.
393
+
/// This will attempt to collect the full result set of the query into memory.
394
+
///
395
+
/// To avoid exhausting available memory, ensure the result set has a known upper bound,
0 commit comments