Skip to content

Commit a7f1fde

Browse files
change property name
1 parent 039a600 commit a7f1fde

File tree

5 files changed

+24
-19
lines changed

5 files changed

+24
-19
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,15 @@ type ClientCredentialsAuth = {
196196
client_secret: string;
197197
};
198198

199+
type PreparedStatementParamStyle = "native" | "fb_numeric";
200+
199201
type ConnectionOptions = {
200202
auth: AccessTokenAuth | ServiceAccountAuth;
201203
database: string;
202204
engineName?: string;
203205
engineEndpoint?: string;
204206
account?: string;
205-
useServerSidePreparedStatement?: boolean;
207+
preparedStatementParamStyle?: PreparedStatementParamStyle;
206208
};
207209
```
208210

@@ -263,7 +265,7 @@ const connection = await firebolt.connect({
263265
<a id="serverSidePreparedStatementConnectionOption"></a>
264266
#### Server-side prepared statement
265267
Driver has the option to use server-side prepared statements, so all parameters are set on the server side, preventing SQL injection attacks.
266-
This behavior can be enabled by setting `useServerSidePreparedStatement` to `true` in the connection options, otherwise, prepared statements will retain default behavior and queries will be formatted client side.
268+
This behavior can be enabled by setting `preparedStatementParamStyle` to `fb_numeric` in the connection options, otherwise, prepared statements will retain default behavior(same behavior if value is set to `native`) and queries will be formatted client side.
267269
```typescript
268270
const connection = await firebolt.connect({
269271
auth: {
@@ -273,7 +275,7 @@ const connection = await firebolt.connect({
273275
engineName: 'engine_name',
274276
account: 'account_name',
275277
database: 'database',
276-
useServerSidePreparedStatement: true
278+
preparedStatementParamStyle: 'fb_numeric'
277279
});
278280
```
279281

src/connection/connection_v2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class ConnectionV2 extends BaseConnection {
129129
query: string,
130130
executeQueryOptions: ExecuteQueryOptions = {}
131131
): Promise<Statement> {
132-
if (this.options.useServerSidePreparedStatement) {
132+
if (this.options.preparedStatementParamStyle === "fb_numeric") {
133133
return this.executePreparedStatement(query, executeQueryOptions);
134134
}
135135
return super.execute(query, executeQueryOptions);

src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export type ServiceAccountAuth = {
8484

8585
export type AuthOptions = UsernamePasswordAuth | ServiceAccountAuth;
8686

87+
export type PreparedStatementParamStyle = "native" | "fb_numeric";
88+
8789
export type ConnectionOptions = {
8890
database?: string;
8991
engineName?: string;
@@ -92,7 +94,7 @@ export type ConnectionOptions = {
9294
account?: string;
9395
auth: AuthOptions;
9496
useCache?: boolean;
95-
useServerSidePreparedStatement?: boolean;
97+
preparedStatementParamStyle?: PreparedStatementParamStyle;
9698
};
9799

98100
export type FireboltClientOptions = {

test/integration/v2/preparedStatement.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import BigNumber from "bignumber.js";
2-
import { Firebolt } from "../../../src";
2+
import { ConnectionOptions, Firebolt } from "../../../src";
3+
import { PreparedStatementParamStyle } from "../../../src/types";
34

4-
const connectionParams = {
5+
const connectionParams: ConnectionOptions = {
56
auth: {
67
client_id: process.env.FIREBOLT_CLIENT_ID as string,
78
client_secret: process.env.FIREBOLT_CLIENT_SECRET as string
89
},
9-
account: process.env.FIREBOLT_ACCOUNT as string,
10-
database: process.env.FIREBOLT_DATABASE as string,
11-
engineName: process.env.FIREBOLT_ENGINE_NAME as string,
12-
useServerSidePreparedStatement: true
10+
account: process.env.FIREBOLT_ACCOUNT,
11+
database: process.env.FIREBOLT_DATABASE,
12+
engineName: process.env.FIREBOLT_ENGINE_NAME,
13+
preparedStatementParamStyle: "fb_numeric"
1314
};
1415

1516
jest.setTimeout(250000);

test/unit/v2/connection.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ describe("Connection V2", () => {
720720
client_secret: "dummy"
721721
},
722722
account: "my_account",
723-
useServerSidePreparedStatement: true
723+
preparedStatementParamStyle: "fb_numeric"
724724
};
725725

726726
const connection = await firebolt.connect(connectionParams);
@@ -781,7 +781,7 @@ describe("Connection V2", () => {
781781
client_secret: "dummy"
782782
},
783783
account: "my_account",
784-
useServerSidePreparedStatement: true
784+
preparedStatementParamStyle: "fb_numeric"
785785
};
786786

787787
const connection = await firebolt.connect(connectionParams);
@@ -840,7 +840,7 @@ describe("Connection V2", () => {
840840
client_secret: "dummy"
841841
},
842842
account: "my_account",
843-
useServerSidePreparedStatement: true
843+
preparedStatementParamStyle: "fb_numeric"
844844
};
845845

846846
const connection = await firebolt.connect(connectionParams);
@@ -906,7 +906,7 @@ describe("Connection V2", () => {
906906
client_secret: "dummy"
907907
},
908908
account: "my_account",
909-
useServerSidePreparedStatement: true
909+
preparedStatementParamStyle: "fb_numeric"
910910
};
911911

912912
const connection = await firebolt.connect(connectionParams);
@@ -965,7 +965,7 @@ describe("Connection V2", () => {
965965
client_secret: "dummy"
966966
},
967967
account: "my_account",
968-
useServerSidePreparedStatement: true
968+
preparedStatementParamStyle: "fb_numeric"
969969
};
970970

971971
const connection = await firebolt.connect(connectionParams);
@@ -1023,7 +1023,7 @@ describe("Connection V2", () => {
10231023
client_secret: "dummy"
10241024
},
10251025
account: "my_account",
1026-
useServerSidePreparedStatement: true
1026+
preparedStatementParamStyle: "fb_numeric"
10271027
};
10281028

10291029
const connection = await firebolt.connect(connectionParams);
@@ -1080,7 +1080,7 @@ describe("Connection V2", () => {
10801080
client_secret: "dummy"
10811081
},
10821082
account: "my_account",
1083-
useServerSidePreparedStatement: true
1083+
preparedStatementParamStyle: "fb_numeric"
10841084
};
10851085

10861086
const connection = await firebolt.connect(connectionParams);
@@ -1142,7 +1142,7 @@ describe("Connection V2", () => {
11421142
client_secret: "dummy"
11431143
},
11441144
account: "my_account",
1145-
useServerSidePreparedStatement: true
1145+
preparedStatementParamStyle: "fb_numeric"
11461146
};
11471147

11481148
const connection = await firebolt.connect(connectionParams);

0 commit comments

Comments
 (0)