Skip to content

Commit d4868ba

Browse files
Finished implementation of CreateDomain
1 parent dfc180b commit d4868ba

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/ast/ddl.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,28 +2170,33 @@ impl fmt::Display for ClusteredBy {
21702170
/// See [PostgreSQL](https://www.postgresql.org/docs/current/sql-createdomain.html)
21712171
pub struct CreateDomain {
21722172
/// The name of the domain to be created.
2173-
name: ObjectName,
2173+
pub name: ObjectName,
21742174
/// The data type of the domain.
2175-
data_type: DataType,
2175+
pub data_type: DataType,
21762176
/// The collation of the domain.
2177-
collation: Option<Ident>,
2177+
pub collation: Option<Ident>,
21782178
/// The default value of the domain.
2179-
default: Option<Expr>,
2179+
pub default: Option<Expr>,
21802180
/// The constraints of the domain.
2181-
constraints: Vec<TableConstraint>,
2181+
pub constraints: Vec<TableConstraint>,
21822182
}
21832183

21842184
impl fmt::Display for CreateDomain {
21852185
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2186-
write!(f, "CREATE DOMAIN {name} AS {data_type}")?;
2187-
if let Some(collation) = collation {
2186+
write!(
2187+
f,
2188+
"CREATE DOMAIN {name} AS {data_type}",
2189+
name = self.name,
2190+
data_type = self.data_type
2191+
)?;
2192+
if let Some(collation) = &self.collation {
21882193
write!(f, " COLLATE {collation}")?;
21892194
}
2190-
if let Some(default) = default {
2195+
if let Some(default) = &self.default {
21912196
write!(f, " DEFAULT {default}")?;
21922197
}
2193-
if !constraints.is_empty() {
2194-
write!(f, " {}", display_separated(constraints, " "))?;
2198+
if !self.constraints.is_empty() {
2199+
write!(f, " {}", display_separated(&self.constraints, " "))?;
21952200
}
21962201
Ok(())
21972202
}

src/ast/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ pub use self::ddl::{
5555
AlterTableAlgorithm, AlterTableLock, AlterTableOperation, AlterType, AlterTypeAddValue,
5656
AlterTypeAddValuePosition, AlterTypeOperation, AlterTypeRename, AlterTypeRenameValue,
5757
ClusteredBy, ColumnDef, ColumnOption, ColumnOptionDef, ColumnPolicy, ColumnPolicyProperty,
58-
ConstraintCharacteristics, CreateConnector, CreateFunction, Deduplicate, DeferrableInitial,
59-
DropBehavior, GeneratedAs, GeneratedExpressionMode, IdentityParameters, IdentityProperty,
60-
IdentityPropertyFormatKind, IdentityPropertyKind, IdentityPropertyOrder, IndexOption,
61-
IndexType, KeyOrIndexDisplay, NullsDistinctOption, Owner, Partition, ProcedureParam,
62-
ReferentialAction, TableConstraint, TagsColumnOption, UserDefinedTypeCompositeAttributeDef,
63-
UserDefinedTypeRepresentation, ViewColumnDef,
58+
ConstraintCharacteristics, CreateConnector, CreateDomain, CreateFunction, Deduplicate,
59+
DeferrableInitial, DropBehavior, GeneratedAs, GeneratedExpressionMode, IdentityParameters,
60+
IdentityProperty, IdentityPropertyFormatKind, IdentityPropertyKind, IdentityPropertyOrder,
61+
IndexOption, IndexType, KeyOrIndexDisplay, NullsDistinctOption, Owner, Partition,
62+
ProcedureParam, ReferentialAction, TableConstraint, TagsColumnOption,
63+
UserDefinedTypeCompositeAttributeDef, UserDefinedTypeRepresentation, ViewColumnDef,
6464
};
6565
pub use self::dml::{CreateIndex, CreateTable, Delete, IndexColumn, Insert};
6666
pub use self::operator::{BinaryOperator, UnaryOperator};

0 commit comments

Comments
 (0)