@query-doctor/core 0.2.3 → 0.2.4
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/index.cjs +25 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/dist/optimizer/genalgo.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1222,7 +1222,31 @@ var _IndexOptimizer = class _IndexOptimizer {
|
|
|
1222
1222
|
// TODO: this doesn't belong in the optimizer
|
|
1223
1223
|
indexAlreadyExists(table, columns) {
|
|
1224
1224
|
return this.existingIndexes.find(
|
|
1225
|
-
(index) => index.index_type === "btree" && index.table_name === table && index.index_columns.length === columns.length && index.index_columns.every((c, i) =>
|
|
1225
|
+
(index) => index.index_type === "btree" && index.table_name === table && index.index_columns.length === columns.length && index.index_columns.every((c, i) => {
|
|
1226
|
+
if (columns[i].column !== c.name) {
|
|
1227
|
+
return false;
|
|
1228
|
+
}
|
|
1229
|
+
if (columns[i].where) {
|
|
1230
|
+
return false;
|
|
1231
|
+
}
|
|
1232
|
+
if (columns[i].sort) {
|
|
1233
|
+
switch (columns[i].sort.dir) {
|
|
1234
|
+
// Sorting is ASC by default in postgres
|
|
1235
|
+
case "SORTBY_DEFAULT":
|
|
1236
|
+
case "SORTBY_ASC":
|
|
1237
|
+
if (c.order !== "ASC") {
|
|
1238
|
+
return false;
|
|
1239
|
+
}
|
|
1240
|
+
break;
|
|
1241
|
+
case "SORTBY_DESC":
|
|
1242
|
+
if (c.order !== "DESC") {
|
|
1243
|
+
return false;
|
|
1244
|
+
}
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
return true;
|
|
1249
|
+
})
|
|
1226
1250
|
);
|
|
1227
1251
|
}
|
|
1228
1252
|
/**
|