fix: parse cnt as int

This commit is contained in:
Nybkox
2025-04-03 22:11:57 +02:00
parent 5af7615054
commit c4a4cd0957

View File

@@ -51,7 +51,8 @@ describe('DB Import/export', () => {
await copyStream(reader, writer); await copyStream(reader, writer);
const res = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`)); const res = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`));
expect(res.rows[0].cnt.toString()).toEqual('6'); const cnt = parseInt(res.rows[0].cnt.toString());
expect(cnt).toEqual(6);
}) })
); );
@@ -75,7 +76,8 @@ describe('DB Import/export', () => {
await copyStream(reader, writer); await copyStream(reader, writer);
const res = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`)); const res = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`));
expect(res.rows[0].cnt.toString()).toEqual('6'); const cnt = parseInt(res.rows[0].cnt.toString());
expect(cnt).toEqual(6);
}) })
); );
@@ -103,10 +105,12 @@ describe('DB Import/export', () => {
await copyStream(reader2, writer2); await copyStream(reader2, writer2);
const res1 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`)); const res1 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`));
expect(res1.rows[0].cnt.toString()).toEqual('6'); const cnt = parseInt(res1.rows[0].cnt.toString());
expect(cnt).toEqual(6);
const res2 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t2`)); const res2 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t2`));
expect(res2.rows[0].cnt.toString()).toEqual('6'); const cnt2 = parseInt(res2.rows[0].cnt.toString());
expect(cnt2).toEqual(6);
}) })
); );
const enginesWithDumpFile = engines.filter(x => x.dumpFile); const enginesWithDumpFile = engines.filter(x => x.dumpFile);
@@ -128,7 +132,8 @@ describe('DB Import/export', () => {
for (const check of engine.dumpChecks || []) { for (const check of engine.dumpChecks || []) {
const res = await driver.query(conn, check.sql); const res = await driver.query(conn, check.sql);
expect(res.rows[0].res.toString()).toEqual(check.res); const cnt = parseInt(res.rows[0].res.toString());
expect(cnt).toEqual(check.res);
} }
// const res1 = await driver.query(conn, `select count(*) as cnt from t1`); // const res1 = await driver.query(conn, `select count(*) as cnt from t1`);
@@ -192,7 +197,8 @@ describe('DB Import/export', () => {
}); });
const res1 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~categories`)); const res1 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~categories`));
expect(res1.rows[0].cnt.toString()).toEqual('4'); const cnt1 = parseInt(res1.rows[0].cnt.toString());
expect(cnt1).toEqual(4);
}) })
); );
}); });