diff options
author | snowman2 <alansnow21@gmail.com> | 2020-05-09 09:17:21 -0400 |
---|---|---|
committer | Gord Thompson <gord@gordthompson.com> | 2020-05-24 06:05:18 -0600 |
commit | 360583a00abc0bf99a29a40b918bb5f741dc5198 (patch) | |
tree | 41eaa15e58fa563fb25bbc01a8dfb4c109b1549f /lib | |
parent | f79953a874c201a31a8972b999d18547bf227f25 (diff) | |
download | sqlalchemy-360583a00abc0bf99a29a40b918bb5f741dc5198.tar.gz |
SYBASE: Added offset support
Fixes: #5294
### Description
Fix for https://github.com/sqlalchemy/sqlalchemy/issues/5294#issue-610311455
I tested it against our database (Adaptive Server Enterprise/16.0 SP02) with `pyodbc+sybase`
### Checklist
This pull request is:
- [x] A short code fix for #5294
- [x] Added tests.
Closes: #5312
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5312
Pull-request-sha: f62c14825f2941fdd54ede17fd8d4f105a052e05
Change-Id: Ic716e17a6f654deef78781cefc3f16333cd725c3
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/dialects/sybase/base.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/sqlalchemy/dialects/sybase/base.py b/lib/sqlalchemy/dialects/sybase/base.py index 77ebfac93..e3848a9b2 100644 --- a/lib/sqlalchemy/dialects/sybase/base.py +++ b/lib/sqlalchemy/dialects/sybase/base.py @@ -516,23 +516,18 @@ class SybaseSQLCompiler(compiler.SQLCompiler): {"doy": "dayofyear", "dow": "weekday", "milliseconds": "millisecond"}, ) - def get_select_precolumns(self, select, **kw): - s = select._distinct and "DISTINCT " or "" - - if select._simple_int_limit and not select._offset: - kw["literal_execute"] = True - s += "TOP %s " % self.process(select._limit_clause, **kw) - - if select._offset: - raise NotImplementedError("Sybase ASE does not support OFFSET") - return s - def get_from_hint_text(self, table, text): return text def limit_clause(self, select, **kw): - # Limit in sybase is after the select keyword - return "" + text = "" + if select._limit_clause is not None: + text += " ROWS LIMIT " + self.process(select._limit_clause, **kw) + if select._offset_clause is not None: + if select._limit_clause is None: + text += " ROWS" + text += " OFFSET " + self.process(select._offset_clause, **kw) + return text def visit_extract(self, extract, **kw): field = self.extract_map.get(extract.field, extract.field) |