Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bugs introduced in 0.3.0 #8764

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/custom-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ In order to extend `UserRepository` functionality you can use `.extend` method o
```typescript
// user.repository.ts
export const UserRepository = dataSource.getRepository(User).extend({
findByName(firstName: string, lastName: string) {
findOneByName(firstName: string, lastName: string) {
return this.createQueryBuilder("user")
.where("user.firstName = :firstName", { firstName })
.andWhere("user.lastName = :lastName", { lastName })
Expand Down
11 changes: 0 additions & 11 deletions src/connection/options-reader/ConnectionOptionsEnvReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,6 @@ export class ConnectionOptionsEnvReader {
"TYPEORM_MAX_QUERY_EXECUTION_TIME",
),
debug: PlatformTools.getEnvVariable("TYPEORM_DEBUG"),
cli: {
entitiesDir: PlatformTools.getEnvVariable(
"TYPEORM_ENTITIES_DIR",
),
migrationsDir: PlatformTools.getEnvVariable(
"TYPEORM_MIGRATIONS_DIR",
),
subscribersDir: PlatformTools.getEnvVariable(
"TYPEORM_SUBSCRIBERS_DIR",
),
},
cache: this.transformCaching(),
uuidExtension: PlatformTools.getEnvVariable(
"TYPEORM_UUID_EXTENSION",
Expand Down
20 changes: 0 additions & 20 deletions src/data-source/BaseDataSourceOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,4 @@ export interface BaseDataSourceOptions {
*/
readonly ignoreErrors?: boolean
}

/**
* CLI settings.
*/
readonly cli?: {
/**
* Directory where entities should be created by default.
*/
readonly entitiesDir?: string

/**
* Directory where migrations should be created by default.
*/
readonly migrationsDir?: string

/**
* Directory where subscribers should be created by default.
*/
readonly subscribersDir?: string
}
}
22 changes: 8 additions & 14 deletions src/data-source/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,6 @@ export class DataSource {
*/
setOptions(options: Partial<DataSourceOptions>): this {
Object.assign(this.options, options)

this.logger = new LoggerFactory().create(
this.options.logger,
this.options.logging,
)
this.driver = new DriverFactory().create(this)
this.namingStrategy =
options.namingStrategy || new DefaultNamingStrategy()
this.queryResultCache = options.cache
? new QueryResultCacheFactory(this).create()
: undefined

// build all metadatas to make sure options are valid
// await this.buildMetadatas();
return this
}

Expand Down Expand Up @@ -681,5 +667,13 @@ export class DataSource {
),
this.driver,
)

// set current data source to the entities
for (let entityKey in flattenedEntities) {
const entity = flattenedEntities[entityKey]
if (InstanceChecker.isBaseEntityConstructor(entity)) {
entity.useDataSource(this)
}
}
}
}
9 changes: 8 additions & 1 deletion src/entity-manager/EntityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,14 @@ export class EntityManager {
withRepository<Entity, R extends Repository<Entity>>(repository: R): R {
const repositoryConstructor =
repository.constructor as typeof Repository
return new repositoryConstructor(repository.target, this) as R
const { target, manager, queryRunner, ...otherRepositoryProperties } =
repository
return Object.assign(
new repositoryConstructor(repository.target, this) as R,
{
...otherRepositoryProperties,
},
)
}

/**
Expand Down