sequel 3.48.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +114 -0
  3. data/Rakefile +10 -7
  4. data/doc/association_basics.rdoc +25 -23
  5. data/doc/code_order.rdoc +7 -0
  6. data/doc/core_extensions.rdoc +0 -10
  7. data/doc/object_model.rdoc +4 -1
  8. data/doc/querying.rdoc +3 -3
  9. data/doc/release_notes/4.0.0.txt +262 -0
  10. data/doc/security.rdoc +0 -28
  11. data/doc/testing.rdoc +8 -14
  12. data/lib/sequel/adapters/ado.rb +7 -11
  13. data/lib/sequel/adapters/ado/access.rb +8 -8
  14. data/lib/sequel/adapters/ado/mssql.rb +4 -4
  15. data/lib/sequel/adapters/amalgalite.rb +6 -6
  16. data/lib/sequel/adapters/cubrid.rb +7 -7
  17. data/lib/sequel/adapters/db2.rb +5 -9
  18. data/lib/sequel/adapters/dbi.rb +2 -6
  19. data/lib/sequel/adapters/do.rb +4 -4
  20. data/lib/sequel/adapters/firebird.rb +4 -4
  21. data/lib/sequel/adapters/ibmdb.rb +8 -8
  22. data/lib/sequel/adapters/informix.rb +2 -10
  23. data/lib/sequel/adapters/jdbc.rb +17 -17
  24. data/lib/sequel/adapters/jdbc/as400.rb +2 -2
  25. data/lib/sequel/adapters/jdbc/cubrid.rb +1 -1
  26. data/lib/sequel/adapters/jdbc/db2.rb +1 -1
  27. data/lib/sequel/adapters/jdbc/derby.rb +1 -1
  28. data/lib/sequel/adapters/jdbc/h2.rb +2 -2
  29. data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
  30. data/lib/sequel/adapters/jdbc/informix.rb +1 -1
  31. data/lib/sequel/adapters/jdbc/mssql.rb +2 -2
  32. data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
  33. data/lib/sequel/adapters/jdbc/oracle.rb +5 -1
  34. data/lib/sequel/adapters/jdbc/postgresql.rb +3 -3
  35. data/lib/sequel/adapters/jdbc/sqlite.rb +3 -3
  36. data/lib/sequel/adapters/jdbc/transactions.rb +3 -3
  37. data/lib/sequel/adapters/mock.rb +7 -7
  38. data/lib/sequel/adapters/mysql.rb +3 -3
  39. data/lib/sequel/adapters/mysql2.rb +4 -4
  40. data/lib/sequel/adapters/odbc.rb +2 -6
  41. data/lib/sequel/adapters/odbc/mssql.rb +1 -1
  42. data/lib/sequel/adapters/openbase.rb +1 -5
  43. data/lib/sequel/adapters/oracle.rb +13 -17
  44. data/lib/sequel/adapters/postgres.rb +20 -25
  45. data/lib/sequel/adapters/shared/cubrid.rb +3 -3
  46. data/lib/sequel/adapters/shared/db2.rb +2 -2
  47. data/lib/sequel/adapters/shared/firebird.rb +7 -7
  48. data/lib/sequel/adapters/shared/mssql.rb +9 -9
  49. data/lib/sequel/adapters/shared/mysql.rb +29 -13
  50. data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +7 -7
  51. data/lib/sequel/adapters/shared/oracle.rb +22 -13
  52. data/lib/sequel/adapters/shared/postgres.rb +61 -46
  53. data/lib/sequel/adapters/shared/sqlite.rb +9 -9
  54. data/lib/sequel/adapters/sqlite.rb +17 -11
  55. data/lib/sequel/adapters/swift.rb +3 -3
  56. data/lib/sequel/adapters/swift/mysql.rb +1 -1
  57. data/lib/sequel/adapters/swift/sqlite.rb +1 -1
  58. data/lib/sequel/adapters/tinytds.rb +8 -8
  59. data/lib/sequel/ast_transformer.rb +3 -1
  60. data/lib/sequel/connection_pool.rb +4 -2
  61. data/lib/sequel/connection_pool/sharded_single.rb +2 -2
  62. data/lib/sequel/connection_pool/sharded_threaded.rb +5 -5
  63. data/lib/sequel/connection_pool/threaded.rb +7 -7
  64. data/lib/sequel/core.rb +4 -67
  65. data/lib/sequel/database.rb +1 -0
  66. data/lib/sequel/database/connecting.rb +2 -8
  67. data/lib/sequel/database/dataset.rb +2 -7
  68. data/lib/sequel/database/dataset_defaults.rb +0 -18
  69. data/lib/sequel/database/features.rb +4 -4
  70. data/lib/sequel/database/misc.rb +6 -8
  71. data/lib/sequel/database/query.rb +5 -61
  72. data/lib/sequel/database/schema_generator.rb +22 -20
  73. data/lib/sequel/database/schema_methods.rb +48 -20
  74. data/lib/sequel/database/transactions.rb +7 -17
  75. data/lib/sequel/dataset.rb +2 -0
  76. data/lib/sequel/dataset/actions.rb +23 -91
  77. data/lib/sequel/dataset/features.rb +1 -4
  78. data/lib/sequel/dataset/graph.rb +3 -47
  79. data/lib/sequel/dataset/misc.rb +4 -33
  80. data/lib/sequel/dataset/prepared_statements.rb +3 -1
  81. data/lib/sequel/dataset/query.rb +116 -240
  82. data/lib/sequel/dataset/sql.rb +19 -97
  83. data/lib/sequel/deprecated.rb +0 -16
  84. data/lib/sequel/exceptions.rb +0 -3
  85. data/lib/sequel/extensions/_pretty_table.rb +1 -1
  86. data/lib/sequel/extensions/columns_introspection.rb +1 -12
  87. data/lib/sequel/extensions/constraint_validations.rb +3 -3
  88. data/lib/sequel/extensions/core_extensions.rb +0 -9
  89. data/lib/sequel/extensions/date_arithmetic.rb +1 -2
  90. data/lib/sequel/extensions/graph_each.rb +11 -0
  91. data/lib/sequel/extensions/migration.rb +5 -5
  92. data/lib/sequel/extensions/null_dataset.rb +11 -13
  93. data/lib/sequel/extensions/pagination.rb +3 -6
  94. data/lib/sequel/extensions/pg_array.rb +6 -4
  95. data/lib/sequel/extensions/pg_array_ops.rb +35 -1
  96. data/lib/sequel/extensions/pg_json.rb +12 -2
  97. data/lib/sequel/extensions/pg_json_ops.rb +266 -0
  98. data/lib/sequel/extensions/pg_range.rb +2 -2
  99. data/lib/sequel/extensions/pg_range_ops.rb +0 -8
  100. data/lib/sequel/extensions/pg_row.rb +2 -2
  101. data/lib/sequel/extensions/pretty_table.rb +0 -4
  102. data/lib/sequel/extensions/query.rb +3 -8
  103. data/lib/sequel/extensions/schema_caching.rb +0 -7
  104. data/lib/sequel/extensions/schema_dumper.rb +10 -17
  105. data/lib/sequel/extensions/select_remove.rb +0 -4
  106. data/lib/sequel/extensions/set_overrides.rb +28 -0
  107. data/lib/sequel/extensions/to_dot.rb +6 -10
  108. data/lib/sequel/model.rb +6 -7
  109. data/lib/sequel/model/associations.rb +127 -182
  110. data/lib/sequel/model/base.rb +88 -211
  111. data/lib/sequel/model/errors.rb +0 -13
  112. data/lib/sequel/model/plugins.rb +2 -2
  113. data/lib/sequel/no_core_ext.rb +0 -1
  114. data/lib/sequel/plugins/after_initialize.rb +11 -17
  115. data/lib/sequel/plugins/association_autoreloading.rb +1 -47
  116. data/lib/sequel/plugins/association_dependencies.rb +2 -2
  117. data/lib/sequel/plugins/auto_validations.rb +2 -8
  118. data/lib/sequel/plugins/blacklist_security.rb +32 -2
  119. data/lib/sequel/plugins/caching.rb +1 -1
  120. data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
  121. data/lib/sequel/plugins/composition.rb +10 -8
  122. data/lib/sequel/plugins/constraint_validations.rb +2 -2
  123. data/lib/sequel/plugins/dataset_associations.rb +4 -0
  124. data/lib/sequel/plugins/defaults_setter.rb +8 -6
  125. data/lib/sequel/plugins/dirty.rb +6 -6
  126. data/lib/sequel/plugins/force_encoding.rb +13 -8
  127. data/lib/sequel/plugins/hook_class_methods.rb +1 -7
  128. data/lib/sequel/plugins/json_serializer.rb +13 -74
  129. data/lib/sequel/plugins/lazy_attributes.rb +2 -4
  130. data/lib/sequel/plugins/list.rb +1 -1
  131. data/lib/sequel/plugins/many_through_many.rb +4 -11
  132. data/lib/sequel/plugins/many_to_one_pk_lookup.rb +1 -49
  133. data/lib/sequel/plugins/nested_attributes.rb +1 -1
  134. data/lib/sequel/plugins/optimistic_locking.rb +3 -5
  135. data/lib/sequel/plugins/pg_array_associations.rb +453 -0
  136. data/lib/sequel/plugins/pg_typecast_on_load.rb +23 -7
  137. data/lib/sequel/plugins/prepared_statements.rb +1 -1
  138. data/lib/sequel/plugins/prepared_statements_associations.rb +20 -14
  139. data/lib/sequel/plugins/prepared_statements_safe.rb +2 -2
  140. data/lib/sequel/plugins/rcte_tree.rb +1 -1
  141. data/lib/sequel/plugins/serialization.rb +5 -4
  142. data/lib/sequel/plugins/serialization_modification_detection.rb +1 -1
  143. data/lib/sequel/plugins/sharding.rb +7 -1
  144. data/lib/sequel/plugins/single_table_inheritance.rb +1 -1
  145. data/lib/sequel/plugins/timestamps.rb +1 -1
  146. data/lib/sequel/plugins/touch.rb +2 -2
  147. data/lib/sequel/plugins/tree.rb +1 -1
  148. data/lib/sequel/plugins/typecast_on_load.rb +19 -4
  149. data/lib/sequel/plugins/validation_class_methods.rb +0 -30
  150. data/lib/sequel/plugins/validation_helpers.rb +13 -31
  151. data/lib/sequel/plugins/xml_serializer.rb +18 -57
  152. data/lib/sequel/sql.rb +20 -22
  153. data/lib/sequel/version.rb +2 -2
  154. data/spec/adapters/db2_spec.rb +14 -23
  155. data/spec/adapters/firebird_spec.rb +25 -29
  156. data/spec/adapters/informix_spec.rb +11 -14
  157. data/spec/adapters/mssql_spec.rb +71 -77
  158. data/spec/adapters/mysql_spec.rb +165 -172
  159. data/spec/adapters/oracle_spec.rb +36 -39
  160. data/spec/adapters/postgres_spec.rb +175 -100
  161. data/spec/adapters/spec_helper.rb +13 -11
  162. data/spec/adapters/sqlite_spec.rb +36 -44
  163. data/spec/core/connection_pool_spec.rb +2 -1
  164. data/spec/core/database_spec.rb +55 -55
  165. data/spec/core/dataset_spec.rb +45 -249
  166. data/spec/core/deprecated_spec.rb +0 -8
  167. data/spec/core/expression_filters_spec.rb +23 -5
  168. data/spec/core/object_graph_spec.rb +4 -66
  169. data/spec/core/schema_spec.rb +35 -12
  170. data/spec/core/spec_helper.rb +3 -2
  171. data/spec/core_extensions_spec.rb +17 -19
  172. data/spec/extensions/arbitrary_servers_spec.rb +2 -3
  173. data/spec/extensions/association_dependencies_spec.rb +14 -14
  174. data/spec/extensions/auto_validations_spec.rb +7 -0
  175. data/spec/extensions/blacklist_security_spec.rb +5 -5
  176. data/spec/extensions/blank_spec.rb +2 -0
  177. data/spec/extensions/class_table_inheritance_spec.rb +2 -2
  178. data/spec/extensions/columns_introspection_spec.rb +2 -29
  179. data/spec/extensions/composition_spec.rb +10 -17
  180. data/spec/extensions/core_refinements_spec.rb +5 -1
  181. data/spec/extensions/dataset_associations_spec.rb +18 -0
  182. data/spec/extensions/date_arithmetic_spec.rb +2 -2
  183. data/spec/extensions/defaults_setter_spec.rb +9 -9
  184. data/spec/extensions/dirty_spec.rb +0 -5
  185. data/spec/extensions/eval_inspect_spec.rb +2 -0
  186. data/spec/extensions/force_encoding_spec.rb +2 -18
  187. data/spec/extensions/hash_aliases_spec.rb +8 -0
  188. data/spec/extensions/hook_class_methods_spec.rb +39 -58
  189. data/spec/extensions/inflector_spec.rb +2 -0
  190. data/spec/extensions/instance_filters_spec.rb +8 -8
  191. data/spec/extensions/json_serializer_spec.rb +1 -41
  192. data/spec/extensions/list_spec.rb +1 -1
  193. data/spec/extensions/many_through_many_spec.rb +106 -109
  194. data/spec/extensions/migration_spec.rb +2 -0
  195. data/spec/extensions/named_timezones_spec.rb +1 -0
  196. data/spec/extensions/pg_array_associations_spec.rb +603 -0
  197. data/spec/extensions/pg_array_ops_spec.rb +25 -0
  198. data/spec/extensions/pg_array_spec.rb +9 -1
  199. data/spec/extensions/pg_hstore_ops_spec.rb +13 -0
  200. data/spec/extensions/pg_hstore_spec.rb +1 -0
  201. data/spec/extensions/pg_json_ops_spec.rb +131 -0
  202. data/spec/extensions/pg_json_spec.rb +10 -4
  203. data/spec/extensions/pg_range_ops_spec.rb +2 -5
  204. data/spec/extensions/pg_range_spec.rb +6 -2
  205. data/spec/extensions/pg_row_ops_spec.rb +2 -0
  206. data/spec/extensions/prepared_statements_associations_spec.rb +26 -5
  207. data/spec/extensions/rcte_tree_spec.rb +15 -15
  208. data/spec/extensions/schema_dumper_spec.rb +0 -1
  209. data/spec/extensions/schema_spec.rb +9 -9
  210. data/spec/extensions/serialization_modification_detection_spec.rb +1 -1
  211. data/spec/extensions/serialization_spec.rb +18 -29
  212. data/spec/extensions/set_overrides_spec.rb +4 -0
  213. data/spec/extensions/{many_to_one_pk_lookup_spec.rb → shared_caching_spec.rb} +1 -4
  214. data/spec/extensions/single_table_inheritance_spec.rb +4 -4
  215. data/spec/extensions/spec_helper.rb +8 -9
  216. data/spec/extensions/sql_expr_spec.rb +2 -0
  217. data/spec/extensions/string_date_time_spec.rb +2 -0
  218. data/spec/extensions/string_stripper_spec.rb +2 -0
  219. data/spec/extensions/tactical_eager_loading_spec.rb +12 -12
  220. data/spec/extensions/thread_local_timezones_spec.rb +2 -0
  221. data/spec/extensions/timestamps_spec.rb +1 -1
  222. data/spec/extensions/to_dot_spec.rb +1 -1
  223. data/spec/extensions/touch_spec.rb +24 -24
  224. data/spec/extensions/tree_spec.rb +7 -7
  225. data/spec/extensions/typecast_on_load_spec.rb +8 -1
  226. data/spec/extensions/update_primary_key_spec.rb +10 -10
  227. data/spec/extensions/validation_class_methods_spec.rb +10 -39
  228. data/spec/extensions/validation_helpers_spec.rb +29 -47
  229. data/spec/extensions/xml_serializer_spec.rb +1 -23
  230. data/spec/integration/associations_test.rb +231 -40
  231. data/spec/integration/database_test.rb +1 -1
  232. data/spec/integration/dataset_test.rb +64 -64
  233. data/spec/integration/eager_loader_test.rb +28 -28
  234. data/spec/integration/migrator_test.rb +1 -1
  235. data/spec/integration/model_test.rb +2 -2
  236. data/spec/integration/plugin_test.rb +21 -21
  237. data/spec/integration/prepared_statement_test.rb +7 -7
  238. data/spec/integration/schema_test.rb +115 -110
  239. data/spec/integration/spec_helper.rb +17 -27
  240. data/spec/integration/timezone_test.rb +1 -1
  241. data/spec/integration/transaction_test.rb +10 -10
  242. data/spec/integration/type_test.rb +2 -2
  243. data/spec/model/association_reflection_spec.rb +2 -28
  244. data/spec/model/associations_spec.rb +239 -188
  245. data/spec/model/base_spec.rb +27 -68
  246. data/spec/model/dataset_methods_spec.rb +4 -4
  247. data/spec/model/eager_loading_spec.rb +160 -172
  248. data/spec/model/hooks_spec.rb +62 -79
  249. data/spec/model/model_spec.rb +36 -51
  250. data/spec/model/plugins_spec.rb +5 -19
  251. data/spec/model/record_spec.rb +125 -151
  252. data/spec/model/spec_helper.rb +8 -6
  253. data/spec/model/validations_spec.rb +4 -17
  254. data/spec/spec_config.rb +2 -10
  255. metadata +50 -56
  256. data/lib/sequel/deprecated_core_extensions.rb +0 -135
  257. data/lib/sequel/extensions/pg_auto_parameterize.rb +0 -185
  258. data/lib/sequel/extensions/pg_statement_cache.rb +0 -318
  259. data/lib/sequel/plugins/identity_map.rb +0 -260
  260. data/lib/sequel_core.rb +0 -2
  261. data/lib/sequel_model.rb +0 -2
  262. data/spec/extensions/association_autoreloading_spec.rb +0 -102
  263. data/spec/extensions/identity_map_spec.rb +0 -337
  264. data/spec/extensions/pg_auto_parameterize_spec.rb +0 -70
  265. data/spec/extensions/pg_statement_cache_spec.rb +0 -208
  266. data/spec/rcov.opts +0 -8
  267. data/spec/spec_config.rb.example +0 -10
