Updates
This commit is contained in:
parent
9ab5543c5c
commit
57f06a631f
@ -142,12 +142,13 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
|||||||
let countSqls = [];
|
let countSqls = [];
|
||||||
for (let i = 0; i < genObject.countSubQueries.length; i++) {
|
for (let i = 0; i < genObject.countSubQueries.length; i++) {
|
||||||
const countSubQuery = genObject.countSubQueries[i];
|
const countSubQuery = genObject.countSubQueries[i];
|
||||||
|
const tableAlias = countSubQuery.table_alias;
|
||||||
let subQStr = `(SELECT COUNT(*)`;
|
let subQStr = `(SELECT COUNT(*)`;
|
||||||
subQStr += ` FROM ${countSubQuery.table}`;
|
subQStr += ` FROM ${countSubQuery.table}${tableAlias ? ` ${tableAlias}` : ""}`;
|
||||||
subQStr += ` WHERE (`;
|
subQStr += ` WHERE (`;
|
||||||
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
|
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
|
||||||
const csqSrc = countSubQuery.srcTrgMap[j];
|
const csqSrc = countSubQuery.srcTrgMap[j];
|
||||||
subQStr += ` ${countSubQuery.table}.${csqSrc.src}`;
|
subQStr += ` ${tableAlias || countSubQuery.table}.${csqSrc.src}`;
|
||||||
if (typeof csqSrc.trg == "string") {
|
if (typeof csqSrc.trg == "string") {
|
||||||
subQStr += ` = ?`;
|
subQStr += ` = ?`;
|
||||||
sqlSearhValues.push(csqSrc.trg);
|
sqlSearhValues.push(csqSrc.trg);
|
||||||
|
|||||||
2
dist/package-shared/types/index.d.ts
vendored
2
dist/package-shared/types/index.d.ts
vendored
@ -846,6 +846,8 @@ export type ServerQueryParamFullTextSearch<T extends {
|
|||||||
};
|
};
|
||||||
export type ServerQueryParamsCount = {
|
export type ServerQueryParamsCount = {
|
||||||
table: string;
|
table: string;
|
||||||
|
/** Alias for the Table From which the count is fetched */
|
||||||
|
table_alias?: string;
|
||||||
srcTrgMap: {
|
srcTrgMap: {
|
||||||
src: string;
|
src: string;
|
||||||
trg: string | ServerQueryParamsCountSrcTrgMap;
|
trg: string | ServerQueryParamsCountSrcTrgMap;
|
||||||
|
|||||||
@ -205,13 +205,21 @@ export default function sqlGenerator<
|
|||||||
|
|
||||||
for (let i = 0; i < genObject.countSubQueries.length; i++) {
|
for (let i = 0; i < genObject.countSubQueries.length; i++) {
|
||||||
const countSubQuery = genObject.countSubQueries[i];
|
const countSubQuery = genObject.countSubQueries[i];
|
||||||
|
const tableAlias = countSubQuery.table_alias;
|
||||||
|
|
||||||
let subQStr = `(SELECT COUNT(*)`;
|
let subQStr = `(SELECT COUNT(*)`;
|
||||||
subQStr += ` FROM ${countSubQuery.table}`;
|
|
||||||
|
subQStr += ` FROM ${countSubQuery.table}${
|
||||||
|
tableAlias ? ` ${tableAlias}` : ""
|
||||||
|
}`;
|
||||||
|
|
||||||
subQStr += ` WHERE (`;
|
subQStr += ` WHERE (`;
|
||||||
|
|
||||||
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
|
for (let j = 0; j < countSubQuery.srcTrgMap.length; j++) {
|
||||||
const csqSrc = countSubQuery.srcTrgMap[j];
|
const csqSrc = countSubQuery.srcTrgMap[j];
|
||||||
subQStr += ` ${countSubQuery.table}.${csqSrc.src}`;
|
subQStr += ` ${tableAlias || countSubQuery.table}.${
|
||||||
|
csqSrc.src
|
||||||
|
}`;
|
||||||
|
|
||||||
if (typeof csqSrc.trg == "string") {
|
if (typeof csqSrc.trg == "string") {
|
||||||
subQStr += ` = ?`;
|
subQStr += ` = ?`;
|
||||||
|
|||||||
@ -1035,6 +1035,8 @@ export type ServerQueryParamFullTextSearch<
|
|||||||
|
|
||||||
export type ServerQueryParamsCount = {
|
export type ServerQueryParamsCount = {
|
||||||
table: string;
|
table: string;
|
||||||
|
/** Alias for the Table From which the count is fetched */
|
||||||
|
table_alias?: string;
|
||||||
srcTrgMap: {
|
srcTrgMap: {
|
||||||
src: string;
|
src: string;
|
||||||
trg: string | ServerQueryParamsCountSrcTrgMap;
|
trg: string | ServerQueryParamsCountSrcTrgMap;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "5.5.0",
|
"version": "5.5.1",
|
||||||
"description": "Cloud-based SQL data management tool",
|
"description": "Cloud-based SQL data management tool",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user