Can you help me test if replaceing this:

        subselect = db(query)._select(
            db.task_scheduled.id,limitby=(0,1),
            orderby=db.task_scheduled.next_run_time)
        db(db.task_scheduled.id.belongs(subselect)).update(
            status=RUNNING,
            assigned_worker_name=self.worker_name,
            last_run_time=datetime.now)


with this

        from gluon.dal import raw
        subselect = db(query)._select(
            db.task_scheduled.id,limitby=(0,1),
            orderby=db.task_scheduled.next_run_time)
        db(db.task_scheduled.id == raw(subselect)).update(
            status=RUNNING,
            assigned_worker_name=self.worker_name,
            last_run_time=datetime.now)

works and fixed the problem with mysql?

On Aug 13, 4:56 am, G <[email protected]> wrote:
> Hello,
> I just tried to use scheduler.py with MySQL instead of SQLite and ran
> into this error:
>
> NotSupportedError: (1235, "This version of MySQL doesn't yet support
> 'LIMIT & IN/ALL/ANY/SOME subquery'")
>
> The MySQL server version is 5.0.77. Searching on the web, it seems
> this limitation is common. Is there a way to work around the issue?
> The offending SQL looks like this:
>
> UPDATE task_scheduled SET
> status='running',assigned_worker_name='crabby#237cf3f0-89e7-4db5-
> b514-56db27a700d5',last_run_time='2011-08-13 09:33:01' WHERE
> (task_scheduled.id IN (SELECT  task_scheduled.id FROM task_scheduled
> WHERE (((((task_scheduled.enabled = 'T') AND (task_scheduled.status =
> 'queued')) AND (task_scheduled.group_name IN ('command','main'))) AND
> (task_scheduled.next_run_time < '2011-08-13 09:33:01')) AND
> (((task_scheduled.assigned_worker_name = '') OR
> (task_scheduled.assigned_worker_name IS NULL)) OR
> (task_scheduled.assigned_worker_name = 'crabby#237cf3f0-89e7-4db5-
> b514-56db27a700d5'))) ORDER BY task_scheduled.next_run_time LIMIT 1
> OFFSET 0));
>
> I'm pretty sure this is coming from the massively complex query in
> assign_next_task.
>
> Thanks,
> G

Reply via email to