@@ -3,7 +3,7 @@ require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
3
3
  Sequel.extension :migration
4
4
  describe Sequel::Migrator do
5
5
  before do
6
- @db = INTEGRATION_DB
6
+ @db = DB
7
7
  @m = Sequel::Migrator
8
8
  end
9
9
  after do
@@ -2,7 +2,7 @@ require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
2
2
 
3
3
  describe "Sequel::Model basic support" do
4
4
  before do
5
- @db = INTEGRATION_DB
5
+ @db = DB
6
6
  @db.create_table!(:items, :engine=>:InnoDB) do
7
7
  primary_key :id
8
8
  String :name
@@ -201,7 +201,7 @@ end
201
201
 
202
202
  describe "Sequel::Model with no existing table" do
203
203
  specify "should not raise an error when setting the dataset" do
204
- db = INTEGRATION_DB
204
+ db = DB
205
205
  db.drop_table?(:items)
206
206
  proc{class ::Item < Sequel::Model(db); end; Object.send(:remove_const, :Item)}.should_not raise_error
207
207
  proc{c = Class.new(Sequel::Model); c.set_dataset(db[:items])}.should_not raise_error
@@ -2,10 +2,10 @@ require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
2
2
 
3
3
  # DB2 does not seem to support USING joins in every version; it seems to be
4
4
  # valid expression in DB2 iSeries UDB though.
5
- unless !INTEGRATION_DB.dataset.supports_join_using? || Sequel.guarded?(:db2)
5
+ unless !DB.dataset.supports_join_using? || Sequel.guarded?(:db2)
6
6
  describe "Class Table Inheritance Plugin" do
7
7
  before(:all) do
8
- @db = INTEGRATION_DB
8
+ @db = DB
9
9
  @db.instance_variable_set(:@schemas, {})
10
10
  @db.drop_table?(:staff, :executives, :managers, :employees)
11
11
  @db.create_table(:employees) do
@@ -148,7 +148,7 @@ end
148
148
 
149
149
  describe "Many Through Many Plugin" do
150
150
  before(:all) do
151
- @db = INTEGRATION_DB
151
+ @db = DB
152
152
  @db.instance_variable_set(:@schemas, {})
153
153
  @db.drop_table?(:albums_artists, :albums, :artists)
154
154
  @db.create_table(:albums) do
@@ -396,7 +396,7 @@ end
396
396
 
397
397
  describe "Lazy Attributes plugin" do
398
398
  before(:all) do
399
- @db = INTEGRATION_DB
399
+ @db = DB
400
400
  @db.create_table!(:items) do
401
401
  primary_key :id
