Skip to content

Commit b819480

Browse files
Added #![forbid(missing_docs)] and documented all methods and attributes
1 parent 3037ddf commit b819480

23 files changed

+2652
-302
lines changed

src/ast/comments.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,16 @@ pub enum Comment {
174174
/// until end-of-line or end-of-file in the source code.
175175
///
176176
/// Note: `content` will include the terminating new-line character, if any.
177-
SingleLine { content: String, prefix: String },
177+
/// A single-line comment, typically introduced with a prefix and spanning
178+
/// until end-of-line or end-of-file in the source code.
179+
///
180+
/// Note: `content` will include the terminating new-line character, if any.
181+
SingleLine {
182+
/// The content of the comment (including trailing newline, if any).
183+
content: String,
184+
/// The prefix introducing the comment (e.g. `--`, `#`).
185+
prefix: String,
186+
},
178187

179188
/// A multi-line comment, typically enclosed in `/* .. */` markers. The
180189
/// string represents the content excluding the markers.

src/ast/data_type.rs

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ use super::{value::escape_single_quote_string, ColumnDef};
3232
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
3333
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
3434
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
35+
/// A member of an ENUM type.
3536
pub enum EnumMember {
37+
/// Just a name.
3638
Name(String),
3739
/// ClickHouse allows to specify an integer value for each enum value.
3840
///
@@ -957,18 +959,31 @@ impl fmt::Display for TimezoneInfo {
957959
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
958960
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
959961
pub enum IntervalFields {
962+
/// `YEAR` field
960963
Year,
964+
/// `MONTH` field
961965
Month,
966+
/// `DAY` field
962967
Day,
968+
/// `HOUR` field
963969
Hour,
970+
/// `MINUTE` field
964971
Minute,
972+
/// `SECOND` field
965973
Second,
974+
/// `YEAR TO MONTH` field
966975
YearToMonth,
976+
/// `DAY TO HOUR` field
967977
DayToHour,
978+
/// `DAY TO MINUTE` field
968979
DayToMinute,
980+
/// `DAY TO SECOND` field
969981
DayToSecond,
982+
/// `HOUR TO MINUTE` field
970983
HourToMinute,
984+
/// `HOUR TO SECOND` field
971985
HourToSecond,
986+
/// `MINUTE TO SECOND` field
972987
MinuteToSecond,
973988
}
974989

@@ -1000,11 +1015,11 @@ impl fmt::Display for IntervalFields {
10001015
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10011016
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
10021017
pub enum ExactNumberInfo {
1003-
/// No additional information, e.g. `DECIMAL`
1018+
/// No additional information, e.g. `DECIMAL`.
10041019
None,
1005-
/// Only precision information, e.g. `DECIMAL(10)`
1020+
/// Only precision information, e.g. `DECIMAL(10)`.
10061021
Precision(u64),
1007-
/// Precision and scale information, e.g. `DECIMAL(10,2)`
1022+
/// Precision and scale information, e.g. `DECIMAL(10,2)`.
10081023
PrecisionAndScale(u64, i64),
10091024
}
10101025

@@ -1031,13 +1046,14 @@ impl fmt::Display for ExactNumberInfo {
10311046
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10321047
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
10331048
pub enum CharacterLength {
1049+
/// Integer length with optional unit (e.g. `CHAR(10)` or `VARCHAR(10 CHARACTERS)`).
10341050
IntegerLength {
10351051
/// Default (if VARYING) or maximum (if not VARYING) length
10361052
length: u64,
10371053
/// Optional unit. If not informed, the ANSI handles it as CHARACTERS implicitly
10381054
unit: Option<CharLengthUnits>,
10391055
},
1040-
/// VARCHAR(MAX) or NVARCHAR(MAX), used in T-SQL (Microsoft SQL Server)
1056+
/// VARCHAR(MAX) or NVARCHAR(MAX), used in T-SQL (Microsoft SQL Server).
10411057
Max,
10421058
}
10431059

@@ -1087,12 +1103,16 @@ impl fmt::Display for CharLengthUnits {
10871103
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
10881104
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10891105
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
1106+
/// Information about [binary length][1], including length and possibly unit.
1107+
///
1108+
/// [1]: https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#binary-length
10901109
pub enum BinaryLength {
1110+
/// Integer length for binary types (e.g. `VARBINARY(100)`).
10911111
IntegerLength {
10921112
/// Default (if VARYING)
10931113
length: u64,
10941114
},
1095-
/// VARBINARY(MAX) used in T-SQL (Microsoft SQL Server)
1115+
/// VARBINARY(MAX) used in T-SQL (Microsoft SQL Server).
10961116
Max,
10971117
}
10981118

@@ -1118,13 +1138,13 @@ impl fmt::Display for BinaryLength {
11181138
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
11191139
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
11201140
pub enum ArrayElemTypeDef {
1121-
/// `ARRAY`
1141+
/// Use `ARRAY` style without an explicit element type.
11221142
None,
1123-
/// `ARRAY<INT>`
1143+
/// Angle-bracket style, e.g. `ARRAY<INT>`.
11241144
AngleBracket(Box<DataType>),
1125-
/// `INT[]` or `INT[2]`
1145+
/// Square-bracket style, e.g. `INT[]` or `INT[2]`.
11261146
SquareBracket(Box<DataType>, Option<u64>),
1127-
/// `Array(Int64)`
1147+
/// Parenthesis style, e.g. `Array(Int64)`.
11281148
Parenthesis(Box<DataType>),
11291149
}
11301150

@@ -1136,12 +1156,19 @@ pub enum ArrayElemTypeDef {
11361156
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
11371157
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
11381158
pub enum GeometricTypeKind {
1159+
/// Point geometry
11391160
Point,
1161+
/// Line geometry
11401162
Line,
1163+
/// Line segment geometry
11411164
LineSegment,
1165+
/// Box geometry
11421166
GeometricBox,
1167+
/// Path geometry
11431168
GeometricPath,
1169+
/// Polygon geometry
11441170
Polygon,
1171+
/// Circle geometry
11451172
Circle,
11461173
}
11471174

src/ast/dcl.rs

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,25 @@ use crate::tokenizer::Span;
3939
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4040
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
4141
pub enum RoleOption {
42+
/// Enable or disable BYPASSRLS.
4243
BypassRLS(bool),
44+
/// Connection limit expression.
4345
ConnectionLimit(Expr),
46+
/// CREATEDB flag.
4447
CreateDB(bool),
48+
/// CREATEROLE flag.
4549
CreateRole(bool),
50+
/// INHERIT flag.
4651
Inherit(bool),
52+
/// LOGIN flag.
4753
Login(bool),
54+
/// Password value or NULL password.
4855
Password(Password),
56+
/// Replication privilege flag.
4957
Replication(bool),
58+
/// SUPERUSER flag.
5059
SuperUser(bool),
60+
/// `VALID UNTIL` expression.
5161
ValidUntil(Expr),
5262
}
5363

@@ -104,8 +114,11 @@ impl fmt::Display for RoleOption {
104114
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
105115
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
106116
pub enum SetConfigValue {
117+
/// Use the default value.
107118
Default,
119+
/// Use the current value (`FROM CURRENT`).
108120
FromCurrent,
121+
/// Set to the provided expression value.
109122
Value(Expr),
110123
}
111124

@@ -116,7 +129,9 @@ pub enum SetConfigValue {
116129
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
117130
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
118131
pub enum ResetConfig {
132+
/// Reset all configuration parameters.
119133
ALL,
134+
/// Reset the named configuration parameter.
120135
ConfigName(ObjectName),
121136
}
122137

@@ -127,28 +142,48 @@ pub enum ResetConfig {
127142
pub enum AlterRoleOperation {
128143
/// Generic
129144
RenameRole {
145+
/// Role name to rename.
130146
role_name: Ident,
131147
},
132148
/// MS SQL Server
133149
/// <https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-role-transact-sql>
134150
AddMember {
151+
/// Member name to add to the role.
135152
member_name: Ident,
136153
},
154+
/// MS SQL Server
155+
///
156+
/// <https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-role-transact-sql>
137157
DropMember {
158+
/// Member name to remove from the role.
138159
member_name: Ident,
139160
},
140161
/// PostgreSQL
141162
/// <https://www.postgresql.org/docs/current/sql-alterrole.html>
142163
WithOptions {
164+
/// Role options to apply.
143165
options: Vec<RoleOption>,
144166
},
167+
/// PostgreSQL
168+
/// <https://www.postgresql.org/docs/current/sql-alterrole.html>
169+
///
170+
/// `SET configuration_parameter { TO | = } { value | DEFAULT }`
145171
Set {
172+
/// Configuration name to set.
146173
config_name: ObjectName,
174+
/// Value to assign to the configuration.
147175
config_value: SetConfigValue,
176+
/// Optional database scope for the setting.
148177
in_database: Option<ObjectName>,
149178
},
179+
/// PostgreSQL
180+
/// <https://www.postgresql.org/docs/current/sql-alterrole.html>
181+
///
182+
/// `RESET configuration_parameter` | `RESET ALL`
150183
Reset {
184+
/// Configuration to reset.
151185
config_name: ResetConfig,
186+
/// Optional database scope for the reset.
152187
in_database: Option<ObjectName>,
153188
},
154189
}
@@ -205,14 +240,22 @@ impl fmt::Display for AlterRoleOperation {
205240
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
206241
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
207242
pub enum Use {
208-
Catalog(ObjectName), // e.g. `USE CATALOG foo.bar`
209-
Schema(ObjectName), // e.g. `USE SCHEMA foo.bar`
210-
Database(ObjectName), // e.g. `USE DATABASE foo.bar`
211-
Warehouse(ObjectName), // e.g. `USE WAREHOUSE foo.bar`
212-
Role(ObjectName), // e.g. `USE ROLE PUBLIC`
213-
SecondaryRoles(SecondaryRoles), // e.g. `USE SECONDARY ROLES ALL`
214-
Object(ObjectName), // e.g. `USE foo.bar`
215-
Default, // e.g. `USE DEFAULT`
243+
/// Switch to the given catalog (e.g. `USE CATALOG ...`).
244+
Catalog(ObjectName),
245+
/// Switch to the given schema (e.g. `USE SCHEMA ...`).
246+
Schema(ObjectName),
247+
/// Switch to the given database (e.g. `USE DATABASE ...`).
248+
Database(ObjectName),
249+
/// Switch to the given warehouse (e.g. `USE WAREHOUSE ...`).
250+
Warehouse(ObjectName),
251+
/// Switch to the given role (e.g. `USE ROLE ...`).
252+
Role(ObjectName),
253+
/// Use secondary roles specification (e.g. `USE SECONDARY ROLES ...`).
254+
SecondaryRoles(SecondaryRoles),
255+
/// Use the specified object (e.g. `USE foo.bar`).
256+
Object(ObjectName),
257+
/// Reset to default (e.g. `USE DEFAULT`).
258+
Default,
216259
}
217260

218261
impl fmt::Display for Use {
@@ -239,8 +282,11 @@ impl fmt::Display for Use {
239282
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
240283
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
241284
pub enum SecondaryRoles {
285+
/// Use all secondary roles.
242286
All,
287+
/// Use no secondary roles.
243288
None,
289+
/// Explicit list of secondary roles.
244290
List(Vec<Ident>),
245291
}
246292

@@ -260,25 +306,43 @@ impl fmt::Display for SecondaryRoles {
260306
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
261307
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
262308
pub struct CreateRole {
309+
/// Role names to create.
263310
pub names: Vec<ObjectName>,
311+
/// Whether `IF NOT EXISTS` was specified.
264312
pub if_not_exists: bool,
265313
// Postgres
314+
/// Whether `LOGIN` was specified.
266315
pub login: Option<bool>,
316+
/// Whether `INHERIT` was specified.
267317
pub inherit: Option<bool>,
318+
/// Whether `BYPASSRLS` was specified.
268319
pub bypassrls: Option<bool>,
320+
/// Optional password for the role.
269321
pub password: Option<Password>,
322+
/// Whether `SUPERUSER` was specified.
270323
pub superuser: Option<bool>,
324+
/// Whether `CREATEDB` was specified.
271325
pub create_db: Option<bool>,
326+
/// Whether `CREATEROLE` was specified.
272327
pub create_role: Option<bool>,
328+
/// Whether `REPLICATION` privilege was specified.
273329
pub replication: Option<bool>,
330+
/// Optional connection limit expression.
274331
pub connection_limit: Option<Expr>,
332+
/// Optional account validity expression.
275333
pub valid_until: Option<Expr>,
334+
/// Members of `IN ROLE` clause.
276335
pub in_role: Vec<Ident>,
336+
/// Members of `IN GROUP` clause.
277337
pub in_group: Vec<Ident>,
338+
/// Roles listed in `ROLE` clause.
278339
pub role: Vec<Ident>,
340+
/// Users listed in `USER` clause.
279341
pub user: Vec<Ident>,
342+
/// Admin users listed in `ADMIN` clause.
280343
pub admin: Vec<Ident>,
281344
// MSSQL
345+
/// Optional authorization owner.
282346
pub authorization_owner: Option<ObjectName>,
283347
}
284348

0 commit comments

Comments
 (0)