Repository navigation
fix(cockroachdb): adjust join in loadTables to load correct table columns - #12413
Conversation
commit: |
Code Review by Qodo
1.
|
|
Persistent review updated to latest commit cd9c44a |
|
Persistent review updated to latest commit 59132d0 |
|
Persistent review updated to latest commit 6e87dfd |
| sqlInMemory.upQueries.length.should.be.equal(0) | ||
| sqlInMemory.downQueries.length.should.be.equal(0) |
There was a problem hiding this comment.
Whenever we have console.log in tests, we are trying to figure out why an assertion is not working. This can always be solved by introducing better assertions, e.g.: expect(array).to.have.length(0) (or lengthOf?) would also log the array values if the expectation is not met ;)
| @@ -24,25 +24,30 @@ describe("multi-schema-and-database > custom-junction-schema", () => { | |||
| Promise.all( | |||
| dataSources.map(async (dataSource) => { | |||
| const queryRunner = dataSource.createQueryRunner() | |||
There was a problem hiding this comment.
Instead of adding try-finally and introducing another level of indentation:
| const queryRunner = dataSource.createQueryRunner() | |
| await using queryRunner = dataSource.createQueryRunner() |
Same can be done in the other tests.
|
Persistent review updated to latest commit 95b1aa9 |
| expect(table.database).to.be.equal("testDB") | ||
| expect(table.schema).to.be.equal("questions") | ||
| expect(table.name).to.be.equal("testDB.questions.question") | ||
| expect(table!.database).to.equal("testDB") |
There was a problem hiding this comment.
nit (no need to change unless there's another change): this is an unnecessary change. we are now making this assertion 3 times instead of only one (before). In tests, we often know that the table exists, so we place the assertion when we read the table.
| describe("custom-table-schema", () => { | ||
| const drivers: DatabaseType[][] = [ | ||
| // SAP throws error during connection if schema specified in connection options does not exist. | ||
| // only testing custom schema specified in Entity decorator | ||
| ["sap"], | ||
| ["mssql", "postgres", "cockroachdb"], | ||
| ] | ||
| for (const driver of drivers) { |
There was a problem hiding this comment.
I'm not sure what are we trying to test here, but we don't have this test structure usually. Additionally, the schema should exist before connecting to the database.
These new tests could be simplified a lot
There was a problem hiding this comment.
SAP HANA has a currentSchema option in the @sap-client package, which is passed if defined in DataSourceOptions.schema, which throws errors. Other drivers in the tests don't have this. Schemas are created beforehand using the logic in test-utils.ts
I will try to simplify this.
There was a problem hiding this comment.
Yeah, we pass DataSourceOptions.schema to the client, which is fine, because the schema that you pass to the client should exist. It's simpler than executing a query to change the schema every time you create a QueryRunner. I only changed it like that for the SAP driver since I'm more familiar with it, but you can make that assumption for all drivers.
…nce test coverage for custom schemas
95b1aa9 to
9837a59
Compare
9298386 to
8b74705
Compare
|
@Cprakhar FYI cherry picking to 0.3 would not be possible for tests (since they use |
…umns (#12413) Co-authored-by: Lucian Mocanu <[email protected]> (cherry picked from commit df09802)
…umns (#12413) Co-authored-by: Lucian Mocanu <[email protected]> (cherry picked from commit df09802)
…umns (#12413) Co-authored-by: Lucian Mocanu <[email protected]> (cherry picked from commit df09802)
Description of change
database-schema/enums/enums.test.ts.persistence/persistence-order/persistence-order.test.ts.SELECT * FROM "${database}"."sys"."schema"-"sys"."schema"->"sys"."schemas". (SqlServerQueryRunner.ts)columnsSqlquery in CockroachDB loadTables to query correct columns from the schema and table.Why: Let's say we have two tables,
public.postandcustom.post, both havingnameas a column. WithcolumnsSql, it was returning two columnsnamefor the tablepublic.post.Pull-Request Checklist
masterbranchFixes #00000tests/**.test.ts)docs/docs/**.md) (N/A)