Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leo-connector-postgres

Package Overview
Dependencies
Maintainers
8
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leo-connector-postgres - npm Package Compare versions

Comparing version 4.0.10-beta to 4.0.11-beta

55

lib/dwconnect.js

@@ -135,2 +135,3 @@ 'use strict';

let sortKey;
let sortKeyType;

@@ -145,4 +146,5 @@ tempTables.push(qualifiedStagingTable);

tasks.push(done => {
client.query(`SELECT sortkey
FROM public.mv_dist_sort_key
client.query(`SELECT sortkey,
sortkeytype
FROM public.v_dist_sort_key
WHERE table_name = '${table}';`, (err, results) => {

@@ -154,2 +156,3 @@ if (err) {

sortKey = results[0].sortkey;
sortKeyType = results[0].sortkeytype;
};

@@ -251,3 +254,9 @@ done();

if (naturalKeyLowerBound !== null) {
naturalKeyFilter = (typeof naturalKeyLowerBound === 'string') ? `'${results[0].minid}'` : `${results[0].minid}`
if (sortKeyType === 'int4' || sortKeyType === 'int8') {
naturalKeyFilter = `${results[0].minid}`;
} else if (sortKeyType === 'varchar') {
naturalKeyFilter = `'${results[0].minid}'`;
} else if (sortKeyType === 'timestamp' && Date.parse(results[0].minid.split(' ')[1])) {
naturalKeyFilter = `'${results[0].minid.split(' ')[1]}'`;
};
};

@@ -349,2 +358,3 @@ done();

let sortKey;
let sortKeyType;

@@ -361,4 +371,5 @@ // Prepare staging tables

tasks.push(done => {
client.query(`SELECT sortkey
FROM public.mv_dist_sort_key
client.query(`SELECT sortkey,
sortkeytype
FROM public.v_dist_sort_key
WHERE table_name = '${table}';`, (err, results) => {

@@ -370,2 +381,3 @@ if (err) {

sortKey = results[0].sortkey;
sortKeyType = results[0].sortkeytype;
};

@@ -551,3 +563,9 @@ done();

if (naturalKeyLowerBound !== null) {
naturalKeyFilter = (typeof naturalKeyLowerBound === 'string') ? `'${results[0].minid}'` : `${results[0].minid}`;
if (sortKeyType === 'int4' || sortKeyType === 'int8') {
naturalKeyFilter = `${results[0].minid}`;
} else if (sortKeyType === 'varchar') {
naturalKeyFilter = `'${results[0].minid}'`;
} else if (sortKeyType === 'timestamp' && Date.parse(results[0].minid.split(' ')[1])) {
naturalKeyFilter = `'${results[0].minid.split(' ')[1]}'`;
};
};

@@ -709,12 +727,14 @@ done();

const qualifiedStagingTable = `${columnConfig.stageSchema}.${columnConfig.stageTablePrefix}_${table} `;
const qualifiedStagingTable = `${columnConfig.stageSchema}.${columnConfig.stageTablePrefix}_${table}`;
let naturalKeyLowerBound;
let naturalKeyFilter;
let sortKey;
let sortKeyType;
// Get lower bound for natural key to avoid unnecessary scanning
if (config.version === 'redshift') {
tasks.push(done => {
client.query(`SELECT sortkey
FROM public.mv_dist_sort_key
WHERE table_name = '${table}'; `, (err, results) => {
client.query(`SELECT sortkey,
sortkeytype
FROM public.v_dist_sort_key
WHERE table_name = '${table}';`, (err, results) => {
if (err) {

@@ -725,2 +745,3 @@ return done(err);

sortKey = results[0].sortkey;
sortKeyType = results[0].sortkeytype;
};

@@ -739,3 +760,9 @@ done();

if (naturalKeyLowerBound !== null) {
naturalKeyFilter = (typeof naturalKeyLowerBound === 'string') ? `'${results[0].minid}'` : `${results[0].minid} `
if (sortKeyType === 'int4' || sortKeyType === 'int8') {
naturalKeyFilter = `${results[0].minid}`;
} else if (sortKeyType === 'varchar') {
naturalKeyFilter = `'${results[0].minid}'`;
} else if (sortKeyType === 'timestamp' && Date.parse(results[0].minid.split(' ')[1])) {
naturalKeyFilter = `'${results[0].minid.split(' ')[1]}'`;
};
};

@@ -752,7 +779,7 @@ done();

sets.push(`${link.destination}_date = coalesce(t.${link.source}::date - '1400-01-01'::date + 10000, 1)`);
sets.push(`${link.destination}_time = coalesce(EXTRACT(EPOCH from t.${link.source}::time) + 10000, 1)`);
sets.push(`${link.destination}_time = coalesce(EXTRACT(EPOCH FROM ${(config.version !== 'redshift') ? `` : `'1970-01-01'::date +`} t.${link.source}::time) + 10000, 1)`);
} else if (columnConfig.useSurrogateDateKeys && (link.table === 'd_date' || link.table === 'date' || link.table === 'dim_date')) {
sets.push(`${link.destination}_date = coalesce(t.${link.source}::date - '1400-01-01'::date + 10000, 1)`);
} else if (columnConfig.useSurrogateDateKeys && (link.table === 'd_time' || link.table === 'time' || link.table === 'dim_time')) {
sets.push(`${link.destination}_time = coalesce(EXTRACT(EPOCH from t.${link.source}::time) + 10000, 1)`);
sets.push(`${link.destination}_time = coalesce(EXTRACT(EPOCH FROM ${(config.version !== 'redshift') ? `` : `'1970-01-01'::date +`} t.${link.source}::time) + 10000, 1)`);
} else {

@@ -784,3 +811,3 @@ if (config.hashedSurrogateKeys) {

AND dm.${columnConfig._auditdate} = ${dwClient.auditdate} AND t.${columnConfig._auditdate} = ${dwClient.auditdate}
${(naturalKeyFilter !== undefined) ? `AND t.${(sortKey !== undefined) ? sortKey : nk[0]} >= ${naturalKeyFilter}` : ``} `, done);
${(naturalKeyFilter !== undefined) ? `AND t.${(sortKey !== undefined) ? sortKey : nk[0]} >= ${naturalKeyFilter}` : ``}`, done);
} else {

@@ -787,0 +814,0 @@ done();

{
"name": "leo-connector-postgres",
"version": "4.0.10-beta",
"version": "4.0.11-beta",
"description": "A Postgres database connector for use with Leo Platform",

@@ -44,2 +44,2 @@ "repository": {

}
}
}
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