Ticket #1892 (new defect)

Opened 3 months ago

Last modified 4 weeks ago

[PATCH]: apply all constraints in testutil.dbtest after creating all tests

Reported by: mw44118 Assigned to: kskuhlman
Priority: normal Milestone: 1.1 beta 2
Component: TurboGears Version: 1.0.4.4
Severity: normal Keywords: needs tests
Cc:

Description (Last modified by Chris Arndt)

I have two tables with foreign keys that refer to each other. I need to create both tables before I apply the FK constraints.

SQLObject docs describe how to do this here: http://sqlobject.org/FAQ.html#mutually-referencing-tables

This patch alters testutil so it waits for all tables to be created before it adds any constraints.

Attachments

my_patch.diff (1.2 kB) - added by mw44118 on 07/09/08 12:09:08.
Waits until all tables are created to go back and add FK constraints.

Change History

07/09/08 12:09:08 changed by mw44118

  • attachment my_patch.diff added.

Waits until all tables are created to go back and add FK constraints.

08/21/08 12:38:49 changed by kskuhlman

  • owner changed from anonymous to kskuhlman.

08/21/08 13:17:11 changed by Chris Arndt

A few comments on the patch:

  • There should be a source code comment explaining what's going on.
  • The if istance(..) body is indented incorrectly.
  • applyConstraints=0 should be applyConstraints=False according to the linked SQLObject documentation.
  • constraints += postponed_constraint should be written a contraints.extends(postponed_constraint).

Also, a test is missing.

08/21/08 13:22:59 changed by mw44118

I'll resubmit the patch with the first few points.

I'm not sure how to write a test for this code. If you outline what is involved, I'll take a shot at it.

08/28/08 14:53:41 changed by Chris Arndt

  • description changed.
  • milestone set to 1.1.

See http://docs.turbogears.org/1.1/Testing on how to write test for TG 1.1. You need to create and example model with mutually referencing tables and then write test methods which check if the setUp method of the test class correctly created the model.

The test should go into the turbogears.tests.test_model module.

09/10/08 16:49:38 changed by Chris Arndt

  • keywords set to needs tests.
  • milestone changed from 1.1 to 1.1 beta 2.