402
402
  String :name
@@ -440,7 +440,7 @@ end
440
440
 
441
441
  describe "Tactical Eager Loading Plugin" do
442
442
  before(:all) do
443
- @db = INTEGRATION_DB
443
+ @db = DB
444
444
  @db.instance_variable_set(:@schemas, {})
445
445
  @db.create_table!(:artists) do
446
446
  primary_key :id
@@ -495,7 +495,7 @@ end
495
495
 
496
496
  describe "Touch plugin" do
497
497
  before(:all) do
498
- @db = INTEGRATION_DB
498
+ @db = DB
499
499
  @db.drop_table? :albums_artists, :albums, :artists
500
500
  @db.create_table(:artists) do
501
501
  primary_key :id
@@ -585,7 +585,7 @@ end
585
585
 
586
586
  describe "Serialization plugin" do
587
587
  before do
588
- @db = INTEGRATION_DB
588
+ @db = DB
589
589
  @db.create_table!(:items) do
590
590
  primary_key :id
591
591
  String :stuff
@@ -612,7 +612,7 @@ end
612
612
 
613
613
  describe "OptimisticLocking plugin" do
614
614
  before(:all) do
615
- @db = INTEGRATION_DB
615
+ @db = DB
616
616
  @db.create_table!(:people) do
617
617
  primary_key :id
618
618
  String :name
@@ -654,7 +654,7 @@ end
654
654
 
655
655
  describe "Composition plugin" do
656
656
  before do
657
- @db = INTEGRATION_DB
657
+ @db = DB
658
658
  @db.create_table!(:events) do
659
659
  primary_key :id
660
660
  Integer :year
@@ -706,10 +706,10 @@ describe "Composition plugin" do
706
706
  end
707
707
 
708
708
  # DB2's implemention of CTE is too limited to use this plugin
709
- if INTEGRATION_DB.dataset.supports_cte? and !Sequel.guarded?(:db2)
709
+ if DB.dataset.supports_cte? and !Sequel.guarded?(:db2)
710
710
  describe "RcteTree Plugin" do
711
711
  before(:all) do
712
- @db = INTEGRATION_DB
712
+ @db = DB
713
713
  @db.create_table!(:nodes) do
714
714
  primary_key :id
715
715
  Integer :parent_id
@@ -941,7 +941,7 @@ end
941
941
 
942
942
  describe "Instance Filters plugin" do
943
943
  before(:all) do
944
- @db = INTEGRATION_DB
944
+ @db = DB
945
945
  @db.create_table!(:items) do
946
946
  primary_key :id
947
947
  String :name
@@ -1004,7 +1004,7 @@ end
1004
1004
 
1005
1005
  describe "UpdatePrimaryKey plugin" do
1006
1006
  before(:all) do
1007
- @db = INTEGRATION_DB
1007
+ @db = DB
1008
1008
  @db.create_table!(:t) do
1009
1009
  Integer :a, :primary_key=>true
1010
1010
  Integer :b
@@ -1062,7 +1062,7 @@ end
1062
1062
 
1063
1063
  describe "AssociationPks plugin" do
1064
1064
  before(:all) do
1065
- @db = INTEGRATION_DB
1065
+ @db = DB
1066
1066
  @db.drop_table?(:albums_tags, :albums_vocalists, :vocalists_instruments, :vocalists_hits, :hits, :instruments, :vocalists, :tags, :albums, :artists)
1067
1067
  @db.create_table(:artists) do
1068
1068
  primary_key :id
@@ -1387,7 +1387,7 @@ end
1387
1387
 
1388
1388
  describe "List plugin without a scope" do
1389
1389
  before(:all) do
1390
- @db = INTEGRATION_DB
1390
+ @db = DB
1391
1391
  @db.create_table!(:sites) do
1392
1392
  primary_key :id
1393
1393
  String :name
@@ -1461,7 +1461,7 @@ end
1461
1461
 
1462
1462
  describe "List plugin with a scope" do
1463
1463
  before(:all) do
1464
- @db = INTEGRATION_DB
1464
+ @db = DB
1465
1465
  @db.create_table!(:pages) do
1466
1466
  primary_key :id
1467
1467
  String :name
@@ -1539,7 +1539,7 @@ end
1539
1539
 
1540
1540
  describe "Sequel::Plugins::Tree" do
1541
1541
  before(:all) do
1542
- @db = INTEGRATION_DB
1542
+ @db = DB
1543
1543
  end
1544
1544
 
1545
1545
  describe "with natural database order" do
@@ -1704,7 +1704,7 @@ end
1704
1704
 
1705
1705
  describe "Sequel::Plugins::PreparedStatements" do
1706
1706
  before(:all) do
1707
- @db = INTEGRATION_DB
1707
+ @db = DB
1708
1708
  @db.create_table!(:ps_test) do
1709
1709
  primary_key :id
1710
1710
  String :name
@@ -1777,7 +1777,7 @@ end
1777
1777
 
1778
1778
  describe "Caching plugins" do
1779
1779
  before(:all) do
