Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
params.push({
name: column,
value,
type: R.prop(findDataType(cacheData.dataType), sqlService.TYPES),
options
})
}
return params
}
/** SQL Service **/
const sqlService = {
// SQL type-mapping adapter. Add new types as required.
TYPES: {
BigInt: mssql.BigInt,
Bit: mssql.Bit,
Char: mssql.Char,
DateTimeOffset: mssql.DateTimeOffset,
DateTime: mssql.DateTime,
DateTime2: mssql.DateTime2,
Decimal: mssql.Decimal,
Float: mssql.Float,
Int: mssql.Int,
Numeric: mssql.Numeric,
NVarChar: mssql.NVarChar,
Real: mssql.Real,
SmallInt: mssql.SmallInt,
UniqueIdentifier: mssql.UniqueIdentifier
}
}
// Name of the admin database
params.push({
name: column,
value,
type: R.prop(findDataType(cacheData.dataType), sqlService.TYPES),
options
})
}
return params
}
/** SQL Service **/
const sqlService = {
// SQL type-mapping adapter. Add new types as required.
TYPES: {
BigInt: mssql.BigInt,
Bit: mssql.Bit,
Char: mssql.Char,
DateTimeOffset: mssql.DateTimeOffset,
Decimal: mssql.Decimal,
Float: mssql.Float,
Int: mssql.Int,
Numeric: mssql.Numeric,
NVarChar: mssql.NVarChar,
Real: mssql.Real,
SmallInt: mssql.SmallInt,
UniqueIdentifier: mssql.UniqueIdentifier
}
}
// Name of the admin database
sqlService.adminSchema = '[mtc_admin]'
var context = getContext(function(err) {
context.execQuery(sql, function(err, records) {
if (err) console.log('sql error', err);
(err === null).should.be.true;
records.length.should.be.above(0);
_.forEach(records, function(record) {
record.object_id.should.be.above(0);
});
}, [{
usertable: {
value: 'USER_TABLE'
}
}, {
mss: {
sqlType: nodemssql.Bit,
value: true
}
}]);
});
});
var context = getContext(function(err) {
context.execPrepared(sql, function(err, records) {
if (err) console.log('sql error', err);
(err === null).should.be.true;
records.length.should.be.above(0);
_.forEach(records, function(record) {
record.object_id.should.be.above(0);
});
}, [{
usertable: {
sqlType: nodemssql.NVarChar,
value: 'USER_TABLE'
}
}, {
mss: {
sqlType: nodemssql.Bit,
value: true
}
}]);
});
});
} else if (name === 'stop_times') {
table.columns.add('trip_id', sql.VarChar(100), {nullable: false})
table.columns.add('arrival_time', sql.Time(0), {nullable: false})
table.columns.add('departure_time', sql.Time(0), {nullable: false})
table.columns.add('arrival_time_24', sql.Bit, {nullable: false})
table.columns.add('departure_time_24', sql.Bit, {nullable: false})
table.columns.add('stop_id', sql.VarChar(50), {nullable: false})
table.columns.add('stop_sequence', sql.Int, {nullable: false})
table.columns.add('stop_headsign', sql.VarChar(50), {nullable: true})
table.columns.add('pickup_type', sql.Int, {nullable: true})
table.columns.add('drop_off_type', sql.Int, {nullable: true})
table.columns.add('shape_dist_traveled', sql.VarChar(50), {nullable: true})
table.columns.add('timepoint', sql.Int, {nullable: true})
} else if (name === 'calendar') {
table.columns.add('service_id', sql.VarChar(100), {nullable: false})
table.columns.add('monday', sql.Bit, {nullable: false})
table.columns.add('tuesday', sql.Bit, {nullable: false})
table.columns.add('wednesday', sql.Bit, {nullable: false})
table.columns.add('thursday', sql.Bit, {nullable: false})
table.columns.add('friday', sql.Bit, {nullable: false})
table.columns.add('saturday', sql.Bit, {nullable: false})
table.columns.add('sunday', sql.Bit, {nullable: false})
table.columns.add('start_date', sql.Date, {nullable: false})
table.columns.add('end_date', sql.Date, {nullable: false})
} else if (name === 'calendar_dates') {
table.columns.add('service_id', sql.VarChar(100), {nullable: false})
table.columns.add('date', sql.Date, {nullable: false})
table.columns.add('exception_type', sql.Int, {nullable: false})
} else {
return null
}
return table
request.input(param.name, database.Float, value);
break;
case 'bigint':
request.input(param.name, database.BigInt, value);
break;
case 'smallint':
case 'byte':
request.input(param.name, database.SmallInt, value);
break;
case 'string':
case 'nvarchar':
request.input(param.name, database.NVarChar, value);
break;
case 'boolean':
case 'bit':
request.input(param.name, database.Bit, value);
break;
case 'datetime':
request.input(param.name, database.DateTime, value);
break;
case 'smalldatetime':
request.input(param.name, database.SmallDateTime, value);
break;
case 'binary':
request.input(param.name, database.Binary, value);
break;
case 'image':
request.input(param.name, database.Image, value);
break;
case 'varbinary':
request.input(param.name, database.VarBinary, value);
break;
const column = mssql.column || code;
let type = mssql.type, options = mssql.options;
if (!type) {
const jstype = _.keys(value) && _.keys(value).length > 0 ? value.type : value;
switch (jstype) {
case String:
type = sql.NVarChar(255);
break;
case Number:
type = sql.NVarChar(255);
break;
case Date:
type = sql.DateTime;
break;
case Boolean:
type = sql.Bit;
break;
default:
type = sql.NVarChar(255);
break;
}
if (['textarea', 'editor'].indexOf(value.ctrltype) != -1) type = sql.NVarChar(4000);
}
if (!options || !_.keys(options) || _.keys(options).length == 0) options = {nullable: (value.required ? false : true)};
table.columns.add(column, type, options);
});
let primaryKey = '';
table.columns.add('route_id', sql.VarChar(100), {nullable: false})
table.columns.add('service_id', sql.VarChar(100), {nullable: false})
table.columns.add('trip_id', sql.VarChar(100), {nullable: false})
table.columns.add('trip_headsign', sql.VarChar(100), {nullable: true})
table.columns.add('trip_short_name', sql.VarChar(50), {nullable: true})
table.columns.add('direction_id', sql.Int, {nullable: true})
table.columns.add('block_id', sql.VarChar(100), {nullable: true})
table.columns.add('shape_id', sql.VarChar(100), {nullable: true})
table.columns.add('wheelchair_accessible', sql.Int, {nullable: true})
table.columns.add('bikes_allowed', sql.Int, {nullable: true})
} else if (name === 'stop_times') {
table.columns.add('trip_id', sql.VarChar(100), {nullable: false})
table.columns.add('arrival_time', sql.Time(0), {nullable: false})
table.columns.add('departure_time', sql.Time(0), {nullable: false})
table.columns.add('arrival_time_24', sql.Bit, {nullable: false})
table.columns.add('departure_time_24', sql.Bit, {nullable: false})
table.columns.add('stop_id', sql.VarChar(50), {nullable: false})
table.columns.add('stop_sequence', sql.Int, {nullable: false})
table.columns.add('stop_headsign', sql.VarChar(50), {nullable: true})
table.columns.add('pickup_type', sql.Int, {nullable: true})
table.columns.add('drop_off_type', sql.Int, {nullable: true})
table.columns.add('shape_dist_traveled', sql.VarChar(50), {nullable: true})
table.columns.add('timepoint', sql.Int, {nullable: true})
} else if (name === 'calendar') {
table.columns.add('service_id', sql.VarChar(100), {nullable: false})
table.columns.add('monday', sql.Bit, {nullable: false})
table.columns.add('tuesday', sql.Bit, {nullable: false})
table.columns.add('wednesday', sql.Bit, {nullable: false})
table.columns.add('thursday', sql.Bit, {nullable: false})
table.columns.add('friday', sql.Bit, {nullable: false})
table.columns.add('saturday', sql.Bit, {nullable: false})
table.columns.add('sunday', sql.Bit, {nullable: false})
request.input(param.name, database.Float, value);
break;
case 'bigint':
request.input(param.name, database.BigInt, value);
break;
case 'smallint':
case 'byte':
request.input(param.name, database.SmallInt, value);
break;
case 'string':
case 'nvarchar':
request.input(param.name, database.NVarChar, value);
break;
case 'boolean':
case 'bit':
request.input(param.name, database.Bit, value);
break;
case 'datetime':
request.input(param.name, database.DateTime, value);
break;
case 'smalldatetime':
request.input(param.name, database.SmallDateTime, value);
break;
case 'binary':
request.input(param.name, database.Binary, value);
break;
case 'image':
request.input(param.name, database.Image, value);
break;
case 'varbinary':
request.input(param.name, database.VarBinary, value);
break;