Skip to content

Commit 2d7cb75

Browse files
authored
Merge pull request #95 from TheBlueMatt/2026-02-empty-store-id
Allow empty `store_id`s
2 parents e4c8359 + 6caba34 commit 2d7cb75

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

rust/api/src/kv_store_tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,12 @@ pub struct TestContext<'a> {
552552
impl<'a> TestContext<'a> {
553553
/// Creates a new [`TestContext`] with the given [`KvStore`] implementation.
554554
pub fn new(kv_store: &'a dyn KvStore) -> Self {
555-
let store_id: String = (0..7).map(|_| thread_rng().sample(Alphanumeric) as char).collect();
556-
TestContext { kv_store, user_token: "userToken".to_string(), store_id }
555+
let store_id_len = thread_rng().gen_range(0..6);
556+
let store_id: String =
557+
(0..store_id_len).map(|_| thread_rng().sample(Alphanumeric) as char).collect();
558+
let user_token: String =
559+
(0..7).map(|_| thread_rng().sample(Alphanumeric) as char).collect();
560+
TestContext { kv_store, user_token, store_id }
557561
}
558562

559563
async fn get_object(&self, key: &str) -> Result<KeyValue, VssError> {

rust/impls/src/migrations.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ pub(crate) const MIGRATIONS: &[&str] = &[
2626
// We do not complain if the table already exists, as users of VSS could have already created this table
2727
"CREATE TABLE IF NOT EXISTS vss_db (
2828
user_token character varying(120) NOT NULL CHECK (user_token <> ''),
29-
store_id character varying(120) NOT NULL CHECK (store_id <> ''),
29+
store_id character varying(120) NOT NULL,
3030
key character varying(600) NOT NULL,
3131
value bytea NULL,
3232
version bigint NOT NULL,
3333
created_at TIMESTAMP WITH TIME ZONE,
3434
last_updated_at TIMESTAMP WITH TIME ZONE,
3535
PRIMARY KEY (user_token, store_id, key)
3636
);",
37+
"ALTER TABLE vss_db DROP CONSTRAINT IF EXISTS vss_db_store_id_check;",
3738
];
3839
#[cfg(test)]
3940
pub(crate) const DUMMY_MIGRATION: &str = "SELECT 1 WHERE FALSE;";

rust/impls/src/postgres/sql/v0_create_vss_db.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE TABLE vss_db (
22
user_token character varying(120) NOT NULL CHECK (user_token <> ''),
3-
store_id character varying(120) NOT NULL CHECK (store_id <> ''),
3+
store_id character varying(120) NOT NULL,
44
key character varying(600) NOT NULL,
55
value bytea NULL,
66
version bigint NOT NULL,

0 commit comments

Comments
 (0)