Improve MySQL option parsing in index definitions (#1997)

This commit is contained in:
Michael Victor Zink 2025-08-08 02:32:20 -07:00 committed by GitHub
parent 18b4a14e0f
commit 67fca82495
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 628 additions and 498 deletions

View file

@ -9189,7 +9189,7 @@ fn ensure_multiple_dialects_are_tested() {
#[test]
fn parse_create_index() {
let sql = "CREATE UNIQUE INDEX IF NOT EXISTS idx_name ON test(name,age DESC)";
let sql = "CREATE UNIQUE INDEX IF NOT EXISTS idx_name ON test(name, age DESC)";
let indexed_columns: Vec<IndexColumn> = vec![
IndexColumn {
operator_class: None,
@ -9235,7 +9235,7 @@ fn parse_create_index() {
#[test]
fn test_create_index_with_using_function() {
let sql = "CREATE UNIQUE INDEX IF NOT EXISTS idx_name ON test USING BTREE (name,age DESC)";
let sql = "CREATE UNIQUE INDEX IF NOT EXISTS idx_name ON test USING BTREE (name, age DESC)";
let indexed_columns: Vec<IndexColumn> = vec![
IndexColumn {
operator_class: None,
@ -9273,6 +9273,8 @@ fn test_create_index_with_using_function() {
nulls_distinct: None,
with,
predicate: None,
index_options,
alter_options,
}) => {
assert_eq!("idx_name", name.to_string());
assert_eq!("test", table_name.to_string());
@ -9283,6 +9285,8 @@ fn test_create_index_with_using_function() {
assert!(if_not_exists);
assert!(include.is_empty());
assert!(with.is_empty());
assert!(index_options.is_empty());
assert!(alter_options.is_empty());
}
_ => unreachable!(),
}
@ -9324,6 +9328,8 @@ fn test_create_index_with_with_clause() {
nulls_distinct: None,
with,
predicate: None,
index_options,
alter_options,
}) => {
pretty_assertions::assert_eq!("title_idx", name.to_string());
pretty_assertions::assert_eq!("films", table_name.to_string());
@ -9333,6 +9339,8 @@ fn test_create_index_with_with_clause() {
assert!(!if_not_exists);
assert!(include.is_empty());
pretty_assertions::assert_eq!(with_parameters, with);
assert!(index_options.is_empty());
assert!(alter_options.is_empty());
}
_ => unreachable!(),
}