typeorm 0.3.18-dev.a909d5b → 0.3.18-dev.befe4f9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +23 -23
  2. package/browser/driver/DriverUtils.js +2 -5
  3. package/browser/driver/DriverUtils.js.map +1 -1
  4. package/browser/driver/sqlserver/SqlServerConnectionCredentialsOptions.d.ts +2 -1
  5. package/browser/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
  6. package/browser/driver/sqlserver/SqlServerConnectionOptions.d.ts +5 -0
  7. package/browser/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  8. package/browser/driver/sqlserver/SqlServerQueryRunner.js +13 -0
  9. package/browser/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  10. package/browser/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.d.ts +12 -0
  11. package/browser/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js +3 -0
  12. package/browser/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js.map +1 -0
  13. package/browser/entity-manager/EntityManager.js +5 -1
  14. package/browser/entity-manager/EntityManager.js.map +1 -1
  15. package/browser/error/QueryFailedError.d.ts +3 -3
  16. package/browser/error/QueryFailedError.js.map +1 -1
  17. package/browser/find-options/FindOptionsUtils.js +1 -1
  18. package/browser/find-options/FindOptionsUtils.js.map +1 -1
  19. package/browser/index.d.ts +1 -0
  20. package/browser/index.js +1 -0
  21. package/browser/index.js.map +1 -1
  22. package/browser/naming-strategy/DefaultNamingStrategy.d.ts +0 -1
  23. package/browser/naming-strategy/DefaultNamingStrategy.js +0 -3
  24. package/browser/naming-strategy/DefaultNamingStrategy.js.map +1 -1
  25. package/browser/naming-strategy/NamingStrategyInterface.d.ts +0 -4
  26. package/browser/naming-strategy/NamingStrategyInterface.js.map +1 -1
  27. package/browser/persistence/Subject.js +2 -1
  28. package/browser/persistence/Subject.js.map +1 -1
  29. package/browser/query-builder/QueryBuilder.js +1 -1
  30. package/browser/query-builder/QueryBuilder.js.map +1 -1
  31. package/browser/repository/Repository.d.ts +1 -1
  32. package/browser/repository/Repository.js +9 -5
  33. package/browser/repository/Repository.js.map +1 -1
  34. package/commands/CommandUtils.js +6 -1
  35. package/commands/CommandUtils.js.map +1 -1
  36. package/commands/EntityCreateCommand.d.ts +3 -0
  37. package/commands/EntityCreateCommand.js +7 -0
  38. package/commands/EntityCreateCommand.js.map +1 -1
  39. package/commands/InitCommand.js +1 -1
  40. package/commands/InitCommand.js.map +1 -1
  41. package/commands/MigrationCreateCommand.d.ts +5 -1
  42. package/commands/MigrationCreateCommand.js +6 -1
  43. package/commands/MigrationCreateCommand.js.map +1 -1
  44. package/commands/MigrationGenerateCommand.d.ts +5 -1
  45. package/commands/MigrationGenerateCommand.js +5 -0
  46. package/commands/MigrationGenerateCommand.js.map +1 -1
  47. package/commands/SubscriberCreateCommand.d.ts +3 -0
  48. package/commands/SubscriberCreateCommand.js +7 -0
  49. package/commands/SubscriberCreateCommand.js.map +1 -1
  50. package/driver/DriverUtils.js +2 -5
  51. package/driver/DriverUtils.js.map +1 -1
  52. package/driver/sqlserver/SqlServerConnectionCredentialsOptions.d.ts +2 -1
  53. package/driver/sqlserver/SqlServerConnectionCredentialsOptions.js.map +1 -1
  54. package/driver/sqlserver/SqlServerConnectionOptions.d.ts +5 -0
  55. package/driver/sqlserver/SqlServerConnectionOptions.js.map +1 -1
  56. package/driver/sqlserver/SqlServerQueryRunner.js +13 -0
  57. package/driver/sqlserver/SqlServerQueryRunner.js.map +1 -1
  58. package/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.d.ts +12 -0
  59. package/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js +4 -0
  60. package/driver/sqlserver/authentication/AzureActiveDirectoryDefaultAuthentication.js.map +1 -0
  61. package/entity-manager/EntityManager.js +5 -1
  62. package/entity-manager/EntityManager.js.map +1 -1
  63. package/error/QueryFailedError.d.ts +3 -3
  64. package/error/QueryFailedError.js.map +1 -1
  65. package/find-options/FindOptionsUtils.js +1 -1
  66. package/find-options/FindOptionsUtils.js.map +1 -1
  67. package/index.d.ts +1 -0
  68. package/index.js +1 -0
  69. package/index.js.map +1 -1
  70. package/index.mjs +2 -0
  71. package/naming-strategy/DefaultNamingStrategy.d.ts +0 -1
  72. package/naming-strategy/DefaultNamingStrategy.js +0 -3
  73. package/naming-strategy/DefaultNamingStrategy.js.map +1 -1
  74. package/naming-strategy/NamingStrategyInterface.d.ts +0 -4
  75. package/naming-strategy/NamingStrategyInterface.js.map +1 -1
  76. package/package.json +1 -1
  77. package/persistence/Subject.js +2 -1
  78. package/persistence/Subject.js.map +1 -1
  79. package/query-builder/QueryBuilder.js +1 -1
  80. package/query-builder/QueryBuilder.js.map +1 -1
  81. package/repository/Repository.d.ts +1 -1
  82. package/repository/Repository.js +9 -5
  83. package/repository/Repository.js.map +1 -1
package/README.md CHANGED
@@ -25,13 +25,13 @@ that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeS
25
25
  and can be used with TypeScript and JavaScript (ES5, ES6, ES7, ES8).
26
26
  Its goal is to always support the latest JavaScript features and provide additional features
27
27
  that help you to develop any kind of application that uses databases - from
28
- small applications with a few tables to large scale enterprise applications
28
+ small applications with a few tables to large-scale enterprise applications
29
29
  with multiple databases.
30
30
 
