diff --git a/CHANGELOG.md b/CHANGELOG.md index bdc36ab6..bd8ba8dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# [3.2.0](https://github.com/tada5hi/typeorm-extension/compare/v3.1.1...v3.2.0) (2023-11-25) + + +### Bug Fixes + +* **deps:** bump @faker-js/faker from 8.2.0 to 8.3.1 ([#782](https://github.com/tada5hi/typeorm-extension/issues/782)) ([fa7a114](https://github.com/tada5hi/typeorm-extension/commit/fa7a114d7508e635377fbf7c19bd9cfbaaf4ab05)) +* **deps:** bump locter from 1.2.2 to 1.2.3 ([#779](https://github.com/tada5hi/typeorm-extension/issues/779)) ([e89daea](https://github.com/tada5hi/typeorm-extension/commit/e89daeab5bd2c0d08ee2503dc259b7e601d790c1)) + + +### Features + +* seeder with non default export ([#776](https://github.com/tada5hi/typeorm-extension/issues/776)) ([e1fe651](https://github.com/tada5hi/typeorm-extension/commit/e1fe651397b9f217ca5321db407aca255e5ae5ad)) + ## [3.1.1](https://github.com/tada5hi/typeorm-extension/compare/v3.1.0...v3.1.1) (2023-10-24) diff --git a/package-lock.json b/package-lock.json index 41e00500..c120536e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "typeorm-extension", - "version": "3.1.1", + "version": "3.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "typeorm-extension", - "version": "3.1.1", + "version": "3.2.0", "license": "MIT", "dependencies": { "@faker-js/faker": "^8.3.1", diff --git a/package.json b/package.json index 7353ab96..91dea3a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typeorm-extension", - "version": "3.1.1", + "version": "3.2.0", "description": "A library to create/drop database, simple seeding data sets, ...", "author": { "name": "Peter Placzek", diff --git a/src/data-source/options/utils/merge.ts b/src/data-source/options/utils/merge.ts index b83797f5..93651833 100644 --- a/src/data-source/options/utils/merge.ts +++ b/src/data-source/options/utils/merge.ts @@ -1,6 +1,18 @@ -import { merge } from 'smob'; +import { createMerger } from 'smob'; import type { DataSourceOptions } from 'typeorm'; +const merge = createMerger({ + strategy: (target, key, value) => { + if (typeof target[key] === 'undefined') { + target[key] = value; + + return target; + } + + return undefined; + }, +}); + export function mergeDataSourceOptions( target: DataSourceOptions, source: DataSourceOptions, diff --git a/test/unit/data-source/options/merge.spec.ts b/test/unit/data-source/options/merge.spec.ts new file mode 100644 index 00000000..17d00b7a --- /dev/null +++ b/test/unit/data-source/options/merge.spec.ts @@ -0,0 +1,32 @@ +import type { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions'; +import { mergeDataSourceOptions } from '../../../../src'; + +describe('src/data-source/options/merge', () => { + it('should merge data source options', () => { + const options = mergeDataSourceOptions({ + type: 'postgres', + password: undefined, + }, { + type: 'postgres', + password: 'password', + }); + + expect(options).toBeDefined(); + expect(options.type).toEqual('postgres'); + expect((options as PostgresConnectionOptions).password).toEqual('password'); + }); + + it('should not merge data source options', () => { + const options = mergeDataSourceOptions({ + type: 'postgres', + password: undefined, + }, { + type: 'mysql', + password: 'password', + }); + + expect(options).toBeDefined(); + expect(options.type).toEqual('postgres'); + expect((options as PostgresConnectionOptions).password).toBeUndefined(); + }); +});