@atscript/db-mysql 0.1.149 → 0.1.150
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 +42 -17
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +44 -19
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -165,6 +165,7 @@ const mysqlDialect = {
|
|
|
165
165
|
params: [pattern]
|
|
166
166
|
};
|
|
167
167
|
},
|
|
168
|
+
integerText: (expr) => `CAST(CAST(${expr} AS SIGNED) AS CHAR)`,
|
|
168
169
|
mapQueryError(error, arithmetic) {
|
|
169
170
|
if (error?.errno !== 1690) return void 0;
|
|
170
171
|
return arithmetic ? (0, _atscript_db_sql_tools.arithOverflowError)() : (0, _atscript_db_sql_tools.numericOutOfRangeError)();
|
|
@@ -1198,9 +1199,9 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
1198
1199
|
});
|
|
1199
1200
|
return hit;
|
|
1200
1201
|
}
|
|
1201
|
-
async updateOne(filter, data, ops, expectedVersion) {
|
|
1202
|
+
async updateOne(filter, data, ops, expectedVersion, opts) {
|
|
1202
1203
|
const where = this._mutationWhere(filter);
|
|
1203
|
-
const versionColumn = this.
|
|
1204
|
+
const versionColumn = this._versionColumnFor(opts, expectedVersion);
|
|
1204
1205
|
const { sql, params } = buildUpdate(this.resolveTableName(), data, where, 1, ops, versionColumn, expectedVersion);
|
|
1205
1206
|
this._log(sql, params);
|
|
1206
1207
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
@@ -1209,9 +1210,9 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
1209
1210
|
modifiedCount: result.changedRows
|
|
1210
1211
|
};
|
|
1211
1212
|
}
|
|
1212
|
-
async updateMany(filter, data, ops) {
|
|
1213
|
+
async updateMany(filter, data, ops, opts) {
|
|
1213
1214
|
const where = this._mutationWhere(filter);
|
|
1214
|
-
const versionColumn = this.
|
|
1215
|
+
const versionColumn = this._versionColumnFor(opts);
|
|
1215
1216
|
const { sql, params } = buildUpdate(this.resolveTableName(), data, where, void 0, ops, versionColumn);
|
|
1216
1217
|
this._log(sql, params);
|
|
1217
1218
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
@@ -1603,7 +1604,9 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
1603
1604
|
const unique = index.type === "unique" ? "UNIQUE " : "";
|
|
1604
1605
|
const fulltext = index.type === "fulltext" ? "FULLTEXT " : "";
|
|
1605
1606
|
const isFulltext = index.type === "fulltext";
|
|
1606
|
-
const
|
|
1607
|
+
const members = isFulltext ? (0, _atscript_db.splitFulltextFields)(index).text : index.fields;
|
|
1608
|
+
if (members.length === 0) return;
|
|
1609
|
+
const cols = members.map((f) => {
|
|
1607
1610
|
const col = qi(f.name);
|
|
1608
1611
|
const prefix = isFulltext ? void 0 : desiredPrefix(f.name);
|
|
1609
1612
|
const order = isFulltext ? "" : ` ${f.sort === "desc" ? "DESC" : "ASC"}`;
|
|
@@ -1674,12 +1677,14 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
1674
1677
|
}
|
|
1675
1678
|
getSearchIndexes() {
|
|
1676
1679
|
const indexes = [];
|
|
1677
|
-
|
|
1680
|
+
const ftAll = [...this._table.indexes.values()].filter((i) => i.type === "fulltext");
|
|
1681
|
+
const ftDefault = (0, _atscript_db.defaultFulltextIndex)(ftAll);
|
|
1682
|
+
for (const index of ftAll) indexes.push({
|
|
1678
1683
|
name: index.key,
|
|
1679
|
-
description: `FULLTEXT index on ${
|
|
1684
|
+
description: (0, _atscript_db.describeFulltext)(index, (names) => `FULLTEXT index on ${names}`),
|
|
1680
1685
|
type: "text",
|
|
1681
1686
|
fields: this._indexLogicalPaths(index),
|
|
1682
|
-
isDefault:
|
|
1687
|
+
isDefault: index === ftDefault
|
|
1683
1688
|
});
|
|
1684
1689
|
let firstVector = true;
|
|
1685
1690
|
for (const [field, vec] of this._vectorFields) {
|
|
@@ -1722,18 +1727,38 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
1722
1727
|
_buildSearchWhere(text, query, indexName) {
|
|
1723
1728
|
const fulltextIndex = this._getFulltextIndex(indexName);
|
|
1724
1729
|
if (!fulltextIndex) throw new Error("No FULLTEXT index found for search");
|
|
1725
|
-
const
|
|
1730
|
+
const { text: textFields, integer: integerFields } = (0, _atscript_db.splitFulltextFields)(fulltextIndex);
|
|
1726
1731
|
const where = buildWhere(query.filter);
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
+
const n = integerFields.length > 0 ? (0, _atscript_db.searchTermInteger)(text) : void 0;
|
|
1733
|
+
const matchClause = `MATCH(${textFields.map((f) => qi(f.name)).join(", ")}) AGAINST(? IN NATURAL LANGUAGE MODE)`;
|
|
1734
|
+
const withWhere = (clause, params) => ({
|
|
1735
|
+
sql: where.sql === "1=1" ? clause : `${where.sql} AND ${clause}`,
|
|
1736
|
+
params: [...where.params, ...params]
|
|
1737
|
+
});
|
|
1738
|
+
if (n === void 0) return textFields.length === 0 ? withWhere(_atscript_db_sql_tools.EMPTY_OR.sql, []) : withWhere(matchClause, [text]);
|
|
1739
|
+
const keys = this._table.primaryKeys.map((key) => qi(this._table.physicalPath(key)));
|
|
1740
|
+
if (keys.length === 0) {
|
|
1741
|
+
const or = (0, _atscript_db_sql_tools.orFragment)([...textFields.length > 0 ? [matchClause] : [], ...integerFields.map((f) => `${qi(f.name)} = ?`)], [...textFields.length > 0 ? [text] : [], ...integerFields.map(() => n)]);
|
|
1742
|
+
return withWhere(or.sql, or.params);
|
|
1743
|
+
}
|
|
1744
|
+
const table = quoteTableName(this.resolveTableName());
|
|
1745
|
+
const keyList = keys.join(", ");
|
|
1746
|
+
const arms = [];
|
|
1747
|
+
const params = [];
|
|
1748
|
+
if (textFields.length > 0) {
|
|
1749
|
+
arms.push(`SELECT ${keyList} FROM ${table} WHERE ${matchClause}`);
|
|
1750
|
+
params.push(text);
|
|
1751
|
+
}
|
|
1752
|
+
for (const f of integerFields) {
|
|
1753
|
+
arms.push(`SELECT ${keyList} FROM ${table} WHERE ${qi(f.name)} = ?`);
|
|
1754
|
+
params.push(n);
|
|
1755
|
+
}
|
|
1756
|
+
return withWhere(`${keys.length === 1 ? keyList : `(${keyList})`} IN (SELECT ${keyList} FROM (${arms.join(" UNION ")}) AS ${qi("_atscript_search")})`, params);
|
|
1732
1757
|
}
|
|
1733
1758
|
_getFulltextIndex(indexName) {
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1759
|
+
const ftAll = [...this._table.indexes.values()].filter((i) => i.type === "fulltext");
|
|
1760
|
+
if (!indexName) return (0, _atscript_db.defaultFulltextIndex)(ftAll);
|
|
1761
|
+
return ftAll.find((index) => index.key === indexName);
|
|
1737
1762
|
}
|
|
1738
1763
|
/**
|
|
1739
1764
|
* Detects native VECTOR type support by inspecting the server version.
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AggregateFn, BaseDbAdapter, BucketUnit, DbQuery, DbSpace, FilterExpr, TColumnDiff, TDbDefaultFn, TDbDeleteResult, TDbFieldMeta, TDbInsertIgnoreSlot, TDbInsertManyResult, TDbInsertResult, TDbObjectKind, TDbUpdateResult, TEnsureTableOptions, TExistingColumn, TExistingTableOption, TFieldOps, TPrimaryKeyChange, TReferencingForeignKey, TSearchIndexInfo, TSyncColumnResult, TTableOptionDiff, TValueFormatterPair, TViewCapability } from "@atscript/db";
|
|
1
|
+
import { AggregateFn, BaseDbAdapter, BucketUnit, DbQuery, DbSpace, FilterExpr, TColumnDiff, TDbDefaultFn, TDbDeleteResult, TDbFieldMeta, TDbInsertIgnoreSlot, TDbInsertManyResult, TDbInsertResult, TDbObjectKind, TDbUpdateOptions, TDbUpdateResult, TEnsureTableOptions, TExistingColumn, TExistingTableOption, TFieldOps, TPrimaryKeyChange, TReferencingForeignKey, TSearchIndexInfo, TSyncColumnResult, TTableOptionDiff, TValueFormatterPair, TViewCapability } from "@atscript/db";
|
|
2
2
|
import { TMetadataMap } from "@atscript/typescript/utils";
|
|
3
3
|
import { FilterExpr as FilterExpr$1 } from "@uniqu/core";
|
|
4
4
|
import { TFilterVisitorOptions, TSqlFragment, TSqlFragment as TSqlFragment$1 } from "@atscript/db-sql-tools";
|
|
@@ -293,8 +293,8 @@ declare class MysqlAdapter extends BaseDbAdapter {
|
|
|
293
293
|
private _mutationWhere;
|
|
294
294
|
/** `true` when a relational predicate of `filter` (nested ones included) reads this table. */
|
|
295
295
|
private _filterReadsOwnTable;
|
|
296
|
-
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
297
|
-
updateMany(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps): Promise<TDbUpdateResult>;
|
|
296
|
+
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, expectedVersion?: number, opts?: TDbUpdateOptions): Promise<TDbUpdateResult>;
|
|
297
|
+
updateMany(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, opts?: TDbUpdateOptions): Promise<TDbUpdateResult>;
|
|
298
298
|
replaceOne(filter: FilterExpr, data: Record<string, unknown>, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
299
299
|
replaceMany(filter: FilterExpr, data: Record<string, unknown>): Promise<TDbUpdateResult>;
|
|
300
300
|
deleteOne(filter: FilterExpr): Promise<TDbDeleteResult>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AggregateFn, BaseDbAdapter, BucketUnit, DbQuery, DbSpace, FilterExpr, TColumnDiff, TDbDefaultFn, TDbDeleteResult, TDbFieldMeta, TDbInsertIgnoreSlot, TDbInsertManyResult, TDbInsertResult, TDbObjectKind, TDbUpdateResult, TEnsureTableOptions, TExistingColumn, TExistingTableOption, TFieldOps, TPrimaryKeyChange, TReferencingForeignKey, TSearchIndexInfo, TSyncColumnResult, TTableOptionDiff, TValueFormatterPair, TViewCapability } from "@atscript/db";
|
|
1
|
+
import { AggregateFn, BaseDbAdapter, BucketUnit, DbQuery, DbSpace, FilterExpr, TColumnDiff, TDbDefaultFn, TDbDeleteResult, TDbFieldMeta, TDbInsertIgnoreSlot, TDbInsertManyResult, TDbInsertResult, TDbObjectKind, TDbUpdateOptions, TDbUpdateResult, TEnsureTableOptions, TExistingColumn, TExistingTableOption, TFieldOps, TPrimaryKeyChange, TReferencingForeignKey, TSearchIndexInfo, TSyncColumnResult, TTableOptionDiff, TValueFormatterPair, TViewCapability } from "@atscript/db";
|
|
2
2
|
import { TFilterVisitorOptions, TSqlFragment, TSqlFragment as TSqlFragment$1 } from "@atscript/db-sql-tools";
|
|
3
3
|
import { FilterExpr as FilterExpr$1 } from "@uniqu/core";
|
|
4
4
|
import { TMetadataMap } from "@atscript/typescript/utils";
|
|
@@ -293,8 +293,8 @@ declare class MysqlAdapter extends BaseDbAdapter {
|
|
|
293
293
|
private _mutationWhere;
|
|
294
294
|
/** `true` when a relational predicate of `filter` (nested ones included) reads this table. */
|
|
295
295
|
private _filterReadsOwnTable;
|
|
296
|
-
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
297
|
-
updateMany(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps): Promise<TDbUpdateResult>;
|
|
296
|
+
updateOne(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, expectedVersion?: number, opts?: TDbUpdateOptions): Promise<TDbUpdateResult>;
|
|
297
|
+
updateMany(filter: FilterExpr, data: Record<string, unknown>, ops?: TFieldOps, opts?: TDbUpdateOptions): Promise<TDbUpdateResult>;
|
|
298
298
|
replaceOne(filter: FilterExpr, data: Record<string, unknown>, expectedVersion?: number): Promise<TDbUpdateResult>;
|
|
299
299
|
replaceMany(filter: FilterExpr, data: Record<string, unknown>): Promise<TDbUpdateResult>;
|
|
300
300
|
deleteOne(filter: FilterExpr): Promise<TDbDeleteResult>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, BaseDbAdapter, DbError, DbSpace, NoopLogger, bucketTimeZoneUnavailable, containsRelationFilter, fkColumns, forEachResolvedRelation, isConflict, uniqueKeyTuple, vectorIndexNotFoundMessage } from "@atscript/db";
|
|
1
|
+
import { ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, BaseDbAdapter, DbError, DbSpace, NoopLogger, bucketTimeZoneUnavailable, containsRelationFilter, defaultFulltextIndex, describeFulltext, fkColumns, forEachResolvedRelation, isConflict, searchTermInteger, splitFulltextFields, uniqueKeyTuple, vectorIndexNotFoundMessage } from "@atscript/db";
|
|
2
2
|
import { resolveAggregateSearch } from "@atscript/db/agg";
|
|
3
|
-
import { SEARCH_SOURCE_ALIAS, arithOverflowError, buildAggregateCount, buildAggregateSelect, buildCreateView, buildDelete, buildGeoSearchCount, buildGeoSearchSelect, buildInsert, buildInsertMany, buildPartitionedSelect, buildSelect, buildUpdate, buildVectorSearchCount, buildVectorSearchSelect, buildWhere as buildWhere$1, chunkInsertRows, defaultValueForType, defaultValueToSqlLiteral, derivedColumnExpr, fillReplacePayload, foreignKeySql, geoWindowFromControls, jsonDollarPath, mapQueryErrors, normalizeGeoPointValue, numericOutOfRangeError, parseRegexString, renameGeoDistance, replaceColumnsFor, sqlTimeZoneLiteral, stripPartitionRowNumber, toSqlValue, vectorDistanceSource } from "@atscript/db-sql-tools";
|
|
3
|
+
import { EMPTY_OR, SEARCH_SOURCE_ALIAS, arithOverflowError, buildAggregateCount, buildAggregateSelect, buildCreateView, buildDelete, buildGeoSearchCount, buildGeoSearchSelect, buildInsert, buildInsertMany, buildPartitionedSelect, buildSelect, buildUpdate, buildVectorSearchCount, buildVectorSearchSelect, buildWhere as buildWhere$1, chunkInsertRows, defaultValueForType, defaultValueToSqlLiteral, derivedColumnExpr, fillReplacePayload, foreignKeySql, geoWindowFromControls, jsonDollarPath, mapQueryErrors, normalizeGeoPointValue, numericOutOfRangeError, orFragment, parseRegexString, renameGeoDistance, replaceColumnsFor, sqlTimeZoneLiteral, stripPartitionRowNumber, toSqlValue, vectorDistanceSource } from "@atscript/db-sql-tools";
|
|
4
4
|
import { BUCKET_MAX_INSTANT, BUCKET_MIN_INSTANT } from "@uniqu/core";
|
|
5
5
|
//#region src/sql-builder.ts
|
|
6
6
|
/** TEXT / BLOB families (`TINYTEXT` … `LONGBLOB`). */
|
|
@@ -164,6 +164,7 @@ const mysqlDialect = {
|
|
|
164
164
|
params: [pattern]
|
|
165
165
|
};
|
|
166
166
|
},
|
|
167
|
+
integerText: (expr) => `CAST(CAST(${expr} AS SIGNED) AS CHAR)`,
|
|
167
168
|
mapQueryError(error, arithmetic) {
|
|
168
169
|
if (error?.errno !== 1690) return void 0;
|
|
169
170
|
return arithmetic ? arithOverflowError() : numericOutOfRangeError();
|
|
@@ -1197,9 +1198,9 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
1197
1198
|
});
|
|
1198
1199
|
return hit;
|
|
1199
1200
|
}
|
|
1200
|
-
async updateOne(filter, data, ops, expectedVersion) {
|
|
1201
|
+
async updateOne(filter, data, ops, expectedVersion, opts) {
|
|
1201
1202
|
const where = this._mutationWhere(filter);
|
|
1202
|
-
const versionColumn = this.
|
|
1203
|
+
const versionColumn = this._versionColumnFor(opts, expectedVersion);
|
|
1203
1204
|
const { sql, params } = buildUpdate$1(this.resolveTableName(), data, where, 1, ops, versionColumn, expectedVersion);
|
|
1204
1205
|
this._log(sql, params);
|
|
1205
1206
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
@@ -1208,9 +1209,9 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
1208
1209
|
modifiedCount: result.changedRows
|
|
1209
1210
|
};
|
|
1210
1211
|
}
|
|
1211
|
-
async updateMany(filter, data, ops) {
|
|
1212
|
+
async updateMany(filter, data, ops, opts) {
|
|
1212
1213
|
const where = this._mutationWhere(filter);
|
|
1213
|
-
const versionColumn = this.
|
|
1214
|
+
const versionColumn = this._versionColumnFor(opts);
|
|
1214
1215
|
const { sql, params } = buildUpdate$1(this.resolveTableName(), data, where, void 0, ops, versionColumn);
|
|
1215
1216
|
this._log(sql, params);
|
|
1216
1217
|
const result = await this._wrapConstraintError(() => this._exec().run(sql, params));
|
|
@@ -1602,7 +1603,9 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
1602
1603
|
const unique = index.type === "unique" ? "UNIQUE " : "";
|
|
1603
1604
|
const fulltext = index.type === "fulltext" ? "FULLTEXT " : "";
|
|
1604
1605
|
const isFulltext = index.type === "fulltext";
|
|
1605
|
-
const
|
|
1606
|
+
const members = isFulltext ? splitFulltextFields(index).text : index.fields;
|
|
1607
|
+
if (members.length === 0) return;
|
|
1608
|
+
const cols = members.map((f) => {
|
|
1606
1609
|
const col = qi(f.name);
|
|
1607
1610
|
const prefix = isFulltext ? void 0 : desiredPrefix(f.name);
|
|
1608
1611
|
const order = isFulltext ? "" : ` ${f.sort === "desc" ? "DESC" : "ASC"}`;
|
|
@@ -1673,12 +1676,14 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
1673
1676
|
}
|
|
1674
1677
|
getSearchIndexes() {
|
|
1675
1678
|
const indexes = [];
|
|
1676
|
-
|
|
1679
|
+
const ftAll = [...this._table.indexes.values()].filter((i) => i.type === "fulltext");
|
|
1680
|
+
const ftDefault = defaultFulltextIndex(ftAll);
|
|
1681
|
+
for (const index of ftAll) indexes.push({
|
|
1677
1682
|
name: index.key,
|
|
1678
|
-
description: `FULLTEXT index on ${
|
|
1683
|
+
description: describeFulltext(index, (names) => `FULLTEXT index on ${names}`),
|
|
1679
1684
|
type: "text",
|
|
1680
1685
|
fields: this._indexLogicalPaths(index),
|
|
1681
|
-
isDefault:
|
|
1686
|
+
isDefault: index === ftDefault
|
|
1682
1687
|
});
|
|
1683
1688
|
let firstVector = true;
|
|
1684
1689
|
for (const [field, vec] of this._vectorFields) {
|
|
@@ -1721,18 +1726,38 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
1721
1726
|
_buildSearchWhere(text, query, indexName) {
|
|
1722
1727
|
const fulltextIndex = this._getFulltextIndex(indexName);
|
|
1723
1728
|
if (!fulltextIndex) throw new Error("No FULLTEXT index found for search");
|
|
1724
|
-
const
|
|
1729
|
+
const { text: textFields, integer: integerFields } = splitFulltextFields(fulltextIndex);
|
|
1725
1730
|
const where = buildWhere(query.filter);
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
+
const n = integerFields.length > 0 ? searchTermInteger(text) : void 0;
|
|
1732
|
+
const matchClause = `MATCH(${textFields.map((f) => qi(f.name)).join(", ")}) AGAINST(? IN NATURAL LANGUAGE MODE)`;
|
|
1733
|
+
const withWhere = (clause, params) => ({
|
|
1734
|
+
sql: where.sql === "1=1" ? clause : `${where.sql} AND ${clause}`,
|
|
1735
|
+
params: [...where.params, ...params]
|
|
1736
|
+
});
|
|
1737
|
+
if (n === void 0) return textFields.length === 0 ? withWhere(EMPTY_OR.sql, []) : withWhere(matchClause, [text]);
|
|
1738
|
+
const keys = this._table.primaryKeys.map((key) => qi(this._table.physicalPath(key)));
|
|
1739
|
+
if (keys.length === 0) {
|
|
1740
|
+
const or = orFragment([...textFields.length > 0 ? [matchClause] : [], ...integerFields.map((f) => `${qi(f.name)} = ?`)], [...textFields.length > 0 ? [text] : [], ...integerFields.map(() => n)]);
|
|
1741
|
+
return withWhere(or.sql, or.params);
|
|
1742
|
+
}
|
|
1743
|
+
const table = quoteTableName(this.resolveTableName());
|
|
1744
|
+
const keyList = keys.join(", ");
|
|
1745
|
+
const arms = [];
|
|
1746
|
+
const params = [];
|
|
1747
|
+
if (textFields.length > 0) {
|
|
1748
|
+
arms.push(`SELECT ${keyList} FROM ${table} WHERE ${matchClause}`);
|
|
1749
|
+
params.push(text);
|
|
1750
|
+
}
|
|
1751
|
+
for (const f of integerFields) {
|
|
1752
|
+
arms.push(`SELECT ${keyList} FROM ${table} WHERE ${qi(f.name)} = ?`);
|
|
1753
|
+
params.push(n);
|
|
1754
|
+
}
|
|
1755
|
+
return withWhere(`${keys.length === 1 ? keyList : `(${keyList})`} IN (SELECT ${keyList} FROM (${arms.join(" UNION ")}) AS ${qi("_atscript_search")})`, params);
|
|
1731
1756
|
}
|
|
1732
1757
|
_getFulltextIndex(indexName) {
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1758
|
+
const ftAll = [...this._table.indexes.values()].filter((i) => i.type === "fulltext");
|
|
1759
|
+
if (!indexName) return defaultFulltextIndex(ftAll);
|
|
1760
|
+
return ftAll.find((index) => index.key === indexName);
|
|
1736
1761
|
}
|
|
1737
1762
|
/**
|
|
1738
1763
|
* Detects native VECTOR type support by inspecting the server version.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-mysql",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.150",
|
|
4
4
|
"description": "MySQL adapter for @atscript/db with mysql2 driver support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -41,19 +41,19 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@atscript/core": "^0.1.
|
|
45
|
-
"@atscript/typescript": "^0.1.
|
|
44
|
+
"@atscript/core": "^0.1.101",
|
|
45
|
+
"@atscript/typescript": "^0.1.101",
|
|
46
46
|
"@uniqu/core": "^0.1.13",
|
|
47
47
|
"mysql2": "^3.11.0",
|
|
48
|
-
"unplugin-atscript": "^0.1.
|
|
48
|
+
"unplugin-atscript": "^0.1.101"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@atscript/core": "^0.1.
|
|
52
|
-
"@atscript/typescript": "^0.1.
|
|
51
|
+
"@atscript/core": "^0.1.101",
|
|
52
|
+
"@atscript/typescript": "^0.1.101",
|
|
53
53
|
"@uniqu/core": "^0.1.13",
|
|
54
54
|
"mysql2": ">=3.0.0",
|
|
55
|
-
"@atscript/db": "^0.1.
|
|
56
|
-
"@atscript/db-sql-tools": "^0.1.
|
|
55
|
+
"@atscript/db": "^0.1.150",
|
|
56
|
+
"@atscript/db-sql-tools": "^0.1.150"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
|
59
59
|
"mysql2": {
|