Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
sqlService.adminSchema = '[mtc_admin]'
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]'
sqlService.initPool = async () => {
if (pool) {
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
sqlService.adminSchema = '[mtc_admin]'
test('datetime is stored with hundred millisecond accuracy', async () => {
const isoDateTimeValue = '2000-01-01T15:00:00.123'
const dateToModify = new Date(isoDateTimeValue)
const sql = `UPDATE mtc_admin.[attendanceCode] SET createdAt=@createdAt
WHERE code=@code`
const params = [
{
name: 'createdAt',
type: mssql.DateTimeOffset,
value: dateToModify
},
{
name: 'code',
type: mssql.Char,
value: 'ABSNT'
}
]
await sut.modify(sql, params)
const result = await sut.query(`SELECT createdAt FROM
mtc_admin.attendanceCode WHERE code='ABSNT'`)
expect(result).toBeDefined()
const record = result[0]
expect(record.createdAt).toBeDefined()
expect(isMoment(record.createdAt)).toBe(true)
const dbValueAsMoment = moment(record.createdAt)