Update sql gen. Add support for raw sql in joins select and regular select sections
This commit is contained in:
@@ -711,6 +711,10 @@ export type ServerQueryParam<
|
||||
| (keyof T | ServerQueryParamGroupBy<T>)[];
|
||||
countSubQueries?: ServerQueryParamsCount[];
|
||||
fullTextSearch?: ServerQueryParamFullTextSearch<T>;
|
||||
/**
|
||||
* Raw SQL to use as select
|
||||
*/
|
||||
select_sql?: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
@@ -894,6 +898,10 @@ export type ServerQueryParamsJoin<
|
||||
}
|
||||
)[];
|
||||
operator?: (typeof ServerQueryOperators)[number];
|
||||
/**
|
||||
* Raw SQL to use as join select
|
||||
*/
|
||||
select_sql?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -221,7 +221,9 @@ export default function sqlGenerator<
|
||||
let queryString = (() => {
|
||||
let str = "SELECT";
|
||||
|
||||
if (genObject?.selectFields?.[0]) {
|
||||
if (genObject?.select_sql) {
|
||||
str += ` ${genObject.select_sql}`;
|
||||
} else if (genObject?.selectFields?.[0]) {
|
||||
if (genObject.join) {
|
||||
str += ` ${genObject.selectFields
|
||||
?.map((fld) =>
|
||||
@@ -310,7 +312,9 @@ export default function sqlGenerator<
|
||||
return null;
|
||||
existingJoinTableNames.push(joinTableName);
|
||||
|
||||
if (joinObj.selectFields) {
|
||||
if (joinObj.select_sql) {
|
||||
return joinObj.select_sql;
|
||||
} else if (joinObj.selectFields) {
|
||||
return joinObj.selectFields
|
||||
.map((selectField) => {
|
||||
if (typeof selectField == "string") {
|
||||
|
||||
Reference in New Issue
Block a user