Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/data/datatypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,8 +1072,6 @@ const postgresTypesBase = {
type: "TIMESTAMP",
color: dateColor,
checkDefault: (field) => {
const content = field.default.split(" ");
const date = content[0].split("-");
const specialValues = [
"epoch",
"infinity",
Expand All @@ -1084,11 +1082,16 @@ const postgresTypesBase = {
"yesterday",
"current_timestamp",
];
if (specialValues.includes(field.default.toLowerCase())) {
return true;
}
if (!/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(field.default)) {
return false;
}
const content = field.default.split(" ");
const date = content[0].split("-");
return (
/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(field.default) ||
(Number.parseInt(date[0]) >= 1970 &&
Number.parseInt(date[0]) <= 2038) ||
specialValues.includes(field.default.toLowerCase())
Number.parseInt(date[0]) >= 1970 && Number.parseInt(date[0]) <= 2038
);
},
hasCheck: false,
Expand Down
8 changes: 4 additions & 4 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function strHasQuotes(str) {
);
}

const keywords = [
const keywords = new Set([
"NULL",
"TRUE",
"FALSE",
Expand All @@ -42,16 +42,16 @@ const keywords = [
"CURRENT_TIMESTAMP",
"LOCALTIME",
"LOCALTIMESTAMP",
];
]);

export function isKeyword(str) {
if (typeof str !== "string") return false;

return keywords.includes(str.toUpperCase());
return keywords.has(str.toUpperCase());
}

export function isFunction(str) {
return /\w+\([^)]*\)$/.test(str);
return /\w+\([^)]*\)\s*$/.test(str);
}

export function areFieldsCompatible(db, field1Type, field2Type) {
Expand Down
Loading