sequel 4.22.0 → 4.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +22 -0
- data/README.rdoc +6 -0
- data/Rakefile +59 -81
- data/doc/migration.rdoc +2 -0
- data/doc/release_notes/4.23.0.txt +65 -0
- data/doc/sharding.rdoc +16 -14
- data/doc/testing.rdoc +61 -77
- data/lib/sequel/adapters/jdbc.rb +1 -0
- data/lib/sequel/adapters/mock.rb +0 -1
- data/lib/sequel/adapters/postgres.rb +1 -0
- data/lib/sequel/adapters/postgresql.rb +1 -0
- data/lib/sequel/adapters/shared/postgres.rb +3 -3
- data/lib/sequel/connection_pool/sharded_threaded.rb +5 -0
- data/lib/sequel/connection_pool/threaded.rb +9 -1
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/transactions.rb +2 -1
- data/lib/sequel/dataset/prepared_statements.rb +1 -1
- data/lib/sequel/extensions/constraint_validations.rb +12 -12
- data/lib/sequel/extensions/date_arithmetic.rb +0 -4
- data/lib/sequel/extensions/pagination.rb +14 -2
- data/lib/sequel/extensions/pg_enum.rb +2 -2
- data/lib/sequel/extensions/pg_hstore.rb +1 -1
- data/lib/sequel/extensions/pg_json_ops.rb +2 -2
- data/lib/sequel/plugins/csv_serializer.rb +2 -0
- data/lib/sequel/plugins/delay_add_association.rb +50 -0
- data/lib/sequel/plugins/list.rb +2 -2
- data/lib/sequel/plugins/nested_attributes.rb +8 -28
- data/lib/sequel/plugins/update_refresh.rb +50 -0
- data/lib/sequel/plugins/validate_associated.rb +55 -0
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/db2_spec.rb +29 -29
- data/spec/adapters/firebird_spec.rb +97 -103
- data/spec/adapters/informix_spec.rb +25 -25
- data/spec/adapters/mssql_spec.rb +156 -172
- data/spec/adapters/mysql_spec.rb +334 -359
- data/spec/adapters/oracle_spec.rb +67 -69
- data/spec/adapters/postgres_spec.rb +1298 -1249
- data/spec/adapters/spec_helper.rb +2 -35
- data/spec/adapters/sqlanywhere_spec.rb +39 -39
- data/spec/adapters/sqlite_spec.rb +203 -200
- data/spec/bin_spec.rb +57 -59
- data/spec/core/connection_pool_spec.rb +402 -401
- data/spec/core/database_spec.rb +953 -944
- data/spec/core/dataset_spec.rb +2178 -2168
- data/spec/core/deprecated_spec.rb +19 -19
- data/spec/core/expression_filters_spec.rb +415 -415
- data/spec/core/mock_adapter_spec.rb +212 -212
- data/spec/core/object_graph_spec.rb +73 -73
- data/spec/core/placeholder_literalizer_spec.rb +71 -71
- data/spec/core/schema_generator_spec.rb +44 -44
- data/spec/core/schema_spec.rb +470 -472
- data/spec/core/spec_helper.rb +5 -20
- data/spec/core/version_spec.rb +2 -2
- data/spec/core_extensions_spec.rb +320 -320
- data/spec/extensions/accessed_columns_spec.rb +12 -12
- data/spec/extensions/active_model_spec.rb +3 -3
- data/spec/extensions/after_initialize_spec.rb +2 -2
- data/spec/extensions/arbitrary_servers_spec.rb +23 -23
- data/spec/extensions/association_dependencies_spec.rb +34 -34
- data/spec/extensions/association_pks_spec.rb +98 -98
- data/spec/extensions/association_proxies_spec.rb +33 -33
- data/spec/extensions/auto_validations_spec.rb +46 -46
- data/spec/extensions/blacklist_security_spec.rb +19 -18
- data/spec/extensions/blank_spec.rb +36 -36
- data/spec/extensions/boolean_readers_spec.rb +36 -36
- data/spec/extensions/caching_spec.rb +82 -82
- data/spec/extensions/class_table_inheritance_spec.rb +72 -72
- data/spec/extensions/column_conflicts_spec.rb +19 -14
- data/spec/extensions/column_select_spec.rb +19 -19
- data/spec/extensions/columns_introspection_spec.rb +43 -43
- data/spec/extensions/composition_spec.rb +64 -64
- data/spec/extensions/connection_validator_spec.rb +92 -90
- data/spec/extensions/constraint_validations_plugin_spec.rb +92 -92
- data/spec/extensions/constraint_validations_spec.rb +80 -80
- data/spec/extensions/core_refinements_spec.rb +220 -220
- data/spec/extensions/csv_serializer_spec.rb +44 -44
- data/spec/extensions/current_datetime_timestamp_spec.rb +8 -8
- data/spec/extensions/dataset_associations_spec.rb +65 -65
- data/spec/extensions/dataset_source_alias_spec.rb +16 -16
- data/spec/extensions/date_arithmetic_spec.rb +51 -58
- data/spec/extensions/defaults_setter_spec.rb +19 -19
- data/spec/extensions/delay_add_association_spec.rb +52 -0
- data/spec/extensions/dirty_spec.rb +51 -51
- data/spec/extensions/eager_each_spec.rb +8 -8
- data/spec/extensions/empty_array_ignore_nulls_spec.rb +10 -10
- data/spec/extensions/error_splitter_spec.rb +2 -2
- data/spec/extensions/error_sql_spec.rb +4 -4
- data/spec/extensions/eval_inspect_spec.rb +3 -3
- data/spec/extensions/filter_having_spec.rb +8 -8
- data/spec/extensions/force_encoding_spec.rb +30 -30
- data/spec/extensions/from_block_spec.rb +7 -7
- data/spec/extensions/graph_each_spec.rb +19 -19
- data/spec/extensions/hash_aliases_spec.rb +5 -5
- data/spec/extensions/hook_class_methods_spec.rb +100 -100
- data/spec/extensions/inflector_spec.rb +54 -54
- data/spec/extensions/input_transformer_spec.rb +10 -10
- data/spec/extensions/insert_returning_select_spec.rb +8 -8
- data/spec/extensions/instance_filters_spec.rb +26 -26
- data/spec/extensions/instance_hooks_spec.rb +85 -85
- data/spec/extensions/json_serializer_spec.rb +68 -68
- data/spec/extensions/lazy_attributes_spec.rb +49 -49
- data/spec/extensions/list_spec.rb +77 -75
- data/spec/extensions/looser_typecasting_spec.rb +16 -16
- data/spec/extensions/many_through_many_spec.rb +627 -627
- data/spec/extensions/meta_def_spec.rb +7 -7
- data/spec/extensions/migration_spec.rb +217 -217
- data/spec/extensions/modification_detection_spec.rb +20 -20
- data/spec/extensions/mssql_optimistic_locking_spec.rb +21 -21
- data/spec/extensions/named_timezones_spec.rb +18 -18
- data/spec/extensions/nested_attributes_spec.rb +107 -107
- data/spec/extensions/null_dataset_spec.rb +24 -24
- data/spec/extensions/optimistic_locking_spec.rb +21 -21
- data/spec/extensions/pagination_spec.rb +52 -52
- data/spec/extensions/pg_array_associations_spec.rb +273 -273
- data/spec/extensions/pg_array_ops_spec.rb +52 -52
- data/spec/extensions/pg_array_spec.rb +152 -152
- data/spec/extensions/pg_enum_spec.rb +13 -13
- data/spec/extensions/pg_hstore_ops_spec.rb +63 -63
- data/spec/extensions/pg_hstore_spec.rb +84 -84
- data/spec/extensions/pg_inet_spec.rb +15 -15
- data/spec/extensions/pg_interval_spec.rb +29 -29
- data/spec/extensions/pg_json_ops_spec.rb +86 -84
- data/spec/extensions/pg_json_spec.rb +104 -104
- data/spec/extensions/pg_loose_count_spec.rb +6 -6
- data/spec/extensions/pg_range_ops_spec.rb +24 -24
- data/spec/extensions/pg_range_spec.rb +143 -143
- data/spec/extensions/pg_row_ops_spec.rb +14 -14
- data/spec/extensions/pg_row_plugin_spec.rb +12 -12
- data/spec/extensions/pg_row_spec.rb +118 -118
- data/spec/extensions/pg_static_cache_updater_spec.rb +28 -28
- data/spec/extensions/pg_typecast_on_load_spec.rb +21 -21
- data/spec/extensions/prepared_statements_associations_spec.rb +42 -42
- data/spec/extensions/prepared_statements_safe_spec.rb +18 -18
- data/spec/extensions/prepared_statements_spec.rb +28 -28
- data/spec/extensions/prepared_statements_with_pk_spec.rb +11 -11
- data/spec/extensions/pretty_table_spec.rb +16 -16
- data/spec/extensions/query_literals_spec.rb +37 -37
- data/spec/extensions/query_spec.rb +32 -32
- data/spec/extensions/rcte_tree_spec.rb +141 -141
- data/spec/extensions/round_timestamps_spec.rb +21 -21
- data/spec/extensions/schema_caching_spec.rb +8 -8
- data/spec/extensions/schema_dumper_spec.rb +78 -78
- data/spec/extensions/schema_spec.rb +31 -27
- data/spec/extensions/scissors_spec.rb +3 -3
- data/spec/extensions/select_remove_spec.rb +14 -14
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +28 -28
- data/spec/extensions/serialization_modification_detection_spec.rb +33 -33
- data/spec/extensions/serialization_spec.rb +79 -78
- data/spec/extensions/server_block_spec.rb +17 -17
- data/spec/extensions/set_overrides_spec.rb +30 -30
- data/spec/extensions/sharding_spec.rb +65 -65
- data/spec/extensions/shared_caching_spec.rb +29 -29
- data/spec/extensions/single_table_inheritance_spec.rb +79 -79
- data/spec/extensions/skip_create_refresh_spec.rb +3 -3
- data/spec/extensions/spec_helper.rb +4 -29
- data/spec/extensions/split_array_nil_spec.rb +9 -9
- data/spec/extensions/split_values_spec.rb +7 -7
- data/spec/extensions/sql_expr_spec.rb +32 -32
- data/spec/extensions/static_cache_spec.rb +123 -123
- data/spec/extensions/string_date_time_spec.rb +34 -34
- data/spec/extensions/string_stripper_spec.rb +15 -15
- data/spec/extensions/subclasses_spec.rb +31 -31
- data/spec/extensions/table_select_spec.rb +15 -15
- data/spec/extensions/tactical_eager_loading_spec.rb +23 -23
- data/spec/extensions/thread_local_timezones_spec.rb +13 -13
- data/spec/extensions/timestamps_spec.rb +40 -40
- data/spec/extensions/to_dot_spec.rb +34 -34
- data/spec/extensions/touch_spec.rb +52 -52
- data/spec/extensions/tree_spec.rb +72 -72
- data/spec/extensions/typecast_on_load_spec.rb +25 -25
- data/spec/extensions/unlimited_update_spec.rb +2 -2
- data/spec/extensions/update_or_create_spec.rb +36 -36
- data/spec/extensions/update_primary_key_spec.rb +35 -35
- data/spec/extensions/update_refresh_spec.rb +41 -0
- data/spec/extensions/validate_associated_spec.rb +52 -0
- data/spec/extensions/validation_class_methods_spec.rb +314 -317
- data/spec/extensions/validation_helpers_spec.rb +195 -195
- data/spec/extensions/xml_serializer_spec.rb +48 -48
- data/spec/guards_helper.rb +55 -0
- data/spec/integration/associations_test.rb +1089 -1088
- data/spec/integration/database_test.rb +29 -29
- data/spec/integration/dataset_test.rb +661 -661
- data/spec/integration/eager_loader_test.rb +147 -147
- data/spec/integration/migrator_test.rb +122 -122
- data/spec/integration/model_test.rb +70 -70
- data/spec/integration/plugin_test.rb +682 -640
- data/spec/integration/prepared_statement_test.rb +172 -172
- data/spec/integration/schema_test.rb +245 -245
- data/spec/integration/spec_helper.rb +1 -64
- data/spec/integration/timezone_test.rb +17 -17
- data/spec/integration/transaction_test.rb +87 -87
- data/spec/integration/type_test.rb +33 -33
- data/spec/model/association_reflection_spec.rb +130 -121
- data/spec/model/associations_spec.rb +1112 -1113
- data/spec/model/base_spec.rb +197 -196
- data/spec/model/class_dataset_methods_spec.rb +118 -118
- data/spec/model/dataset_methods_spec.rb +49 -49
- data/spec/model/eager_loading_spec.rb +705 -702
- data/spec/model/hooks_spec.rb +169 -168
- data/spec/model/inflector_spec.rb +5 -5
- data/spec/model/model_spec.rb +287 -297
- data/spec/model/plugins_spec.rb +47 -47
- data/spec/model/record_spec.rb +534 -535
- data/spec/model/spec_helper.rb +3 -21
- data/spec/model/validations_spec.rb +72 -70
- data/spec/spec_config.rb +8 -0
- metadata +41 -9
- data/lib/sequel/adapters/fdbsql.rb +0 -286
- data/lib/sequel/adapters/jdbc/fdbsql.rb +0 -66
- data/lib/sequel/adapters/openbase.rb +0 -54
- data/lib/sequel/adapters/shared/fdbsql.rb +0 -550
- data/spec/adapters/fdbsql_spec.rb +0 -429
- data/spec/rspec_helper.rb +0 -22
@@ -1,336 +1,336 @@
|
|
1
1
|
require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
|
2
2
|
|
3
3
|
describe "Sequel Mock Adapter" do
|
4
|
-
|
4
|
+
it "should have an adapter method" do
|
5
5
|
db = Sequel.mock
|
6
|
-
db.
|
7
|
-
db.adapter_scheme.
|
6
|
+
db.must_be_kind_of(Sequel::Mock::Database)
|
7
|
+
db.adapter_scheme.must_equal :mock
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
Sequel::Mock::Database.new.
|
10
|
+
it "should have constructor accept no arguments" do
|
11
|
+
Sequel::Mock::Database.new.must_be_kind_of(Sequel::Mock::Database)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
it "should each not return any rows by default" do
|
15
15
|
called = false
|
16
16
|
Sequel.mock[:t].each{|r| called = true}
|
17
|
-
called.
|
17
|
+
called.must_equal false
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
Sequel.mock[:t].update(:a=>1).
|
22
|
-
Sequel.mock[:t].delete.
|
23
|
-
Sequel.mock[:t].with_sql_delete('DELETE FROM t').
|
24
|
-
Sequel.mock.execute_dui('DELETE FROM t').
|
20
|
+
it "should return 0 for update/delete/with_sql_delete/execute_dui by default" do
|
21
|
+
Sequel.mock[:t].update(:a=>1).must_equal 0
|
22
|
+
Sequel.mock[:t].delete.must_equal 0
|
23
|
+
Sequel.mock[:t].with_sql_delete('DELETE FROM t').must_equal 0
|
24
|
+
Sequel.mock.execute_dui('DELETE FROM t').must_equal 0
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
Sequel.mock[:t].insert(:a=>1).
|
29
|
-
Sequel.mock.execute_insert('INSERT INTO a () DEFAULT VALUES').
|
27
|
+
it "should return nil for insert/execute_insert by default" do
|
28
|
+
Sequel.mock[:t].insert(:a=>1).must_equal nil
|
29
|
+
Sequel.mock.execute_insert('INSERT INTO a () DEFAULT VALUES').must_equal nil
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
it "should be able to set the rows returned by each using :fetch option with a single hash" do
|
33
33
|
rs = []
|
34
34
|
db = Sequel.mock(:fetch=>{:a=>1})
|
35
35
|
db[:t].each{|r| rs << r}
|
36
|
-
rs.
|
36
|
+
rs.must_equal [{:a=>1}]
|
37
37
|
db[:t].each{|r| rs << r}
|
38
|
-
rs.
|
38
|
+
rs.must_equal [{:a=>1}, {:a=>1}]
|
39
39
|
db[:t].each{|r| r[:a] = 2; rs << r}
|
40
|
-
rs.
|
40
|
+
rs.must_equal [{:a=>1}, {:a=>1}, {:a=>2}]
|
41
41
|
db[:t].each{|r| rs << r}
|
42
|
-
rs.
|
42
|
+
rs.must_equal [{:a=>1}, {:a=>1}, {:a=>2}, {:a=>1}]
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
it "should be able to set the rows returned by each using :fetch option with an array of hashes" do
|
46
46
|
rs = []
|
47
47
|
db = Sequel.mock(:fetch=>[{:a=>1}, {:a=>2}])
|
48
48
|
db[:t].each{|r| rs << r}
|
49
|
-
rs.
|
49
|
+
rs.must_equal [{:a=>1}, {:a=>2}]
|
50
50
|
db[:t].each{|r| rs << r}
|
51
|
-
rs.
|
51
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>1}, {:a=>2}]
|
52
52
|
db[:t].each{|r| r[:a] += 2; rs << r}
|
53
|
-
rs.
|
53
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>1}, {:a=>2}, {:a=>3}, {:a=>4}]
|
54
54
|
db[:t].each{|r| rs << r}
|
55
|
-
rs.
|
55
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>1}, {:a=>2}, {:a=>3}, {:a=>4}, {:a=>1}, {:a=>2}]
|
56
56
|
end
|
57
57
|
|
58
|
-
|
58
|
+
it "should be able to set the rows returned by each using :fetch option with an array or arrays of hashes" do
|
59
59
|
rs = []
|
60
60
|
db = Sequel.mock(:fetch=>[[{:a=>1}, {:a=>2}], [{:a=>3}, {:a=>4}]])
|
61
61
|
db[:t].each{|r| rs << r}
|
62
|
-
rs.
|
62
|
+
rs.must_equal [{:a=>1}, {:a=>2}]
|
63
63
|
db[:t].each{|r| rs << r}
|
64
|
-
rs.
|
64
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>3}, {:a=>4}]
|
65
65
|
db[:t].each{|r| rs << r}
|
66
|
-
rs.
|
66
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>3}, {:a=>4}]
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
it "should be able to set the rows returned by each using :fetch option with a proc that takes sql" do
|
70
70
|
rs = []
|
71
71
|
db = Sequel.mock(:fetch=>proc{|sql| sql =~ /FROM t/ ? {:b=>1} : [{:a=>1}, {:a=>2}]})
|
72
72
|
db[:t].each{|r| rs << r}
|
73
|
-
rs.
|
73
|
+
rs.must_equal [{:b=>1}]
|
74
74
|
db[:b].each{|r| rs << r}
|
75
|
-
rs.
|
75
|
+
rs.must_equal [{:b=>1}, {:a=>1}, {:a=>2}]
|
76
76
|
db[:t].each{|r| r[:b] += 1; rs << r}
|
77
77
|
db[:b].each{|r| r[:a] += 2; rs << r}
|
78
|
-
rs.
|
78
|
+
rs.must_equal [{:b=>1}, {:a=>1}, {:a=>2}, {:b=>2}, {:a=>3}, {:a=>4}]
|
79
79
|
db[:t].each{|r| rs << r}
|
80
80
|
db[:b].each{|r| rs << r}
|
81
|
-
rs.
|
81
|
+
rs.must_equal [{:b=>1}, {:a=>1}, {:a=>2}, {:b=>2}, {:a=>3}, {:a=>4}, {:b=>1}, {:a=>1}, {:a=>2}]
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
it "should have a fetch= method for setting rows returned by each after the fact" do
|
85
85
|
rs = []
|
86
86
|
db = Sequel.mock
|
87
87
|
db.fetch = {:a=>1}
|
88
88
|
db[:t].each{|r| rs << r}
|
89
|
-
rs.
|
89
|
+
rs.must_equal [{:a=>1}]
|
90
90
|
db[:t].each{|r| rs << r}
|
91
|
-
rs.
|
91
|
+
rs.must_equal [{:a=>1}] * 2
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
it "should be able to set an exception to raise by setting the :fetch option to an exception class " do
|
95
95
|
db = Sequel.mock(:fetch=>ArgumentError)
|
96
|
-
proc{db[:t].all}.
|
96
|
+
proc{db[:t].all}.must_raise(Sequel::DatabaseError)
|
97
97
|
begin
|
98
98
|
db[:t].all
|
99
99
|
rescue => e
|
100
100
|
end
|
101
|
-
e.
|
102
|
-
e.wrapped_exception.
|
101
|
+
e.must_be_kind_of(Sequel::DatabaseError)
|
102
|
+
e.wrapped_exception.must_be_kind_of(ArgumentError)
|
103
103
|
end
|
104
104
|
|
105
|
-
|
105
|
+
it "should be able to set separate kinds of results for fetch using an array" do
|
106
106
|
rs = []
|
107
107
|
db = Sequel.mock(:fetch=>[{:a=>1}, [{:a=>2}, {:a=>3}], proc{|s| {:a=>4}}, proc{|s| }, nil, ArgumentError])
|
108
108
|
db[:t].each{|r| rs << r}
|
109
|
-
rs.
|
109
|
+
rs.must_equal [{:a=>1}]
|
110
110
|
db[:t].each{|r| rs << r}
|
111
|
-
rs.
|
111
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>3}]
|
112
112
|
db[:t].each{|r| rs << r}
|
113
|
-
rs.
|
113
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>3}, {:a=>4}]
|
114
114
|
db[:t].each{|r| rs << r}
|
115
|
-
rs.
|
115
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>3}, {:a=>4}]
|
116
116
|
db[:t].each{|r| rs << r}
|
117
|
-
rs.
|
118
|
-
proc{db[:t].all}.
|
117
|
+
rs.must_equal [{:a=>1}, {:a=>2}, {:a=>3}, {:a=>4}]
|
118
|
+
proc{db[:t].all}.must_raise(Sequel::DatabaseError)
|
119
119
|
end
|
120
120
|
|
121
|
-
|
121
|
+
it "should be able to set the rows returned by each on a per dataset basis using _fetch" do
|
122
122
|
rs = []
|
123
123
|
db = Sequel.mock(:fetch=>{:a=>1})
|
124
124
|
ds = db[:t]
|
125
125
|
ds.each{|r| rs << r}
|
126
|
-
rs.
|
126
|
+
rs.must_equal [{:a=>1}]
|
127
127
|
ds._fetch = {:b=>2}
|
128
128
|
ds.each{|r| rs << r}
|
129
|
-
rs.
|
129
|
+
rs.must_equal [{:a=>1}, {:b=>2}]
|
130
130
|
end
|
131
131
|
|
132
|
-
|
133
|
-
proc{Sequel.mock(:fetch=>Class.new).get(:a)}.
|
134
|
-
proc{Sequel.mock(:fetch=>Object.new).get(:a)}.
|
132
|
+
it "should raise Error if given an invalid object to fetch" do
|
133
|
+
proc{Sequel.mock(:fetch=>Class.new).get(:a)}.must_raise(Sequel::DatabaseError)
|
134
|
+
proc{Sequel.mock(:fetch=>Object.new).get(:a)}.must_raise(Sequel::DatabaseError)
|
135
135
|
end
|
136
136
|
|
137
|
-
|
137
|
+
it "should be able to set the number of rows modified by update and delete using :numrows option as an integer" do
|
138
138
|
db = Sequel.mock(:numrows=>2)
|
139
|
-
db[:t].update(:a=>1).
|
140
|
-
db[:t].delete.
|
141
|
-
db[:t].update(:a=>1).
|
142
|
-
db[:t].delete.
|
139
|
+
db[:t].update(:a=>1).must_equal 2
|
140
|
+
db[:t].delete.must_equal 2
|
141
|
+
db[:t].update(:a=>1).must_equal 2
|
142
|
+
db[:t].delete.must_equal 2
|
143
143
|
end
|
144
144
|
|
145
|
-
|
145
|
+
it "should be able to set the number of rows modified by update and delete using :numrows option as an array of integers" do
|
146
146
|
db = Sequel.mock(:numrows=>[2, 1])
|
147
|
-
db[:t].update(:a=>1).
|
148
|
-
db[:t].delete.
|
149
|
-
db[:t].update(:a=>1).
|
150
|
-
db[:t].delete.
|
147
|
+
db[:t].update(:a=>1).must_equal 2
|
148
|
+
db[:t].delete.must_equal 1
|
149
|
+
db[:t].update(:a=>1).must_equal 0
|
150
|
+
db[:t].delete.must_equal 0
|
151
151
|
end
|
152
152
|
|
153
|
-
|
153
|
+
it "should be able to set the number of rows modified by update and delete using :numrows option as a proc" do
|
154
154
|
db = Sequel.mock(:numrows=>proc{|sql| sql =~ / t/ ? 2 : 1})
|
155
|
-
db[:t].update(:a=>1).
|
156
|
-
db[:t].delete.
|
157
|
-
db[:b].update(:a=>1).
|
158
|
-
db[:b].delete.
|
155
|
+
db[:t].update(:a=>1).must_equal 2
|
156
|
+
db[:t].delete.must_equal 2
|
157
|
+
db[:b].update(:a=>1).must_equal 1
|
158
|
+
db[:b].delete.must_equal 1
|
159
159
|
end
|
160
160
|
|
161
|
-
|
161
|
+
it "should be able to set an exception to raise by setting the :numrows option to an exception class " do
|
162
162
|
db = Sequel.mock(:numrows=>ArgumentError)
|
163
|
-
proc{db[:t].update(:a=>1)}.
|
163
|
+
proc{db[:t].update(:a=>1)}.must_raise(Sequel::DatabaseError)
|
164
164
|
begin
|
165
165
|
db[:t].delete
|
166
166
|
rescue => e
|
167
167
|
end
|
168
|
-
e.
|
169
|
-
e.wrapped_exception.
|
168
|
+
e.must_be_kind_of(Sequel::DatabaseError)
|
169
|
+
e.wrapped_exception.must_be_kind_of(ArgumentError)
|
170
170
|
end
|
171
171
|
|
172
|
-
|
172
|
+
it "should be able to set separate kinds of results for numrows using an array" do
|
173
173
|
db = Sequel.mock(:numrows=>[1, proc{|s| 2}, nil, ArgumentError])
|
174
|
-
db[:t].delete.
|
175
|
-
db[:t].update(:a=>1).
|
176
|
-
db[:t].delete.
|
177
|
-
proc{db[:t].delete}.
|
174
|
+
db[:t].delete.must_equal 1
|
175
|
+
db[:t].update(:a=>1).must_equal 2
|
176
|
+
db[:t].delete.must_equal 0
|
177
|
+
proc{db[:t].delete}.must_raise(Sequel::DatabaseError)
|
178
178
|
end
|
179
179
|
|
180
|
-
|
180
|
+
it "should have a numrows= method to set the number of rows modified by update and delete after the fact" do
|
181
181
|
db = Sequel.mock
|
182
182
|
db.numrows = 2
|
183
|
-
db[:t].update(:a=>1).
|
184
|
-
db[:t].delete.
|
185
|
-
db[:t].update(:a=>1).
|
186
|
-
db[:t].delete.
|
183
|
+
db[:t].update(:a=>1).must_equal 2
|
184
|
+
db[:t].delete.must_equal 2
|
185
|
+
db[:t].update(:a=>1).must_equal 2
|
186
|
+
db[:t].delete.must_equal 2
|
187
187
|
end
|
188
188
|
|
189
|
-
|
189
|
+
it "should be able to set the number of rows modified by update and delete on a per dataset basis" do
|
190
190
|
db = Sequel.mock(:numrows=>2)
|
191
191
|
ds = db[:t]
|
192
|
-
ds.update(:a=>1).
|
193
|
-
ds.delete.
|
192
|
+
ds.update(:a=>1).must_equal 2
|
193
|
+
ds.delete.must_equal 2
|
194
194
|
ds.numrows = 3
|
195
|
-
ds.update(:a=>1).
|
196
|
-
ds.delete.
|
195
|
+
ds.update(:a=>1).must_equal 3
|
196
|
+
ds.delete.must_equal 3
|
197
197
|
end
|
198
198
|
|
199
|
-
|
200
|
-
proc{Sequel.mock(:numrows=>Class.new)[:a].delete}.
|
201
|
-
proc{Sequel.mock(:numrows=>Object.new)[:a].delete}.
|
202
|
-
proc{Sequel.mock(:autoid=>Class.new)[:a].insert}.
|
203
|
-
proc{Sequel.mock(:autoid=>Object.new)[:a].insert}.
|
199
|
+
it "should raise Error if given an invalid object for numrows or autoid" do
|
200
|
+
proc{Sequel.mock(:numrows=>Class.new)[:a].delete}.must_raise(Sequel::DatabaseError)
|
201
|
+
proc{Sequel.mock(:numrows=>Object.new)[:a].delete}.must_raise(Sequel::DatabaseError)
|
202
|
+
proc{Sequel.mock(:autoid=>Class.new)[:a].insert}.must_raise(Sequel::DatabaseError)
|
203
|
+
proc{Sequel.mock(:autoid=>Object.new)[:a].insert}.must_raise(Sequel::DatabaseError)
|
204
204
|
end
|
205
205
|
|
206
|
-
|
206
|
+
it "should be able to set the autogenerated primary key returned by insert using :autoid option as an integer" do
|
207
207
|
db = Sequel.mock(:autoid=>1)
|
208
|
-
db[:t].insert(:a=>1).
|
209
|
-
db[:t].insert(:a=>1).
|
210
|
-
db[:t].insert(:a=>1).
|
208
|
+
db[:t].insert(:a=>1).must_equal 1
|
209
|
+
db[:t].insert(:a=>1).must_equal 2
|
210
|
+
db[:t].insert(:a=>1).must_equal 3
|
211
211
|
end
|
212
212
|
|
213
|
-
|
213
|
+
it "should be able to set the autogenerated primary key returned by insert using :autoid option as an array of integers" do
|
214
214
|
db = Sequel.mock(:autoid=>[1, 3, 5])
|
215
|
-
db[:t].insert(:a=>1).
|
216
|
-
db[:t].insert(:a=>1).
|
217
|
-
db[:t].insert(:a=>1).
|
218
|
-
db[:t].insert(:a=>1).
|
215
|
+
db[:t].insert(:a=>1).must_equal 1
|
216
|
+
db[:t].insert(:a=>1).must_equal 3
|
217
|
+
db[:t].insert(:a=>1).must_equal 5
|
218
|
+
db[:t].insert(:a=>1).must_equal nil
|
219
219
|
end
|
220
220
|
|
221
|
-
|
221
|
+
it "should be able to set the autogenerated primary key returned by insert using :autoid option as a proc" do
|
222
222
|
db = Sequel.mock(:autoid=>proc{|sql| sql =~ /INTO t / ? 2 : 1})
|
223
|
-
db[:t].insert(:a=>1).
|
224
|
-
db[:t].insert(:a=>1).
|
225
|
-
db[:b].insert(:a=>1).
|
226
|
-
db[:b].insert(:a=>1).
|
223
|
+
db[:t].insert(:a=>1).must_equal 2
|
224
|
+
db[:t].insert(:a=>1).must_equal 2
|
225
|
+
db[:b].insert(:a=>1).must_equal 1
|
226
|
+
db[:b].insert(:a=>1).must_equal 1
|
227
227
|
end
|
228
228
|
|
229
|
-
|
229
|
+
it "should be able to set an exception to raise by setting the :autoid option to an exception class " do
|
230
230
|
db = Sequel.mock(:autoid=>ArgumentError)
|
231
|
-
proc{db[:t].insert(:a=>1)}.
|
231
|
+
proc{db[:t].insert(:a=>1)}.must_raise(Sequel::DatabaseError)
|
232
232
|
begin
|
233
233
|
db[:t].insert
|
234
234
|
rescue => e
|
235
235
|
end
|
236
|
-
e.
|
237
|
-
e.wrapped_exception.
|
236
|
+
e.must_be_kind_of(Sequel::DatabaseError)
|
237
|
+
e.wrapped_exception.must_be_kind_of(ArgumentError)
|
238
238
|
end
|
239
239
|
|
240
|
-
|
240
|
+
it "should be able to set separate kinds of results for autoid using an array" do
|
241
241
|
db = Sequel.mock(:autoid=>[1, proc{|s| 2}, nil, ArgumentError])
|
242
|
-
db[:t].insert.
|
243
|
-
db[:t].insert.
|
244
|
-
db[:t].insert.
|
245
|
-
proc{db[:t].insert}.
|
242
|
+
db[:t].insert.must_equal 1
|
243
|
+
db[:t].insert.must_equal 2
|
244
|
+
db[:t].insert.must_equal nil
|
245
|
+
proc{db[:t].insert}.must_raise(Sequel::DatabaseError)
|
246
246
|
end
|
247
247
|
|
248
|
-
|
248
|
+
it "should have an autoid= method to set the autogenerated primary key returned by insert after the fact" do
|
249
249
|
db = Sequel.mock
|
250
250
|
db.autoid = 1
|
251
|
-
db[:t].insert(:a=>1).
|
252
|
-
db[:t].insert(:a=>1).
|
253
|
-
db[:t].insert(:a=>1).
|
251
|
+
db[:t].insert(:a=>1).must_equal 1
|
252
|
+
db[:t].insert(:a=>1).must_equal 2
|
253
|
+
db[:t].insert(:a=>1).must_equal 3
|
254
254
|
end
|
255
255
|
|
256
|
-
|
256
|
+
it "should be able to set the autogenerated primary key returned by insert on a per dataset basis" do
|
257
257
|
db = Sequel.mock(:autoid=>1)
|
258
258
|
ds = db[:t]
|
259
|
-
ds.insert(:a=>1).
|
259
|
+
ds.insert(:a=>1).must_equal 1
|
260
260
|
ds.autoid = 5
|
261
|
-
ds.insert(:a=>1).
|
262
|
-
ds.insert(:a=>1).
|
263
|
-
db[:t].insert(:a=>1).
|
261
|
+
ds.insert(:a=>1).must_equal 5
|
262
|
+
ds.insert(:a=>1).must_equal 6
|
263
|
+
db[:t].insert(:a=>1).must_equal 2
|
264
264
|
end
|
265
265
|
|
266
|
-
|
266
|
+
it "should be able to set the columns to set in the dataset as an array of symbols" do
|
267
267
|
db = Sequel.mock(:columns=>[:a, :b])
|
268
|
-
db[:t].columns.
|
269
|
-
db.sqls.
|
268
|
+
db[:t].columns.must_equal [:a, :b]
|
269
|
+
db.sqls.must_equal ["SELECT * FROM t LIMIT 1"]
|
270
270
|
ds = db[:t]
|
271
271
|
ds.all
|
272
|
-
db.sqls.
|
273
|
-
ds.columns.
|
274
|
-
db.sqls.
|
275
|
-
db[:t].columns.
|
272
|
+
db.sqls.must_equal ["SELECT * FROM t"]
|
273
|
+
ds.columns.must_equal [:a, :b]
|
274
|
+
db.sqls.must_equal []
|
275
|
+
db[:t].columns.must_equal [:a, :b]
|
276
276
|
end
|
277
277
|
|
278
|
-
|
278
|
+
it "should be able to set the columns to set in the dataset as an array of arrays of symbols" do
|
279
279
|
db = Sequel.mock(:columns=>[[:a, :b], [:c, :d]])
|
280
|
-
db[:t].columns.
|
281
|
-
db[:t].columns.
|
280
|
+
db[:t].columns.must_equal [:a, :b]
|
281
|
+
db[:t].columns.must_equal [:c, :d]
|
282
282
|
end
|
283
283
|
|
284
|
-
|
284
|
+
it "should be able to set the columns to set in the dataset as a proc" do
|
285
285
|
db = Sequel.mock(:columns=>proc{|sql| (sql =~ / t/) ? [:a, :b] : [:c, :d]})
|
286
|
-
db[:b].columns.
|
287
|
-
db[:t].columns.
|
286
|
+
db[:b].columns.must_equal [:c, :d]
|
287
|
+
db[:t].columns.must_equal [:a, :b]
|
288
288
|
end
|
289
289
|
|
290
|
-
|
290
|
+
it "should have a columns= method to set the columns to set after the fact" do
|
291
291
|
db = Sequel.mock
|
292
292
|
db.columns = [[:a, :b], [:c, :d]]
|
293
|
-
db[:t].columns.
|
294
|
-
db[:t].columns.
|
293
|
+
db[:t].columns.must_equal [:a, :b]
|
294
|
+
db[:t].columns.must_equal [:c, :d]
|
295
295
|
end
|
296
296
|
|
297
|
-
|
298
|
-
proc{Sequel.mock(:columns=>Object.new)[:a].columns}.
|
297
|
+
it "should raise Error if given an invalid columns" do
|
298
|
+
proc{Sequel.mock(:columns=>Object.new)[:a].columns}.must_raise(Sequel::DatabaseError)
|
299
299
|
end
|
300
300
|
|
301
|
-
|
302
|
-
Sequel.mock.send(:quote_identifiers_default).
|
301
|
+
it "should not quote identifiers by default" do
|
302
|
+
Sequel.mock.send(:quote_identifiers_default).must_equal false
|
303
303
|
end
|
304
304
|
|
305
|
-
|
305
|
+
it "should allow overriding of server_version" do
|
306
306
|
db = Sequel.mock
|
307
|
-
db.server_version.
|
307
|
+
db.server_version.must_equal nil
|
308
308
|
db.server_version = 80102
|
309
|
-
db.server_version.
|
309
|
+
db.server_version.must_equal 80102
|
310
310
|
end
|
311
311
|
|
312
|
-
|
313
|
-
Sequel.mock.send(:identifier_input_method_default).
|
314
|
-
Sequel.mock.send(:identifier_output_method_default).
|
312
|
+
it "should not have identifier input/output methods by default" do
|
313
|
+
Sequel.mock.send(:identifier_input_method_default).must_equal nil
|
314
|
+
Sequel.mock.send(:identifier_output_method_default).must_equal nil
|
315
315
|
end
|
316
316
|
|
317
|
-
|
317
|
+
it "should keep a record of all executed SQL in #sqls" do
|
318
318
|
db = Sequel.mock
|
319
319
|
db[:t].all
|
320
320
|
db[:b].delete
|
321
321
|
db[:c].insert(:a=>1)
|
322
322
|
db[:d].update(:a=>1)
|
323
|
-
db.sqls.
|
323
|
+
db.sqls.must_equal ['SELECT * FROM t', 'DELETE FROM b', 'INSERT INTO c (a) VALUES (1)', 'UPDATE d SET a = 1']
|
324
324
|
end
|
325
325
|
|
326
|
-
|
326
|
+
it "should clear sqls on retrieval" do
|
327
327
|
db = Sequel.mock
|
328
328
|
db[:t].all
|
329
|
-
db.sqls.
|
330
|
-
db.sqls.
|
329
|
+
db.sqls.must_equal ['SELECT * FROM t']
|
330
|
+
db.sqls.must_equal []
|
331
331
|
end
|
332
332
|
|
333
|
-
|
333
|
+
it "should also log SQL executed to the given loggers" do
|
334
334
|
a = []
|
335
335
|
def a.method_missing(m, *x) push(*x) end
|
336
336
|
db = Sequel.mock(:loggers=>[a])
|
@@ -338,84 +338,84 @@ describe "Sequel Mock Adapter" do
|
|
338
338
|
db[:b].delete
|
339
339
|
db[:c].insert(:a=>1)
|
340
340
|
db[:d].update(:a=>1)
|
341
|
-
a.
|
341
|
+
a.must_equal ['SELECT * FROM t', 'DELETE FROM b', 'INSERT INTO c (a) VALUES (1)', 'UPDATE d SET a = 1']
|
342
342
|
end
|
343
343
|
|
344
|
-
|
344
|
+
it "should correctly handle transactions" do
|
345
345
|
db = Sequel.mock
|
346
346
|
db.transaction{db[:a].all}
|
347
|
-
db.sqls.
|
347
|
+
db.sqls.must_equal ['BEGIN', 'SELECT * FROM a', 'COMMIT']
|
348
348
|
db.transaction{db[:a].all; raise Sequel::Rollback}
|
349
|
-
db.sqls.
|
350
|
-
proc{db.transaction{db[:a].all; raise ArgumentError}}.
|
351
|
-
db.sqls.
|
352
|
-
proc{db.transaction(:rollback=>:reraise){db[:a].all; raise Sequel::Rollback}}.
|
353
|
-
db.sqls.
|
349
|
+
db.sqls.must_equal ['BEGIN', 'SELECT * FROM a', 'ROLLBACK']
|
350
|
+
proc{db.transaction{db[:a].all; raise ArgumentError}}.must_raise(ArgumentError)
|
351
|
+
db.sqls.must_equal ['BEGIN', 'SELECT * FROM a', 'ROLLBACK']
|
352
|
+
proc{db.transaction(:rollback=>:reraise){db[:a].all; raise Sequel::Rollback}}.must_raise(Sequel::Rollback)
|
353
|
+
db.sqls.must_equal ['BEGIN', 'SELECT * FROM a', 'ROLLBACK']
|
354
354
|
db.transaction(:rollback=>:always){db[:a].all}
|
355
|
-
db.sqls.
|
355
|
+
db.sqls.must_equal ['BEGIN', 'SELECT * FROM a', 'ROLLBACK']
|
356
356
|
db.transaction{db.transaction{db[:a].all; raise Sequel::Rollback}}
|
357
|
-
db.sqls.
|
357
|
+
db.sqls.must_equal ['BEGIN', 'SELECT * FROM a', 'ROLLBACK']
|
358
358
|
db.transaction{db.transaction(:savepoint=>true){db[:a].all; raise Sequel::Rollback}}
|
359
|
-
db.sqls.
|
359
|
+
db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'SELECT * FROM a', 'ROLLBACK TO SAVEPOINT autopoint_1', 'COMMIT']
|
360
360
|
db.transaction{db.transaction(:savepoint=>true){db[:a].all}; raise Sequel::Rollback}
|
361
|
-
db.sqls.
|
361
|
+
db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'SELECT * FROM a', 'RELEASE SAVEPOINT autopoint_1', 'ROLLBACK']
|
362
362
|
end
|
363
363
|
|
364
|
-
|
364
|
+
it "should correctly handle transactions when sharding" do
|
365
365
|
db = Sequel.mock(:servers=>{:test=>{}})
|
366
366
|
db.transaction{db.transaction(:server=>:test){db[:a].all; db[:t].server(:test).all}}
|
367
|
-
db.sqls.
|
367
|
+
db.sqls.must_equal ['BEGIN', 'BEGIN -- test', 'SELECT * FROM a', 'SELECT * FROM t -- test', 'COMMIT -- test', 'COMMIT']
|
368
368
|
end
|
369
369
|
|
370
|
-
|
370
|
+
it "should yield a mock connection object from synchronize" do
|
371
371
|
c = Sequel.mock.synchronize{|conn| conn}
|
372
|
-
c.
|
372
|
+
c.must_be_kind_of(Sequel::Mock::Connection)
|
373
373
|
end
|
374
374
|
|
375
|
-
|
375
|
+
it "should deal correctly with sharding" do
|
376
376
|
db = Sequel.mock(:servers=>{:test=>{}})
|
377
377
|
c1 = db.synchronize{|conn| conn}
|
378
378
|
c2 = db.synchronize(:test){|conn| conn}
|
379
|
-
c1.server.
|
380
|
-
c2.server.
|
379
|
+
c1.server.must_equal :default
|
380
|
+
c2.server.must_equal :test
|
381
381
|
end
|
382
382
|
|
383
|
-
|
383
|
+
it "should disconnect correctly" do
|
384
384
|
db = Sequel.mock
|
385
385
|
db.test_connection
|
386
|
-
|
386
|
+
db.disconnect
|
387
387
|
end
|
388
388
|
|
389
|
-
|
390
|
-
Sequel.mock(:extend=>Module.new{def foo(v) v * 2 end}).foo(3).
|
389
|
+
it "should accept :extend option for extending the object with a module" do
|
390
|
+
Sequel.mock(:extend=>Module.new{def foo(v) v * 2 end}).foo(3).must_equal 6
|
391
391
|
end
|
392
392
|
|
393
|
-
|
393
|
+
it "should accept :sqls option for where to store the SQL queries" do
|
394
394
|
a = []
|
395
395
|
Sequel.mock(:sqls=>a)[:t].all
|
396
|
-
a.
|
396
|
+
a.must_equal ['SELECT * FROM t']
|
397
397
|
end
|
398
398
|
|
399
|
-
|
399
|
+
it "should include :append option in SQL if it is given" do
|
400
400
|
db = Sequel.mock(:append=>'a')
|
401
401
|
db[:t].all
|
402
|
-
db.sqls.
|
402
|
+
db.sqls.must_equal ['SELECT * FROM t -- a']
|
403
403
|
end
|
404
404
|
|
405
|
-
|
405
|
+
it "should append :arguments option to execute to the SQL if present" do
|
406
406
|
db = Sequel.mock
|
407
407
|
db.execute('SELECT * FROM t', :arguments=>[1, 2])
|
408
|
-
db.sqls.
|
408
|
+
db.sqls.must_equal ['SELECT * FROM t -- args: [1, 2]']
|
409
409
|
end
|
410
410
|
|
411
|
-
|
411
|
+
it "should have Dataset#columns take columns to set and return self" do
|
412
412
|
db = Sequel.mock
|
413
413
|
ds = db[:t].columns(:id, :a, :b)
|
414
|
-
ds.
|
415
|
-
ds.columns.
|
414
|
+
ds.must_be_kind_of(Sequel::Mock::Dataset)
|
415
|
+
ds.columns.must_equal [:id, :a, :b]
|
416
416
|
end
|
417
417
|
|
418
|
-
|
418
|
+
it "should be able to load dialects based on the database name" do
|
419
419
|
begin
|
420
420
|
qi = class Sequel::Database; @quote_identifiers; end
|
421
421
|
ii = class Sequel::Database; @identifier_input_method; end
|
@@ -423,17 +423,17 @@ describe "Sequel Mock Adapter" do
|
|
423
423
|
Sequel.quote_identifiers = nil
|
424
424
|
class Sequel::Database; @identifier_input_method=nil; end
|
425
425
|
class Sequel::Database; @identifier_output_method=nil; end
|
426
|
-
Sequel.mock(:host=>'access').select(Date.new(2011, 12, 13)).sql.
|
427
|
-
Sequel.mock(:host=>'cubrid').from(:a).offset(1).sql.
|
428
|
-
Sequel.mock(:host=>'db2').select(1).sql.
|
429
|
-
Sequel.mock(:host=>'firebird')[:a].distinct.limit(1, 2).sql.
|
430
|
-
Sequel.mock(:host=>'informix')[:a].distinct.limit(1, 2).sql.
|
431
|
-
Sequel.mock(:host=>'mssql')[:a].full_text_search(:b, 'c').sql.
|
432
|
-
Sequel.mock(:host=>'mysql')[:a].full_text_search(:b, 'c').sql.
|
433
|
-
Sequel.mock(:host=>'oracle')[:a].limit(1).sql.
|
434
|
-
Sequel.mock(:host=>'postgres')[:a].full_text_search(:b, 'c').sql.
|
435
|
-
Sequel.mock(:host=>'sqlanywhere').from(:a).offset(1).sql.
|
436
|
-
Sequel.mock(:host=>'sqlite')[:a___b].sql.
|
426
|
+
Sequel.mock(:host=>'access').select(Date.new(2011, 12, 13)).sql.must_equal 'SELECT #2011-12-13#'
|
427
|
+
Sequel.mock(:host=>'cubrid').from(:a).offset(1).sql.must_equal 'SELECT * FROM "a" LIMIT 1,4294967295'
|
428
|
+
Sequel.mock(:host=>'db2').select(1).sql.must_equal 'SELECT 1 FROM "SYSIBM"."SYSDUMMY1"'
|
429
|
+
Sequel.mock(:host=>'firebird')[:a].distinct.limit(1, 2).sql.must_equal 'SELECT DISTINCT FIRST 1 SKIP 2 * FROM "A"'
|
430
|
+
Sequel.mock(:host=>'informix')[:a].distinct.limit(1, 2).sql.must_equal 'SELECT SKIP 2 FIRST 1 DISTINCT * FROM A'
|
431
|
+
Sequel.mock(:host=>'mssql')[:a].full_text_search(:b, 'c').sql.must_equal "SELECT * FROM [A] WHERE (CONTAINS ([B], 'c'))"
|
432
|
+
Sequel.mock(:host=>'mysql')[:a].full_text_search(:b, 'c').sql.must_equal "SELECT * FROM `a` WHERE (MATCH (`b`) AGAINST ('c'))"
|
433
|
+
Sequel.mock(:host=>'oracle')[:a].limit(1).sql.must_equal 'SELECT * FROM (SELECT * FROM "A") "T1" WHERE (ROWNUM <= 1)'
|
434
|
+
Sequel.mock(:host=>'postgres')[:a].full_text_search(:b, 'c').sql.must_equal "SELECT * FROM \"a\" WHERE (to_tsvector(CAST('simple' AS regconfig), (COALESCE(\"b\", ''))) @@ to_tsquery(CAST('simple' AS regconfig), 'c'))"
|
435
|
+
Sequel.mock(:host=>'sqlanywhere').from(:a).offset(1).sql.must_equal 'SELECT TOP 2147483647 START AT (1 + 1) * FROM "A"'
|
436
|
+
Sequel.mock(:host=>'sqlite')[:a___b].sql.must_equal "SELECT * FROM `a` AS 'b'"
|
437
437
|
ensure
|
438
438
|
Sequel.quote_identifiers = qi
|
439
439
|
Sequel::Database.send(:instance_variable_set, :@identifier_input_method, ii)
|
@@ -441,22 +441,22 @@ describe "Sequel Mock Adapter" do
|
|
441
441
|
end
|
442
442
|
end
|
443
443
|
|
444
|
-
|
445
|
-
Sequel.mock(:host=>'postgres').server_version.
|
446
|
-
Sequel.mock(:host=>'mssql').server_version.
|
447
|
-
Sequel.mock(:host=>'mysql').server_version.
|
448
|
-
Sequel.mock(:host=>'sqlite').sqlite_version.
|
444
|
+
it "should automatically set version for adapters nedding versions" do
|
445
|
+
Sequel.mock(:host=>'postgres').server_version.must_equal 90400
|
446
|
+
Sequel.mock(:host=>'mssql').server_version.must_equal 11000000
|
447
|
+
Sequel.mock(:host=>'mysql').server_version.must_equal 50617
|
448
|
+
Sequel.mock(:host=>'sqlite').sqlite_version.must_equal 30804
|
449
449
|
end
|
450
450
|
|
451
|
-
|
452
|
-
Sequel.mock(:host=>'postgres').primary_key(:t).
|
451
|
+
it "should stub out the primary_key method for postgres" do
|
452
|
+
Sequel.mock(:host=>'postgres').primary_key(:t).must_equal :id
|
453
453
|
end
|
454
454
|
|
455
|
-
|
456
|
-
Sequel.mock(:host=>'postgres').bound_variable_arg(:t, nil).
|
455
|
+
it "should stub out the bound_variable_arg method for postgres" do
|
456
|
+
Sequel.mock(:host=>'postgres').bound_variable_arg(:t, nil).must_equal :t
|
457
457
|
end
|
458
458
|
|
459
|
-
|
460
|
-
|
459
|
+
it "should handle creating tables on oracle" do
|
460
|
+
Sequel.mock(:host=>'oracle').create_table(:a){String :b}
|
461
461
|
end
|
462
462
|
end
|