1780
- @db = INTEGRATION_DB
1780
+ @db = DB
1781
1781
  @db.drop_table?(:albums, :artists)
1782
1782
  @db.create_table(:artists) do
1783
1783
  primary_key :id
@@ -1840,7 +1840,7 @@ end
1840
1840
 
1841
1841
  describe "Sequel::Plugins::ConstraintValidations" do
1842
1842
  before(:all) do
1843
- @db = INTEGRATION_DB
1843
+ @db = DB
1844
1844
  @db.extension(:constraint_validations)
1845
1845
  @db.create_constraint_validations_table
1846
1846
  @ds = @db[:cv_test]
@@ -2029,7 +2029,7 @@ describe "date_arithmetic extension" do
2029
2029
  end
2030
2030
 
2031
2031
  before(:all) do
2032
- @db = INTEGRATION_DB
2032
+ @db = DB
2033
2033
  @db.extension(:date_arithmetic)
2034
2034
  if @db.database_type == :sqlite
2035
2035
  @db.use_timestamp_timezones = false
@@ -2,7 +2,7 @@ require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
2
2
 
3
3
  describe "Prepared Statements and Bound Arguments" do
4
4
  before do
5
- @db = INTEGRATION_DB
5
+ @db = DB
6
6
  @db.create_table!(:items) do
7
7
  primary_key :id
8
8
  integer :numb
@@ -258,7 +258,7 @@ end
258
258
 
259
259
  describe "Bound Argument Types" do
260
260
  before(:all) do
261
- @db = INTEGRATION_DB
261
+ @db = DB
262
262
  @db.create_table!(:items) do
263
263
  primary_key :id
264
264
  Date :d
@@ -343,9 +343,9 @@ end
343
343
 
344
344
  describe "Dataset#unbind" do
345
345
  before do
346
- @ds = ds = INTEGRATION_DB[:items]
346
+ @ds = ds = DB[:items]
347
347
  @ct = proc do |t, v|
348
- INTEGRATION_DB.create_table!(:items) do
348
+ DB.create_table!(:items) do
349
349
  column :c, t
350
350
  end
351
351
  ds.insert(:c=>v)
@@ -353,7 +353,7 @@ describe "Dataset#unbind" do
353
353
  @u = proc{|ds1| ds2, bv = ds1.unbind; ds2.call(:first, bv)}
354
354
  end
355
355
  after do
356
- INTEGRATION_DB.drop_table?(:items)
356
+ DB.drop_table?(:items)
357
357
  end
358
358
 
359
359
  specify "should unbind values assigned to equality and inequality statements" do
@@ -374,7 +374,7 @@ describe "Dataset#unbind" do
374
374
  @ct[String, 'foo']
375
375
  @u[@ds.filter(:c=>'foo')].should == {:c=>'foo'}
376
376
 
377
- INTEGRATION_DB.create_table!(:items) do
377
+ DB.create_table!(:items) do
378
378
  BigDecimal :c, :size=>[15,2]
379
379
  end
380
380
  @ds.insert(:c=>BigDecimal.new('1.1'))
@@ -395,7 +395,7 @@ describe "Dataset#unbind" do
395
395
  end
396
396
 
397
397
  specify "should handle deep nesting" do
398
- INTEGRATION_DB.create_table!(:items) do
398
+ DB.create_table!(:items) do
399
399
  Integer :a
400
400
  Integer :b
401
401
  Integer :c
@@ -2,71 +2,71 @@ require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
2
2
 
3
3
  describe "Database schema parser" do
4
4
  before do
5
- @iom = INTEGRATION_DB.identifier_output_method
6
- @iim = INTEGRATION_DB.identifier_input_method
7
- @qi = INTEGRATION_DB.quote_identifiers?
5
+ @iom = DB.identifier_output_method
6
+ @iim = DB.identifier_input_method
7
+ @qi = DB.quote_identifiers?
8
8
  end
9
9
  after do
10
- INTEGRATION_DB.identifier_output_method = @iom
11
- INTEGRATION_DB.identifier_input_method = @iim
12
- INTEGRATION_DB.quote_identifiers = @qi
13
- INTEGRATION_DB.drop_table?(:items)
10
+ DB.identifier_output_method = @iom
11
+ DB.identifier_input_method = @iim
12
+ DB.quote_identifiers = @qi
13
+ DB.drop_table?(:items)
14
14
  end
15
15
 
16
16
  specify "should handle a database with a identifier methods" do
17
- INTEGRATION_DB.identifier_output_method = :reverse
18
- INTEGRATION_DB.identifier_input_method = :reverse
19
- INTEGRATION_DB.quote_identifiers = true
20
- INTEGRATION_DB.create_table!(:items){Integer :number}
17
+ DB.identifier_output_method = :reverse
18
+ DB.identifier_input_method = :reverse
19
+ DB.quote_identifiers = true
20
+ DB.create_table!(:items){Integer :number}
21
21
  begin
22
- INTEGRATION_DB.schema(:items, :reload=>true).should be_a_kind_of(Array)
23
- INTEGRATION_DB.schema(:items, :reload=>true).first.first.should == :number
22
+ DB.schema(:items, :reload=>true).should be_a_kind_of(Array)
23
+ DB.schema(:items, :reload=>true).first.first.should == :number
24
24
  ensure
25
- INTEGRATION_DB.drop_table(:items)
25
+ DB.drop_table(:items)
26
26
  end
27
27
  end
28
28
 
29
29
  specify "should handle a dataset with identifier methods different than the database's" do
30
- INTEGRATION_DB.identifier_output_method = :reverse
31
- INTEGRATION_DB.identifier_input_method = :reverse
32
- INTEGRATION_DB.quote_identifiers = true
33
- INTEGRATION_DB.create_table!(:items){Integer :number}
34
- INTEGRATION_DB.identifier_output_method = @iom
35
- INTEGRATION_DB.identifier_input_method = @iim
36
- ds = INTEGRATION_DB[:items]
30
+ DB.identifier_output_method = :reverse
31
+ DB.identifier_input_method = :reverse
32
+ DB.quote_identifiers = true
33
+ DB.create_table!(:items){Integer :number}
34
+ DB.identifier_output_method = @iom
35
+ DB.identifier_input_method = @iim
36
+ ds = DB[:items]
37
37
  ds.identifier_output_method = :reverse
38
38
  ds.identifier_input_method = :reverse
39
39
  begin
