I'm working with a legacy SQL Server dtabase that stores dates NOT in UTC format. I'm trying to insert a smalldatetime
using TypeORM.
This is what TypeORM executes:
INSERT INTO foo(date) VALUES (@0)
-- PARAMS: SELECT * FROM @OutputTable -- PARAMETERS: [{"value":"2020-11-09T23:00:00.000Z","type":"smalldatetime","params":[]}]
This should save '2020-11-10 00:00:00' in DB (GMT +1, server also GMT +1) but, for some reason, is saving '2020-11-09 00:00:00'. I think when the result date that TypeORM tries to insert is 00:00:00 it doesn't change the day. I've tried with other timestamps and, as long as it's greater or equal 00:01:00 it works
- Operating System: Windows
- Node.js: v12.16.2
- Typescript: v4.0.3
- TypeORM: v0.2.28
UPDATE:
According to this thread: https://github.com/typeorm/typeorm/issues/3202 it probably has something to do with tedious
version. Now problem is when I tried to update mssql 7.0.0-alpha.1
version (in order to update tedious
) typeorm can't connect:
const serverSql: SqlServerConnectionOptions = {
name: process.env.DB_SQL_DEFAULT_NAME,
entities: [`${__dirname}/../../schemas/**/*.js`],
type: 'mssql',
host: process.env.DB_SQL_DEFAULT_HOST,
port: Number(process.env.DB_SQL_DEFAULT_PORT),
username: process.env.DB_SQL_DEFAULT_USER,
password: process.env.DB_SQL_DEFAULT_PASSWORD,
requestTimeout: 30000,
options: {
connectionIsolationLevel: 'READ_UNCOMMITTED',
isolation: 'READ_UNCOMMITTED',
enableArithAbort: false
},
pool: {
acquireTimeoutMillis: 30000
},
logging: 'all'
};
await createConnections([serverSql]);
Throws this error: Connection error: The "config.options.connectionIsolationLevel" property must be of type number. Received type string (READ_UNCOMMITTED)