@ronin/compiler 0.14.9-leo-ron-1099-1-experimental-341 → 0.14.9-leo-ron-1099-1-experimental-343
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/README.md +1 -20
- package/dist/index.d.ts +0 -2
- package/dist/index.js +3 -16
- package/package.json +1 -1
package/README.md
CHANGED
@@ -127,26 +127,7 @@ new Transaction(queries, {
|
|
127
127
|
// Instead of returning an array of parameters for every statement (which allows for
|
128
128
|
// preventing SQL injections), all parameters are inlined directly into the SQL strings.
|
129
129
|
// This option should only be used if the generated SQL will be manually verified.
|
130
|
-
inlineParams: true
|
131
|
-
|
132
|
-
// By default, in the generated SQL statements, the compiler does not alias columns if
|
133
|
-
// multiple different tables with the same column names are being joined. Only the table
|
134
|
-
// names themselves are aliased.
|
135
|
-
//
|
136
|
-
// This ensures the cleanest possible SQL statements in conjunction with the default
|
137
|
-
// behavior of SQL databases, where the result of a statement is a list (array) of
|
138
|
-
// values, which are inherently not prone to conflicts.
|
139
|
-
//
|
140
|
-
// If the driver being used instead returns an object for every row, the driver must
|
141
|
-
// ensure the uniqueness of every key in that object, which means prefixing duplicated
|
142
|
-
// column names with the name of the respective table, if multiple tables are joined
|
143
|
-
// (example for an object key: "table_name.column_name").
|
144
|
-
//
|
145
|
-
// Drivers that return objects for rows offer this behavior as an option that is
|
146
|
-
// usually called "expand columns". If the driver being used does not offer such an
|
147
|
-
// option, you can instead activate the option in the compiler, which results in longer
|
148
|
-
// SQL statements because all column names are aliased.
|
149
|
-
expandColumns: true
|
130
|
+
inlineParams: true
|
150
131
|
});
|
151
132
|
```
|
152
133
|
|
package/dist/index.d.ts
CHANGED
@@ -394,8 +394,6 @@ interface TransactionOptions {
|
|
394
394
|
* separating them out into a dedicated `params` array.
|
395
395
|
*/
|
396
396
|
inlineParams?: boolean;
|
397
|
-
/** Alias column names that are duplicated when joining multiple tables. */
|
398
|
-
expandColumns?: boolean;
|
399
397
|
}
|
400
398
|
declare class Transaction {
|
401
399
|
#private;
|
package/dist/index.js
CHANGED
@@ -424,7 +424,6 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
424
424
|
}
|
425
425
|
return newField;
|
426
426
|
});
|
427
|
-
if (instructions.selecting) options.expandColumns = true;
|
428
427
|
const joinedSelectedFields = [];
|
429
428
|
const joinedColumns = [];
|
430
429
|
if (instructions.including) {
|
@@ -440,7 +439,6 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
440
439
|
const { queryModel, queryInstructions } = splitQuery(symbol2.value);
|
441
440
|
const subQueryModel = getModelBySlug(models, queryModel);
|
442
441
|
isJoining = true;
|
443
|
-
if (queryInstructions?.selecting) options.expandColumns = true;
|
444
442
|
const subSingle = queryModel !== subQueryModel.pluralSlug;
|
445
443
|
if (!model.tableAlias)
|
446
444
|
model.tableAlias = single && !subSingle ? `sub_${model.table}` : model.table;
|
@@ -478,11 +476,7 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
478
476
|
});
|
479
477
|
}
|
480
478
|
}
|
481
|
-
|
482
|
-
const fieldsToExpand = options.expandColumns ? selectedFields : selectedFields.filter(
|
483
|
-
(loadedField) => typeof loadedField.mountedValue !== "undefined"
|
484
|
-
);
|
485
|
-
const extraColumns = fieldsToExpand.map((selectedField) => {
|
479
|
+
const columns = selectedFields.map((selectedField) => {
|
486
480
|
if (selectedField.mountedValue) {
|
487
481
|
return `${selectedField.mountedValue} as "${selectedField.slug}"`;
|
488
482
|
}
|
@@ -494,11 +488,6 @@ var handleSelecting = (models, model, statementParams, single, instructions, opt
|
|
494
488
|
}
|
495
489
|
return fieldSelector;
|
496
490
|
});
|
497
|
-
if (options.expandColumns) {
|
498
|
-
columns = extraColumns;
|
499
|
-
} else if (extraColumns) {
|
500
|
-
columns.push(...extraColumns);
|
501
|
-
}
|
502
491
|
columns.push(...joinedColumns);
|
503
492
|
selectedFields.push(...joinedSelectedFields);
|
504
493
|
return { columns: columns.join(", "), isJoining, selectedFields };
|
@@ -648,8 +637,7 @@ var compileQueryInput = (defaultQuery, models, statementParams, options) => {
|
|
648
637
|
{
|
649
638
|
selecting: instructions?.selecting,
|
650
639
|
including: instructions?.including
|
651
|
-
}
|
652
|
-
options
|
640
|
+
}
|
653
641
|
);
|
654
642
|
let statement = "";
|
655
643
|
switch (queryType) {
|
@@ -1995,8 +1983,7 @@ var Transaction = class {
|
|
1995
1983
|
const { dependencies, main, selectedFields } = compileQueryInput(
|
1996
1984
|
query,
|
1997
1985
|
modelsWithPresets,
|
1998
|
-
options?.inlineParams ? null : []
|
1999
|
-
{ expandColumns: options?.expandColumns }
|
1986
|
+
options?.inlineParams ? null : []
|
2000
1987
|
);
|
2001
1988
|
const preDependencies = dependencies.filter(({ after }) => !after);
|
2002
1989
|
const postDependencies = dependencies.map(({ after, ...rest }) => after ? rest : null).filter((item) => item != null);
|
package/package.json
CHANGED