I'm running web2py (version Version 2.21.1) on pythonanywhere with Python 3.7:
I've been wrestling with sqlform.grid in a project.
When the page first loads, this component is loaded with this code:
{=LOAD('default', 'video_row_assignments.load', vars={"packageId":packageId,"videoId":videoId,"display_type":"available_seasons","show":"mainPage","calledBy":"video_seasons_div"}, ajax=True)}}
But when I try to update the grid it returns this error:
Query Not Supported: (1064, "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 '-20' at line 1")
But it also returns working pagination links such as this (I've disable this as a link below by changing <a to <aX, because this is not a publicly accessible site):
and those pagination links bring up the correct records. This tells me it's not really a SQL syntax problem, but something else.
Here's my Controller code, attempting to retrieve all the records in this case:
(`seasons`.`id` >= 0)
available_seasons = SQLFORM.grid(self.query, fields=[db.series.id, db.seasons.id, Field.Virtual('videoId', lambda row: self.videoId)],maxtextlengths={'db.series.id' : 250,'db.seasons.id':250},left=self.left, deletable=False, editable=False, orderby=self.orderby, details=False, csv=False, field_id=db.seasons.id, selectable=self.selectable, selectable_submit_button='Add Video To Checked Seasons',formname='addSeasons',headers=headers)
Any ideas on what's going on here? It seems like it's trying to load page 0, when it should be loading page 1.
Thanks in advance for any help.
I turns out this was a pagination problem of sorts. I had two divs on the client side with the same "page" id, which caused the client to pass a page=0 value to the controller.
My controller code was perfectly fine, it was just getting an illegal page value.
Sometimes, when you're too deep in the weeds, you can't see what's really going on!
This issue has been solved.