1 parent
b38e30cd7f
commit
8b02ba003b
2 files changed
+11
-2
No files matched your search
@@ -1166,7 +1166,7 @@ const KnownColumnPatterns: Array<{ pattern: RegExp; generatorKey: string }> = [
|
|||||||
export function findGeneratorKey(columnName: string, dataType: string, isAutoIncrement?: boolean): string {
|
export function findGeneratorKey(columnName: string, dataType: string, isAutoIncrement?: boolean): string {
|
||||||
if (isAutoIncrement) return "sequence";
|
if (isAutoIncrement) return "sequence";
|
||||||
const type = dataType.toLowerCase();
|
const type = dataType.toLowerCase();
|
||||||
const isNumeric = type.includes("int") || type === "smallint" || type === "bigint" || type.includes("bool") || type.includes("decimal") || type.includes("numeric") || type.includes("float") || type.includes("double") || type === "real";
|
const isNumeric = /^number(?:\s*\([^)]*\))?$/.test(type.trim()) || type.includes("int") || type === "smallint" || type === "bigint" || type.includes("bool") || type.includes("decimal") || type.includes("numeric") || type.includes("float") || type.includes("double") || type === "real";
|
||||||
const isDateTime = type.includes("date") || type.includes("timestamp") || type === "time";
|
const isDateTime = type.includes("date") || type.includes("timestamp") || type === "time";
|
||||||
const isBinary = type.includes("binary") || type.includes("blob") || type.includes("bytea");
|
const isBinary = type.includes("binary") || type.includes("blob") || type.includes("bytea");
|
||||||
const isBoolType = type === "bool" || type === "boolean" || type === "bit" || type === "tinyint(1)";
|
const isBoolType = type === "bool" || type === "boolean" || type === "bit" || type === "tinyint(1)";
|
||||||
|
|||||||
+10
-1
@@ -1,6 +1,15 @@
|
|||||||
import { strict as assert } from "node:assert";
|
import { strict as assert } from "node:assert";
|
||||||
import { test, vi } from "vitest";
|
import { test, vi } from "vitest";
|
||||||
import { defaultGeneratorParams, displayGeneratedValue, generateTableData, generateValue, supportsGeneratedMultiRowValues } from "../../apps/desktop/src/lib/dataGrid/dataGenerate.ts";
|
import { defaultGeneratorParams, displayGeneratedValue, findGeneratorKey, generateTableData, generateValue, supportsGeneratedMultiRowValues } from "../../apps/desktop/src/lib/dataGrid/dataGenerate.ts";
|
||||||
|
|
||||||
|
test("recognizes Oracle-compatible NUMBER column types as numeric", () => {
|
||||||
|
assert.equal(findGeneratorKey("value", "NUMBER"), "number");
|
||||||
|
assert.equal(findGeneratorKey("value", "NUMBER(10)"), "number");
|
||||||
|
assert.equal(findGeneratorKey("value", "NUMBER(18, 2)"), "number");
|
||||||
|
assert.equal(findGeneratorKey("value", "NUMBER(10)", true), "sequence");
|
||||||
|
assert.equal(findGeneratorKey("value", "serial_number_code"), "text");
|
||||||
|
assert.equal(findGeneratorKey("value", "NUMBER CODE"), "text");
|
||||||
|
});
|
||||||
|
|
||||||
test("enables default values for columns with schema defaults", () => {
|
test("enables default values for columns with schema defaults", () => {
|
||||||
const params = defaultGeneratorParams(
|
const params = defaultGeneratorParams(
|
||||||
|
|||||||
Reference in new issue
Block a user