Opened 18 years ago
Closed 16 years ago
#3246 closed defect (wontfix)
SQL generation not working properly in per-object-permissions branch
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | other branch |
Severity: | normal | Keywords: | per-object-permissions |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm getting the following error when I use the per-object-permission branch when performing a validation in a form (using newforms).
NOTE: this works fine on trunk... this bug only applies to branches/per-object-permission.
The error:
Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "/home/stefan/projects/svac2/svac/../svac/project/views.py" in application 10. if form.is_valid(): File "/usr/lib/python2.4/site-packages/django/newforms/forms.py" in is_valid 77. return not self.ignore_errors and not bool(self.errors) File "/usr/lib/python2.4/site-packages/django/newforms/forms.py" in _errors 68. self.full_clean() File "/usr/lib/python2.4/site-packages/django/newforms/forms.py" in full_clean 154. value = getattr(self, 'clean_%s' % name)() File "/home/stefan/projects/svac2/svac/../svac/project/forms.py" in clean_name 13. p = Project.objects.get(name=name) File "/usr/lib/python2.4/site-packages/django/db/models/manager.py" in get 67. return self.get_query_set().get(*args, **kwargs) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in get 211. obj_list = list(clone) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in __iter__ 103. return iter(self._get_data()) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in _get_data 430. self._result_cache = list(self.iterator()) File "/usr/lib/python2.4/site-packages/django/db/models/query.py" in iterator 172. cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select) + sql, params) File "/usr/lib/python2.4/site-packages/django/db/backends/util.py" in execute 12. return self.cursor.execute(sql, params) ProgrammingError at /project/application/ ERROR: column "a" does not exist SELECT "project_project"."id","project_project"."name","project_project"."owner_id","project_project"."short_description","project_project"."long_description","project_project"."active" FROM "project_project" WHERE ("project_project"."name" = a)
The model:
class Project(models.Model): name = models.CharField(maxlength=64,unique=True) owner = models.ForeignKey(User) short_description = models.TextField(maxlength=256) long_description = models.TextField() active = models.BooleanField()
The form:
class ApplicationForm(forms.Form): name = forms.CharField(max_length=64) short_description = forms.CharField(max_length=256, widget=Textarea) long_description = forms.CharField(widget=Textarea) def clean_name(self): name = self.clean_data['name'] p = Project.objects.get(name=name) if p: raise ValidationError(u'Project name is taken, please choose another name.') return name
The view:
def application(request): if request.POST: form = ApplicationForm(request.POST) if form.is_valid(): #project = Project print 'form is valid' return HttpResponseRedirect('/project/application') else: context = {'form':form, 'error_msg':"Please correct the error(s) below"} else: context = {'form':ApplicationForm()} return render_to_response("project/application.html", context, context_instance=RequestContext(request))
The error occurs when I submit the form containing valid information... it seems that the SQL generated from the line p = Project.objects.get(name=name) is invalid. The value of the "name" variable is 'a' but it isn't surrounded by quotes in the SQL to specify that it is a string so it's taken to be a column name.
Change History (2)
comment:1 by , 18 years ago
Component: | Core framework → Database wrapper |
---|---|
Keywords: | per-object-permissions added |
Triage Stage: | Unreviewed → Accepted |
Version: | SVN → other branch |
comment:2 by , 16 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Given that the branch in question is inactive and unlikely to be resurrected in its current form, this isn't going to be attended to.