Update JSON data type matcher
This commit is contained in:
Vendored
+7
-3
@@ -1,6 +1,7 @@
|
||||
import buildColumnDefinition, { fieldRequiresNotNull, } from "./build-column-definition";
|
||||
import createTable from "./create-table";
|
||||
import getTableColumns, {} from "./get-table-columns";
|
||||
import getTableColumnsGemini from "./get-table-columns-gemnini";
|
||||
import isVectorField from "./is-vector-field";
|
||||
import mapDataType from "./map-data-types";
|
||||
import MariaDBQuoteGen from "./mariadb-quote-gen";
|
||||
@@ -110,7 +111,9 @@ function columnAttributesDiverged(live, field) {
|
||||
if (wantsOnUpdate && hasOnUpdate) {
|
||||
const liveOnUpdate = normalizeDefault((live.extra.match(/on update\s+(.+)/i) || [])[1] || "");
|
||||
const expectedOu = normalizeDefault(wantsOnUpdate);
|
||||
if (liveOnUpdate && expectedOu && !defaultsMatch(liveOnUpdate, expectedOu)) {
|
||||
if (liveOnUpdate &&
|
||||
expectedOu &&
|
||||
!defaultsMatch(liveOnUpdate, expectedOu)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -185,7 +188,7 @@ async function recreateColumn({ tableName, field, config, }) {
|
||||
await addColumn({ tableName, field, config });
|
||||
}
|
||||
export default async function updateTable({ table, config, }) {
|
||||
const existingColumns = await getTableColumns({
|
||||
const existingColumns = await getTableColumnsGemini({
|
||||
tableName: table.tableName,
|
||||
config,
|
||||
});
|
||||
@@ -207,7 +210,8 @@ export default async function updateTable({ table, config, }) {
|
||||
fieldsToAdd.push(field);
|
||||
}
|
||||
else {
|
||||
let typeDiverged = !columnTypesMatch(liveField.type, mapDataType(field));
|
||||
let mapped_data_type = mapDataType(field);
|
||||
let typeDiverged = !columnTypesMatch(liveField.type, mapped_data_type);
|
||||
if (isVectorField(field)) {
|
||||
typeDiverged = vectorTypeDiverged(liveField.type, liveField.comment || "", field);
|
||||
if (typeDiverged) {
|
||||
|
||||
Reference in New Issue
Block a user