diff --git a/replibyte/src/source/mysql.rs b/replibyte/src/source/mysql.rs index 1bd6ffcb..87c352b5 100644 --- a/replibyte/src/source/mysql.rs +++ b/replibyte/src/source/mysql.rs @@ -199,42 +199,44 @@ fn transform_columns( let mut columns = vec![]; for (i, column_name) in column_names.iter().enumerate() { - let value_token = column_values.get(i).unwrap(); - - let column = match value_token { - Token::Number(column_value, _) => { - if column_value.contains(".") { - Column::FloatNumberValue( - column_name.to_string(), - column_value.parse::().unwrap(), - ) - } else { - Column::NumberValue( - column_name.to_string(), - column_value.parse::().unwrap(), - ) + let column = if let Some(value_token) = column_values.get(i) { + match value_token { + Token::Number(column_value, _) => { + if column_value.contains(".") { + Column::FloatNumberValue( + column_name.to_string(), + column_value.parse::().unwrap(), + ) + } else { + Column::NumberValue( + column_name.to_string(), + column_value.parse::().unwrap(), + ) + } } + Token::Char(column_value) => { + Column::CharValue(column_name.to_string(), column_value.clone()) + } + Token::SingleQuotedString(column_value) => { + Column::StringValue(column_name.to_string(), column_value.clone()) + } + Token::NationalStringLiteral(column_value) => { + Column::StringValue(column_name.to_string(), column_value.clone()) + } + Token::HexStringLiteral(column_value) => { + Column::StringValue(column_name.to_string(), column_value.clone()) + } + Token::Word(w) + if (w.value == "true" || w.value == "false") + && w.quote_style == None + && w.keyword == NoKeyword => + { + Column::BooleanValue(column_name.to_string(), w.value.parse::().unwrap()) + } + _ => Column::None(column_name.to_string()), } - Token::Char(column_value) => { - Column::CharValue(column_name.to_string(), column_value.clone()) - } - Token::SingleQuotedString(column_value) => { - Column::StringValue(column_name.to_string(), column_value.clone()) - } - Token::NationalStringLiteral(column_value) => { - Column::StringValue(column_name.to_string(), column_value.clone()) - } - Token::HexStringLiteral(column_value) => { - Column::StringValue(column_name.to_string(), column_value.clone()) - } - Token::Word(w) - if (w.value == "true" || w.value == "false") - && w.quote_style == None - && w.keyword == NoKeyword => - { - Column::BooleanValue(column_name.to_string(), w.value.parse::().unwrap()) - } - _ => Column::None(column_name.to_string()), + } else { + Column::None(column_name.to_string()) }; // get the right transformer for the right column name diff --git a/replibyte/src/source/postgres.rs b/replibyte/src/source/postgres.rs index 3f948e0f..23b1c278 100644 --- a/replibyte/src/source/postgres.rs +++ b/replibyte/src/source/postgres.rs @@ -286,42 +286,44 @@ fn transform_columns( let mut columns = vec![]; for (i, column_name) in column_names.iter().enumerate() { - let value_token = column_values.get(i).unwrap(); - - let column = match value_token { - Token::Number(column_value, _) => { - if column_value.contains(".") { - Column::FloatNumberValue( - column_name.to_string(), - column_value.parse::().unwrap(), - ) - } else { - Column::NumberValue( - column_name.to_string(), - column_value.parse::().unwrap(), - ) + let column = if let Some(value_token) = column_values.get(i) { + match value_token { + Token::Number(column_value, _) => { + if column_value.contains(".") { + Column::FloatNumberValue( + column_name.to_string(), + column_value.parse::().unwrap(), + ) + } else { + Column::NumberValue( + column_name.to_string(), + column_value.parse::().unwrap(), + ) + } } + Token::Char(column_value) => { + Column::CharValue(column_name.to_string(), column_value.clone()) + } + Token::SingleQuotedString(column_value) => { + Column::StringValue(column_name.to_string(), column_value.clone()) + } + Token::NationalStringLiteral(column_value) => { + Column::StringValue(column_name.to_string(), column_value.clone()) + } + Token::HexStringLiteral(column_value) => { + Column::StringValue(column_name.to_string(), column_value.clone()) + } + Token::Word(w) + if (w.value == "true" || w.value == "false") + && w.quote_style == None + && w.keyword == NoKeyword => + { + Column::BooleanValue(column_name.to_string(), w.value.parse::().unwrap()) + } + _ => Column::None(column_name.to_string()), } - Token::Char(column_value) => { - Column::CharValue(column_name.to_string(), column_value.clone()) - } - Token::SingleQuotedString(column_value) => { - Column::StringValue(column_name.to_string(), column_value.clone()) - } - Token::NationalStringLiteral(column_value) => { - Column::StringValue(column_name.to_string(), column_value.clone()) - } - Token::HexStringLiteral(column_value) => { - Column::StringValue(column_name.to_string(), column_value.clone()) - } - Token::Word(w) - if (w.value == "true" || w.value == "false") - && w.quote_style == None - && w.keyword == NoKeyword => - { - Column::BooleanValue(column_name.to_string(), w.value.parse::().unwrap()) - } - _ => Column::None(column_name.to_string()), + } else { + Column::None(column_name.to_string()) }; // get the right transformer for the right column name