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 - QueryBuilder MySQL skip sql is wrong #1099

Closed
Diluka opened this issue Oct 26, 2017 · 3 comments
Closed

BUG - QueryBuilder MySQL skip sql is wrong #1099

Diluka opened this issue Oct 26, 2017 · 3 comments
Labels

Comments

@Diluka
Copy link
Contributor

Diluka commented Oct 26, 2017

I set skip(20) then generate a wrong sql

SELECT DISTINCT `distinctAlias`.`ta_id` as "ids_ta_id"  FROM (SELECT `ta`.`id` AS `ta_id` FROM `TourArticle` `ta`) `distinctAlias` ORDER BY `ta_id` ASC OFFSET 20

Error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OFFSET 20' at line 1
@pleerock
Copy link
Member

can you please create a PR with a test for this issue?

@pleerock
Copy link
Member

Okay so answer to this issue is here. You cannot have offset in the mysql without limit applied. And as I remember its not only mysql limitation. So you have to use take in conjunction with skip.

@pleerock
Copy link
Member

I made a small change - now query runner will throw OffsetWithoutLimitNotSupportedError error for mysql driver when user uses skip without offset and updated your test.

pleerock pushed a commit that referenced this issue Nov 21, 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
sfodor added a commit to zooshgroup/typeorm that referenced this issue Sep 6, 2019
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