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

BUG? - Update using Repository.createQueryBuilder #1084

Closed
Diluka opened this issue Oct 24, 2017 · 4 comments
Closed

BUG? - Update using Repository.createQueryBuilder #1084

Diluka opened this issue Oct 24, 2017 · 4 comments
Labels

Comments

@Diluka
Copy link
Contributor

Diluka commented Oct 24, 2017

Repository.createQueryBuilder must pass a string as alias but update sql doesn't declare alias.

        await giftRepository.createQueryBuilder("g")
            .update()
            .set({"used": () => "used + 1"})
            .where("g.id = :id", {id: gift.id})
            .execute();
UPDATE `G0002_Gift` SET `used` = used + 1 WHERE g.id = ?

Error: Unknown column 'g.id' in 'where clause'

@pleerock
Copy link
Member

in delete/update/insert query builders you don't need to use aliases, e.g. replace g.id to simply id

@Diluka
Copy link
Contributor Author

Diluka commented Oct 24, 2017

If await giftRepository.createQueryBuilder() compiler tells me there must be 1 parameter

@Diluka
Copy link
Contributor Author

Diluka commented Oct 26, 2017

Any update? @pleerock
Is there a typing error or I should not use Repository.createQueryBuilder to update?

Repository.createQueryBuilder need at least 1 parameter

@pleerock
Copy link
Member

maybe we can make alias argument optional in repository too

@pleerock pleerock reopened this Oct 26, 2017
pleerock pushed a commit that referenced this issue Nov 21, 2017
* master:
  fixing #1055 related issues
  fixes #1084
  fixed #1099
  Update working-with-entity-manager.md
  Update working-with-entity-manager.md
  version bump
  driver(sqljs): added missing promises in test
  pool.connect => pool.getConnection
  issue #1099 sql generation error with skip condition
  Added tests for GitHub issue #1055

# Conflicts:
#	docs/working-with-entity-manager.md
#	package.json
#	test/functional/query-builder/insert/query-builder-insert.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants