Skip to content

Commit b09f0ed

Browse files
Huliiiiiityt2y3
authored andcommitted
Fix serializing iden as a value in ALTER TYPE ... RENAME TO ... statements (#924)
<!-- Thank you for contributing to this project! If you need any help please feel free to contact us on Discord: https://discord.com/invite/uCPdDXzbdv Or, mention our core members by typing `@GitHub_Handle` on any issue / PR Add some test cases! It help reviewers to understand the behaviour and prevent it to be broken in the future. --> ## PR Info <!-- mention the related issue --> - Closes #898 <!-- is this PR depends on other PR? (if applicable) --> - Dependencies: - <!-- PR link --> <!-- any PR depends on this PR? (if applicable) --> - Dependents: - <!-- PR link --> ## New Features - [ ] <!-- what are the new features? --> ## Bug Fixes - [x] Fix serializing iden as a value in `ALTER TYPE ... RENAME TO ...` statements ## Breaking Changes - [ ] <!-- any change in behaviour or method signature? is it backward compatible? --> ## Changes - [ ] <!-- any other non-breaking changes to the codebase -->
1 parent 25e4e87 commit b09f0ed

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/backend/postgres/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl PostgresQueryBuilder {
113113
}
114114
TypeAlterOpt::Rename(new_name) => {
115115
write!(sql, " RENAME TO ").unwrap();
116-
self.prepare_value(&new_name.to_string().into(), sql);
116+
self.prepare_iden(new_name, sql);
117117
}
118118
TypeAlterOpt::RenameValue(existing, new_name) => {
119119
write!(sql, " RENAME VALUE ").unwrap();

tests/postgres/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn alter_4() {
141141
.name(Font::Table)
142142
.rename_to("typeface")
143143
.to_string(PostgresQueryBuilder),
144-
r#"ALTER TYPE "font" RENAME TO 'typeface'"#
144+
r#"ALTER TYPE "font" RENAME TO "typeface""#
145145
)
146146
}
147147

@@ -163,6 +163,6 @@ fn alter_6() {
163163
.name(("schema", Font::Table))
164164
.rename_to("typeface")
165165
.to_string(PostgresQueryBuilder),
166-
r#"ALTER TYPE "schema"."font" RENAME TO 'typeface'"#
166+
r#"ALTER TYPE "schema"."font" RENAME TO "typeface""#
167167
)
168168
}

0 commit comments

Comments
 (0)