bun-query-builder 0.2.13 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +18 -12
- package/dist/src/index.js +17 -11
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -28419,7 +28419,7 @@ function detectTypeFromValidationRule(rule) {
|
|
|
28419
28419
|
case "string":
|
|
28420
28420
|
case "text": {
|
|
28421
28421
|
const maxValue = extractMaxFromRules(ruleObj);
|
|
28422
|
-
return maxValue && maxValue >
|
|
28422
|
+
return maxValue && maxValue > MAX_BOUNDED_VARCHAR_LENGTH ? "text" : "string";
|
|
28423
28423
|
}
|
|
28424
28424
|
case "integer":
|
|
28425
28425
|
case "int":
|
|
@@ -28569,7 +28569,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
28569
28569
|
inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
|
|
28570
28570
|
if (inferred === "string") {
|
|
28571
28571
|
const maxLength = extractMaxFromRules(attr.validation?.rule);
|
|
28572
|
-
if (maxLength && maxLength >
|
|
28572
|
+
if (maxLength && maxLength > MAX_BOUNDED_VARCHAR_LENGTH)
|
|
28573
28573
|
inferred = "text";
|
|
28574
28574
|
}
|
|
28575
28575
|
if (!inferred || inferred === "enum") {
|
|
@@ -28608,7 +28608,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
28608
28608
|
hasDefault: typeof attr.default !== "undefined",
|
|
28609
28609
|
defaultValue: normalizeDefaultValue(attr.default),
|
|
28610
28610
|
enumValues,
|
|
28611
|
-
maxLength: typeof maxLen === "number" && maxLen > 0 && maxLen <=
|
|
28611
|
+
maxLength: typeof maxLen === "number" && maxLen > 0 && maxLen <= MAX_BOUNDED_VARCHAR_LENGTH ? maxLen : undefined
|
|
28612
28612
|
};
|
|
28613
28613
|
if (columnName.endsWith("_id") && attr.foreignKey !== false && !polymorphicColumns.has(columnName)) {
|
|
28614
28614
|
if (typeof attr.foreignKey === "object" && attr.foreignKey !== null) {
|
|
@@ -29296,14 +29296,20 @@ function generateDiffOperations(previous, next, opts = {}) {
|
|
|
29296
29296
|
removedCols = detected.removed;
|
|
29297
29297
|
addedCols = detected.added;
|
|
29298
29298
|
}
|
|
29299
|
-
if (preserveUnknownColumns
|
|
29299
|
+
if (preserveUnknownColumns) {
|
|
29300
29300
|
const preserved = removedCols.map((name) => prevCols[name]);
|
|
29301
|
-
const
|
|
29302
|
-
|
|
29303
|
-
|
|
29304
|
-
|
|
29305
|
-
|
|
29306
|
-
|
|
29301
|
+
const keptIndexes = prev.indexes.filter((idx) => !currIdx[indexKey(idx, prev.table)]);
|
|
29302
|
+
if (preserved.length > 0 || keptIndexes.length > 0) {
|
|
29303
|
+
if (preserved.length > 0) {
|
|
29304
|
+
info2(`-- Keeping ${preserved.length} column(s) on "${curr.table}" no model declares: ${removedCols.join(", ")} \u2014 reconciled from the database, where an undeclared column is out of scope rather than removed`);
|
|
29305
|
+
}
|
|
29306
|
+
if (keptIndexes.length > 0) {
|
|
29307
|
+
info2(`-- Keeping ${keptIndexes.length} index(es) on "${curr.table}" no model declares: ${keptIndexes.map((index) => index.name).join(", ")} \u2014 reconciled from the database, where an undeclared index is out of scope rather than removed`);
|
|
29308
|
+
}
|
|
29309
|
+
curr = { ...curr, columns: [...curr.columns, ...preserved], indexes: [...curr.indexes, ...keptIndexes] };
|
|
29310
|
+
currCols = mapColumnsByName(curr.columns);
|
|
29311
|
+
currIdx = mapIndexesByKey(curr.indexes, curr.table);
|
|
29312
|
+
}
|
|
29307
29313
|
removedCols = [];
|
|
29308
29314
|
}
|
|
29309
29315
|
const modifiedCols = Object.keys(currCols).filter((n2) => prevCols[n2] && columnsAreDifferent(prevCols[n2], currCols[n2], dialect));
|
|
@@ -29453,7 +29459,7 @@ function generateDiffOperations(previous, next, opts = {}) {
|
|
|
29453
29459
|
function generateDiffSql(previous, next, opts = {}) {
|
|
29454
29460
|
return generateDiffOperations(previous, next, opts).statements;
|
|
29455
29461
|
}
|
|
29456
|
-
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated";
|
|
29462
|
+
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated", MAX_BOUNDED_VARCHAR_LENGTH = 767;
|
|
29457
29463
|
var init_migrations = __esm(() => {
|
|
29458
29464
|
init_config();
|
|
29459
29465
|
init_drivers();
|
|
@@ -31542,7 +31548,7 @@ function getPrefix() {
|
|
|
31542
31548
|
}
|
|
31543
31549
|
var prefix = getPrefix();
|
|
31544
31550
|
// package.json
|
|
31545
|
-
var version2 = "0.2.
|
|
31551
|
+
var version2 = "0.2.15";
|
|
31546
31552
|
|
|
31547
31553
|
// bin/cli.ts
|
|
31548
31554
|
init_actions();
|
package/dist/src/index.js
CHANGED
|
@@ -28418,7 +28418,7 @@ function detectTypeFromValidationRule(rule) {
|
|
|
28418
28418
|
case "string":
|
|
28419
28419
|
case "text": {
|
|
28420
28420
|
const maxValue = extractMaxFromRules(ruleObj);
|
|
28421
|
-
return maxValue && maxValue >
|
|
28421
|
+
return maxValue && maxValue > MAX_BOUNDED_VARCHAR_LENGTH ? "text" : "string";
|
|
28422
28422
|
}
|
|
28423
28423
|
case "integer":
|
|
28424
28424
|
case "int":
|
|
@@ -28568,7 +28568,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
28568
28568
|
inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
|
|
28569
28569
|
if (inferred === "string") {
|
|
28570
28570
|
const maxLength = extractMaxFromRules(attr.validation?.rule);
|
|
28571
|
-
if (maxLength && maxLength >
|
|
28571
|
+
if (maxLength && maxLength > MAX_BOUNDED_VARCHAR_LENGTH)
|
|
28572
28572
|
inferred = "text";
|
|
28573
28573
|
}
|
|
28574
28574
|
if (!inferred || inferred === "enum") {
|
|
@@ -28607,7 +28607,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
28607
28607
|
hasDefault: typeof attr.default !== "undefined",
|
|
28608
28608
|
defaultValue: normalizeDefaultValue(attr.default),
|
|
28609
28609
|
enumValues,
|
|
28610
|
-
maxLength: typeof maxLen === "number" && maxLen > 0 && maxLen <=
|
|
28610
|
+
maxLength: typeof maxLen === "number" && maxLen > 0 && maxLen <= MAX_BOUNDED_VARCHAR_LENGTH ? maxLen : undefined
|
|
28611
28611
|
};
|
|
28612
28612
|
if (columnName.endsWith("_id") && attr.foreignKey !== false && !polymorphicColumns.has(columnName)) {
|
|
28613
28613
|
if (typeof attr.foreignKey === "object" && attr.foreignKey !== null) {
|
|
@@ -29295,14 +29295,20 @@ function generateDiffOperations(previous, next, opts = {}) {
|
|
|
29295
29295
|
removedCols = detected.removed;
|
|
29296
29296
|
addedCols = detected.added;
|
|
29297
29297
|
}
|
|
29298
|
-
if (preserveUnknownColumns
|
|
29298
|
+
if (preserveUnknownColumns) {
|
|
29299
29299
|
const preserved = removedCols.map((name) => prevCols[name]);
|
|
29300
|
-
const
|
|
29301
|
-
|
|
29302
|
-
|
|
29303
|
-
|
|
29304
|
-
|
|
29305
|
-
|
|
29300
|
+
const keptIndexes = prev.indexes.filter((idx) => !currIdx[indexKey(idx, prev.table)]);
|
|
29301
|
+
if (preserved.length > 0 || keptIndexes.length > 0) {
|
|
29302
|
+
if (preserved.length > 0) {
|
|
29303
|
+
info2(`-- Keeping ${preserved.length} column(s) on "${curr.table}" no model declares: ${removedCols.join(", ")} \u2014 reconciled from the database, where an undeclared column is out of scope rather than removed`);
|
|
29304
|
+
}
|
|
29305
|
+
if (keptIndexes.length > 0) {
|
|
29306
|
+
info2(`-- Keeping ${keptIndexes.length} index(es) on "${curr.table}" no model declares: ${keptIndexes.map((index) => index.name).join(", ")} \u2014 reconciled from the database, where an undeclared index is out of scope rather than removed`);
|
|
29307
|
+
}
|
|
29308
|
+
curr = { ...curr, columns: [...curr.columns, ...preserved], indexes: [...curr.indexes, ...keptIndexes] };
|
|
29309
|
+
currCols = mapColumnsByName(curr.columns);
|
|
29310
|
+
currIdx = mapIndexesByKey(curr.indexes, curr.table);
|
|
29311
|
+
}
|
|
29306
29312
|
removedCols = [];
|
|
29307
29313
|
}
|
|
29308
29314
|
const modifiedCols = Object.keys(currCols).filter((n2) => prevCols[n2] && columnsAreDifferent(prevCols[n2], currCols[n2], dialect));
|
|
@@ -29452,7 +29458,7 @@ function generateDiffOperations(previous, next, opts = {}) {
|
|
|
29452
29458
|
function generateDiffSql(previous, next, opts = {}) {
|
|
29453
29459
|
return generateDiffOperations(previous, next, opts).statements;
|
|
29454
29460
|
}
|
|
29455
|
-
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated";
|
|
29461
|
+
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated", MAX_BOUNDED_VARCHAR_LENGTH = 767;
|
|
29456
29462
|
var init_migrations = __esm(() => {
|
|
29457
29463
|
init_config();
|
|
29458
29464
|
init_drivers();
|
package/package.json
CHANGED