31
31
  TypeORM supports both [Active Record](./docs/active-record-data-mapper.md#what-is-the-active-record-pattern) and [Data Mapper](./docs/active-record-data-mapper.md#what-is-the-data-mapper-pattern) patterns,
32
32
  unlike all other JavaScript ORMs currently in existence,
33
- which means you can write high quality, loosely coupled, scalable,
34
- maintainable applications the most productive way.
33
+ which means you can write high-quality, loosely coupled, scalable,
34
+ maintainable applications in the most productive way.
35
35
 
36
36
  TypeORM is highly influenced by other ORMs, such as [Hibernate](http://hibernate.org/orm/),
37
37
  [Doctrine](http://www.doctrine-project.org/) and [Entity Framework](https://www.asp.net/entity-framework).
@@ -43,10 +43,10 @@ TypeORM is highly influenced by other ORMs, such as [Hibernate](http://hibernate
43
43
  - Database-specific column types.
44
44
  - Entity manager.
45
45
  - Repositories and custom repositories.
46
- - Clean object relational model.
46
+ - Clean object-relational model.
47
47
  - Associations (relations).
48
48
  - Eager and lazy relations.
49
- - Uni-directional, bi-directional and self-referenced relations.
49
+ - Uni-directional, bi-directional, and self-referenced relations.
50
50
  - Supports multiple inheritance patterns.
51
51
  - Cascades.
52
52
  - Indices.
@@ -55,7 +55,7 @@ TypeORM is highly influenced by other ORMs, such as [Hibernate](http://hibernate
55
55
  - Connection pooling.
56
56
  - Replication.
57
57
  - Using multiple database instances.
58
- - Working with multiple databases types.
58
+ - Working with multiple database types.
59
59
  - Cross-database and cross-schema queries.
60
60
  - Elegant-syntax, flexible and powerful QueryBuilder.
61
61
  - Left and inner joins.
@@ -71,7 +71,7 @@ TypeORM is highly influenced by other ORMs, such as [Hibernate](http://hibernate
71
71
  - Works in NodeJS / Browser / Ionic / Cordova / React Native / NativeScript / Expo / Electron platforms.
72
72
  - TypeScript and JavaScript support.
73
73
  - ESM and CommonJS support.
74
- - Produced code is performant, flexible, clean and maintainable.
74
+ - Produced code is performant, flexible, clean, and maintainable.
75
75
  - Follows all possible best practices.
76
76
  - CLI.
77
77
 
@@ -361,7 +361,7 @@ This guide will show you how to set up TypeORM from scratch and make it do what
361
361
 
362
362
  ### Create a model
363
363
 
364
- Working with a database starts from creating tables.
364
+ Working with a database starts with creating tables.
365
365
  How do you tell TypeORM to create a database table?
366
366
  The answer is - through the models.
367
367
  Your models in your app are your database tables.
@@ -409,7 +409,7 @@ export class Photo {
409
409
 
410
410
  Now, a database table will be created for the `Photo` entity and we'll be able to work with it anywhere in our app.
411
411
  We have created a database table, however, what table can exist without columns?
412
- Let's create few columns in our database table.
412
+ Let's create a few columns in our database table.
413
413
 
414
414
  ### Adding table columns
415
415
 
@@ -441,7 +441,7 @@ export class Photo {
441
441
  }
442
442
  ```
443
443
 
444
- Now `id`, `name`, `description`, `filename`, `views` and `isPublished` columns will be added to the `photo` table.
444
+ Now `id`, `name`, `description`, `filename`, `views`, and `isPublished` columns will be added to the `photo` table.
445
445
  Column types in the database are inferred from the property types you used, e.g.
446
446
  `number` will be converted into `integer`, `string` into `varchar`, `boolean` into `bool`, etc.
447
447
  But you can use any column type your database supports by explicitly specifying a column type into the `@Column` decorator.
@@ -515,7 +515,7 @@ export class Photo {
515
515
  Next, let's fix our data types. By default, the string is mapped to a varchar(255)-like type (depending on the database type).
516
516
  The number is mapped to an integer-like type (depending on the database type).
517
517
  We don't want all our columns to be limited varchars or integers.
518
- Let's setup correct data types:
518
+ Let's setup the correct data types:
519
519
 
520
520
  ```javascript
521
521
  import { Entity, Column, PrimaryGeneratedColumn } from "typeorm"
@@ -569,7 +569,7 @@ const AppDataSource = new DataSource({
569
569
  logging: false,
570
570
  })
571
571
 
572
- // to initialize initial connection with the database, register all entities
572
+ // to initialize the initial connection with the database, register all entities
573
573
  // and "synchronize" database schema, call "initialize()" method of a newly created database
574
574
  // once in your application bootstrap
575
575
  AppDataSource.initialize()
@@ -583,7 +583,7 @@ We are using Postgres in this example, but you can use any other supported datab
583
583
  To use another database, simply change the `type` in the options to the database type you are using:
584
584
  `mysql`, `mariadb`, `postgres`, `cockroachdb`, `sqlite`, `mssql`, `oracle`, `sap`, `spanner`, `cordova`, `nativescript`, `react-native`,
585
585
  `expo`, or `mongodb`.
586
- Also make sure to use your own host, port, username, password and database settings.
586
+ Also make sure to use your own host, port, username, password, and database settings.
587
587
 
588
588
  We added our Photo entity to the list of entities for this data source.
589
589
  Each entity you are using in your connection must be listed there.
@@ -815,7 +815,7 @@ If you run the app, you'll see a newly generated table, and it will contain a co
815
815
 
816
816
  ### Save a one-to-one relation
817
817
 
818
- Now let's save a photo, its metadata and attach them to each other.
818
+ Now let's save a photo, and its metadata and attach them to each other.
819
819
 
820
820
  ```javascript
821
821
  import { Photo } from "./entity/Photo"
@@ -954,7 +954,7 @@ export class Photo {
954
954
 
955
955
  Now let's load our photo and its photo metadata in a single query.
956
956
  There are two ways to do it - using `find*` methods or using `QueryBuilder` functionality.
957
- Let's use `find*` methods first.
957
+ Let's use `find*` method first.
958
958
  `find*` methods allow you to specify an object with the `FindOneOptions` / `FindManyOptions` interface.
959
959
 
960
960
  ```javascript
@@ -1008,7 +1008,7 @@ export class Photo {
1008
1008
  }
1009
1009
  ```
1010
1010
 
1011
- Using `cascade` allows us not to separately save photo and separately save metadata objects now.
1011
+ Using `cascade` allows us not to separately save photos and separately save metadata objects now.
1012
1012
  Now we can simply save a photo object, and the metadata object will be saved automatically because of cascade options.
1013
1013
 
1014
1014
  ```javascript
@@ -1040,7 +1040,7 @@ await photoRepository.save(photo)
1040
1040
  console.log("Photo is saved, photo metadata is saved too.")
1041
1041
  ```
1042
1042
 
1043
- Notice that we now set the photo's `metadata` property, instead of the metadata's `photo` property as before. The `cascade` feature only works if you connect the photo to its metadata from the photo's side. If you set the metadata's side, the metadata would not be saved automatically.
1043
+ Notice that we now set the photo's `metadata` property, instead of the metadata's `photo` property as before. The `cascade` feature only works if you connect the photo to its metadata from the photo's side. If you set the metadata side, the metadata would not be saved automatically.
1044
1044
 
1045
1045
  ### Creating a many-to-one / one-to-many relation
1046
1046
 
@@ -1090,7 +1090,7 @@ export class Photo {
1090
1090
  }
1091
1091
  ```
1092
1092
 
1093
- In many-to-one / one-to-many relation, the owner side is always many-to-one.
1093
+ In many-to-one / one-to-many relations, the owner side is always many-to-one.
1094
1094
  It means that the class that uses `@ManyToOne` will store the id of the related object.
1095
1095
 
1096
1096
  After you run the application, the ORM will create the `author` table:
@@ -1181,7 +1181,7 @@ const options: DataSourceOptions = {
1181
1181
  }
1182
1182
  ```
1183
1183
 
1184
- Now let's insert albums and photos to our database:
1184
+ Now let's insert albums and photos into our database:
1185
1185
 
1186
1186
  ```javascript
1187
1187
  import { AppDataSource } from "./index"
@@ -1257,7 +1257,7 @@ This query selects all published photos with "My" or "Mishka" names.
1257
1257
  It will select results from position 5 (pagination offset)
1258
1258
  and will select only 10 results (pagination limit).
1259
1259
  The selection result will be ordered by id in descending order.
1260
- The photo's albums will be left joined and their metadata will be inner joined.
1260
+ The photo albums will be left joined and their metadata will be inner joined.
1261
1261
 
1262
1262
  You'll use the query builder in your application a lot.
1263
1263
  Learn more about QueryBuilder [here](./docs/select-query-builder.md).
@@ -1266,7 +1266,7 @@ Learn more about QueryBuilder [here](./docs/select-query-builder.md).
1266
1266
 
1267
1267
  Take a look at the samples in [sample](https://github.com/typeorm/typeorm/tree/master/sample) for examples of usage.
1268
1268
 
1269
- There are a few repositories which you can clone and start with:
1269
+ There are a few repositories that you can clone and start with:
1270
1270
 
1271
1271
  - [Example how to use TypeORM with TypeScript](https://github.com/typeorm/typescript-example)
1272
1272
  - [Example how to use TypeORM with JavaScript](https://github.com/typeorm/javascript-example)
@@ -1291,7 +1291,7 @@ There are several extensions that simplify working with TypeORM and integrating
1291
1291
  - [TypeORM + GraphQL framework](https://github.com/vesper-framework/vesper)
1292
1292
  - [TypeORM integration](https://github.com/typeorm/typeorm-typedi-extensions) with [TypeDI](https://github.com/pleerock/typedi)
1293
1293
  - [TypeORM integration](https://github.com/typeorm/typeorm-routing-controllers-extensions) with [routing-controllers](https://github.com/pleerock/routing-controllers)
1294
- - Models generation from existing database - [typeorm-model-generator](https://github.com/Kononnable/typeorm-model-generator)
1294
+ - Models generation from the existing database - [typeorm-model-generator](https://github.com/Kononnable/typeorm-model-generator)
1295
1295
  - Fixtures loader - [typeorm-fixtures-cli](https://github.com/RobinCK/typeorm-fixtures)
1296
1296
  - ER Diagram generator - [typeorm-uml](https://github.com/eugene-manuilov/typeorm-uml/)
1297
1297
  - another ER Diagram generator - [erdia](https://www.npmjs.com/package/erdia/)
@@ -1302,7 +1302,7 @@ There are several extensions that simplify working with TypeORM and integrating
1302
1302
 
1303
1303
  ## Contributing
1304
1304
 
1305
- Learn about contribution [here](https://github.com/typeorm/typeorm/blob/master/CONTRIBUTING.md) and how to setup your development environment [here](https://github.com/typeorm/typeorm/blob/master/DEVELOPER.md).
1305
+ Learn about contribution [here](https://github.com/typeorm/typeorm/blob/master/CONTRIBUTING.md) and how to set up your development environment [here](https://github.com/typeorm/typeorm/blob/master/DEVELOPER.md).
1306
1306
 
1307
1307
  This project exists thanks to all the people who contribute:
1308
1308
 
@@ -90,11 +90,8 @@ export class DriverUtils {
90
90
  * @return An alias that is no longer than the divers max alias length.
91
91
  */
92
92
  static buildAlias({ maxAliasLength }, buildOptions, ...alias) {
93
- const newAlias = alias.length === 1
94
- ? alias[0]
95
- : alias.join(buildOptions && buildOptions.joiner
96
- ? buildOptions.joiner
97
- : "_");
93
+ const joiner = buildOptions && buildOptions.joiner ? buildOptions.joiner : "_";
94
+ let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner);
98
95
  if (maxAliasLength &&
99
96
  maxAliasLength > 0 &&
100
97
  newAlias.length > maxAliasLength) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/driver/DriverUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;GAEG;AACH,MAAM,OAAO,WAAW;IACpB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAc;QAChC,OAAO;YACH,QAAQ;YACR,SAAS;YACT,cAAc;YACd,cAAc;YACd,OAAO;YACP,MAAM;YACN,gBAAgB;YAChB,WAAW;SACd,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAc;QAC/B,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7D,CA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kBAAkB,CAAC,QAAQ,CAAC;YACtC,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;YACtC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACvC,QAAQ,EAAE,SAAS,IAAI,SAAS;SACnC,CAAA;QAED,uDAAuD;QACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YACtD,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SAC7B;QAED,OAAO,aAAa,CAAA;IACxB,CAAC;CACJ","file":"DriverUtils.js","sourcesContent":["import { Driver } from \"./Driver\"\nimport { hash, shorten } from \"../util/StringUtils\"\nimport { VersionUtils } from \"../util/VersionUtils\"\n\n/**\n * Common driver utility functions.\n */\nexport class DriverUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns true if given driver is SQLite-based driver.\n */\n static isSQLiteFamily(driver: Driver): boolean {\n return [\n \"sqlite\",\n \"cordova\",\n \"react-native\",\n \"nativescript\",\n \"sqljs\",\n \"expo\",\n \"better-sqlite3\",\n \"capacitor\",\n ].includes(driver.options.type)\n }\n\n /**\n * Returns true if given driver is MySQL-based driver.\n */\n static isMySQLFamily(driver: Driver): boolean {\n return [\"mysql\", \"mariadb\"].includes(driver.options.type)\n }\n\n static isReleaseVersionOrGreater(driver: Driver, version: string): boolean {\n return (\n driver.version != null &&\n VersionUtils.isGreaterOrEqual(driver.version, version)\n )\n }\n\n static isPostgresFamily(driver: Driver): boolean {\n return [\"postgres\", \"aurora-postgres\", \"cockroachdb\"].includes(\n driver.options.type,\n )\n }\n\n /**\n * Normalizes and builds a new driver options.\n * Extracts settings from connection url and sets to a new options object.\n */\n static buildDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseConnectionUrl(options.url) as {\n [key: string]: any\n }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * buildDriverOptions for MongodDB only to support replica set\n */\n static buildMongoDBDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseMongoDBConnectionUrl(\n options.url,\n ) as { [key: string]: any }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * Joins and shortens alias if needed.\n *\n * If the alias length is greater than the limit allowed by the current\n * driver, replaces it with a shortend string, if the shortend string\n * is still too long, it will then hash the alias.\n *\n * @param driver Current `Driver`.\n * @param buildOptions Optional settings.\n * @param alias Alias parts.\n *\n * @return An alias that is no longer than the divers max alias length.\n */\n static buildAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | undefined,\n ...alias: string[]\n ): string {\n const newAlias =\n alias.length === 1\n ? alias[0]\n : alias.join(\n buildOptions && buildOptions.joiner\n ? buildOptions.joiner\n : \"_\",\n )\n if (\n maxAliasLength &&\n maxAliasLength > 0 &&\n newAlias.length > maxAliasLength\n ) {\n if (buildOptions && buildOptions.shorten === true) {\n const shortenedAlias = shorten(newAlias)\n if (shortenedAlias.length < maxAliasLength) {\n return shortenedAlias\n }\n }\n\n return hash(newAlias, { length: maxAliasLength })\n }\n\n return newAlias\n }\n\n /**\n * @deprecated use `buildAlias` instead.\n */\n static buildColumnAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | string,\n ...alias: string[]\n ) {\n if (typeof buildOptions === \"string\") {\n alias.unshift(buildOptions)\n buildOptions = { shorten: false, joiner: \"_\" }\n } else {\n buildOptions = Object.assign(\n { shorten: false, joiner: \"_\" },\n buildOptions,\n )\n }\n return this.buildAlias(\n { maxAliasLength } as Driver,\n buildOptions,\n ...alias,\n )\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Extracts connection data from the connection url.\n */\n private static parseConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n // remove mongodb query params\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n const [host, port] = hostAndPort.split(\":\")\n\n return {\n type: type,\n host: host,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n }\n\n /**\n * Extracts connection data from the connection url for MongoDB to support replica set.\n */\n private static parseMongoDBConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n let afterQuestionMark = \"\"\n let host = undefined\n let port = undefined\n let hostReplicaSet = undefined\n let replicaSet = undefined\n\n let optionsObject: any = {}\n\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n // split params\n afterQuestionMark = afterBase.substr(\n afterBase.indexOf(\"?\") + 1,\n afterBase.length,\n )\n\n const optionsList = afterQuestionMark.split(\"&\")\n let optionKey: string\n let optionValue: string\n\n // create optionsObject for merge with connectionUrl object before return\n optionsList.forEach((optionItem) => {\n optionKey = optionItem.split(\"=\")[0]\n optionValue = optionItem.split(\"=\")[1]\n optionsObject[optionKey] = optionValue\n })\n\n // specific replicaSet value to set options about hostReplicaSet\n replicaSet = optionsObject[\"replicaSet\"]\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n\n // If replicaSet have value set It as hostlist, If not set like standalone host\n if (replicaSet) {\n hostReplicaSet = hostAndPort\n } else {\n ;[host, port] = hostAndPort.split(\":\")\n }\n\n let connectionUrl: any = {\n type: type,\n host: host,\n hostReplicaSet: hostReplicaSet,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n\n // Loop to set every options in connectionUrl to object\n for (const [key, value] of Object.entries(optionsObject)) {\n connectionUrl[key] = value\n }\n\n return connectionUrl\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/driver/DriverUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAA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B,CAAA;QAClC,IAAI,QAAQ,GAAG,EAAE,CAAA;QACjB,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACnD,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;YACnB,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;YACpD,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;SACxD;QAED,+EAA+E;QAC/E,IAAI,UAAU,EAAE;YACZ,cAAc,GAAG,WAAW,CAAA;SAC/B;aAAM;YACH,CAAC;YAAA,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;SACzC;QAED,IAAI,aAAa,GAAQ;YACrB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,cAAc,EAAE,cAAc;YAC9B,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;YACtC,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC;YACtC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;YACvC,QAAQ,EAAE,SAAS,IAAI,SAAS;SACnC,CAAA;QAED,uDAAuD;QACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YACtD,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SAC7B;QAED,OAAO,aAAa,CAAA;IACxB,CAAC;CACJ","file":"DriverUtils.js","sourcesContent":["import { Driver } from \"./Driver\"\nimport { hash, shorten } from \"../util/StringUtils\"\nimport { VersionUtils } from \"../util/VersionUtils\"\n\n/**\n * Common driver utility functions.\n */\nexport class DriverUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns true if given driver is SQLite-based driver.\n */\n static isSQLiteFamily(driver: Driver): boolean {\n return [\n \"sqlite\",\n \"cordova\",\n \"react-native\",\n \"nativescript\",\n \"sqljs\",\n \"expo\",\n \"better-sqlite3\",\n \"capacitor\",\n ].includes(driver.options.type)\n }\n\n /**\n * Returns true if given driver is MySQL-based driver.\n */\n static isMySQLFamily(driver: Driver): boolean {\n return [\"mysql\", \"mariadb\"].includes(driver.options.type)\n }\n\n static isReleaseVersionOrGreater(driver: Driver, version: string): boolean {\n return (\n driver.version != null &&\n VersionUtils.isGreaterOrEqual(driver.version, version)\n )\n }\n\n static isPostgresFamily(driver: Driver): boolean {\n return [\"postgres\", \"aurora-postgres\", \"cockroachdb\"].includes(\n driver.options.type,\n )\n }\n\n /**\n * Normalizes and builds a new driver options.\n * Extracts settings from connection url and sets to a new options object.\n */\n static buildDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseConnectionUrl(options.url) as {\n [key: string]: any\n }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * buildDriverOptions for MongodDB only to support replica set\n */\n static buildMongoDBDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseMongoDBConnectionUrl(\n options.url,\n ) as { [key: string]: any }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * Joins and shortens alias if needed.\n *\n * If the alias length is greater than the limit allowed by the current\n * driver, replaces it with a shortend string, if the shortend string\n * is still too long, it will then hash the alias.\n *\n * @param driver Current `Driver`.\n * @param buildOptions Optional settings.\n * @param alias Alias parts.\n *\n * @return An alias that is no longer than the divers max alias length.\n */\n static buildAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | undefined,\n ...alias: string[]\n ): string {\n const joiner =\n buildOptions && buildOptions.joiner ? buildOptions.joiner : \"_\"\n\n let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner)\n\n if (\n maxAliasLength &&\n maxAliasLength > 0 &&\n newAlias.length > maxAliasLength\n ) {\n if (buildOptions && buildOptions.shorten === true) {\n const shortenedAlias = shorten(newAlias)\n if (shortenedAlias.length < maxAliasLength) {\n return shortenedAlias\n }\n }\n\n return hash(newAlias, { length: maxAliasLength })\n }\n\n return newAlias\n }\n\n /**\n * @deprecated use `buildAlias` instead.\n */\n static buildColumnAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | string,\n ...alias: string[]\n ) {\n if (typeof buildOptions === \"string\") {\n alias.unshift(buildOptions)\n buildOptions = { shorten: false, joiner: \"_\" }\n } else {\n buildOptions = Object.assign(\n { shorten: false, joiner: \"_\" },\n buildOptions,\n )\n }\n return this.buildAlias(\n { maxAliasLength } as Driver,\n buildOptions,\n ...alias,\n )\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Extracts connection data from the connection url.\n */\n private static parseConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n // remove mongodb query params\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n const [host, port] = hostAndPort.split(\":\")\n\n return {\n type: type,\n host: host,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n }\n\n /**\n * Extracts connection data from the connection url for MongoDB to support replica set.\n */\n private static parseMongoDBConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n let afterQuestionMark = \"\"\n let host = undefined\n let port = undefined\n let hostReplicaSet = undefined\n let replicaSet = undefined\n\n let optionsObject: any = {}\n\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n // split params\n afterQuestionMark = afterBase.substr(\n afterBase.indexOf(\"?\") + 1,\n afterBase.length,\n )\n\n const optionsList = afterQuestionMark.split(\"&\")\n let optionKey: string\n let optionValue: string\n\n // create optionsObject for merge with connectionUrl object before return\n optionsList.forEach((optionItem) => {\n optionKey = optionItem.split(\"=\")[0]\n optionValue = optionItem.split(\"=\")[1]\n optionsObject[optionKey] = optionValue\n })\n\n // specific replicaSet value to set options about hostReplicaSet\n replicaSet = optionsObject[\"replicaSet\"]\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n\n // If replicaSet have value set It as hostlist, If not set like standalone host\n if (replicaSet) {\n hostReplicaSet = hostAndPort\n } else {\n ;[host, port] = hostAndPort.split(\":\")\n }\n\n let connectionUrl: any = {\n type: type,\n host: host,\n hostReplicaSet: hostReplicaSet,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n\n // Loop to set every options in connectionUrl to object\n for (const [key, value] of Object.entries(optionsObject)) {\n connectionUrl[key] = value\n }\n\n return connectionUrl\n }\n}\n"],"sourceRoot":".."}
@@ -1,11 +1,12 @@
1
1
  import { DefaultAuthentication } from "./authentication/DefaultAuthentication";
2
2
  import { AzureActiveDirectoryAccessTokenAuthentication } from "./authentication/AzureActiveDirectoryAccessTokenAuthentication";
3
+ import { AzureActiveDirectoryDefaultAuthentication } from "./authentication/AzureActiveDirectoryDefaultAuthentication";
3
4
  import { AzureActiveDirectoryMsiAppServiceAuthentication } from "./authentication/AzureActiveDirectoryMsiAppServiceAuthentication";
4
5
  import { AzureActiveDirectoryMsiVmAuthentication } from "./authentication/AzureActiveDirectoryMsiVmAuthentication";
5
6
  import { AzureActiveDirectoryPasswordAuthentication } from "./authentication/AzureActiveDirectoryPasswordAuthentication";
6
7
  import { AzureActiveDirectoryServicePrincipalSecret } from "./authentication/AzureActiveDirectoryServicePrincipalSecret";
7
8
  import { NtlmAuthentication } from "./authentication/NtlmAuthentication";
8
- export type SqlServerConnectionCredentialsAuthenticationOptions = DefaultAuthentication | NtlmAuthentication | AzureActiveDirectoryAccessTokenAuthentication | AzureActiveDirectoryMsiAppServiceAuthentication | AzureActiveDirectoryMsiVmAuthentication | AzureActiveDirectoryPasswordAuthentication | AzureActiveDirectoryServicePrincipalSecret;
9
+ export type SqlServerConnectionCredentialsAuthenticationOptions = DefaultAuthentication | NtlmAuthentication | AzureActiveDirectoryAccessTokenAuthentication | AzureActiveDirectoryDefaultAuthentication | AzureActiveDirectoryMsiAppServiceAuthentication | AzureActiveDirectoryMsiVmAuthentication | AzureActiveDirectoryPasswordAuthentication | AzureActiveDirectoryServicePrincipalSecret;
9
10
  /**
10
11
  * SqlServer specific connection credential options.
11
12
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/driver/sqlserver/SqlServerConnectionCredentialsOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionCredentialsOptions.js","sourcesContent":["import { DefaultAuthentication } from \"./authentication/DefaultAuthentication\"\nimport { AzureActiveDirectoryAccessTokenAuthentication } from \"./authentication/AzureActiveDirectoryAccessTokenAuthentication\"\nimport { AzureActiveDirectoryMsiAppServiceAuthentication } from \"./authentication/AzureActiveDirectoryMsiAppServiceAuthentication\"\nimport { AzureActiveDirectoryMsiVmAuthentication } from \"./authentication/AzureActiveDirectoryMsiVmAuthentication\"\nimport { AzureActiveDirectoryPasswordAuthentication } from \"./authentication/AzureActiveDirectoryPasswordAuthentication\"\nimport { AzureActiveDirectoryServicePrincipalSecret } from \"./authentication/AzureActiveDirectoryServicePrincipalSecret\"\nimport { NtlmAuthentication } from \"./authentication/NtlmAuthentication\"\n\nexport type SqlServerConnectionCredentialsAuthenticationOptions =\n | DefaultAuthentication\n | NtlmAuthentication\n | AzureActiveDirectoryAccessTokenAuthentication\n | AzureActiveDirectoryMsiAppServiceAuthentication\n | AzureActiveDirectoryMsiVmAuthentication\n | AzureActiveDirectoryPasswordAuthentication\n | AzureActiveDirectoryServicePrincipalSecret\n\n/**\n * SqlServer specific connection credential options.\n */\nexport interface SqlServerConnectionCredentialsOptions {\n /**\n * Connection url where perform connection to.\n */\n readonly url?: string\n\n /**\n * Database host.\n */\n readonly host?: string\n\n /**\n * Database host port.\n */\n readonly port?: number\n\n /**\n * Database name to connect to.\n */\n readonly database?: string\n\n /**\n * Database username.\n */\n readonly username?: string\n\n /**\n * Database password.\n */\n readonly password?: string\n\n /**\n * Authentication settings\n * It overrides username and password, when passed.\n */\n readonly authentication?: SqlServerConnectionCredentialsAuthenticationOptions\n\n /**\n * Once you set domain, driver will connect to SQL Server using domain login.\n * @see SqlServerConnectionCredentialsOptions.authentication\n * @see NtlmAuthentication\n * @deprecated\n */\n readonly domain?: string\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/driver/sqlserver/SqlServerConnectionCredentialsOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionCredentialsOptions.js","sourcesContent":["import { DefaultAuthentication } from \"./authentication/DefaultAuthentication\"\nimport { AzureActiveDirectoryAccessTokenAuthentication } from \"./authentication/AzureActiveDirectoryAccessTokenAuthentication\"\nimport { AzureActiveDirectoryDefaultAuthentication } from \"./authentication/AzureActiveDirectoryDefaultAuthentication\"\nimport { AzureActiveDirectoryMsiAppServiceAuthentication } from \"./authentication/AzureActiveDirectoryMsiAppServiceAuthentication\"\nimport { AzureActiveDirectoryMsiVmAuthentication } from \"./authentication/AzureActiveDirectoryMsiVmAuthentication\"\nimport { AzureActiveDirectoryPasswordAuthentication } from \"./authentication/AzureActiveDirectoryPasswordAuthentication\"\nimport { AzureActiveDirectoryServicePrincipalSecret } from \"./authentication/AzureActiveDirectoryServicePrincipalSecret\"\nimport { NtlmAuthentication } from \"./authentication/NtlmAuthentication\"\n\nexport type SqlServerConnectionCredentialsAuthenticationOptions =\n | DefaultAuthentication\n | NtlmAuthentication\n | AzureActiveDirectoryAccessTokenAuthentication\n | AzureActiveDirectoryDefaultAuthentication\n | AzureActiveDirectoryMsiAppServiceAuthentication\n | AzureActiveDirectoryMsiVmAuthentication\n | AzureActiveDirectoryPasswordAuthentication\n | AzureActiveDirectoryServicePrincipalSecret\n\n/**\n * SqlServer specific connection credential options.\n */\nexport interface SqlServerConnectionCredentialsOptions {\n /**\n * Connection url where perform connection to.\n */\n readonly url?: string\n\n /**\n * Database host.\n */\n readonly host?: string\n\n /**\n * Database host port.\n */\n readonly port?: number\n\n /**\n * Database name to connect to.\n */\n readonly database?: string\n\n /**\n * Database username.\n */\n readonly username?: string\n\n /**\n * Database password.\n */\n readonly password?: string\n\n /**\n * Authentication settings\n * It overrides username and password, when passed.\n */\n readonly authentication?: SqlServerConnectionCredentialsAuthenticationOptions\n\n /**\n * Once you set domain, driver will connect to SQL Server using domain login.\n * @see SqlServerConnectionCredentialsOptions.authentication\n * @see NtlmAuthentication\n * @deprecated\n */\n readonly domain?: string\n}\n"],"sourceRoot":"../.."}
@@ -148,6 +148,11 @@ export interface SqlServerConnectionOptions extends BaseDataSourceOptions, SqlSe
148
148
  * A boolean, controlling whatever to disable RETURNING / OUTPUT statements.
149
149
  */
150
150
  readonly disableOutputReturning?: boolean;
151
+ /**
152
+ * A boolean, controlling whether MssqlParameter types char, varchar, and text are converted to their unicode equivalents, nchar, nvarchar, and ntext.
153
+ * (default: false, meaning that char/varchar/text parameters will be converted to nchar/nvarchar/ntext)
154
+ */
155
+ readonly disableAsciiToUnicodeParamConversion?: boolean;
151
156
  /**
152
157
  * Debug options
153
158
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/driver/sqlserver/SqlServerConnectionOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SqlServerConnectionCredentialsOptions } from \"./SqlServerConnectionCredentialsOptions\"\n\n/**\n * Microsoft Sql Server specific connection options.\n */\nexport interface SqlServerConnectionOptions\n extends BaseDataSourceOptions,\n SqlServerConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mssql\"\n\n /**\n * Connection timeout in ms (default: 15000).\n */\n readonly connectionTimeout?: number\n\n /**\n * Request timeout in ms (default: 15000). NOTE: msnodesqlv8 driver doesn't support timeouts < 1 second.\n */\n readonly requestTimeout?: number\n\n /**\n * Stream recordsets/rows instead of returning them all at once as an argument of callback (default: false).\n * You can also enable streaming for each request independently (request.stream = true).\n * Always set to true if you plan to work with large amount of rows.\n */\n readonly stream?: boolean\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"mssql\")`\n */\n readonly driver?: any\n\n /**\n * An optional object/dictionary with the any of the properties\n */\n readonly pool?: {\n /**\n * Maximum number of resources to create at any given time. (default=1)\n */\n readonly max?: number\n\n /**\n * Minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently\n * set the min to equal max. (default=0)\n */\n readonly min?: number\n\n /**\n * Maximum number of queued requests allowed, additional acquire calls will be callback with an err in a future\n * cycle of the event loop.\n */\n readonly maxWaitingClients?: number\n\n /**\n * Should the pool validate resources before giving them to clients. Requires that either factory.validate or\n * factory.validateAsync to be specified\n */\n readonly testOnBorrow?: boolean\n\n /**\n * Max milliseconds an acquire call will wait for a resource before timing out. (default no limit), if supplied should non-zero positive integer.\n */\n readonly acquireTimeoutMillis?: number\n\n /**\n * If true the oldest resources will be first to be allocated. If false the most recently released resources will\n * be the first to be allocated. This in effect turns the pool's behaviour from a queue into a stack. boolean,\n * (default true)\n */\n readonly fifo?: boolean\n\n /**\n * Int between 1 and x - if set, borrowers can specify their relative priority in the queue if no resources\n * are available. see example. (default 1)\n */\n readonly priorityRange?: number\n\n /**\n * How often to run eviction checks. Default: 0 (does not run).\n */\n readonly evictionRunIntervalMillis?: number\n\n /**\n * Number of resources to check each eviction run. Default: 3.\n */\n readonly numTestsPerRun?: number\n\n /**\n * Amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object\n * evictor (if any), with the extra condition that at least \"min idle\" object instances remain in the pool.\n * Default -1 (nothing can get evicted)\n */\n readonly softIdleTimeoutMillis?: number\n\n /**\n * The minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due\n * to idle time. Supercedes softIdleTimeoutMillis Default: 30000\n */\n readonly idleTimeoutMillis?: number\n\n /*\n * Function handling errors thrown by drivers pool.\n * Defaults to logging error with `warn` level.\n */\n readonly errorHandler?: (err: any) => any\n }\n\n /**\n * Extra options\n */\n readonly options?: {\n /**\n * The named instance to connect to\n */\n readonly instanceName?: string\n\n /**\n * By default, if the database requestion by options.database cannot be accessed, the connection will fail with\n * an error. However, if options.fallbackToDefaultDb is set to true, then the user's default database will\n * be used instead (Default: false).\n */\n readonly fallbackToDefaultDb?: boolean\n\n /**\n * If true, SET ANSI_NULL_DFLT_ON ON will be set in the initial sql. This means new columns will be nullable by\n * default. See the T-SQL documentation for more details. (Default: true).\n */\n readonly enableAnsiNullDefault?: boolean\n\n /**\n * The number of milliseconds before the attempt to connect is considered failed (default: 15000).\n */\n readonly connectTimeout?: number\n\n /**\n * The number of milliseconds before the cancel (abort) of a request is considered failed (default: 5000).\n */\n readonly cancelTimeout?: number\n\n /**\n * The size of TDS packets (subject to negotiation with the server). Should be a power of 2. (default: 4096).\n */\n readonly packetSize?: number\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: false).\n */\n readonly useUTC?: boolean\n\n /**\n * A boolean determining whether to rollback a transaction automatically if any error is encountered during\n * the given transaction's execution. This sets the value for SET XACT_ABORT during the initial SQL phase\n * of a connection (documentation).\n */\n readonly abortTransactionOnError?: boolean\n\n /**\n * A string indicating which network interface (ip address) to use when connecting to SQL Server.\n */\n readonly localAddress?: string\n\n /**\n * A boolean determining whether to return rows as arrays or key-value collections. (default: false).\n */\n readonly useColumnNames?: boolean\n\n /**\n * A boolean, controlling whether the column names returned will have the first letter converted to lower case\n * (true) or not. This value is ignored if you provide a columnNameReplacer. (default: false).\n */\n readonly camelCaseColumns?: boolean\n\n /**\n * A boolean, controlling whatever to disable RETURNING / OUTPUT statements.\n */\n readonly disableOutputReturning?: boolean\n\n /**\n * Debug options\n */\n readonly debug?: {\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet details\n * (default: false).\n */\n readonly packet?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet data details\n * (default: false).\n */\n readonly data?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet payload details\n * (default: false).\n */\n readonly payload?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing token stream tokens\n * (default: false).\n */\n readonly token?: boolean\n }\n\n /**\n * The default isolation level that transactions will be run with. The isolation levels are available\n * from require('tedious').ISOLATION_LEVEL. (default: READ_COMMITTED).\n */\n readonly isolation?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * The default isolation level for new connections. All out-of-transaction queries are executed with this\n * setting. The isolation levels are available from require('tedious').ISOLATION_LEVEL .\n */\n readonly connectionIsolationLevel?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * A boolean, determining whether the connection will request read only access from a SQL Server\n * Availability Group. For more information, see here. (default: false).\n */\n readonly readOnlyIntent?: boolean\n\n /**\n * A boolean determining whether or not the connection will be encrypted. Set to true if you're on\n * Windows Azure. (default: true).\n */\n readonly encrypt?: boolean\n\n /**\n * When encryption is used, an object may be supplied that will be used for the first argument when calling\n * tls.createSecurePair (default: {}).\n */\n readonly cryptoCredentialsDetails?: any\n\n /**\n * A boolean, that when true will expose received rows in Requests' done* events. See done, doneInProc and\n * doneProc. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnDone?: boolean\n\n /**\n * A boolean, that when true will expose received rows in Requests' completion callback. See new Request. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnRequestCompletion?: boolean\n\n /**\n * The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.\n * The versions are available from require('tedious').TDS_VERSION. (default: 7_4).\n */\n readonly tdsVersion?: string\n\n /**\n * A boolean, that when true will abort a query when an overflow or divide-by-zero error occurs during query execution.\n */\n readonly enableArithAbort?: boolean\n\n /**\n * Application name used for identifying a specific application in profiling, logging or tracing tools of SQL Server.\n * (default: node-mssql)\n */\n readonly appName?: string\n\n /**\n * A boolean, controlling whether encryption occurs if there is no verifiable server certificate.\n * (default: false)\n */\n readonly trustServerCertificate?: boolean\n }\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: SqlServerConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: SqlServerConnectionCredentialsOptions[]\n }\n\n readonly poolSize?: never\n}\n"],"sourceRoot":"../.."}
1
+ {"version":3,"sources":["../browser/src/driver/sqlserver/SqlServerConnectionOptions.ts"],"names":[],"mappings":"","file":"SqlServerConnectionOptions.js","sourcesContent":["import { BaseDataSourceOptions } from \"../../data-source/BaseDataSourceOptions\"\nimport { SqlServerConnectionCredentialsOptions } from \"./SqlServerConnectionCredentialsOptions\"\n\n/**\n * Microsoft Sql Server specific connection options.\n */\nexport interface SqlServerConnectionOptions\n extends BaseDataSourceOptions,\n SqlServerConnectionCredentialsOptions {\n /**\n * Database type.\n */\n readonly type: \"mssql\"\n\n /**\n * Connection timeout in ms (default: 15000).\n */\n readonly connectionTimeout?: number\n\n /**\n * Request timeout in ms (default: 15000). NOTE: msnodesqlv8 driver doesn't support timeouts < 1 second.\n */\n readonly requestTimeout?: number\n\n /**\n * Stream recordsets/rows instead of returning them all at once as an argument of callback (default: false).\n * You can also enable streaming for each request independently (request.stream = true).\n * Always set to true if you plan to work with large amount of rows.\n */\n readonly stream?: boolean\n\n /**\n * Database schema.\n */\n readonly schema?: string\n\n /**\n * The driver object\n * This defaults to `require(\"mssql\")`\n */\n readonly driver?: any\n\n /**\n * An optional object/dictionary with the any of the properties\n */\n readonly pool?: {\n /**\n * Maximum number of resources to create at any given time. (default=1)\n */\n readonly max?: number\n\n /**\n * Minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently\n * set the min to equal max. (default=0)\n */\n readonly min?: number\n\n /**\n * Maximum number of queued requests allowed, additional acquire calls will be callback with an err in a future\n * cycle of the event loop.\n */\n readonly maxWaitingClients?: number\n\n /**\n * Should the pool validate resources before giving them to clients. Requires that either factory.validate or\n * factory.validateAsync to be specified\n */\n readonly testOnBorrow?: boolean\n\n /**\n * Max milliseconds an acquire call will wait for a resource before timing out. (default no limit), if supplied should non-zero positive integer.\n */\n readonly acquireTimeoutMillis?: number\n\n /**\n * If true the oldest resources will be first to be allocated. If false the most recently released resources will\n * be the first to be allocated. This in effect turns the pool's behaviour from a queue into a stack. boolean,\n * (default true)\n */\n readonly fifo?: boolean\n\n /**\n * Int between 1 and x - if set, borrowers can specify their relative priority in the queue if no resources\n * are available. see example. (default 1)\n */\n readonly priorityRange?: number\n\n /**\n * How often to run eviction checks. Default: 0 (does not run).\n */\n readonly evictionRunIntervalMillis?: number\n\n /**\n * Number of resources to check each eviction run. Default: 3.\n */\n readonly numTestsPerRun?: number\n\n /**\n * Amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object\n * evictor (if any), with the extra condition that at least \"min idle\" object instances remain in the pool.\n * Default -1 (nothing can get evicted)\n */\n readonly softIdleTimeoutMillis?: number\n\n /**\n * The minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due\n * to idle time. Supercedes softIdleTimeoutMillis Default: 30000\n */\n readonly idleTimeoutMillis?: number\n\n /*\n * Function handling errors thrown by drivers pool.\n * Defaults to logging error with `warn` level.\n */\n readonly errorHandler?: (err: any) => any\n }\n\n /**\n * Extra options\n */\n readonly options?: {\n /**\n * The named instance to connect to\n */\n readonly instanceName?: string\n\n /**\n * By default, if the database requestion by options.database cannot be accessed, the connection will fail with\n * an error. However, if options.fallbackToDefaultDb is set to true, then the user's default database will\n * be used instead (Default: false).\n */\n readonly fallbackToDefaultDb?: boolean\n\n /**\n * If true, SET ANSI_NULL_DFLT_ON ON will be set in the initial sql. This means new columns will be nullable by\n * default. See the T-SQL documentation for more details. (Default: true).\n */\n readonly enableAnsiNullDefault?: boolean\n\n /**\n * The number of milliseconds before the attempt to connect is considered failed (default: 15000).\n */\n readonly connectTimeout?: number\n\n /**\n * The number of milliseconds before the cancel (abort) of a request is considered failed (default: 5000).\n */\n readonly cancelTimeout?: number\n\n /**\n * The size of TDS packets (subject to negotiation with the server). Should be a power of 2. (default: 4096).\n */\n readonly packetSize?: number\n\n /**\n * A boolean determining whether to pass time values in UTC or local time. (default: false).\n */\n readonly useUTC?: boolean\n\n /**\n * A boolean determining whether to rollback a transaction automatically if any error is encountered during\n * the given transaction's execution. This sets the value for SET XACT_ABORT during the initial SQL phase\n * of a connection (documentation).\n */\n readonly abortTransactionOnError?: boolean\n\n /**\n * A string indicating which network interface (ip address) to use when connecting to SQL Server.\n */\n readonly localAddress?: string\n\n /**\n * A boolean determining whether to return rows as arrays or key-value collections. (default: false).\n */\n readonly useColumnNames?: boolean\n\n /**\n * A boolean, controlling whether the column names returned will have the first letter converted to lower case\n * (true) or not. This value is ignored if you provide a columnNameReplacer. (default: false).\n */\n readonly camelCaseColumns?: boolean\n\n /**\n * A boolean, controlling whatever to disable RETURNING / OUTPUT statements.\n */\n readonly disableOutputReturning?: boolean\n\n /**\n * A boolean, controlling whether MssqlParameter types char, varchar, and text are converted to their unicode equivalents, nchar, nvarchar, and ntext.\n * (default: false, meaning that char/varchar/text parameters will be converted to nchar/nvarchar/ntext)\n */\n readonly disableAsciiToUnicodeParamConversion?: boolean\n\n /**\n * Debug options\n */\n readonly debug?: {\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet details\n * (default: false).\n */\n readonly packet?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet data details\n * (default: false).\n */\n readonly data?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing packet payload details\n * (default: false).\n */\n readonly payload?: boolean\n\n /**\n * A boolean, controlling whether debug events will be emitted with text describing token stream tokens\n * (default: false).\n */\n readonly token?: boolean\n }\n\n /**\n * The default isolation level that transactions will be run with. The isolation levels are available\n * from require('tedious').ISOLATION_LEVEL. (default: READ_COMMITTED).\n */\n readonly isolation?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * The default isolation level for new connections. All out-of-transaction queries are executed with this\n * setting. The isolation levels are available from require('tedious').ISOLATION_LEVEL .\n */\n readonly connectionIsolationLevel?:\n | \"READ_UNCOMMITTED\"\n | \"READ_COMMITTED\"\n | \"REPEATABLE_READ\"\n | \"SERIALIZABLE\"\n | \"SNAPSHOT\"\n\n /**\n * A boolean, determining whether the connection will request read only access from a SQL Server\n * Availability Group. For more information, see here. (default: false).\n */\n readonly readOnlyIntent?: boolean\n\n /**\n * A boolean determining whether or not the connection will be encrypted. Set to true if you're on\n * Windows Azure. (default: true).\n */\n readonly encrypt?: boolean\n\n /**\n * When encryption is used, an object may be supplied that will be used for the first argument when calling\n * tls.createSecurePair (default: {}).\n */\n readonly cryptoCredentialsDetails?: any\n\n /**\n * A boolean, that when true will expose received rows in Requests' done* events. See done, doneInProc and\n * doneProc. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnDone?: boolean\n\n /**\n * A boolean, that when true will expose received rows in Requests' completion callback. See new Request. (default: false)\n * Caution: If many row are received, enabling this option could result in excessive memory usage.\n */\n readonly rowCollectionOnRequestCompletion?: boolean\n\n /**\n * The version of TDS to use. If server doesn't support specified version, negotiated version is used instead.\n * The versions are available from require('tedious').TDS_VERSION. (default: 7_4).\n */\n readonly tdsVersion?: string\n\n /**\n * A boolean, that when true will abort a query when an overflow or divide-by-zero error occurs during query execution.\n */\n readonly enableArithAbort?: boolean\n\n /**\n * Application name used for identifying a specific application in profiling, logging or tracing tools of SQL Server.\n * (default: node-mssql)\n */\n readonly appName?: string\n\n /**\n * A boolean, controlling whether encryption occurs if there is no verifiable server certificate.\n * (default: false)\n */\n readonly trustServerCertificate?: boolean\n }\n\n /**\n * Replication setup.\n */\n readonly replication?: {\n /**\n * Master server used by orm to perform writes.\n */\n readonly master: SqlServerConnectionCredentialsOptions\n\n /**\n * List of read-from severs (slaves).\n */\n readonly slaves: SqlServerConnectionCredentialsOptions[]\n }\n\n readonly poolSize?: never\n}\n"],"sourceRoot":"../.."}
@@ -2368,6 +2368,7 @@ export class SqlServerQueryRunner extends BaseQueryRunner {
2368
2368
  * Converts MssqlParameter into real mssql parameter type.
2369
2369
  */
2370
2370
  mssqlParameterToNativeParameter(parameter) {
2371
+ var _a, _b, _c;
2371
2372
  switch (this.driver.normalizeType({ type: parameter.type })) {
2372
2373
  case "bit":
2373
2374
  return this.driver.mssql.Bit;
@@ -2392,12 +2393,24 @@ export class SqlServerQueryRunner extends BaseQueryRunner {
2392
2393
  case "tinyint":
2393
2394
  return this.driver.mssql.TinyInt;
2394
2395
  case "char":
2396
+ if ((_a = this.driver.options.options) === null || _a === void 0 ? void 0 : _a.disableAsciiToUnicodeParamConversion) {
2397
+ return this.driver.mssql.Char(...parameter.params);
2398
+ }
2399
+ return this.driver.mssql.NChar(...parameter.params);
2395
2400
  case "nchar":
2396
2401
  return this.driver.mssql.NChar(...parameter.params);
2397
2402
  case "text":
2403
+ if ((_b = this.driver.options.options) === null || _b === void 0 ? void 0 : _b.disableAsciiToUnicodeParamConversion) {
2404
+ return this.driver.mssql.Text;
2405
+ }
2406
+ return this.driver.mssql.Ntext;
2398
2407
  case "ntext":
2399
2408
  return this.driver.mssql.Ntext;
2400
2409
  case "varchar":
2410
+ if ((_c = this.driver.options.options) === null || _c === void 0 ? void 0 : _c.disableAsciiToUnicodeParamConversion) {
2411
+ return this.driver.mssql.VarChar(...parameter.params);
2412
+ }
2413
+ return this.driver.mssql.NVarChar(...parameter.params);
2401
2414
  case "nvarchar":
2402
2415
  return this.driver.mssql.NVarChar(...parameter.params);
2403
2416
  case "xml":