40
- INTEGRATION_DB.schema(ds, :reload=>true).should be_a_kind_of(Array)
41
- INTEGRATION_DB.schema(ds, :reload=>true).first.first.should == :number
40
+ DB.schema(ds, :reload=>true).should be_a_kind_of(Array)
41
+ DB.schema(ds, :reload=>true).first.first.should == :number
42
42
  ensure
43
- INTEGRATION_DB.identifier_output_method = :reverse
44
- INTEGRATION_DB.identifier_input_method = :reverse
45
- INTEGRATION_DB.drop_table(:items)
43
+ DB.identifier_output_method = :reverse
44
+ DB.identifier_input_method = :reverse
45
+ DB.drop_table(:items)
46
46
  end
47
47
  end
48
48
 
49
49
  specify "should not issue an sql query if the schema has been loaded unless :reload is true" do
50
- INTEGRATION_DB.create_table!(:items){Integer :number}
51
- INTEGRATION_DB.schema(:items, :reload=>true)
52
- INTEGRATION_DB.schema(:items)
53
- INTEGRATION_DB.schema(:items, :reload=>true)
50
+ DB.create_table!(:items){Integer :number}
51
+ DB.schema(:items, :reload=>true)
52
+ DB.schema(:items)
53
+ DB.schema(:items, :reload=>true)
54
54
  end
55
55
 
56
56
  specify "Model schema should include columns in the table, even if they aren't selected" do
57
- INTEGRATION_DB.create_table!(:items){String :a; Integer :number}
58
- m = Sequel::Model(INTEGRATION_DB[:items].select(:a))
57
+ DB.create_table!(:items){String :a; Integer :number}
58
+ m = Sequel::Model(DB[:items].select(:a))
59
59
  m.columns.should == [:a]
60
60
  m.db_schema[:number][:type].should == :integer
61
61
  end
62
62
 
63
63
  specify "should raise an error when the table doesn't exist" do
64
- proc{INTEGRATION_DB.schema(:no_table)}.should raise_error(Sequel::Error)
64
+ proc{DB.schema(:no_table)}.should raise_error(Sequel::Error)
65
65
  end
66
66
 
67
67
  specify "should return the schema correctly" do
68
- INTEGRATION_DB.create_table!(:items){Integer :number}
69
- schema = INTEGRATION_DB.schema(:items, :reload=>true)
68
+ DB.create_table!(:items){Integer :number}
69
+ schema = DB.schema(:items, :reload=>true)
70
70
  schema.should be_a_kind_of(Array)
71
71
  schema.length.should == 1
72
72
  col = schema.first
@@ -76,110 +76,110 @@ describe "Database schema parser" do
76
76
  col_info = col.last
77
77
  col_info.should be_a_kind_of(Hash)
78
78
  col_info[:type].should == :integer
79
- INTEGRATION_DB.schema(:items)
79
+ DB.schema(:items)
80
80
  end
81
81
 
82
82
  specify "should parse primary keys from the schema properly" do
83
- INTEGRATION_DB.create_table!(:items){Integer :number}
84
- INTEGRATION_DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == []
85
- INTEGRATION_DB.create_table!(:items){primary_key :number}
86
- INTEGRATION_DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == [:number]
87
- INTEGRATION_DB.create_table!(:items){Integer :number1; Integer :number2; primary_key [:number1, :number2]}
88
- INTEGRATION_DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == [:number1, :number2]
83
+ DB.create_table!(:items){Integer :number}
84
+ DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == []
85
+ DB.create_table!(:items){primary_key :number}
86
+ DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == [:number]
87
+ DB.create_table!(:items){Integer :number1; Integer :number2; primary_key [:number1, :number2]}
88
+ DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == [:number1, :number2]
89
89
  end
90
90
 
91
91
  specify "should parse NULL/NOT NULL from the schema properly" do
92
- INTEGRATION_DB.create_table!(:items){Integer :number, :null=>true}
93
- INTEGRATION_DB.schema(:items).first.last[:allow_null].should == true
94
- INTEGRATION_DB.create_table!(:items){Integer :number, :null=>false}
95
- INTEGRATION_DB.schema(:items).first.last[:allow_null].should == false
92
+ DB.create_table!(:items){Integer :number, :null=>true}
93
+ DB.schema(:items).first.last[:allow_null].should == true
94
+ DB.create_table!(:items){Integer :number, :null=>false}
95
+ DB.schema(:items).first.last[:allow_null].should == false
96
96
  end
97
97
 
98
98
  specify "should parse defaults from the schema properly" do
99
- INTEGRATION_DB.create_table!(:items){Integer :number}
100
- INTEGRATION_DB.schema(:items).first.last[:ruby_default].should == nil
101
- INTEGRATION_DB.create_table!(:items){Integer :number, :default=>0}
102
- INTEGRATION_DB.schema(:items).first.last[:ruby_default].should == 0
103
- INTEGRATION_DB.create_table!(:items){String :a, :default=>"blah"}
104
- INTEGRATION_DB.schema(:items).first.last[:ruby_default].should == 'blah'
99
+ DB.create_table!(:items){Integer :number}
100
+ DB.schema(:items).first.last[:ruby_default].should == nil
101
+ DB.create_table!(:items){Integer :number, :default=>0}
102
+ DB.schema(:items).first.last[:ruby_default].should == 0
103
+ DB.create_table!(:items){String :a, :default=>"blah"}
104
+ DB.schema(:items).first.last[:ruby_default].should == 'blah'
105
105
  end
106
106
 
107
107
  specify "should parse current timestamp defaults from the schema properly" do
108
- INTEGRATION_DB.create_table!(:items){Time :a, :default=>Sequel::CURRENT_TIMESTAMP}
109
- INTEGRATION_DB.schema(:items).first.last[:ruby_default].should == Sequel::CURRENT_TIMESTAMP
108
+ DB.create_table!(:items){Time :a, :default=>Sequel::CURRENT_TIMESTAMP}
109
+ DB.schema(:items).first.last[:ruby_default].should == Sequel::CURRENT_TIMESTAMP
110
110
  end
111
111
 
112
112
  cspecify "should parse current date defaults from the schema properly", :mysql, :oracle do
113
- INTEGRATION_DB.create_table!(:items){Date :a, :default=>Sequel::CURRENT_DATE}
114
- INTEGRATION_DB.schema(:items).first.last[:ruby_default].should == Sequel::CURRENT_DATE
113
+ DB.create_table!(:items){Date :a, :default=>Sequel::CURRENT_DATE}
114
+ DB.schema(:items).first.last[:ruby_default].should == Sequel::CURRENT_DATE
115
115
  end
116
116
 
117
117
  cspecify "should parse types from the schema properly", [:jdbc, :db2], :oracle do
118
- INTEGRATION_DB.create_table!(:items){Integer :number}
119
- INTEGRATION_DB.schema(:items).first.last[:type].should == :integer
120
- INTEGRATION_DB.create_table!(:items){Fixnum :number}
121
- INTEGRATION_DB.schema(:items).first.last[:type].should == :integer
122
- INTEGRATION_DB.create_table!(:items){Bignum :number}
123
- INTEGRATION_DB.schema(:items).first.last[:type].should == :integer
124
- INTEGRATION_DB.create_table!(:items){Float :number}
125
- INTEGRATION_DB.schema(:items).first.last[:type].should == :float
126
- INTEGRATION_DB.create_table!(:items){BigDecimal :number, :size=>[11, 2]}
127
- INTEGRATION_DB.schema(:items).first.last[:type].should == :decimal
128
- INTEGRATION_DB.create_table!(:items){Numeric :number, :size=>[12, 0]}
129
- INTEGRATION_DB.schema(:items).first.last[:type].should == :integer
130
- INTEGRATION_DB.create_table!(:items){String :number}
131
- INTEGRATION_DB.schema(:items).first.last[:type].should == :string
132
- INTEGRATION_DB.create_table!(:items){Date :number}
133
- INTEGRATION_DB.schema(:items).first.last[:type].should == :date
134
- INTEGRATION_DB.create_table!(:items){Time :number}
135
- INTEGRATION_DB.schema(:items).first.last[:type].should == :datetime
136
- INTEGRATION_DB.create_table!(:items){DateTime :number}
137
- INTEGRATION_DB.schema(:items).first.last[:type].should == :datetime
138
- INTEGRATION_DB.create_table!(:items){File :number}
139
- INTEGRATION_DB.schema(:items).first.last[:type].should == :blob
140
- INTEGRATION_DB.create_table!(:items){TrueClass :number}
141
- INTEGRATION_DB.schema(:items).first.last[:type].should == :boolean
142
- INTEGRATION_DB.create_table!(:items){FalseClass :number}
143
- INTEGRATION_DB.schema(:items).first.last[:type].should == :boolean
144
- end
145
- end if INTEGRATION_DB.supports_schema_parsing?
118
+ DB.create_table!(:items){Integer :number}
119
+ DB.schema(:items).first.last[:type].should == :integer
120
+ DB.create_table!(:items){Fixnum :number}
121
+ DB.schema(:items).first.last[:type].should == :integer
122
+ DB.create_table!(:items){Bignum :number}
123
+ DB.schema(:items).first.last[:type].should == :integer
124
+ DB.create_table!(:items){Float :number}
125
+ DB.schema(:items).first.last[:type].should == :float
126
+ DB.create_table!(:items){BigDecimal :number, :size=>[11, 2]}
127
+ DB.schema(:items).first.last[:type].should == :decimal
128
+ DB.create_table!(:items){Numeric :number, :size=>[12, 0]}
129
+ DB.schema(:items).first.last[:type].should == :integer
130
+ DB.create_table!(:items){String :number}
131
+ DB.schema(:items).first.last[:type].should == :string
132
+ DB.create_table!(:items){Date :number}
133
+ DB.schema(:items).first.last[:type].should == :date
134
+ DB.create_table!(:items){Time :number}
135
+ DB.schema(:items).first.last[:type].should == :datetime
136
+ DB.create_table!(:items){DateTime :number}
137
+ DB.schema(:items).first.last[:type].should == :datetime
138
+ DB.create_table!(:items){File :number}
139
+ DB.schema(:items).first.last[:type].should == :blob
140
+ DB.create_table!(:items){TrueClass :number}
141
+ DB.schema(:items).first.last[:type].should == :boolean
142
+ DB.create_table!(:items){FalseClass :number}
143
+ DB.schema(:items).first.last[:type].should == :boolean
144
+ end
145
+ end if DB.supports_schema_parsing?
146
146
 
147
147
  describe "Database index parsing" do
148
148
  after do
149
- INTEGRATION_DB.drop_table?(:items)
149
+ DB.drop_table?(:items)
150
150
  end
151
151
 
152
152
  specify "should parse indexes into a hash" do
153
153
  # Delete :deferrable entry, since not all adapters implement it
154
- f = lambda{h = INTEGRATION_DB.indexes(:items); h.values.each{|h2| h2.delete(:deferrable)}; h}
154
+ f = lambda{h = DB.indexes(:items); h.values.each{|h2| h2.delete(:deferrable)}; h}
155
155
 
156
- INTEGRATION_DB.create_table!(:items){Integer :n; Integer :a}
156
+ DB.create_table!(:items){Integer :n; Integer :a}
157
157
  f.call.should == {}
158
- INTEGRATION_DB.add_index(:items, :n)
158
+ DB.add_index(:items, :n)
159
159
  f.call.should == {:items_n_index=>{:columns=>[:n], :unique=>false}}
160
- INTEGRATION_DB.drop_index(:items, :n)
160
+ DB.drop_index(:items, :n)
161
161
  f.call.should == {}
162
- INTEGRATION_DB.add_index(:items, :n, :unique=>true, :name=>:blah_blah_index)
162
+ DB.add_index(:items, :n, :unique=>true, :name=>:blah_blah_index)
163
163
  f.call.should == {:blah_blah_index=>{:columns=>[:n], :unique=>true}}
164
- INTEGRATION_DB.add_index(:items, [:n, :a])
164
+ DB.add_index(:items, [:n, :a])
165
165
  f.call.should == {:blah_blah_index=>{:columns=>[:n], :unique=>true}, :items_n_a_index=>{:columns=>[:n, :a], :unique=>false}}
166
- INTEGRATION_DB.drop_index(:items, :n, :name=>:blah_blah_index)
166
+ DB.drop_index(:items, :n, :name=>:blah_blah_index)
167
167
  f.call.should == {:items_n_a_index=>{:columns=>[:n, :a], :unique=>false}}
168
- INTEGRATION_DB.drop_index(:items, [:n, :a])
168
+ DB.drop_index(:items, [:n, :a])
169
169
  f.call.should == {}
170
170
  end
171
171
 
172
172
  specify "should not include a primary key index" do
173
- INTEGRATION_DB.create_table!(:items){primary_key :n}
174
- INTEGRATION_DB.indexes(:items).should == {}
175
- INTEGRATION_DB.create_table!(:items){Integer :n; Integer :a; primary_key [:n, :a]}
176
- INTEGRATION_DB.indexes(:items).should == {}
173
+ DB.create_table!(:items){primary_key :n}
174
+ DB.indexes(:items).should == {}
175
+ DB.create_table!(:items){Integer :n; Integer :a; primary_key [:n, :a]}
176
+ DB.indexes(:items).should == {}
177
177
  end
