question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: this.subQuery is not a function

See original GitHub issue

I don’t really know what I am doing wrong, can you help me?

This is the complete output:

 yarn ts-node -r tsconfig-paths/register ../../node_modules/typeorm-seeding/dist/cli.js seed
yarn run v1.22.0
$ /Volumes/SD/Users/bruno/Projects/corona-down/node_modules/.bin/ts-node -r tsconfig-paths/register ../../node_modules/typeorm-seeding/dist/cli.js seed
🌱 TypeORM Seeding v1.4.4
✔ ORM Config loaded
✔ Factories are imported
✔ Seeders are imported
✔ Database connected
✖ Could not run the seed CreateApplicationToken!
TypeError: this.subQuery is not a function
    at InsertQueryBuilder.QueryBuilder.createFromAlias (/Volumes/SD/Users/bruno/Projects/corona-down/src/query-builder/QueryBuilder.ts:551:131)
    at InsertQueryBuilder.into (/Volumes/SD/Users/bruno/Projects/corona-down/src/query-builder/InsertQueryBuilder.ts:158:32)
    at CreateApplicationToken.run (/Volumes/SD/Users/bruno/Projects/corona-down/packages/backend/src/database/seeds/CreateApplicationToken.ts:11:8)
    at /Volumes/SD/Users/bruno/Projects/corona-down/node_modules/typeorm-seeding/src/typeorm-seeding.ts:48:17
    at step (/Volumes/SD/Users/bruno/Projects/corona-down/node_modules/tslib/tslib.js:139:27)
    at Object.next (/Volumes/SD/Users/bruno/Projects/corona-down/node_modules/tslib/tslib.js:120:57)
    at /Volumes/SD/Users/bruno/Projects/corona-down/node_modules/tslib/tslib.js:113:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Volumes/SD/Users/bruno/Projects/corona-down/node_modules/tslib/tslib.js:109:16)
    at Object.exports.runSeeder (/Volumes/SD/Users/bruno/Projects/corona-down/node_modules/typeorm-seeding/src/typeorm-seeding.ts:46:57)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This is my seeder:

import { Factory, Seeder } from 'typeorm-seeding';
import { Connection } from 'typeorm';
import { ApplicationToken } from '@backend/entities/ApplicationToken';
import uniqueString = require('unique-string');

export default class CreateApplicationToken implements Seeder {
  public async run(_factory: Factory, connection: Connection): Promise<void> {
    await connection
      .createQueryBuilder()
      .insert()
      .into(ApplicationToken)
      .values([
        { token: uniqueString() },
      ])
      .execute();
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
eranshmilcommented, Apr 15, 2020

This also happened to me, fixed that by setting the TYPEORM_ENTITIES environment variable.

1reaction
hirsch88commented, May 11, 2020

The error TypeError: this.subQuery is not a function is because typeorm could not find any entities.

Please check your paths in your config file

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error message TypeError: this.subQuery is not a function ...
If I run the tests with jest, I got always the error message TypeError: this.subQuery is not a function with a reference on...
Read more >
typeorm/typeorm - Gitter
Error during migration run: TypeError: this.subQuery is not a function. node_modules/typeorm/query-builder/QueryBuilder.js:361:57. Shijie Zhou. @shijiezhou1.
Read more >
Meme Overflow
Error message TypeError: this.subQuery is not a function appears https://stackoverflow.com/questions/69066313/806889…
Read more >
TypeORM - Query Builder with Subquery
IMPORTANT: What is setParameters() ? When you set some parameters on a subquery, setting values is not ready to execute with the main...
Read more >
TypeORM Sucks!! Something I wanted to talk about since ...
Relational query is not supported - subquery on relation etc. Eager loading is not supported. Cannot extend query builder. Repository is just ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found