Django

Code

Ticket #3447 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

Attempt to add new inline-edited item in admin interface results in ProgrammingError ERROR: invalid input syntax for integer: "". Used to work in older SVN snapshot.

Reported by: mdkemp Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: SVN Keywords: edit_inline, ProgrammingError
Cc: mir@noris.de Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Consider the following extremely-simple inline-edited relationship:

class Case(models.Model):
	name = models.CharField(maxlength=100)

	class Admin:
		pass


class Label(models.Model):
	case = models.ForeignKey(Case, edit_inline=models.TABULAR)
	name = models.CharField(maxlength=100, core=True)

	class Admin:
		pass

In this case, if I try to add a new Label to a Case (while editing the Case via its admin interface view), I get the following error:

Exception Type:  	ProgrammingError
Exception Value: 	ERROR: invalid input syntax for integer: "" SELECT 1 FROM "peopledb_label" WHERE "id"='' LIMIT 1

The following were the arguments from the HTTP POST operation when I clicked Save:

label.0.id     ''
name           'Case1'
label.0.name   'TestLabel1'

It appears that when trying to determine if an old record should be updated rather than inserted into the database, an invalid query was built. I've encountered this problem now on three different django projects. This used to work in a version of django from a SVN snapshot around 12/15/2006, and does work if I revert my installed django to that version.

Attachments

Change History

(follow-up: ↓ 3 ) 02/07/07 03:59:21 changed by ramiro <rm0 _at_ gmx.net>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

I guess this is caused by [4459]

Could you try your test case against r4458 and report back please?

02/07/07 07:41:03 changed by Michael Radziej <mir@noris.de>

  • cc set to mir@noris.de.

(in reply to: ↑ 1 ) 02/07/07 12:52:15 changed by mdkemp <mdkemp-django@mdkemp.net>

Replying to ramiro <rm0 _at_ gmx.net>:

I guess this is caused by [4459] Could you try your test case against r4458 and report back please?

Indeed, it worked with r4458 and failed with r4459.

02/07/07 14:25:10 changed by Michael Radziej <mir@noris.de>

  • stage changed from Unreviewed to Accepted.

02/07/07 16:56:53 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [4463]) Fixes #3447, Refs #2160 -- Reverting change [4459] because it breaks admin. Apologies for the inconvenience, guys.


Add/Change #3447 (Attempt to add new inline-edited item in admin interface results in ProgrammingError ERROR: invalid input syntax for integer: "". Used to work in older SVN snapshot.)




Change Properties
Action