Updates
This commit is contained in:
parent
a68e42beab
commit
0e44676226
@ -101,6 +101,19 @@ function sqlGenerator({ tableName, genObject, dbFullName, count }) {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
function generateJoinStr(mtch, join) {
|
function generateJoinStr(mtch, join) {
|
||||||
|
if (mtch.__batch) {
|
||||||
|
let btch_mtch = ``;
|
||||||
|
btch_mtch += `(`;
|
||||||
|
for (let i = 0; i < mtch.__batch.matches.length; i++) {
|
||||||
|
const __mtch = mtch.__batch.matches[i];
|
||||||
|
btch_mtch += `${generateJoinStr(__mtch, join)}`;
|
||||||
|
if (i < mtch.__batch.matches.length - 1) {
|
||||||
|
btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
btch_mtch += `)`;
|
||||||
|
return btch_mtch;
|
||||||
|
}
|
||||||
return `${finalDbName}${typeof mtch.source == "object" ? mtch.source.tableName : tableName}.${typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source}=${(() => {
|
return `${finalDbName}${typeof mtch.source == "object" ? mtch.source.tableName : tableName}.${typeof mtch.source == "object" ? mtch.source.fieldName : mtch.source}=${(() => {
|
||||||
if (mtch.targetLiteral) {
|
if (mtch.targetLiteral) {
|
||||||
return `'${mtch.targetLiteral}'`;
|
return `'${mtch.targetLiteral}'`;
|
||||||
|
|||||||
6
dist/package-shared/types/index.d.ts
vendored
6
dist/package-shared/types/index.d.ts
vendored
@ -1039,11 +1039,15 @@ export type ServerQueryParamsJoinMatchObject<Field extends object = {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}> = {
|
}> = {
|
||||||
/** Field name from the **Root Table** */
|
/** Field name from the **Root Table** */
|
||||||
source: string | ServerQueryParamsJoinMatchSourceTargetObject;
|
source?: string | ServerQueryParamsJoinMatchSourceTargetObject;
|
||||||
/** Field name from the **Join Table** */
|
/** Field name from the **Join Table** */
|
||||||
target?: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject;
|
target?: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject;
|
||||||
/** A literal value: No source and target Needed! */
|
/** A literal value: No source and target Needed! */
|
||||||
targetLiteral?: string;
|
targetLiteral?: string;
|
||||||
|
__batch?: {
|
||||||
|
matches: Omit<ServerQueryParamsJoinMatchObject<Field>, "__batch">[];
|
||||||
|
operator: "AND" | "OR";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
export type ServerQueryParamsJoinMatchSourceTargetObject = {
|
export type ServerQueryParamsJoinMatchSourceTargetObject = {
|
||||||
tableName: string;
|
tableName: string;
|
||||||
|
|||||||
@ -146,6 +146,23 @@ export default function sqlGenerator<
|
|||||||
mtch: ServerQueryParamsJoinMatchObject,
|
mtch: ServerQueryParamsJoinMatchObject,
|
||||||
join: ServerQueryParamsJoin,
|
join: ServerQueryParamsJoin,
|
||||||
) {
|
) {
|
||||||
|
if (mtch.__batch) {
|
||||||
|
let btch_mtch = ``;
|
||||||
|
btch_mtch += `(`;
|
||||||
|
|
||||||
|
for (let i = 0; i < mtch.__batch.matches.length; i++) {
|
||||||
|
const __mtch = mtch.__batch.matches[i];
|
||||||
|
btch_mtch += `${generateJoinStr(__mtch, join)}`;
|
||||||
|
if (i < mtch.__batch.matches.length - 1) {
|
||||||
|
btch_mtch += ` ${mtch.__batch.operator || "OR"} `;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
btch_mtch += `)`;
|
||||||
|
|
||||||
|
return btch_mtch;
|
||||||
|
}
|
||||||
|
|
||||||
return `${finalDbName}${
|
return `${finalDbName}${
|
||||||
typeof mtch.source == "object" ? mtch.source.tableName : tableName
|
typeof mtch.source == "object" ? mtch.source.tableName : tableName
|
||||||
}.${
|
}.${
|
||||||
|
|||||||
@ -1258,11 +1258,15 @@ export type ServerQueryParamsJoinMatchObject<
|
|||||||
Field extends object = { [key: string]: any },
|
Field extends object = { [key: string]: any },
|
||||||
> = {
|
> = {
|
||||||
/** Field name from the **Root Table** */
|
/** Field name from the **Root Table** */
|
||||||
source: string | ServerQueryParamsJoinMatchSourceTargetObject;
|
source?: string | ServerQueryParamsJoinMatchSourceTargetObject;
|
||||||
/** Field name from the **Join Table** */
|
/** Field name from the **Join Table** */
|
||||||
target?: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject;
|
target?: keyof Field | ServerQueryParamsJoinMatchSourceTargetObject;
|
||||||
/** A literal value: No source and target Needed! */
|
/** A literal value: No source and target Needed! */
|
||||||
targetLiteral?: string;
|
targetLiteral?: string;
|
||||||
|
__batch?: {
|
||||||
|
matches: Omit<ServerQueryParamsJoinMatchObject<Field>, "__batch">[];
|
||||||
|
operator: "AND" | "OR";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ServerQueryParamsJoinMatchSourceTargetObject = {
|
export type ServerQueryParamsJoinMatchSourceTargetObject = {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/datasquirel",
|
"name": "@moduletrace/datasquirel",
|
||||||
"version": "5.7.55",
|
"version": "5.7.56",
|
||||||
"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