sequel 4.22.0 → 4.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module Sequel
|
|
2
|
+
module Plugins
|
|
3
|
+
# The validates_associated plugin allows you to validate associated
|
|
4
|
+
# objects. It also offers the ability to delay the validation of
|
|
5
|
+
# associated objects until the current object is validated.
|
|
6
|
+
# If the associated object is invalid, validation error messages
|
|
7
|
+
# from the associated object will be added to the current object's
|
|
8
|
+
# validation errors.
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
#
|
|
12
|
+
# # Make all model subclass support validating associated objects
|
|
13
|
+
# Sequel::Model.plugin :validate_associated
|
|
14
|
+
#
|
|
15
|
+
# # Make the Album class support validating associated objects
|
|
16
|
+
# Album.plugin :validate_associated
|
|
17
|
+
module ValidateAssociated
|
|
18
|
+
# Depend on the instance_hooks plugin.
|
|
19
|
+
def self.apply(mod)
|
|
20
|
+
mod.plugin :instance_hooks
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
module InstanceMethods
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
# Delay validating the associated object until validating the current object.
|
|
27
|
+
def delay_validate_associated_object(reflection, obj)
|
|
28
|
+
after_validation_hook{validate_associated_object(reflection, obj)}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Validate the given associated object, adding any validation error messages from the
|
|
32
|
+
# given object to the parent object.
|
|
33
|
+
def validate_associated_object(reflection, obj)
|
|
34
|
+
return if reflection[:validate] == false
|
|
35
|
+
association = reflection[:name]
|
|
36
|
+
if (reflection[:type] == :one_to_many || reflection[:type] == :one_to_one) && (key = reflection[:key]).is_a?(Symbol) && !(pk_val = obj.values[key])
|
|
37
|
+
# There could be a presence validation on the foreign key in the associated model,
|
|
38
|
+
# which will fail if we validate before saving the current object. If there is
|
|
39
|
+
# no value for the foreign key, set it to the current primary key value, or a dummy
|
|
40
|
+
# value of 0 if we haven't saved the current object.
|
|
41
|
+
p_key = pk unless pk.is_a?(Array)
|
|
42
|
+
obj.values[key] = p_key || 0
|
|
43
|
+
key = nil if p_key
|
|
44
|
+
end
|
|
45
|
+
obj.errors.full_messages.each{|m| errors.add(association, m)} unless obj.valid?
|
|
46
|
+
if key && !pk_val
|
|
47
|
+
# If we used a dummy value of 0, remove it so it doesn't accidently remain.
|
|
48
|
+
obj.values.delete(key)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
data/lib/sequel/version.rb
CHANGED
|
@@ -3,7 +3,7 @@ module Sequel
|
|
|
3
3
|
MAJOR = 4
|
|
4
4
|
# The minor version of Sequel. Bumped for every non-patch level
|
|
5
5
|
# release, generally around once a month.
|
|
6
|
-
MINOR =
|
|
6
|
+
MINOR = 23
|
|
7
7
|
# The tiny version of Sequel. Usually 0, only bumped for bugfix
|
|
8
8
|
# releases that fix regressions from previous versions.
|
|
9
9
|
TINY = 0
|
data/spec/adapters/db2_spec.rb
CHANGED
|
@@ -17,14 +17,14 @@ describe Sequel::Database do
|
|
|
17
17
|
@db.drop_table(:test)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
it "should provide disconnect functionality after preparing a connection" do
|
|
21
21
|
@ds.prepare(:first, :a).call
|
|
22
22
|
@db.disconnect
|
|
23
|
-
@db.pool.size.
|
|
23
|
+
@db.pool.size.must_equal 0
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
@db.db2_version.
|
|
26
|
+
it "should return version correctly" do
|
|
27
|
+
@db.db2_version.must_match(/DB2 v/i)
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
@@ -47,15 +47,15 @@ describe "Simple Dataset operations" do
|
|
|
47
47
|
DB.drop_table(:items)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
it "should insert with a primary key specified" do
|
|
51
51
|
@ds.insert(:id => 1, :number => 10)
|
|
52
52
|
@ds.insert(:id => 100, :number => 20)
|
|
53
|
-
@ds.select_hash(:id, :number).
|
|
53
|
+
@ds.select_hash(:id, :number).must_equal(1 => 10, 100 => 20)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
it "should insert into binary columns" do
|
|
57
57
|
@ds.insert(:id => 1, :bin_string => Sequel.blob("\1"), :bin_clob => Sequel.blob("\2"))
|
|
58
|
-
@ds.select(:bin_string, :bin_clob).first.
|
|
58
|
+
@ds.select(:bin_string, :bin_clob).first.must_equal(:bin_string => "\1", :bin_clob => "\2")
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -66,13 +66,13 @@ describe Sequel::Database do
|
|
|
66
66
|
after do
|
|
67
67
|
@db.drop_table(:items)
|
|
68
68
|
end
|
|
69
|
-
|
|
69
|
+
it "should parse primary keys from the schema properly" do
|
|
70
70
|
@db.create_table!(:items){Integer :number}
|
|
71
|
-
@db.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.
|
|
71
|
+
@db.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.must_equal []
|
|
72
72
|
@db.create_table!(:items){primary_key :number}
|
|
73
|
-
@db.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.
|
|
73
|
+
@db.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.must_equal [:number]
|
|
74
74
|
@db.create_table!(:items){Integer :number1, :null => false; Integer :number2, :null => false; primary_key [:number1, :number2]}
|
|
75
|
-
@db.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.
|
|
75
|
+
@db.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.must_equal [:number1, :number2]
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
|
@@ -87,42 +87,42 @@ describe "Sequel::IBMDB.convert_smallint_to_bool" do
|
|
|
87
87
|
@db.drop_table(:booltest)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
@db.schema(:booltest, :reload=>true).first.last[:type].
|
|
92
|
-
@db.schema(:booltest, :reload=>true).first.last[:db_type].
|
|
90
|
+
it "should consider smallint datatypes as boolean if set, but not larger smallints" do
|
|
91
|
+
@db.schema(:booltest, :reload=>true).first.last[:type].must_equal :boolean
|
|
92
|
+
@db.schema(:booltest, :reload=>true).first.last[:db_type].must_match /smallint/i
|
|
93
93
|
Sequel::IBMDB.convert_smallint_to_bool = false
|
|
94
|
-
@db.schema(:booltest, :reload=>true).first.last[:type].
|
|
95
|
-
@db.schema(:booltest, :reload=>true).first.last[:db_type].
|
|
94
|
+
@db.schema(:booltest, :reload=>true).first.last[:type].must_equal :integer
|
|
95
|
+
@db.schema(:booltest, :reload=>true).first.last[:db_type].must_match /smallint/i
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
it "should return smallints as bools and integers as integers when set" do
|
|
99
99
|
Sequel::IBMDB.convert_smallint_to_bool = true
|
|
100
100
|
@ds.delete
|
|
101
101
|
@ds << {:b=>true, :i=>10}
|
|
102
|
-
@ds.all.
|
|
102
|
+
@ds.all.must_equal [{:b=>true, :i=>10}]
|
|
103
103
|
@ds.delete
|
|
104
104
|
@ds << {:b=>false, :i=>0}
|
|
105
|
-
@ds.all.
|
|
105
|
+
@ds.all.must_equal [{:b=>false, :i=>0}]
|
|
106
106
|
@ds.delete
|
|
107
107
|
@ds << {:b=>true, :i=>1}
|
|
108
|
-
@ds.all.
|
|
108
|
+
@ds.all.must_equal [{:b=>true, :i=>1}]
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
it "should return all smallints as integers when unset" do
|
|
112
112
|
Sequel::IBMDB.convert_smallint_to_bool = false
|
|
113
113
|
@ds.delete
|
|
114
114
|
@ds << {:b=>true, :i=>10}
|
|
115
|
-
@ds.all.
|
|
115
|
+
@ds.all.must_equal [{:b=>1, :i=>10}]
|
|
116
116
|
@ds.delete
|
|
117
117
|
@ds << {:b=>false, :i=>0}
|
|
118
|
-
@ds.all.
|
|
118
|
+
@ds.all.must_equal [{:b=>0, :i=>0}]
|
|
119
119
|
|
|
120
120
|
@ds.delete
|
|
121
121
|
@ds << {:b=>1, :i=>10}
|
|
122
|
-
@ds.all.
|
|
122
|
+
@ds.all.must_equal [{:b=>1, :i=>10}]
|
|
123
123
|
@ds.delete
|
|
124
124
|
@ds << {:b=>0, :i=>0}
|
|
125
|
-
@ds.all.
|
|
125
|
+
@ds.all.must_equal [{:b=>0, :i=>0}]
|
|
126
126
|
end
|
|
127
127
|
end if DB.adapter_scheme == :ibmdb
|
|
128
128
|
|
|
@@ -138,11 +138,11 @@ describe "Simple Dataset operations in transactions" do
|
|
|
138
138
|
DB.drop_table(:items_insert_in_transaction)
|
|
139
139
|
end
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
it "should insert correctly with a primary key specified inside a transaction" do
|
|
142
142
|
DB.transaction do
|
|
143
143
|
@ds.insert(:id=>100, :number=>20)
|
|
144
|
-
@ds.count.
|
|
145
|
-
@ds.order(:id).all.
|
|
144
|
+
@ds.count.must_equal 1
|
|
145
|
+
@ds.order(:id).all.must_equal [{:id=>100, :number=>20}]
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
end
|
|
@@ -44,15 +44,15 @@ describe "A Firebird database" do
|
|
|
44
44
|
@db = DB
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
it "should provide disconnect functionality" do
|
|
48
48
|
@db.tables
|
|
49
|
-
@db.pool.size.
|
|
49
|
+
@db.pool.size.must_equal 1
|
|
50
50
|
@db.disconnect
|
|
51
|
-
@db.pool.size.
|
|
51
|
+
@db.pool.size.must_equal 0
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
proc{@db << "SELECT 1 + 'a'"}.
|
|
54
|
+
it "should raise Sequel::Error on error" do
|
|
55
|
+
proc{@db << "SELECT 1 + 'a'"}.must_raise(Sequel::Error)
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -63,28 +63,28 @@ describe "A Firebird dataset" do
|
|
|
63
63
|
@d.quote_identifiers = true
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
@d.count.
|
|
66
|
+
it "should return the correct record count" do
|
|
67
|
+
@d.count.must_equal 0
|
|
68
68
|
@d << {:name => 'abc', :val => 123}
|
|
69
69
|
@d << {:name => 'abc', :val => 456}
|
|
70
70
|
@d << {:name => 'def', :val => 789}
|
|
71
|
-
@d.count.
|
|
71
|
+
@d.count.must_equal 3
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
@d.to_a.
|
|
74
|
+
it "should return the correct records" do
|
|
75
|
+
@d.to_a.must_equal []
|
|
76
76
|
@d << {:name => 'abc', :val => 123}
|
|
77
77
|
@d << {:name => 'abc', :val => 456}
|
|
78
78
|
@d << {:name => 'def', :val => 789}
|
|
79
79
|
|
|
80
|
-
@d.order(:val).to_a.
|
|
80
|
+
@d.order(:val).to_a.must_equal [
|
|
81
81
|
{:name => 'abc', :val => 123},
|
|
82
82
|
{:name => 'abc', :val => 456},
|
|
83
83
|
{:name => 'def', :val => 789}
|
|
84
84
|
]
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
it "should update records correctly" do
|
|
88
88
|
@d << {:name => 'abc', :val => 123}
|
|
89
89
|
@d << {:name => 'abc', :val => 456}
|
|
90
90
|
@d << {:name => 'def', :val => 789}
|
|
@@ -92,111 +92,111 @@ describe "A Firebird dataset" do
|
|
|
92
92
|
|
|
93
93
|
# the third record should stay the same
|
|
94
94
|
# floating-point precision bullshit
|
|
95
|
-
@d[:name => 'def'][:val].
|
|
96
|
-
@d.filter(:val => 530).count.
|
|
95
|
+
@d[:name => 'def'][:val].must_equal 789
|
|
96
|
+
@d.filter(:val => 530).count.must_equal 2
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
it "should delete records correctly" do
|
|
100
100
|
@d << {:name => 'abc', :val => 123}
|
|
101
101
|
@d << {:name => 'abc', :val => 456}
|
|
102
102
|
@d << {:name => 'def', :val => 789}
|
|
103
103
|
@d.filter(:name => 'abc').delete
|
|
104
104
|
|
|
105
|
-
@d.count.
|
|
106
|
-
@d.first[:name].
|
|
105
|
+
@d.count.must_equal 1
|
|
106
|
+
@d.first[:name].must_equal 'def'
|
|
107
107
|
end
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
it "should be able to literalize booleans" do
|
|
110
|
+
@d.literal(true)
|
|
111
|
+
@d.literal(false)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
it "should quote columns and tables using double quotes if quoting identifiers" do
|
|
115
115
|
@d.quote_identifiers = true
|
|
116
|
-
@d.select(:name).sql.
|
|
116
|
+
@d.select(:name).sql.must_equal \
|
|
117
117
|
'SELECT "NAME" FROM "TEST"'
|
|
118
118
|
|
|
119
|
-
@d.select('COUNT(*)'.lit).sql.
|
|
119
|
+
@d.select('COUNT(*)'.lit).sql.must_equal \
|
|
120
120
|
'SELECT COUNT(*) FROM "TEST"'
|
|
121
121
|
|
|
122
|
-
@d.select(:max[:val]).sql.
|
|
122
|
+
@d.select(:max[:val]).sql.must_equal \
|
|
123
123
|
'SELECT max("VAL") FROM "TEST"'
|
|
124
124
|
|
|
125
|
-
@d.select(:now[]).sql.
|
|
125
|
+
@d.select(:now[]).sql.must_equal \
|
|
126
126
|
'SELECT now() FROM "TEST"'
|
|
127
127
|
|
|
128
|
-
@d.select(:max[:items__val]).sql.
|
|
128
|
+
@d.select(:max[:items__val]).sql.must_equal \
|
|
129
129
|
'SELECT max("ITEMS"."VAL") FROM "TEST"'
|
|
130
130
|
|
|
131
|
-
@d.order(:name.desc).sql.
|
|
131
|
+
@d.order(:name.desc).sql.must_equal \
|
|
132
132
|
'SELECT * FROM "TEST" ORDER BY "NAME" DESC'
|
|
133
133
|
|
|
134
|
-
@d.select('TEST.NAME AS item_:name'.lit).sql.
|
|
134
|
+
@d.select('TEST.NAME AS item_:name'.lit).sql.must_equal \
|
|
135
135
|
'SELECT TEST.NAME AS item_:name FROM "TEST"'
|
|
136
136
|
|
|
137
|
-
@d.select('"NAME"'.lit).sql.
|
|
137
|
+
@d.select('"NAME"'.lit).sql.must_equal \
|
|
138
138
|
'SELECT "NAME" FROM "TEST"'
|
|
139
139
|
|
|
140
|
-
@d.select('max(TEST."NAME") AS "max_:name"'.lit).sql.
|
|
140
|
+
@d.select('max(TEST."NAME") AS "max_:name"'.lit).sql.must_equal \
|
|
141
141
|
'SELECT max(TEST."NAME") AS "max_:name" FROM "TEST"'
|
|
142
142
|
|
|
143
|
-
@d.select(:test[:ABC, 'hello']).sql.
|
|
143
|
+
@d.select(:test[:ABC, 'hello']).sql.must_equal \
|
|
144
144
|
"SELECT test(\"ABC\", 'hello') FROM \"TEST\""
|
|
145
145
|
|
|
146
|
-
@d.select(:test[:ABC__DEF, 'hello']).sql.
|
|
146
|
+
@d.select(:test[:ABC__DEF, 'hello']).sql.must_equal \
|
|
147
147
|
"SELECT test(\"ABC\".\"DEF\", 'hello') FROM \"TEST\""
|
|
148
148
|
|
|
149
|
-
@d.select(:test[:ABC__DEF, 'hello'].as(:X2)).sql.
|
|
149
|
+
@d.select(:test[:ABC__DEF, 'hello'].as(:X2)).sql.must_equal \
|
|
150
150
|
"SELECT test(\"ABC\".\"DEF\", 'hello') AS \"X2\" FROM \"TEST\""
|
|
151
151
|
|
|
152
|
-
@d.insert_sql(:val => 333).
|
|
152
|
+
@d.insert_sql(:val => 333).must_match \
|
|
153
153
|
/\AINSERT INTO "TEST" \("VAL"\) VALUES \(333\)( RETURNING NULL)?\z/
|
|
154
154
|
|
|
155
|
-
@d.insert_sql(:X => :Y).
|
|
155
|
+
@d.insert_sql(:X => :Y).must_match \
|
|
156
156
|
/\AINSERT INTO "TEST" \("X"\) VALUES \("Y"\)( RETURNING NULL)?\z/
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
it "should quote fields correctly when reversing the order if quoting identifiers" do
|
|
160
160
|
@d.quote_identifiers = true
|
|
161
|
-
@d.reverse_order(:name).sql.
|
|
161
|
+
@d.reverse_order(:name).sql.must_equal \
|
|
162
162
|
'SELECT * FROM "TEST" ORDER BY "NAME" DESC'
|
|
163
163
|
|
|
164
|
-
@d.reverse_order(:name.desc).sql.
|
|
164
|
+
@d.reverse_order(:name.desc).sql.must_equal \
|
|
165
165
|
'SELECT * FROM "TEST" ORDER BY "NAME" ASC'
|
|
166
166
|
|
|
167
|
-
@d.reverse_order(:name, :test.desc).sql.
|
|
167
|
+
@d.reverse_order(:name, :test.desc).sql.must_equal \
|
|
168
168
|
'SELECT * FROM "TEST" ORDER BY "NAME" DESC, "TEST" ASC'
|
|
169
169
|
|
|
170
|
-
@d.reverse_order(:name.desc, :test).sql.
|
|
170
|
+
@d.reverse_order(:name.desc, :test).sql.must_equal \
|
|
171
171
|
'SELECT * FROM "TEST" ORDER BY "NAME" ASC, "TEST" DESC'
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
it "should support transactions" do
|
|
175
175
|
DB.transaction do
|
|
176
176
|
@d << {:name => 'abc', :val => 1}
|
|
177
177
|
end
|
|
178
178
|
|
|
179
|
-
@d.count.
|
|
179
|
+
@d.count.must_equal 1
|
|
180
180
|
end
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
it "should have #transaction yield the connection" do
|
|
183
183
|
DB.transaction do |conn|
|
|
184
|
-
conn.
|
|
184
|
+
conn.wont_equal nil
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
it "should correctly rollback transactions" do
|
|
189
189
|
proc do
|
|
190
190
|
DB.transaction do
|
|
191
191
|
@d << {:name => 'abc', :val => 1}
|
|
192
192
|
raise RuntimeError, 'asdf'
|
|
193
193
|
end
|
|
194
|
-
end.
|
|
194
|
+
end.must_raise(RuntimeError)
|
|
195
195
|
|
|
196
|
-
@d.count.
|
|
196
|
+
@d.count.must_equal 0
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
it "should handle returning inside of the block by committing" do
|
|
200
200
|
def DB.ret_commit
|
|
201
201
|
transaction do
|
|
202
202
|
self[:test] << {:name => 'abc'}
|
|
@@ -204,24 +204,24 @@ describe "A Firebird dataset" do
|
|
|
204
204
|
self[:test] << {:name => 'd'}
|
|
205
205
|
end
|
|
206
206
|
end
|
|
207
|
-
@d.count.
|
|
207
|
+
@d.count.must_equal 0
|
|
208
208
|
DB.ret_commit
|
|
209
|
-
@d.count.
|
|
209
|
+
@d.count.must_equal 1
|
|
210
210
|
DB.ret_commit
|
|
211
|
-
@d.count.
|
|
211
|
+
@d.count.must_equal 2
|
|
212
212
|
proc do
|
|
213
213
|
DB.transaction do
|
|
214
214
|
raise RuntimeError, 'asdf'
|
|
215
215
|
end
|
|
216
|
-
end.
|
|
216
|
+
end.must_raise(RuntimeError)
|
|
217
217
|
|
|
218
|
-
@d.count.
|
|
218
|
+
@d.count.must_equal 2
|
|
219
219
|
end
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
it "should quote and upcase reserved keywords" do
|
|
222
222
|
@d = DB[:testing]
|
|
223
223
|
@d.quote_identifiers = true
|
|
224
|
-
@d.select(:select).sql.
|
|
224
|
+
@d.select(:select).sql.must_equal \
|
|
225
225
|
'SELECT "SELECT" FROM "TESTING"'
|
|
226
226
|
end
|
|
227
227
|
end
|
|
@@ -232,11 +232,11 @@ describe "A Firebird dataset with a timestamp field" do
|
|
|
232
232
|
@d.delete
|
|
233
233
|
end
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
it "should store milliseconds in time fields" do
|
|
236
236
|
t = Time.now
|
|
237
237
|
@d << {:val=>1, :time_stamp=>t}
|
|
238
|
-
@d.literal(@d[:val =>'1'][:time_stamp]).
|
|
239
|
-
@d[:val=>'1'][:time_stamp].usec.
|
|
238
|
+
@d.literal(@d[:val =>'1'][:time_stamp]).must_equal @d.literal(t)
|
|
239
|
+
@d[:val=>'1'][:time_stamp].usec.must_equal t.usec - t.usec % 100
|
|
240
240
|
end
|
|
241
241
|
end
|
|
242
242
|
|
|
@@ -247,10 +247,10 @@ describe "A Firebird database" do
|
|
|
247
247
|
@db.sqls.clear
|
|
248
248
|
end
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
it "should allow us to name the sequences" do
|
|
251
251
|
@db.create_table(:posts){primary_key :id, :sequence_name => "seq_test"}
|
|
252
252
|
check_sqls do
|
|
253
|
-
@db.sqls.
|
|
253
|
+
@db.sqls.must_equal [
|
|
254
254
|
"DROP SEQUENCE SEQ_TEST",
|
|
255
255
|
"CREATE TABLE POSTS (ID integer PRIMARY KEY )",
|
|
256
256
|
"CREATE SEQUENCE SEQ_TEST",
|
|
@@ -259,10 +259,10 @@ describe "A Firebird database" do
|
|
|
259
259
|
end
|
|
260
260
|
end
|
|
261
261
|
|
|
262
|
-
|
|
262
|
+
it "should allow us to set the starting position for the sequences" do
|
|
263
263
|
@db.create_table(:posts){primary_key :id, :sequence_start_position => 999}
|
|
264
264
|
check_sqls do
|
|
265
|
-
@db.sqls.
|
|
265
|
+
@db.sqls.must_equal [
|
|
266
266
|
"DROP SEQUENCE SEQ_POSTS_ID",
|
|
267
267
|
"CREATE TABLE POSTS (ID integer PRIMARY KEY )",
|
|
268
268
|
"CREATE SEQUENCE SEQ_POSTS_ID",
|
|
@@ -272,10 +272,10 @@ describe "A Firebird database" do
|
|
|
272
272
|
end
|
|
273
273
|
end
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
it "should allow us to name and set the starting position for the sequences" do
|
|
276
276
|
@db.create_table(:posts){primary_key :id, :sequence_name => "seq_test", :sequence_start_position => 999}
|
|
277
277
|
check_sqls do
|
|
278
|
-
@db.sqls.
|
|
278
|
+
@db.sqls.must_equal [
|
|
279
279
|
"DROP SEQUENCE SEQ_TEST",
|
|
280
280
|
"CREATE TABLE POSTS (ID integer PRIMARY KEY )",
|
|
281
281
|
"CREATE SEQUENCE SEQ_TEST",
|
|
@@ -285,10 +285,10 @@ describe "A Firebird database" do
|
|
|
285
285
|
end
|
|
286
286
|
end
|
|
287
287
|
|
|
288
|
-
|
|
288
|
+
it "should allow us to name the triggers" do
|
|
289
289
|
@db.create_table(:posts){primary_key :id, :trigger_name => "trig_test"}
|
|
290
290
|
check_sqls do
|
|
291
|
-
@db.sqls.
|
|
291
|
+
@db.sqls.must_equal [
|
|
292
292
|
"DROP SEQUENCE SEQ_POSTS_ID",
|
|
293
293
|
"CREATE TABLE POSTS (ID integer PRIMARY KEY )",
|
|
294
294
|
"CREATE SEQUENCE SEQ_POSTS_ID",
|
|
@@ -297,20 +297,20 @@ describe "A Firebird database" do
|
|
|
297
297
|
end
|
|
298
298
|
end
|
|
299
299
|
|
|
300
|
-
|
|
300
|
+
it "should allow us to not create the sequence" do
|
|
301
301
|
@db.create_table(:posts){primary_key :id, :create_sequence => false}
|
|
302
302
|
check_sqls do
|
|
303
|
-
@db.sqls.
|
|
303
|
+
@db.sqls.must_equal [
|
|
304
304
|
"CREATE TABLE POSTS (ID integer PRIMARY KEY )",
|
|
305
305
|
" CREATE TRIGGER BI_POSTS_ID for POSTS\n ACTIVE BEFORE INSERT position 0\n as begin\n if ((new.ID is null) or (new.ID = 0)) then\n begin\n new.ID = next value for seq_posts_id;\n end\n end\n\n"
|
|
306
306
|
]
|
|
307
307
|
end
|
|
308
308
|
end
|
|
309
309
|
|
|
310
|
-
|
|
310
|
+
it "should allow us to not create the trigger" do
|
|
311
311
|
@db.create_table(:posts){primary_key :id, :create_trigger => false}
|
|
312
312
|
check_sqls do
|
|
313
|
-
@db.sqls.
|
|
313
|
+
@db.sqls.must_equal [
|
|
314
314
|
"DROP SEQUENCE SEQ_POSTS_ID",
|
|
315
315
|
"CREATE TABLE POSTS (ID integer PRIMARY KEY )",
|
|
316
316
|
"CREATE SEQUENCE SEQ_POSTS_ID",
|
|
@@ -318,48 +318,48 @@ describe "A Firebird database" do
|
|
|
318
318
|
end
|
|
319
319
|
end
|
|
320
320
|
|
|
321
|
-
|
|
321
|
+
it "should allow us to not create either the sequence nor the trigger" do
|
|
322
322
|
@db.create_table(:posts){primary_key :id, :create_sequence => false, :create_trigger => false}
|
|
323
323
|
check_sqls do
|
|
324
|
-
@db.sqls.
|
|
324
|
+
@db.sqls.must_equal [
|
|
325
325
|
"CREATE TABLE POSTS (ID integer PRIMARY KEY )"
|
|
326
326
|
]
|
|
327
327
|
end
|
|
328
328
|
end
|
|
329
329
|
|
|
330
|
-
|
|
330
|
+
it "should support column operations" do
|
|
331
331
|
@db.create_table!(:test2){varchar :name, :size => 50; integer :val}
|
|
332
332
|
@db[:test2] << {}
|
|
333
|
-
@db[:test2].columns.
|
|
333
|
+
@db[:test2].columns.must_equal [:name, :val]
|
|
334
334
|
|
|
335
335
|
@db.add_column :test2, :xyz, :varchar, :size => 50
|
|
336
|
-
@db[:test2].columns.
|
|
336
|
+
@db[:test2].columns.must_equal [:name, :val, :xyz]
|
|
337
337
|
|
|
338
|
-
@db[:test2].columns.
|
|
338
|
+
@db[:test2].columns.must_equal [:name, :val, :xyz]
|
|
339
339
|
@db.drop_column :test2, :xyz
|
|
340
340
|
|
|
341
|
-
@db[:test2].columns.
|
|
341
|
+
@db[:test2].columns.must_equal [:name, :val]
|
|
342
342
|
|
|
343
343
|
@db[:test2].delete
|
|
344
344
|
@db.add_column :test2, :xyz, :varchar, :default => '000', :size => 50#, :create_domain => 'xyz_varchar'
|
|
345
345
|
@db[:test2] << {:name => 'mmm', :val => 111, :xyz => 'qqqq'}
|
|
346
346
|
|
|
347
|
-
@db[:test2].columns.
|
|
347
|
+
@db[:test2].columns.must_equal [:name, :val, :xyz]
|
|
348
348
|
@db.rename_column :test2, :xyz, :zyx
|
|
349
|
-
@db[:test2].columns.
|
|
350
|
-
@db[:test2].first[:zyx].
|
|
349
|
+
@db[:test2].columns.must_equal [:name, :val, :zyx]
|
|
350
|
+
@db[:test2].first[:zyx].must_equal 'qqqq'
|
|
351
351
|
|
|
352
352
|
@db.add_column :test2, :xyz, :decimal, :elements => [12, 2]
|
|
353
353
|
@db[:test2].delete
|
|
354
354
|
@db[:test2] << {:name => 'mmm', :val => 111, :xyz => 56.4}
|
|
355
355
|
@db.set_column_type :test2, :xyz, :varchar, :size => 50
|
|
356
356
|
|
|
357
|
-
@db[:test2].first[:xyz].
|
|
357
|
+
@db[:test2].first[:xyz].must_equal "56.40"
|
|
358
358
|
end
|
|
359
359
|
|
|
360
|
-
|
|
360
|
+
it "should allow us to retrieve the primary key for a table" do
|
|
361
361
|
@db.create_table!(:test2){primary_key :id}
|
|
362
|
-
@db.primary_key(:test2).
|
|
362
|
+
@db.primary_key(:test2).must_equal ["id"]
|
|
363
363
|
end
|
|
364
364
|
end
|
|
365
365
|
|
|
@@ -369,31 +369,25 @@ describe "Postgres::Dataset#insert" do
|
|
|
369
369
|
@ds.delete
|
|
370
370
|
end
|
|
371
371
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
@ds.
|
|
375
|
-
@ds.
|
|
372
|
+
it "should have insert_returning_sql use the RETURNING keyword" do
|
|
373
|
+
@ds.insert_returning_sql(:XID, :val=>10).must_equal "INSERT INTO TEST5 (VAL) VALUES (10) RETURNING XID"
|
|
374
|
+
@ds.insert_returning_sql('*'.lit, :val=>10).must_equal "INSERT INTO TEST5 (VAL) VALUES (10) RETURNING *"
|
|
375
|
+
@ds.insert_returning_sql('NULL'.lit, :val=>10).must_equal "INSERT INTO TEST5 (VAL) VALUES (10) RETURNING NULL"
|
|
376
376
|
end
|
|
377
377
|
|
|
378
|
-
|
|
379
|
-
@ds.insert_returning_sql(:XID, :val=>10).should == "INSERT INTO TEST5 (VAL) VALUES (10) RETURNING XID"
|
|
380
|
-
@ds.insert_returning_sql('*'.lit, :val=>10).should == "INSERT INTO TEST5 (VAL) VALUES (10) RETURNING *"
|
|
381
|
-
@ds.insert_returning_sql('NULL'.lit, :val=>10).should == "INSERT INTO TEST5 (VAL) VALUES (10) RETURNING NULL"
|
|
382
|
-
end
|
|
383
|
-
|
|
384
|
-
specify "should correctly return the inserted record's primary key value" do
|
|
378
|
+
it "should correctly return the inserted record's primary key value" do
|
|
385
379
|
value1 = 10
|
|
386
380
|
id1 = @ds.insert(:val=>value1)
|
|
387
|
-
@ds.first(:XID=>id1)[:val].
|
|
381
|
+
@ds.first(:XID=>id1)[:val].must_equal value1
|
|
388
382
|
value2 = 20
|
|
389
383
|
id2 = @ds.insert(:val=>value2)
|
|
390
|
-
@ds.first(:XID=>id2)[:val].
|
|
384
|
+
@ds.first(:XID=>id2)[:val].must_equal value2
|
|
391
385
|
end
|
|
392
386
|
|
|
393
|
-
|
|
387
|
+
it "should return nil if the table has no primary key" do
|
|
394
388
|
ds = DB[:test]
|
|
395
389
|
ds.delete
|
|
396
|
-
ds.insert(:name=>'a').
|
|
390
|
+
ds.insert(:name=>'a').must_equal nil
|
|
397
391
|
end
|
|
398
392
|
end
|
|
399
393
|
|
|
@@ -403,15 +397,15 @@ describe "Postgres::Dataset#insert" do
|
|
|
403
397
|
@ds.delete
|
|
404
398
|
end
|
|
405
399
|
|
|
406
|
-
|
|
400
|
+
it "should insert and retrieve a blob successfully" do
|
|
407
401
|
value1 = "\1\2\2\2\2222\2\2\2"
|
|
408
402
|
value2 = "abcd"
|
|
409
403
|
value3 = "efgh"
|
|
410
404
|
value4 = "ijkl"
|
|
411
405
|
id1 = @ds.insert(:val=>value1, :val2=>value2, :val3=>value3, :val4=>value4)
|
|
412
|
-
@ds.first(:XID=>id1)[:val].
|
|
413
|
-
@ds.first(:XID=>id1)[:val2].
|
|
414
|
-
@ds.first(:XID=>id1)[:val3].
|
|
415
|
-
@ds.first(:XID=>id1)[:val4].
|
|
406
|
+
@ds.first(:XID=>id1)[:val].must_equal value1
|
|
407
|
+
@ds.first(:XID=>id1)[:val2].must_equal value2
|
|
408
|
+
@ds.first(:XID=>id1)[:val3].must_equal value3
|
|
409
|
+
@ds.first(:XID=>id1)[:val4].must_equal value4
|
|
416
410
|
end
|
|
417
411
|
end
|