Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function test_table2() {
var table = new sql.Table('#temp_table2');
table.create = true;
([
{ name: 'name', type: { typeName: 'VarChar', length: sql.MAX }, nullable: false },
{ name: 'type', type: { typeName: 'Int' }, nullable: false },
{ name: 'type', type: { typeName: 'Decimal', precision: 7, scale: 2 }, nullable: false }
] as any[])
.forEach((col: sql.IColumn) =>
table.columns.add(col.name, _getSqlType(col.type), { nullable: col.nullable }));
[['name', 42, 3.50], ['name2', 7, 3.14]].forEach((row: sql.IRow) => table.rows.add(...row));
}
function test_table() {
var table = new sql.Table('#temp_table');
table.create = true;
table.columns.add('name', sql.VarChar(sql.MAX), { nullable: false });
table.columns.add('type', sql.Int, { nullable: false });
table.columns.add('amount', sql.Decimal(7, 2), { nullable: false });
table.rows.add('name', 42, 3.50);
table.rows.add('name2', 7, 3.14);
}
useMetrics: function( metrics, namespace ) {
this.metrics = metrics;
this.metricsNamespace = namespace;
}
};
_.each( sql.TYPES, function( val, key ) {
seriate[ key ] = sql.TYPES[ key ];
seriate[ key.toUpperCase() ] = sql.TYPES[ key ];
} );
_.each( sql.ISOLATION_LEVEL, function( val, key ) {
seriate[ key ] = sql.ISOLATION_LEVEL[ key ];
} );
seriate.MAX = sql.MAX;
var api = _.assign( seriate, Monologue );
connections.on( "connected", function( info ) {
api.emit( "connected", info );
} );
connections.on( "closed", function( info ) {
api.emit( "closed", info );
} );
connections.on( "failed", function( info ) {
api.emit( "failed", info );
} );
module.exports = api;
it( "should expose mssql.MAX", function() {
sql.MAX.should.equal( require( "mssql" ).MAX );
} );
SET
jobStatus_id = (
SELECT id
FROM [mtc_admin].[jobStatus]
WHERE jobStatusCode = @jobStatusCode
),
jobOutput=@jobOutput,
errorOutput=@errorOutput
OUTPUT Inserted.id
WHERE urlSlug=@urlSlug`
const request = new mssql.Request(pool)
request.input('urlSlug', mssql.UniqueIdentifier, urlSlug)
request.input('jobStatusCode', mssql.Char(3), jobStatusCode)
request.input('jobOutput', mssql.NVarChar(mssql.MAX), jobOutput)
request.input('errorOutput', mssql.NVarChar(mssql.MAX), errorOutput)
const result = await request.query(sql)
return R.path(['id'], R.head(R.path(['recordset'], result)))
}
module.exports.sqlLoadStagingTable = async (context, pool, censusTable, blobContent) => {
if (!pool) {
await this.initPool(context)
}
const table = new mssql.Table(censusTable)
table.create = true
table.columns.add('id', mssql.Int, { nullable: false, primary: true, identity: true })
table.columns.add('lea', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('estab', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('upn', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('surname', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('forename', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('middlenames', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('gender', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('dob', mssql.NVarChar(mssql.MAX), { nullable: false })
for (let i = 1; i < blobContent.length; i++) {
const row = blobContent[i]
table.rows.add(i, row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8])
}
const request = new mssql.Request(pool)
const result = await request.bulk(table)
return result.rowsAffected
}
const sql = `UPDATE [mtc_admin].[job]
SET
jobStatus_id = (
SELECT id
FROM [mtc_admin].[jobStatus]
WHERE jobStatusCode = @jobStatusCode
),
jobOutput=@jobOutput,
errorOutput=@errorOutput
OUTPUT Inserted.id
WHERE urlSlug=@urlSlug`
const request = new mssql.Request(pool)
request.input('urlSlug', mssql.UniqueIdentifier, urlSlug)
request.input('jobStatusCode', mssql.Char(3), jobStatusCode)
request.input('jobOutput', mssql.NVarChar(mssql.MAX), jobOutput)
request.input('errorOutput', mssql.NVarChar(mssql.MAX), errorOutput)
const result = await request.query(sql)
return R.path(['id'], R.head(R.path(['recordset'], result)))
}
module.exports.sqlLoadStagingTable = async (context, pool, censusTable, blobContent) => {
if (!pool) {
await this.initPool(context)
}
const table = new mssql.Table(censusTable)
table.create = true
table.columns.add('id', mssql.Int, { nullable: false, primary: true, identity: true })
table.columns.add('lea', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('estab', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('upn', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('surname', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('forename', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('middlenames', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('gender', mssql.NVarChar(mssql.MAX), { nullable: false })
table.columns.add('dob', mssql.NVarChar(mssql.MAX), { nullable: false })
for (let i = 1; i < blobContent.length; i++) {
const row = blobContent[i]
table.rows.add(i, row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8])
}
const request = new mssql.Request(pool)
const result = await request.bulk(table)
return result.rowsAffected
}