Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.template = function () {
let values;
const fields = record.fields.map(pgp.as.name).join(',');
if (concat) {
values = '$1';
} else {
values = `(${this.namedTemplate()})`;
}
// TODO: https://trello.com/c/D3iBP5UZ/220-remove-on-conflict-do-nothing-from-inserts-function
return pgp.as.format('INSERT INTO $1~($2^) VALUES $3^ ON CONFLICT DO NOTHING', [record.table, fields, values]);
};
this.template = function () {
let values;
const fields = record.fields.map(pgp.as.name).join(',');
if (concat) {
values = '$1';
} else {
values = `(${this.namedTemplate()})`;
}
// TODO: https://trello.com/c/D3iBP5UZ/220-remove-on-conflict-do-nothing-from-inserts-function
return pgp.as.format('INSERT INTO $1~($2^) VALUES $3^ ON CONFLICT DO NOTHING', [record.table, fields, values]);
};
any(q, p) {
return PG.as.format(q, p);
}
function getPrimaryKeyColumnName({host, guest, escaped}) {
const rawName = `${host.name}_${guest.name}_pkey`;
return escaped ? pgp.as.name(rawName) : rawName;
}
this.template = function () {
var values;
var fields = record.fields.map(pgp.as.name).join(',');
if (concat) {
values = '$1^';
} else {
values = '(' + this.namedTemplate() + ')';
}
return pgp.as.format('INSERT INTO $1~($2^) VALUES $3^', [record.table, fields, values]);
};
addresses.map((address) => pgp.as.format('($1)', address)).join(', ')
);
const props = _.keys(_data).map(k => pgp.as.name(k)).join();
const values = _.values(_data);
'(CASE WHEN producedblocks + missedblocks = 0 THEN 0.00 ELSE',
'ROUND(100 - (missedblocks::numeric / (producedblocks + missedblocks) * 100), 2)',
'END)::float AS productivity,',
'COALESCE(v.voters_cnt, 0) AS voters_cnt,',
't.timestamp AS register_timestamp',
'FROM delegates d',
'LEFT JOIN mem_accounts m ON d.username = m.username',
'LEFT JOIN trs t ON d."transactionId" = t.id',
'LEFT JOIN (SELECT "dependentId", COUNT(1)::int AS voters_cnt from mem_accounts2delegates GROUP BY "dependentId") v ON v."dependentId" = ENCODE(m."publicKey", \'hex\')',
'WHERE m."isDelegate" = 1',
'ORDER BY ' + [params.sortField, params.sortMethod].join(' ') + ')',
'SELECT * FROM delegates WHERE username LIKE ${q} LIMIT ${limit}'
].join(' ');
params.q = '%' + String(params.q).toLowerCase() + '%';
return pgp.as.format(sql, params);
},
var queries = sqles.concat(round).map(function (sql) {
return pgp.as.format(sql.query, sql.values);
}).join('');
public static createBulkAccountsSQL(addresses: string[]) {
if (!addresses) {
return '';
}
addresses = addresses.filter((addr) => addr);
if (addresses.length === 0) {
return '';
}
return pgp.as.format(
`
INSERT into mem_accounts(address)
SELECT address from (VALUES $1:raw ) i (address)
LEFT JOIN mem_accounts m1 USING(address)
WHERE m1.address IS NULL`,
addresses.map((address) => pgp.as.format('($1)', address)).join(', ')
);
}
}