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
4 changes: 2 additions & 2 deletions src/components/EditorHeader/SideSheet/Sidesheet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Sidesheet({ type, title, setTitle, onClose }) {
case SIDESHEET.VERSIONS:
return t("versions");
default:
break;
return "";
}
}

Expand All @@ -36,7 +36,7 @@ export default function Sidesheet({ type, title, setTitle, onClose }) {
/>
);
default:
break;
return null;
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/components/EditorSidePanel/TypesTab/TypeInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export default function TypeInfo({ index, data }) {
const [editField, setEditField] = useState({});
const { t } = useTranslation();

// TODO: remove indexes, not a valid case after adding id to types
const typeId = data.id ?? index;

return (
Expand All @@ -34,7 +33,7 @@ export default function TypeInfo({ index, data }) {
{data.name}
</div>
}
itemKey={`${index}`}
itemKey={`${typeId}`}
>
<div className="flex items-center mb-2.5">
<div className="text-md font-semibold break-keep">{t("name")}: </div>
Expand Down Expand Up @@ -90,7 +89,7 @@ export default function TypeInfo({ index, data }) {
/>
</div>
{data.fields.map((f, j) => (
<TypeField key={j} data={f} fid={j} tid={index} />
<TypeField key={j} data={f} fid={j} tid={typeId} />
))}
<Card
bodyStyle={{ padding: "4px" }}
Expand Down
14 changes: 10 additions & 4 deletions src/utils/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ function checkDefault(field, database) {
!field.notNull &&
typeof field.default === "string" &&
field.default.toLowerCase() === "null"
)
) {
return true;
if (!dbToTypes[database][field.type].checkDefault) return true;
}

const dbTypes = dbToTypes[database];
if (!dbTypes) return true;

const typeConfig = dbTypes[field.type];
if (!typeConfig || !typeConfig.checkDefault) return true;

return dbToTypes[database][field.type].checkDefault(field);
return typeConfig.checkDefault(field);
}

export function getIssues(diagram) {
Expand Down Expand Up @@ -121,7 +127,7 @@ export function getIssues(diagram) {
});

table.indices.forEach((index) => {
if (index.name.trim() === "") {
if ((index.name || "").trim() === "") {
issues.push(i18n.t("empty_index_name", { tableName: table.name }));
}
if (index.fields.length === 0) {
Expand Down
11 changes: 8 additions & 3 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ export function isFunction(str) {

export function areFieldsCompatible(db, field1Type, field2Type) {
const same = field1Type === field2Type;
const isCompatible =
dbToTypes[db][field1Type].compatibleWith &&
dbToTypes[db][field1Type].compatibleWith.includes(field2Type);

const dbTypes = dbToTypes[db];
if (!dbTypes) return same;

const typeConfig = dbTypes[field1Type];
if (!typeConfig || !typeConfig.compatibleWith) return same;

const isCompatible = typeConfig.compatibleWith.includes(field2Type);
return same || isCompatible;
}

Expand Down