New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fxjs/sql-query

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fxjs/sql-query - npm Package Compare versions

Comparing version 0.9.3-alpha.0 to 0.9.3-alpha.2

27

lib/Select.js

@@ -65,7 +65,9 @@ Object.defineProperty(exports, "__esModule", { value: true });

const from_select_arr = this.sql.from[idx].select;
var idx2 = from_select_arr.length - 1;
if (typeof from_select_arr[idx2] == "string") {
from_select_arr[idx2] = { column_name: from_select_arr[idx2] };
const idx2 = from_select_arr.length - 1;
if (typeof from_select_arr[idx2] === "string") {
from_select_arr[idx2] = {
column_name: from_select_arr[idx2]
};
}
from_select_arr[from_select_arr.length - 1].as = _as || null;
from_select_arr[idx2].as = _as || null;
}

@@ -258,9 +260,10 @@ return this;

const tableAliasMap = {};
for (let i = 0; i < sql_from.length; i++) {
const from_len = sql_from.length;
for (let i = 0; i < from_len; i++) {
sql_from[i].alias = Helpers.pickAliasFromFromDescriptor(sql_from[i]) || Helpers.defaultTableAliasNameRule(i + 1);
tableAliasMap[`${sql_from[i].alias}`] = `${sql_from[i].table}`;
}
const single_query = sql_from.length === 1;
const single_query = from_len === 1;
const sqlBuilder = this.Dialect.knex(tableAliasMap);
for (let i = 0; i < sql_from.length; i++) {
for (let i = 0; i < from_len; i++) {
if (!sql_from[i].select)

@@ -282,3 +285,3 @@ continue;

sql_from_item,
having
{ having, from_len }
]);

@@ -430,3 +433,3 @@ if (should_continue)

}
function buildObjectTypeSelectItem(knexSqlBuilder, sql_select_obj, single_query, sql_from_item, having) {
function buildObjectTypeSelectItem(knexSqlBuilder, sql_select_obj, single_query, sql_from_item, __helper_info) {
const alias = Helpers.pickAliasFromFromDescriptor(sql_from_item);

@@ -438,9 +441,11 @@ const return_wrapper = {

if (!sql_select_obj.func_name && sql_select_obj.column_name) {
// TODO: use better normalization for whole sql_select_obj
const col_name = sql_select_obj.column_name;
const col_id = __helper_info.from_len > 1 ? `${alias}.${col_name}` : col_name;
const _as = Helpers.pickColumnAsFromSelectFieldsDescriptor(sql_select_obj);
if (_as) {
knexSqlBuilder.select(this.Dialect.knex.ref(col_name).as(_as));
knexSqlBuilder.select(this.Dialect.knex.ref(col_id).as(_as));
}
else {
knexSqlBuilder.select(col_name);
knexSqlBuilder.select(col_id);
}

@@ -447,0 +452,0 @@ }

@@ -57,9 +57,42 @@ import { FxSqlAggregation } from "./Aggregation";

interface SqlSelectFieldItemDescriptor {
/**
* @description fun name
*/
func_name?: string;
/**
* @description column name
* expect NO table prefix
*
* ```
* recommended: `col`
* ```
*
* but this allowed also
*
* ```
* allowed also: `table.col`
* ````
*
*/
column_name?: SqlColumnType;
/**
* @description column as
*/
as?: FxSqlQuerySql.NormalizedSimpleSqlColumnType;
a?: SqlSelectFieldItemDescriptor['as'];
/**
* @description fun_stack
*/
func_stack?: FxSqlAggregation.SupportedAggregationFunction[];
/**
* @description pure sql
*/
sql?: string;
/**
* @description GUESS: useful when this object refer to one complex descriptor?
*/
select?: string;
/**
* @description having sub query statement
*/
having?: string;

@@ -66,0 +99,0 @@ }

{
"name": "@fxjs/sql-query",
"version": "0.9.3-alpha.0",
"version": "0.9.3-alpha.2+ae583e3",
"private": false,

@@ -44,3 +44,3 @@ "description": "",

},
"gitHead": "34ef694b334be3f4af278b2ed3ce32f2008117ce"
"gitHead": "ae583e39d542449e640da9b05979592cb0cf5169"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc