db.select "limit" clause should map to "top #" on mssql databases
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
web.py |
Fix Released
|
Low
|
Anand Chitipothu |
Bug Description
import web
db = web.database(
app = web.application
render = web.template.
urls = (
'/', 'get_data',
)
class get_data:
def GET(self):
records = db.select(
return render.
-------
Running the above on a MSSQL database fails because MSSQL does not have a limit clause. It has a "top" clause which can be used for equivalence.
127.0.0.1:56305 - - [01/Feb/2009 14:05:41] "HTTP/1.1 GET /" - 500 Internal Server Error
ERR: SELECT * FROM some_table LIMIT 33
Traceback (most recent call last):
File "C:\Python25\
return self.handle()
File "C:\Python25\
return self._delegate(fn, self.fvars, args)
File "C:\Python25\
return handle_class(cls)
File "C:\Python25\
return tocall(*args)
File "C:\webpy\
records = db.select(
File "c:\python25\
return self.query(qout, processed=True)
File "c:\python25\
self.
File "c:\python25\
for x in sql_query.
File "c:\python25\
self.
File "c:\python25\
raise DatabaseError, "internal error: %s" % self.__
DatabaseError: internal error: SQL Server message 102, severity 15, state 1, line 1:
Incorrect syntax near '33'.
DB-Lib error message 10007, severity 5:
General SQL Server error: Check messages from the SQL Server.
-------
Running the basic command in Query Analyzer fails as well.
-------
The database select functions should check if the database engine is mssql, then map LIMIT to TOP and put it AFTER the select statement, but before the field list.
Example.
db.select(
use_top = False --> Select * from some_table limit 4
use_top = True --> Select top 4 * from some_table
Changed in webpy: | |
assignee: | nobody → anandology |
importance: | Undecided → Low |
milestone: | none → 0.32 |
status: | New → Fix Committed |
Changed in webpy: | |
status: | Fix Committed → Fix Released |