diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index f631d29e..7c745fe7 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -35,6 +35,9 @@ jobs: uses: Swatinem/rust-cache@v2 with: key: rust-${{ matrix.platform.runner }}-${{ matrix.python-version }} + - name: Rust tests (no default features) + run: cargo test --no-default-features --verbose + - name: Rust tests run: cargo test --verbose @@ -81,4 +84,4 @@ jobs: if [ $status -ne 0 ]; then echo "::error::Third-party notices validation failed. Please update /about.toml and rerun." exit $status - fi \ No newline at end of file + fi diff --git a/Cargo.toml b/Cargo.toml index c25a3bd1..c9f9c711 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,10 @@ lto = true name = "cocoindex_engine" crate-type = ["cdylib"] +[features] +default = ["legacy-states-v0"] +legacy-states-v0 = [] + [dependencies] pyo3 = { version = "0.25.1", features = [ "abi3-py311", diff --git a/src/builder/exec_ctx.rs b/src/builder/exec_ctx.rs index 0410d43b..646149f6 100644 --- a/src/builder/exec_ctx.rs +++ b/src/builder/exec_ctx.rs @@ -55,9 +55,14 @@ fn build_import_op_exec_ctx( let existing_keys_schema: &[schema::ValueType] = if let Some(keys_schema) = &state.keys_schema { keys_schema - } else if let Some(key_schema) = &state.key_schema { - std::slice::from_ref(key_schema) } else { + #[cfg(feature = "legacy-states-v0")] + if let Some(key_schema) = &state.key_schema { + std::slice::from_ref(key_schema) + } else { + &[] + } + #[cfg(not(feature = "legacy-states-v0"))] &[] }; if existing_keys_schema == keys_schema_no_attrs.as_ref() { @@ -83,6 +88,7 @@ fn build_import_op_exec_ctx( // Keep this field for backward compatibility, // so users can still swap back to older version if needed. + #[cfg(feature = "legacy-states-v0")] key_schema: Some(if keys_schema_no_attrs.len() == 1 { keys_schema_no_attrs[0].clone() } else { diff --git a/src/setup/states.rs b/src/setup/states.rs index 33ecafcc..683e39dd 100644 --- a/src/setup/states.rs +++ b/src/setup/states.rs @@ -176,6 +176,7 @@ pub struct SourceSetupState { pub keys_schema: Option>, /// DEPRECATED. For backward compatibility. + #[cfg(feature = "legacy-states-v0")] #[serde(default, skip_serializing_if = "Option::is_none")] pub key_schema: Option,