DibiTranslator: respect %if blocks for %lmt and %ofs as well #145
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes issue #87.
In current dibi, something like
yields
SELECT * FROM foo /* */ LIMIT 3 OFFSET 5
, which is probably not what you want.This changes the translation of
%lmt
and%ofs
to only set->limit
and->offset
when->comment
is falsy.The new behaviour is to generate
SELECT * FROM foo /* (limit 3) ... (offset 5) */
.I would have preferred to generate proper SQL, but it would have been possible only with the MySQL_, Postgres and SQLite_ drivers. The other drivers'
applyLimit
changes the whole SQL statement and thus would generate horrible stuff.Thus, while I feel it's necessary to mention the limit/offset in the comment (because debugability), I think we should not pretend to generate valid SQL by making it
/* LIMIT 3 OFFSET 5 */
because since we can't make it valid always, we should be explicit about it not being valid.But feel free to change it, obviously :).