fix(grid): preserve null text during editing
This commit is contained in:
1 parent
834ad772c6
commit
f8baedc6e6
3 files changed
+37
-1
No files matched your search
@@ -34,6 +34,26 @@ describe("dataGridCellDisplayText", () => {
|
||||
});
|
||||
|
||||
describe("coerceDataGridCellValue", () => {
|
||||
it.each(["null", "NULL", "Null", "nUlL"])("preserves literal %s input as text", (value) => {
|
||||
expect(
|
||||
coerceDataGridCellValue({
|
||||
value,
|
||||
oldValue: null,
|
||||
databaseType: "mysql",
|
||||
columnInfo: { data_type: "varchar(255)" },
|
||||
}),
|
||||
).toBe(value);
|
||||
|
||||
expect(
|
||||
coerceDataGridCellValue({
|
||||
value,
|
||||
oldValue: "previous",
|
||||
databaseType: "postgres",
|
||||
columnInfo: { data_type: "text" },
|
||||
}),
|
||||
).toBe(value);
|
||||
});
|
||||
|
||||
it("preserves an explicitly generated empty string for a null cell", () => {
|
||||
const options = {
|
||||
value: "",
|
||||
|
||||
@@ -11,7 +11,6 @@ export interface CoerceDataGridCellValueOptions {
|
||||
|
||||
export function coerceDataGridCellValue(options: CoerceDataGridCellValueOptions): GridCellValue {
|
||||
const { value, oldValue } = options;
|
||||
if (value.toUpperCase() === "NULL") return null;
|
||||
if (value === "" && oldValue === null && !options.preserveEmptyString) return null;
|
||||
const postgresArrayValue = coercePostgresArrayValue(options);
|
||||
if (postgresArrayValue !== undefined) return postgresArrayValue;
|
||||
|
||||
Reference in new issue
Block a user