Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions crates/flow/tests/d1_target_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,33 +844,39 @@ async fn test_diff_setup_states_create_new_table() {
}

#[tokio::test]
#[ignore = "Requires understanding StateChange construction from recoco - API changed"]
async fn test_diff_setup_states_existing_table() {
// TODO: Update this test once we understand how to construct StateChange for existing state
// The new recoco API uses Vec<StateChange<T>> instead of Option<T> for staging field
// We need to figure out how to properly construct a StateChange with existing state
let factory = D1TargetFactory;
let key_fields = [test_field_schema("id", BasicValueType::Int64, false)];
let value_fields = [test_field_schema("name", BasicValueType::Str, false)];

let _factory = D1TargetFactory;
let _key_fields = [test_field_schema("id", BasicValueType::Int64, false)];
let _value_fields = [test_field_schema("name", BasicValueType::Str, false)];
let desired_state = D1SetupState::new(&test_table_id(), &key_fields, &value_fields)
.expect("Failed to create desired state");

// This needs proper StateChange construction:
// let _desired_state = D1SetupState::new(&test_table_id(), &_key_fields, &_value_fields)
// .expect("Failed to create desired state");
let existing_state = desired_state.clone();

// let _existing_states: CombinedState<D1SetupState> = CombinedState {
// staging: vec![/* StateChange with existing_state */],
// current: None, // or Some(state)?
// legacy_state_key: None,
// };
let existing_states: CombinedState<D1SetupState> = CombinedState {
staging: vec![recoco::setup::StateChange::Upsert(existing_state)],
current: None,
legacy_state_key: None,
};

let _flow_context = Arc::new(recoco::ops::interface::FlowInstanceContext {
let flow_context = Arc::new(recoco::ops::interface::FlowInstanceContext {
flow_instance_name: "test_flow".to_string(),
auth_registry: Arc::new(recoco::setup::AuthRegistry::new()),
});

// Test would verify that no CREATE TABLE is generated when table exists
// assert!(change.create_table_sql.is_none());
let change = factory
.diff_setup_states(
test_table_id(),
Some(desired_state),
existing_states,
flow_context,
)
.await
.expect("Failed to diff setup states");

// Test verifies that no CREATE TABLE is generated when table exists
assert!(change.create_table_sql.is_none());
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions crates/language/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,17 +1721,17 @@ pub fn from_extension(path: &Path) -> Option<SupportLang> {
}

// Handle extensionless files or files with unknown extensions
if let Some(_file_name) = path.file_name().and_then(|n| n.to_str()) {
if let Some(file_name) = path.file_name().and_then(|n| n.to_str()) {
// 1. Check if the full filename matches a known extension (e.g. .bashrc)
#[cfg(any(feature = "bash", feature = "all-parsers"))]
if constants::BASH_EXTS.contains(&_file_name) {
if constants::BASH_EXTS.contains(&file_name) {
return Some(SupportLang::Bash);
}

// 2. Check known extensionless file names
#[cfg(any(feature = "bash", feature = "all-parsers", feature = "ruby"))]
for (name, lang) in constants::LANG_RELATIONSHIPS_WITH_NO_EXTENSION {
if *name == _file_name {
if *name == file_name {
return Some(*lang);
}
}
Expand Down
Loading