From a87c4ac555ed763b4e4e48716a7d4402dd439b99 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 22 Jun 2026 09:47:39 -0700 Subject: [PATCH] Object not chain of ifs Refs https://github.com/simonw/datasette/pull/2789/changes#r3453964430 --- datasette/static/edit-tools.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/datasette/static/edit-tools.js b/datasette/static/edit-tools.js index 779ec702..4c6d7d10 100644 --- a/datasette/static/edit-tools.js +++ b/datasette/static/edit-tools.js @@ -60,17 +60,14 @@ function tableCreateColumnTypes() { : ["text", "integer", "float", "blob"]; } +var SQLITE_COLUMN_TYPE_LABELS = { + float: "floating point number", + real: "floating point number", + blob: "blob - binary data", +}; + function sqliteColumnTypeLabel(type) { - if (type === "float") { - return "floating point number"; - } - if (type === "real") { - return "floating point number"; - } - if (type === "blob") { - return "blob - binary data"; - } - return type; + return SQLITE_COLUMN_TYPE_LABELS[type] || type; } function populateSqliteColumnTypeSelect(select, type, options) {