Skip to content

Commit 68f369b

Browse files
samsamaityt2y3
authored andcommitted
Support Uuid column type
1 parent 1fe10f2 commit 68f369b

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

src/backend/mysql/table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ impl TableBuilder for MysqlQueryBuilder {
8282
ColumnType::Json => "json".into(),
8383
ColumnType::JsonBinary => "json".into(),
8484
ColumnType::Custom(iden) => iden.to_string(),
85+
ColumnType::Uuid => format!("binary(16)"),
8586
}
8687
)
8788
.unwrap()

src/backend/postgres/table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ impl TableBuilder for PostgresQueryBuilder {
8282
ColumnType::Json => "json".into(),
8383
ColumnType::JsonBinary => "jsonb".into(),
8484
ColumnType::Custom(iden) => iden.to_string(),
85+
ColumnType::Uuid => "uuid".into(),
8586
}
8687
)
8788
.unwrap()

src/backend/sqlite/table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl TableBuilder for SqliteQueryBuilder {
102102
ColumnType::Json => "text".into(),
103103
ColumnType::JsonBinary => "text".into(),
104104
ColumnType::Custom(iden) => iden.to_string(),
105+
ColumnType::Uuid => "text(36)".into(),
105106
}
106107
)
107108
.unwrap()

src/table/column.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub enum ColumnType {
3232
Json,
3333
JsonBinary,
3434
Custom(DynIden),
35+
Uuid,
3536
}
3637

3738
/// All column specification keywords
@@ -321,4 +322,10 @@ impl ColumnDef {
321322
pub fn get_column_spec(&self) -> &Vec<ColumnSpec> {
322323
self.spec.as_ref()
323324
}
325+
326+
/// Set column type as uuid
327+
pub fn uuid(mut self) -> Self {
328+
self.types = Some(ColumnType::Uuid);
329+
self
330+
}
324331
}

0 commit comments

Comments
 (0)