Updates
This commit is contained in:
@@ -348,15 +348,16 @@ export default function sqlGenerator<
|
||||
return genSqlSrchStr({ queryObj, field, join: genObject?.join });
|
||||
});
|
||||
|
||||
if (sqlSearhString?.[0] && sqlSearhString.find((str) => str)) {
|
||||
const isSearchStr =
|
||||
sqlSearhString?.[0] && sqlSearhString.find((str) => str);
|
||||
|
||||
if (isSearchStr) {
|
||||
const stringOperator = genObject?.searchOperator || "AND";
|
||||
queryString += ` WHERE ${sqlSearhString.join(` ${stringOperator} `)}`;
|
||||
} else if (
|
||||
genObject?.fullTextSearch &&
|
||||
fullTextSearchStr &&
|
||||
fullTextMatchStr
|
||||
) {
|
||||
queryString += ` WHERE ${fullTextMatchStr}`;
|
||||
}
|
||||
|
||||
if (genObject?.fullTextSearch && fullTextSearchStr && fullTextMatchStr) {
|
||||
queryString += `${isSearchStr ? " AND" : " WHERE"} ${fullTextMatchStr}`;
|
||||
sqlSearhValues.push(fullTextSearchStr);
|
||||
}
|
||||
|
||||
@@ -367,14 +368,23 @@ export default function sqlGenerator<
|
||||
}
|
||||
|
||||
if (genObject?.order && !count) {
|
||||
queryString += ` ORDER BY ${
|
||||
genObject?.fullTextSearch &&
|
||||
genObject.fullTextSearch.scoreAlias == genObject.order.field
|
||||
? `${genObject.fullTextSearch.scoreAlias}`
|
||||
: genObject.join
|
||||
? `${finalDbName}${tableName}.${String(genObject.order.field)}`
|
||||
: String(genObject.order.field)
|
||||
} ${genObject.order.strategy}`;
|
||||
let orderFields = [];
|
||||
|
||||
let orderSrt = ` ORDER BY`;
|
||||
|
||||
if (genObject?.fullTextSearch && genObject.fullTextSearch.scoreAlias) {
|
||||
orderFields.push(genObject.fullTextSearch.scoreAlias);
|
||||
} else if (genObject.join) {
|
||||
orderFields.push(
|
||||
`${finalDbName}${tableName}.${String(genObject.order.field)})}`
|
||||
);
|
||||
} else {
|
||||
orderFields.push(genObject.order.field);
|
||||
}
|
||||
|
||||
orderSrt += ` ${orderFields.join(", ")} ${genObject.order.strategy}`;
|
||||
|
||||
queryString += ` ${orderSrt}`;
|
||||
}
|
||||
|
||||
if (genObject?.limit && !count) queryString += ` LIMIT ${genObject.limit}`;
|
||||
|
||||
Reference in New Issue
Block a user