feat: working Insert Row + smart cell editors

Insert Row now stages an editable pending row at the top of the data
grid (with an accent outline) instead of an invisible all-null insert
that failed on commit. Committing inserts only the filled columns so
serial/identity/generated defaults apply; empty-column inserts fall
back to DEFAULT VALUES.

Cell editors are now type-aware: date/time/datetime pickers, a boolean
select, and number inputs for the matching column types (enums and FKs
already had dropdowns). Applies to both new rows and inline editing.
Datetime values commit in the canonical space-separated format accepted
by both PostgreSQL and MySQL.
This commit is contained in:
2026-09-06 12:49:20 +08:00
parent bff4e612ab
commit f480d0f864
15 changed files with 349 additions and 60 deletions
@@ -566,6 +566,14 @@ pub fn build_pg_insert_sql(
table: &str,
columns: &[(String, serde_json::Value)],
) -> (String, Vec<serde_json::Value>) {
// A table with no editable columns (e.g. only a serial/identity PK) inserts
// with all defaults — `INSERT ... () VALUES ()` is invalid SQL.
if columns.is_empty() {
return (
format!("INSERT INTO \"{}\".\"{}\" DEFAULT VALUES", schema, table),
vec![],
);
}
let cols: Vec<String> = columns.iter().map(|(c, _)| format!("\"{}\"", c)).collect();
let mut params: Vec<serde_json::Value> = Vec::new();
let placeholders: Vec<String> = columns
@@ -3102,6 +3110,15 @@ mod tests {
);
}
/// A table with no editable columns (only a serial/identity PK) must insert
/// with `DEFAULT VALUES`, not the invalid `INSERT ... () VALUES ()`.
#[test]
fn build_pg_insert_sql_empty_columns_uses_default_values() {
let (sql, params) = build_pg_insert_sql("public", "t", &[]);
assert_eq!(sql, "INSERT INTO \"public\".\"t\" DEFAULT VALUES");
assert!(params.is_empty());
}
/// Verify that `get_sqlite_ddl` returns the stored CREATE TABLE statement
/// from `sqlite_master`.
#[test]