//! Matrix coverage for `insert into T (vals)` (Form C — bare //! value list, no `values` keyword). //! //! Form C shares the `( ... )` opener with Form A but resolves //! the paren contents as values rather than column names. Per //! handoff-12 §2.2 the Form C path is *type-unaware* — its //! grammar uses the schemaless `INSERT_PAREN_LIST` shape, not //! the typed `column_value_list`. Type validation happens at //! bind time, not parse time. //! //! The previous commit's Form C/A disambiguation means //! column-shaped items (idents) inside the parens now flag as //! "did you mean Form A?". This file pins both the happy-path //! (literals only) and the Form-A-recovery (column-shaped //! items). use crate::typing_surface::*; use rdbms_playground::input_render::InputState; #[test] fn form_c_with_text_literals_parses() { let schema = schema_text_pk(); let a = assess_at_end( "insert into Items ('SKU-1', 'Widget')", &schema, ); assert!(matches!(a.state, InputState::Valid)); assert_eq!(a.parse_result.as_deref(), Ok("Insert")); crate::snap!("form_c_text_literals", a); } #[test] fn form_c_with_mixed_literals_parses() { let schema = schema_serial_pk(); let a = assess_at_end( "insert into Customers (1, 'Alice', 'a@b.c')", &schema, ); assert!(matches!(a.state, InputState::Valid)); assert_eq!(a.parse_result.as_deref(), Ok("Insert")); crate::snap!("form_c_mixed_literals", a); } #[test] fn form_c_with_null_first_parses() { let schema = schema_serial_pk(); let a = assess_at_end( "insert into Customers (null, 'Alice', 'a@b.c')", &schema, ); assert!(matches!(a.state, InputState::Valid)); crate::snap!("form_c_null_first", a); } #[test] fn form_c_with_column_shaped_item_flags_as_form_a_in_progress() { let schema = schema_serial_pk(); let a = assess_at_end("insert into Customers (Name)", &schema); assert!( matches!(a.state, InputState::IncompleteAtEof), "expected IncompleteAtEof (Form A recovery), got {:?}", a.state, ); assert_candidate_present(&a, &["values"]); crate::snap!("form_c_column_shaped_recovery", a); } #[test] fn form_c_with_two_columns_flags_as_form_a_in_progress() { let schema = schema_serial_pk(); let a = assess_at_end("insert into Customers (Name, Email)", &schema); assert!(matches!(a.state, InputState::IncompleteAtEof)); assert_candidate_present(&a, &["values"]); crate::snap!("form_c_two_columns_recovery", a); } #[test] fn form_c_type_unaware_grammar_accepts_decimal_for_int_column() { // Form C's grammar uses INSERT_PAREN_LIST (the pre-Phase-D // schemaless choice), so type mismatches aren't caught at // parse time. Bind time catches them. Handoff §2.2 // documents this as known. let schema = schema_serial_pk(); let a = assess_at_end( "insert into Customers (3.14, 'Alice', 'a@b.c')", &schema, ); assert!(matches!(a.state, InputState::Valid)); crate::snap!("form_c_type_unaware", a); } #[test] fn form_c_in_progress_after_comma_is_incomplete() { let schema = schema_serial_pk(); let a = assess_at_end("insert into Customers (1, ", &schema); assert!(matches!(a.state, InputState::IncompleteAtEof)); crate::snap!("form_c_in_progress_after_comma", a); } #[test] fn form_c_in_progress_without_close_paren_is_incomplete() { let schema = schema_serial_pk(); let a = assess_at_end( "insert into Customers (1, 'Alice'", &schema, ); assert!(matches!(a.state, InputState::IncompleteAtEof)); crate::snap!("form_c_in_progress_no_close", a); }