select should verify its arguments

Bug #276901 reported by Aaron Bentley
2
Affects Status Importance Assigned to Milestone
Storm
New
Undecided
Unassigned

Bug Description

I wrote this:
Job.blocked_jobs = Select(
    Job.id, Job.id == JobDependency.dependant,
    PrerequisiteJob.id == JobDependency.prerequisite,
    PrerequisiteJob.status != JobStatus.COMPLETED)

I got this:
Error in test test_blockedJobs (canonical.launchpad.database.tests.test_job.TestJobDependency)
Traceback (most recent call last):
  File "/home/abentley/launchpad/split-mail/lib/canonical/launchpad/testing/__init__.py", line 171, in run
    testMethod()
  File "/home/abentley/launchpad/split-mail/lib/canonical/launchpad/database/tests/test_job.py", line 170, in test_blockedJobs
    self.assertEqual(
  File "/home/abentley/launchpad/split-mail/lib/storm/store.py", line 956, in __iter__
    result = self._store._connection.execute(self._get_select())
  File "/home/abentley/launchpad/split-mail/lib/storm/databases/postgres.py", line 257, in execute
    return Connection.execute(self, statement, params, noresult)
  File "/home/abentley/launchpad/split-mail/lib/storm/database.py", line 200, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "/home/abentley/launchpad/split-mail/lib/storm/databases/postgres.py", line 267, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "/home/abentley/launchpad/split-mail/lib/storm/database.py", line 281, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  File "/home/abentley/launchpad/split-mail/lib/storm/database.py", line 322, in _check_disconnect
    return function(*args, **kwargs)
  File "/home/abentley/launchpad/split-mail/lib/canonical/ftests/pgsql.py", line 100, in execute
    return self.__dict__['real_cursor'].execute(*args, **kwargs)
ProgrammingError: syntax error at or near "="
LINE 1: ...M Job WHERE Job.id IN (SELECT Job.id FROM "_1".id = JobDepen...

This is because PrerequisiteJob.id == JobDependency.prerequisite and PrerequisiteJob.status != JobStatus.COMPLETED were assigned to the tables and default_tables parameters, and SQL was blindly generated.

It would be nice if Storm had warned me that the parameters were wrong.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.