1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
use serde::{Deserialize, Serialize};
/// Static description of features a driver supports.
///
/// The UI inspects [`Capabilities`] to enable or disable commands without
/// hard-coding driver names. New flags are added by extending this struct;
/// existing drivers default to `false` for unknown features.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Capabilities {
/// Driver supports explicit transactions (`BEGIN`/`COMMIT`/`ROLLBACK`).
pub transactions: bool,
/// Driver can request asynchronous cancellation of an in-flight query.
pub cancellation: bool,
/// Driver exposes more than one logical schema/namespace.
pub multiple_schemas: bool,
/// Driver supports server-side prepared statements with parameter binding.
pub prepared_statements: bool,
/// Driver supports nested transactions via savepoints.
pub savepoints: bool,
/// Driver can report row counts for `UPDATE`/`DELETE` statements.
pub rows_affected: bool,
/// Driver returns rows progressively from [`crate::Connection::stream`] —
/// i.e. the stream yields rows as the server produces them, without
/// materialising the entire result set in memory first.
///
/// Drivers that currently buffer the full result before exposing the
/// stream (notably `MySQL`, which is awaiting a real `stream_and_drop`
/// implementation) must leave this `false` so the UI can warn the
/// user and refuse to launch open-ended streams over large tables.
pub streaming: bool,
/// Driver supports row-level DML through the standard
/// `INSERT`/`UPDATE`/`DELETE` grammar that
/// [`crate::Connection::execute`] accepts.
///
/// Most engines do; the notable exception is `ClickHouse`, where
/// row-level changes have to go through `ALTER TABLE ... UPDATE`
/// or `ALTER TABLE ... DELETE` async mutations. The pending-changes
/// pipeline gates `o`/`O`/`d`/cell-edit on this flag so it never
/// emits a statement the driver cannot consume. Defaults to
/// `false`; drivers opt in explicitly via
/// [`Self::with_row_level_dml`].
pub row_level_dml: bool,
}
impl Capabilities {
/// Builder-style mutation used by drivers to assemble their capability set.
#[must_use]
pub const fn with_transactions(mut self, value: bool) -> Self {
self.transactions = value;
self
}
#[must_use]
pub const fn with_cancellation(mut self, value: bool) -> Self {
self.cancellation = value;
self
}
#[must_use]
pub const fn with_multiple_schemas(mut self, value: bool) -> Self {
self.multiple_schemas = value;
self
}
#[must_use]
pub const fn with_prepared_statements(mut self, value: bool) -> Self {
self.prepared_statements = value;
self
}
#[must_use]
pub const fn with_savepoints(mut self, value: bool) -> Self {
self.savepoints = value;
self
}
#[must_use]
pub const fn with_rows_affected(mut self, value: bool) -> Self {
self.rows_affected = value;
self
}
#[must_use]
pub const fn with_streaming(mut self, value: bool) -> Self {
self.streaming = value;
self
}
#[must_use]
pub const fn with_row_level_dml(mut self, value: bool) -> Self {
self.row_level_dml = value;
self
}
}