Skip to content

Commit

Permalink
Merge pull request SeaQL#286 from ikrivosheev/fix/issues-285_timestam…
Browse files Browse the repository at this point in the history
…p_with_time_zone_len

issues-285 Fix timestamp_with_time_zone_len
  • Loading branch information
tyt2y3 authored Apr 2, 2022
2 parents 9d59487 + 9a1018a commit 794afe9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/backend/postgres/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl TableBuilder for PostgresQueryBuilder {
None => "timestamp".into(),
},
ColumnType::TimestampWithTimeZone(precision) => match precision {
Some(precision) => format!("timestamp with time zone({})", precision),
Some(precision) => format!("timestamp({}) with time zone", precision),
None => "timestamp with time zone".into(),
},
ColumnType::Time(precision) => match precision {
Expand Down
2 changes: 2 additions & 0 deletions src/tests_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum Character {
SizeW,
SizeH,
FontId,
CreatedAt,
}

/// A shorthand for [`Character`]
Expand All @@ -39,6 +40,7 @@ impl Iden for Character {
Self::SizeW => "size_w",
Self::SizeH => "size_h",
Self::FontId => "font_id",
Self::CreatedAt => "created_at",
}
)
.unwrap();
Expand Down
20 changes: 20 additions & 0 deletions tests/postgres/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,26 @@ fn create_10() {
);
}

#[test]
fn create_11() {
assert_eq!(
Table::create()
.table(Char::Table)
.col(
ColumnDef::new(Char::CreatedAt)
.timestamp_with_time_zone_len(0)
.not_null()
)
.to_string(PostgresQueryBuilder),
vec![
r#"CREATE TABLE "character" ("#,
r#""created_at" timestamp(0) with time zone NOT NULL"#,
r#")"#,
]
.join(" ")
);
}

#[test]
fn drop_1() {
assert_eq!(
Expand Down

0 comments on commit 794afe9

Please sign in to comment.