mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 08:55:40 +01:00
make table name not repeat in simulator
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
use indexmap::IndexSet;
|
||||
use rand::Rng;
|
||||
use turso_core::Value;
|
||||
@@ -9,10 +11,13 @@ use crate::model::table::{Column, ColumnType, Name, SimValue, Table};
|
||||
|
||||
use super::ArbitraryFromMaybe;
|
||||
|
||||
static COUNTER: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
impl Arbitrary for Name {
|
||||
fn arbitrary<R: Rng + ?Sized, C: GenerationContext>(rng: &mut R, _c: &C) -> Self {
|
||||
let name = readable_name_custom("_", rng);
|
||||
Name(name.replace("-", "_"))
|
||||
let base = readable_name_custom("_", rng).replace("-", "_");
|
||||
let id = COUNTER.fetch_add(1, Ordering::Relaxed);
|
||||
Name(format!("{}_{}", base, id))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user