178
- end if INTEGRATION_DB.supports_index_parsing?
178
+ end if DB.supports_index_parsing?
179
179
 
180
180
  describe "Database foreign key parsing" do
181
181
  before do
182
- @db = INTEGRATION_DB
182
+ @db = DB
183
183
  @pr = lambda do |table, *expected|
184
184
  actual = @db.foreign_key_list(table).sort_by{|c| c[:columns].map{|s| s.to_s}.join << (c[:key]||[]).map{|s| s.to_s}.join}.map{|v| v.values_at(:columns, :table, :key)}
185
185
  actual.zip(expected).each do |a, e|
@@ -231,11 +231,11 @@ describe "Database foreign key parsing" do
231
231
  @db.create_table!(:b, :engine=>:InnoDB){Integer :e; Integer :f; foreign_key [:e, :f], :a; foreign_key [:f, :e], :a, :key=>[:c, :b]}
232
232
  @pr[:b, [[:e, :f], :a, [:pk, :b, :c]], [[:f, :e], :a, [:c, :b]]]
233
233
  end
234
- end if INTEGRATION_DB.supports_foreign_key_parsing?
234
+ end if DB.supports_foreign_key_parsing?
235
235
 
236
236
  describe "Database schema modifiers" do
237
237
  before do
238
- @db = INTEGRATION_DB
238
+ @db = DB
239
239
  @ds = @db[:items]
240
240
  end
241
241
  after do
@@ -269,7 +269,7 @@ describe "Database schema modifiers" do
269
269
  @ds.insert(:number=>2)
270
270
  end
271
271
  after do
272
- @db.drop_view(:items_view)
272
+ @db.drop_view(:items_view) rescue nil
273
273
  end
274
274
 
275
275
  specify "should create views correctly" do
@@ -277,6 +277,11 @@ describe "Database schema modifiers" do
277
277
  @db[:items_view].map(:number).should == [1]
278
278
  end
279
279
 
280
+ cspecify "should create views with explicit columns correctly", :sqlite do
281
+ @db.create_view(:items_view, @ds.where(:number=>1), :columns=>[:n])
282
+ @db[:items_view].map(:n).should == [1]
283
+ end
284
+
280
285
  specify "should create or replace views correctly" do
281
286
  @db.create_or_replace_view(:items_view, @ds.where(:number=>1))
282
287
  @db[:items_view].map(:number).should == [1]
@@ -289,7 +294,7 @@ describe "Database schema modifiers" do
289
294
  @db.drop_table?(:items)
290
295
  @db.transaction(:rollback=>:always){@db.create_table(:items){Integer :number}}
291
296
  @db.table_exists?(:items).should be_false
292
- end if INTEGRATION_DB.supports_transactional_ddl?
297
+ end if DB.supports_transactional_ddl?
293
298
 
294
299
  describe "join tables" do
295
300
  after do
@@ -307,7 +312,7 @@ describe "Database schema modifiers" do
307
312
  end
308
313
 
309
314
  specify "should create temporary tables without raising an exception" do
310
- @db.create_table!(:items, :temp=>true){Integer :number}
315
+ @db.create_table!(:items_temp, :temp=>true){Integer :number}
311
316
  end
312
317
 
313
318
  specify "should have create_table? only create the table if it doesn't already exist" do
@@ -646,7 +651,7 @@ describe "Database schema modifiers" do
646
651
  @db.create_table!(:items){foreign_key :id, :items2, :deferrable=>true}
647
652
  proc{@db[:items].insert(1)}.should raise_error(Sequel::DatabaseError)
648
653
  proc{@db.transaction{proc{@db[:items].insert(1)}.should_not raise_error}}.should raise_error(Sequel::DatabaseError)
649
- end if INTEGRATION_DB.supports_deferrable_foreign_key_constraints?
654
+ end if DB.supports_deferrable_foreign_key_constraints?
650
655
 
651
656
  specify "should support deferrable unique constraints when creating or altering tables" do
652
657
  @db.create_table!(:items){Integer :t; unique [:t], :name=>:atest_def, :deferrable=>true, :using=>:btree}
@@ -661,7 +666,7 @@ describe "Database schema modifiers" do
661
666
  @db[:items].insert(2)
662
667
  proc{@db[:items].insert(2)}.should raise_error(Sequel::DatabaseError)
663
668
  proc{@db.transaction{proc{@db[:items].insert(2)}.should_not raise_error}}.should raise_error(Sequel::DatabaseError)
664
- end if INTEGRATION_DB.supports_deferrable_constraints?
669
+ end if DB.supports_deferrable_constraints?
665
670
  end
666
671
 
667
672
  describe "Database#tables" do
@@ -672,7 +677,7 @@ describe "Database#tables" do
672
677
  "xxxxx#{@@xxxxx += 1}"
673
678
  end
674
679
  end
675
- @db = INTEGRATION_DB
680
+ @db = DB
676
681
  @db.create_table(:sequel_test_table){Integer :a}
677
682
  @db.create_view :sequel_test_view, @db[:sequel_test_table]
678
683
  @iom = @db.identifier_output_method
@@ -698,7 +703,7 @@ describe "Database#tables" do
698
703
  @db.identifier_input_method = :xxxxx
699
704
  @db.tables.each{|t| t.to_s.should =~ /\Ax{5}\d+\z/}
700
705
  end
701
- end if INTEGRATION_DB.supports_table_listing?
706
+ end if DB.supports_table_listing?
702
707
 
703
708
  describe "Database#views" do
704
709
  before do
@@ -708,7 +713,7 @@ describe "Database#views" do
708
713
  "xxxxx#{@@xxxxx += 1}"
709
714
  end
710
715
  end
711
- @db = INTEGRATION_DB
716
+ @db = DB
712
717
  @db.create_table(:sequel_test_table){Integer :a}
713
718
  @db.create_view :sequel_test_view, @db[:sequel_test_table]
714
719
  @iom = @db.identifier_output_method
@@ -734,4 +739,4 @@ describe "Database#views" do
734
739
  @db.identifier_input_method = :xxxxx
735
740
  @db.views.each{|t| t.to_s.should =~ /\Ax{5}\d+\z/}
736
741
  end
737
- end if INTEGRATION_DB.supports_view_listing?
742
+ end if DB.supports_view_listing?