Skip to content

Commit 295b870

Browse files
committed
fix defect
1 parent 499278f commit 295b870

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

packages/extension-driver-canner/src/lib/cannerAdapter.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ export class CannerAdapter {
3636
headers?: Record<string, string>
3737
): Promise<string[]> {
3838
this.logger.debug(`Create async request to Canner.`);
39-
let data = await this.getWorkspaceRequestData('post', '/v2/async-queries', {
40-
data: {
41-
sql,
42-
timeout: 600,
43-
noLimit: true,
39+
let data = await this.getWorkspaceRequestData(
40+
'post',
41+
'/v2/async-queries',
42+
{
43+
data: {
44+
sql,
45+
timeout: 600,
46+
noLimit: true,
47+
},
4448
},
45-
headers,
46-
});
49+
headers
50+
);
4751

4852
const { id: requestId } = data;
4953
this.logger.debug(`Wait Async request to finished.`);
@@ -70,10 +74,7 @@ export class CannerAdapter {
7074
await this.prepare();
7175
try {
7276
const response = await axios({
73-
headers: {
74-
...headers,
75-
Authorization: `Token ${this.PAT}`,
76-
},
77+
headers: { ...headers, Authorization: `Token ${this.PAT}` },
7778
params: {
7879
workspaceSqlName: this.workspaceSqlName,
7980
},
@@ -84,7 +85,9 @@ export class CannerAdapter {
8485
return response.data;
8586
} catch (error: any) {
8687
const message = error.response
87-
? `response status: ${error.response.status}, response data: ${error.response.data}`
88+
? `response status: ${
89+
error.response.status
90+
}, response data: ${JSON.stringify(error.response.data)}`
8891
: `remote server does not response. request ${error.toJSON()}}`;
8992
throw new InternalError(
9093
`Failed to get workspace request "${urlPath}" data, ${message}`

packages/extension-driver-canner/src/lib/cannerDataSource.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class CannerDataSource extends DataSource<any, PGOptions> {
6262
sql,
6363
directory,
6464
profileName,
65-
options: cannerpOtions,
65+
options: cannerOptions,
6666
}: ExportOptions): Promise<void> {
6767
if (!this.poolMapping.has(profileName)) {
6868
throw new InternalError(`Profile instance ${profileName} not found`);
@@ -76,7 +76,7 @@ export class CannerDataSource extends DataSource<any, PGOptions> {
7676
const cannerAdapter = new CannerAdapter(connection);
7777
try {
7878
this.logger.debug('Send the async query to the Canner Enterprise');
79-
const header = this.getCannerRequestHeader(properties, cannerpOtions);
79+
const header = this.getCannerRequestHeader(properties, cannerOptions);
8080
const presignedUrls = await cannerAdapter.createAsyncQueryResultUrls(
8181
sql,
8282
header
@@ -96,7 +96,7 @@ export class CannerDataSource extends DataSource<any, PGOptions> {
9696
cannerOptions?: any
9797
) {
9898
const header: Record<string, string> = {};
99-
const { userId } = cannerOptions;
99+
const userId = cannerOptions?.userId;
100100
const rootUserId = properties?.['rootUserId'];
101101
if (userId && rootUserId) {
102102
header[

packages/extension-driver-canner/test/cannerDataSource.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ it('Data source should export successfully', async () => {
5555
sql: 'select 1',
5656
directory,
5757
profileName: 'profile1',
58+
options: {},
5859
} as ExportOptions)
5960
).resolves.not.toThrow();
6061
expect(fs.readdirSync(directory).length).toBe(1);
@@ -86,6 +87,7 @@ it('Data source should throw error when fail to export data', async () => {
8687
sql: 'select 1',
8788
directory,
8889
profileName: 'profile1',
90+
options: {},
8991
} as ExportOptions)
9092
).rejects.toThrow();
9193
expect(fs.readdirSync(directory).length).toBe(0);
@@ -105,6 +107,7 @@ it('Data source should throw error when given directory is not exist', async ()
105107
sql: 'select 1',
106108
directory: directory,
107109
profileName: 'profile1',
110+
options: {},
108111
} as ExportOptions)
109112
).rejects.toThrow();
110113
}, 100000);
@@ -121,6 +124,7 @@ it('Data source should throw error when given profile name is not exist', async
121124
sql: 'select 1',
122125
directory,
123126
profileName: 'profile not exist',
127+
options: {},
124128
} as ExportOptions)
125129
).rejects.toThrow();
126130
}, 100000);

packages/extension-driver-canner/test/cannerServer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class CannerServer {
2020
database: process.env['CANNER_WORKSPACE_SQL_NAME'],
2121
} as PGOptions,
2222
allow: '*',
23+
properties: {},
2324
};
2425
}
2526
}

packages/extension-store-canner/src/test/cannerProfileReader.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ describe('Test CannerProfileReader', () => {
9898

9999
sinon.default.stub(configModule, 'getEnvConfig').returns({
100100
storage: sinon.stubInterface<configModule.StorageServiceOptions>(),
101+
properties: {},
101102
profile: {
102103
host,
103104
password,
@@ -164,6 +165,7 @@ describe('Test CannerProfileReader', () => {
164165

165166
sinon.default.stub(configModule, 'getEnvConfig').returns({
166167
storage: sinon.stubInterface<configModule.StorageServiceOptions>(),
168+
properties: {},
167169
profile: {
168170
...connectionInfo,
169171
},

0 commit comments

Comments
 (0)