Skip to content

Commit

Permalink
fix: avoid possible duplicate table and column name
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePieWw committed Apr 23, 2024
1 parent abfa6e5 commit ead6ff2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests-fuzz/src/generator/create_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ impl<R: Rng + 'static> Generator<CreateTableExpr, R> for CreateLogicalTableExprG
.unwrap();

let mut table = table_generator.generate(rng)?;
while table.table_name.value == physical_table_name {
table.table_name = table_generator.name_generator.gen(rng);
}
let logical_ts = table.columns.iter().position(|column| {
column
.options
Expand All @@ -290,8 +293,8 @@ impl<R: Rng + 'static> Generator<CreateTableExpr, R> for CreateLogicalTableExprG
.options
.retain(|option| option == &ColumnOption::PrimaryKey);
// Ensures the column name is unique.
while column.name == self.table_ctx.columns[0].name
|| column.name == self.table_ctx.columns[1].name
while column.name.value == self.table_ctx.columns[0].name.value
|| column.name.value == self.table_ctx.columns[1].name.value
{
column.name = table_generator.name_generator.gen(rng);
}
Expand Down

0 comments on commit ead6ff2

Please sign in to comment.