Changeset 3293
- Timestamp:
- 07/07/06 16:31:16 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/multiple-db-support/tests/modeltests/multiple_databases/models.py
r3281 r3293 132 132 True 133 133 134 # When not using transaction management, model save will commit only134 # When transactions are not managed, model save will commit only 135 135 # for the model's connection. 136 136 137 137 >>> from django.db import transaction 138 138 >>> transaction.enter_transaction_management() 139 >>> transaction.managed(False) 139 140 >>> a = Artist(name="Joan Miro", alive=False) 140 141 >>> w = Widget(code="99rbln", weight=1) django/branches/multiple-db-support/tests/othertests/ansi_sql.py
r3261 r3293 1 # For Python 2.3 2 if not hasattr(__builtins__, 'set'): 3 from sets import Set as set 4 1 5 """ 2 6 >>> from django.db import models … … 34 38 >>> builder.models_already_seen 35 39 [<class 'othertests.ansi_sql.Car'>] 36 >>> builder.models_already_seen = []40 >>> builder.models_already_seen = set() 37 41 38 42 # test that styles are used … … 41 45 42 46 # test pending relationships 43 >>> builder.models_already_seen = []47 >>> builder.models_already_seen = set() 44 48 >>> real_cnst = Mod._meta.connection_info.backend.supports_constraints 45 49 >>> Mod._meta.connection_info.backend.supports_constraints = True 46 50 >>> builder.get_create_table(Mod) 47 ([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL,...);')], [BoundStatement('ALTER TABLE "ansi_sql_mod" ADD CONSTRAINT ... FOREIGN KEY ("car_id") REFERENCES "ansi_sql_car" ("id");')])48 >>> builder.models_already_seen = []51 ([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL,...);')], {<class 'othertests.ansi_sql.Car'>: [BoundStatement('ALTER TABLE "ansi_sql_mod" ADD CONSTRAINT ... FOREIGN KEY ("car_id") REFERENCES "ansi_sql_car" ("id");')]}) 52 >>> builder.models_already_seen = set() 49 53 >>> builder.get_create_table(Car) 50 ([BoundStatement('CREATE TABLE "ansi_sql_car" (...);')], [])54 ([BoundStatement('CREATE TABLE "ansi_sql_car" (...);')], {}) 51 55 >>> builder.get_create_table(Mod) 52 ([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL REFERENCES "ansi_sql_car" ("id"),...);')], [])56 ([BoundStatement('CREATE TABLE "ansi_sql_mod" (..."car_id" integer NOT NULL REFERENCES "ansi_sql_car" ("id"),...);')], {}) 53 57 >>> Mod._meta.connection_info.backend.supports_constraints = real_cnst 54 58 55 59 # test many-many 56 60 >>> builder.get_create_table(Collector) 57 ([BoundStatement('CREATE TABLE "ansi_sql_collector" (...);')], [])61 ([BoundStatement('CREATE TABLE "ansi_sql_collector" (...);')], {}) 58 62 >>> builder.get_create_many_to_many(Collector) 59 [BoundStatement('CREATE TABLE "ansi_sql_collector_cars" (...);')] 63 {<class 'othertests.ansi_sql.Car'>: [BoundStatement('CREATE TABLE "ansi_sql_collector_cars" (...);')]} 60 64 61 65 # test indexes django/branches/multiple-db-support/tests/othertests/manager_schema_manipulation.py
r3266 r3293 88 88 89 89 >>> DA.objects.install() 90 [] 90 {} 91 91 >>> QA.objects.install() 92 [] 92 {} 93 93 >>> QB.objects.install() 94 [] 94 {} 95 95 >>> DA.objects.all() 96 96 [] … … 108 108 # meant to establish foreign key relationships to tables that don't 109 109 # exist. These are bound to the model's connection and should 110 # be executed after all models in the app have been installed. 110 # be executed after all models in the app have been installed. The pending 111 # statments are returned as a dict keyed by the model which must be installed 112 # before the pending statements can be installed. 111 113 112 114 # NOTE: pretend db supports constraints for this test … … 115 117 >>> result = PA.objects.install() 116 118 >>> result 117 [BoundStatement('ALTER TABLE "othertests_pa" ADD CONSTRAINT "c_id_referencing_othertests_pc_id" FOREIGN KEY ("c_id") REFERENCES "othertests_pc" ("id");')] 119 {<class 'othertests.manager_schema_manipulation.PC'>: [BoundStatement('ALTER TABLE "othertests_pa" ADD CONSTRAINT "c_id_referencing_othertests_pc_id" FOREIGN KEY ("c_id") REFERENCES "othertests_pc" ("id");')]} 118 120 119 121 # NOTE: restore real constraint flag 120 122 >>> PA._meta.connection_info.backend.supports_constraints = real_cnst 121 123 122 # Models with many-many relationships willalso have pending statement124 # Models with many-many relationships may also have pending statement 123 125 # lists. Like other pending statements, these should be executed after 124 # all models in the app have been installed. 126 # all models in the app have been installed. If the related table's model 127 # has already been created, then there will be no pending list. 125 128 126 129 >>> QC.objects.install() 127 [] 130 {} 128 131 >>> QD.objects.install() 129 [BoundStatement('CREATE TABLE "othertests_qd_qcs" (...);')] 132 {} 130 133 131 134 """
