Comments (9)
@dhensby thank for your suggestion.
I have change the code in TypeORM, once multSubnetFailover option get added to SqlServerConnectionOptions. After the change, the multSubnetFailover option will be passed down from TypeORM => NodeMSSQL => TediosJS correctly.
I have create a pull request in TypeORM as typeorm/typeorm#10804
from node-mssql.
I'm not sure what the extra
prop is meant to be, we don't support that as part of our config object at all.
The way to pass options directly to tedious is using the options
prop (as you are for trustServerCertificate
).
I don't know about tedious' underlying support for the option (I don't see it in the link you provided), which is going to be what decides if it is supported or not.
edit: I was only my phone when initially reviewing this and didn't realise you were linking to the node-mssql connection code and not tedious
.
Tedious does accept the option: https://github.com/tediousjs/tedious/blob/7e84a2f54c6cb983b18a75ad1fc4bf274b2398e5/src/connection.ts#L377 - so it just needs to be set appropriately:
export const AppDataSource = new DataSource({
type: "mssql",
host: "localhost",
username: "sa",
password: "***",
database: "test",
synchronize: false,
logging: false,
entities: [User],
migrations: [],
subscribers: [],
options: {
+ multiSubnetFailover: true,
trustServerCertificate: true
},
- extra: {
- multiSubnetFailover: true
- }
})
from node-mssql.
@dhensby , I worked with @ibm-mai . Currently the issue is that node-mssql did not pass the multiSubnetFailover to tediosjs.
I have open PR #1626 to resolve this issue.
from node-mssql.
from TypeORM, option prop is type check with
https://github.com/typeorm/typeorm/blob/83567f533482d0170c35e2f99e627962b8f99a08/src/driver/sqlserver/SqlServerConnectionOptions.ts , and currently SqlServerConnectionOptions.ts does not have multiSubnetFailover, thus we cannot add multiSubnetFailover in TypeORM option yet, since it will violate type-checking.
extra prop is custom properties with any type, thus it allow us to pass any property that may not yet defined in SqlServerConnectionOptions.ts, we can see from the below source code of TypeORM that extra prob will be merge with options prop to construct options for NodeMSSQL.
https://github.com/typeorm/typeorm/blob/83567f533482d0170c35e2f99e627962b8f99a08/src/driver/sqlserver/SqlServerDriver.ts#L1100
from node-mssql.
Can you elaborate on the extra prop is merged with the base object and not the options sub object, which is where it is needed.
You can coerce types in typescript so you can add arbitrary props. Eg: value as unknown as Interface
from node-mssql.
to elaborate that options
and extra
prop get merged in TypeORM before send to Node-MSSQL.
let say in TypeORM we construct datasource with both trustServerCertificate
and multiSubnetFailover
in extra section only
export const AppDataSource = new DataSource({
type: "mssql",
host: "127.0.0.1",
username: "sa",
password: "Passwd@1234",
database: "tempdb",
synchronize: true,
logging: false,
entities: [User],
migrations: [],
subscribers: [],
extra: {
trustServerCertificate: true,
multiSubnetFailover: true,
}
})
Once I ran this code and set break point at TypeORM SqlServerDriver.js , function createPool().
We can see that the connectionOptions
is the merged value between options
and extra
prop
this is the value that TypeORM send to node-mssql.
so... using extra option in TypeORM is able to pass multiSubnetFailover option to node-mssql.
from node-mssql.
the current issue is that mssql.ConnectionPool(connectionOptions)
in node-mssql did not passed down multiSubnetFailover
option to tediusjs driver currently.
That why i create the PR to try to fix this issue.
from node-mssql.
This library does not support the property multiSubnetFailover
in the config object. If you want to provide that value to tedious it must be done in the options
sub-object in the config.
There is no problem here and I'm quite confused as to why my solution is not satisfactory.
If TypeORM has issues with the typing for the DB config object, then those typings need fixing instead of expanding the API surface of this library.
export const AppDataSource = new DataSource({
type: "mssql",
host: "localhost",
username: "sa",
password: "***",
database: "test",
synchronize: false,
logging: false,
entities: [User],
migrations: [],
subscribers: [],
options: {
multiSubnetFailover: true,
trustServerCertificate: true
},
} as unknown as SqlServerConnectionOptions);
Better yet, open a PR there to fix SqlServerConnectionOptions
from node-mssql.
Also, just to add (for sake of clarity) your example of adding trustServerCertificate
to extra
will also not work because it must be in the the options
sub-object not the root level. Your solution in the linked PR is not scalable or reasonable as a solution as the natural conclusion is that every property that is added in the root object be duplicated in the options
just to allow TypeORM to add these values in the extra
object...
Fix the upstream library, don't add one-off "fixes" to this library to support the narrow implementation of TypeORM.
from node-mssql.
Related Issues (20)
- you have a typo in your readme sql.query`some query` HOT 1
- ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified HOT 1
- Potential impact of disabling connection validation when released from the pool HOT 1
- RequestError: Incorrect syntax near '='. Unable to query to table when values containing equal sign '=', HOT 7
- The "config.server" property is required and must be of type string. HOT 1
- @azure/core-rest-pipeline breaking support for node.js 14 HOT 2
- Suspected memory leak when streaming data HOT 4
- arrayRowMode returns a function for the column type HOT 6
- Problem with Persian/Arabic characters when using input() HOT 4
- Testing library-using code in Jest results in SyntaxError: Unexpected token 'export' HOT 1
- Request timeouts in mssql/msnodesqlv8 when using default Pool size HOT 4
- Bulk Insert row lock not supported HOT 1
- Committing a transaction early, within a transaction ? HOT 4
- [Question] Does node-mssql support Kerberos authentication HOT 1
- ConnectionError: Connection not yet open. HOT 1
- How to bind a multidimensional array HOT 3
- How to add order by from user input? HOT 1
- (node:1009) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [ConnectionPool]. Use emitter.setMaxListeners() to increase limit HOT 1
- Bulk Insert Time Out HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-mssql.