sequel 4.41.0 → 4.42.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +98 -0
- data/README.rdoc +23 -10
- data/doc/active_record.rdoc +4 -4
- data/doc/advanced_associations.rdoc +2 -2
- data/doc/association_basics.rdoc +5 -2
- data/doc/cheat_sheet.rdoc +3 -3
- data/doc/core_extensions.rdoc +2 -2
- data/doc/dataset_basics.rdoc +4 -4
- data/doc/dataset_filtering.rdoc +1 -1
- data/doc/migration.rdoc +19 -1
- data/doc/prepared_statements.rdoc +2 -2
- data/doc/release_notes/4.42.0.txt +221 -0
- data/doc/testing.rdoc +3 -1
- data/lib/sequel/adapters/ado/access.rb +0 -1
- data/lib/sequel/adapters/ado/mssql.rb +0 -1
- data/lib/sequel/adapters/do/mysql.rb +0 -1
- data/lib/sequel/adapters/do/postgres.rb +0 -1
- data/lib/sequel/adapters/do/sqlite3.rb +0 -1
- data/lib/sequel/adapters/ibmdb.rb +21 -25
- data/lib/sequel/adapters/jdbc.rb +8 -16
- data/lib/sequel/adapters/jdbc/as400.rb +0 -1
- data/lib/sequel/adapters/jdbc/cubrid.rb +0 -1
- data/lib/sequel/adapters/jdbc/db2.rb +0 -1
- data/lib/sequel/adapters/jdbc/derby.rb +0 -1
- data/lib/sequel/adapters/jdbc/firebirdsql.rb +0 -1
- data/lib/sequel/adapters/jdbc/h2.rb +0 -1
- data/lib/sequel/adapters/jdbc/hsqldb.rb +0 -1
- data/lib/sequel/adapters/jdbc/informix-sqli.rb +0 -1
- data/lib/sequel/adapters/jdbc/jdbcprogress.rb +0 -1
- data/lib/sequel/adapters/jdbc/jtds.rb +0 -1
- data/lib/sequel/adapters/jdbc/mssql.rb +0 -1
- data/lib/sequel/adapters/jdbc/mysql.rb +0 -1
- data/lib/sequel/adapters/jdbc/oracle.rb +0 -1
- data/lib/sequel/adapters/jdbc/postgresql.rb +0 -13
- data/lib/sequel/adapters/jdbc/sqlanywhere.rb +0 -1
- data/lib/sequel/adapters/jdbc/sqlite.rb +0 -1
- data/lib/sequel/adapters/jdbc/sqlserver.rb +3 -4
- data/lib/sequel/adapters/mock.rb +54 -12
- data/lib/sequel/adapters/mysql.rb +1 -1
- data/lib/sequel/adapters/mysql2.rb +11 -17
- data/lib/sequel/adapters/odbc/mssql.rb +0 -1
- data/lib/sequel/adapters/oracle.rb +8 -20
- data/lib/sequel/adapters/postgres.rb +11 -29
- data/lib/sequel/adapters/shared/access.rb +5 -12
- data/lib/sequel/adapters/shared/cubrid.rb +4 -13
- data/lib/sequel/adapters/shared/db2.rb +4 -2
- data/lib/sequel/adapters/shared/firebird.rb +2 -4
- data/lib/sequel/adapters/shared/informix.rb +4 -2
- data/lib/sequel/adapters/shared/mssql.rb +3 -5
- data/lib/sequel/adapters/shared/mysql.rb +4 -14
- data/lib/sequel/adapters/shared/oracle.rb +1 -3
- data/lib/sequel/adapters/shared/postgres.rb +16 -38
- data/lib/sequel/adapters/shared/progress.rb +0 -2
- data/lib/sequel/adapters/shared/sqlanywhere.rb +0 -2
- data/lib/sequel/adapters/shared/sqlite.rb +20 -16
- data/lib/sequel/adapters/sqlite.rb +8 -20
- data/lib/sequel/adapters/swift/mysql.rb +0 -1
- data/lib/sequel/adapters/swift/postgres.rb +0 -1
- data/lib/sequel/adapters/swift/sqlite.rb +0 -1
- data/lib/sequel/adapters/tinytds.rb +4 -12
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +1 -1
- data/lib/sequel/adapters/utils/mysql_mysql2.rb +2 -2
- data/lib/sequel/adapters/utils/mysql_prepared_statements.rb +11 -34
- data/lib/sequel/adapters/utils/stored_procedures.rb +9 -22
- data/lib/sequel/adapters/utils/unmodified_identifiers.rb +26 -0
- data/lib/sequel/ast_transformer.rb +2 -2
- data/lib/sequel/database/dataset.rb +1 -1
- data/lib/sequel/database/dataset_defaults.rb +0 -66
- data/lib/sequel/database/features.rb +6 -0
- data/lib/sequel/database/misc.rb +31 -17
- data/lib/sequel/database/query.rb +7 -4
- data/lib/sequel/database/schema_methods.rb +1 -1
- data/lib/sequel/dataset.rb +8 -8
- data/lib/sequel/dataset/actions.rb +140 -46
- data/lib/sequel/dataset/features.rb +1 -5
- data/lib/sequel/dataset/graph.rb +7 -8
- data/lib/sequel/dataset/misc.rb +127 -56
- data/lib/sequel/dataset/mutation.rb +9 -20
- data/lib/sequel/dataset/placeholder_literalizer.rb +10 -1
- data/lib/sequel/dataset/prepared_statements.rb +102 -46
- data/lib/sequel/dataset/query.rb +155 -72
- data/lib/sequel/dataset/sql.rb +26 -9
- data/lib/sequel/extensions/columns_introspection.rb +3 -1
- data/lib/sequel/extensions/core_extensions.rb +5 -5
- data/lib/sequel/extensions/core_refinements.rb +5 -5
- data/lib/sequel/extensions/duplicate_columns_handler.rb +4 -2
- data/lib/sequel/extensions/freeze_datasets.rb +69 -0
- data/lib/sequel/extensions/identifier_mangling.rb +196 -0
- data/lib/sequel/extensions/looser_typecasting.rb +11 -7
- data/lib/sequel/extensions/migration.rb +1 -1
- data/lib/sequel/extensions/null_dataset.rb +5 -2
- data/lib/sequel/extensions/pagination.rb +42 -23
- data/lib/sequel/extensions/pg_enum.rb +3 -3
- data/lib/sequel/extensions/query.rb +3 -3
- data/lib/sequel/extensions/sequel_3_dataset_methods.rb +15 -8
- data/lib/sequel/model/associations.rb +25 -8
- data/lib/sequel/model/base.rb +88 -29
- data/lib/sequel/model/dataset_module.rb +37 -0
- data/lib/sequel/plugins/association_pks.rb +4 -4
- data/lib/sequel/plugins/class_table_inheritance.rb +2 -2
- data/lib/sequel/plugins/constraint_validations.rb +1 -2
- data/lib/sequel/plugins/csv_serializer.rb +2 -2
- data/lib/sequel/plugins/dataset_associations.rb +8 -8
- data/lib/sequel/plugins/eager_each.rb +2 -2
- data/lib/sequel/plugins/instance_filters.rb +1 -1
- data/lib/sequel/plugins/json_serializer.rb +2 -2
- data/lib/sequel/plugins/lazy_attributes.rb +1 -1
- data/lib/sequel/plugins/list.rb +4 -4
- data/lib/sequel/plugins/prepared_statements.rb +2 -4
- data/lib/sequel/plugins/prepared_statements_associations.rb +1 -3
- data/lib/sequel/plugins/prepared_statements_with_pk.rb +1 -1
- data/lib/sequel/plugins/rcte_tree.rb +13 -13
- data/lib/sequel/plugins/sharding.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +9 -4
- data/lib/sequel/plugins/tactical_eager_loading.rb +4 -4
- data/lib/sequel/plugins/validation_class_methods.rb +1 -1
- data/lib/sequel/plugins/validation_helpers.rb +1 -1
- data/lib/sequel/plugins/xml_serializer.rb +2 -2
- data/lib/sequel/sql.rb +69 -36
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/db2_spec.rb +10 -0
- data/spec/adapters/firebird_spec.rb +1 -1
- data/spec/adapters/mssql_spec.rb +4 -5
- data/spec/adapters/mysql_spec.rb +9 -9
- data/spec/adapters/postgres_spec.rb +67 -68
- data/spec/adapters/spec_helper.rb +6 -1
- data/spec/adapters/sqlite_spec.rb +29 -15
- data/spec/core/connection_pool_spec.rb +14 -14
- data/spec/core/database_spec.rb +38 -180
- data/spec/core/dataset_mutation_spec.rb +253 -0
- data/spec/core/dataset_spec.rb +394 -537
- data/spec/core/expression_filters_spec.rb +34 -32
- data/spec/core/mock_adapter_spec.rb +27 -35
- data/spec/core/placeholder_literalizer_spec.rb +2 -4
- data/spec/core/schema_generator_spec.rb +4 -4
- data/spec/core/schema_spec.rb +1 -2
- data/spec/core_extensions_spec.rb +22 -29
- data/spec/extensions/active_model_spec.rb +6 -6
- data/spec/extensions/association_dependencies_spec.rb +2 -2
- data/spec/extensions/blacklist_security_spec.rb +3 -3
- data/spec/extensions/boolean_readers_spec.rb +12 -12
- data/spec/extensions/caching_spec.rb +13 -10
- data/spec/extensions/class_table_inheritance_spec.rb +38 -43
- data/spec/extensions/column_conflicts_spec.rb +1 -3
- data/spec/extensions/columns_introspection_spec.rb +2 -3
- data/spec/extensions/composition_spec.rb +5 -3
- data/spec/extensions/constraint_validations_plugin_spec.rb +5 -5
- data/spec/extensions/constraint_validations_spec.rb +14 -8
- data/spec/extensions/core_refinements_spec.rb +22 -29
- data/spec/extensions/csv_serializer_spec.rb +7 -6
- data/spec/extensions/date_arithmetic_spec.rb +15 -15
- data/spec/extensions/defaults_setter_spec.rb +2 -2
- data/spec/extensions/delay_add_association_spec.rb +1 -1
- data/spec/extensions/dirty_spec.rb +19 -10
- data/spec/extensions/duplicate_columns_handler_spec.rb +12 -18
- data/spec/extensions/eager_each_spec.rb +12 -16
- data/spec/extensions/empty_array_consider_nulls_spec.rb +1 -1
- data/spec/extensions/eval_inspect_spec.rb +4 -3
- data/spec/extensions/force_encoding_spec.rb +12 -12
- data/spec/extensions/freeze_datasets_spec.rb +31 -0
- data/spec/extensions/graph_each_spec.rb +6 -18
- data/spec/extensions/hook_class_methods_spec.rb +7 -7
- data/spec/extensions/identifier_mangling_spec.rb +307 -0
- data/spec/extensions/instance_filters_spec.rb +5 -6
- data/spec/extensions/instance_hooks_spec.rb +12 -12
- data/spec/extensions/json_serializer_spec.rb +12 -15
- data/spec/extensions/lazy_attributes_spec.rb +4 -4
- data/spec/extensions/list_spec.rb +19 -21
- data/spec/extensions/many_through_many_spec.rb +108 -163
- data/spec/extensions/meta_def_spec.rb +7 -2
- data/spec/extensions/migration_spec.rb +10 -12
- data/spec/extensions/mssql_optimistic_locking_spec.rb +4 -3
- data/spec/extensions/named_timezones_spec.rb +4 -3
- data/spec/extensions/nested_attributes_spec.rb +2 -2
- data/spec/extensions/null_dataset_spec.rb +17 -12
- data/spec/extensions/optimistic_locking_spec.rb +4 -5
- data/spec/extensions/pagination_spec.rb +8 -10
- data/spec/extensions/pg_array_associations_spec.rb +28 -27
- data/spec/extensions/pg_array_ops_spec.rb +2 -1
- data/spec/extensions/pg_array_spec.rb +6 -2
- data/spec/extensions/pg_enum_spec.rb +5 -3
- data/spec/extensions/pg_hstore_ops_spec.rb +3 -1
- data/spec/extensions/pg_hstore_spec.rb +7 -6
- data/spec/extensions/pg_inet_ops_spec.rb +2 -1
- data/spec/extensions/pg_inet_spec.rb +2 -1
- data/spec/extensions/pg_interval_spec.rb +2 -1
- data/spec/extensions/pg_json_ops_spec.rb +2 -1
- data/spec/extensions/pg_json_spec.rb +6 -3
- data/spec/extensions/pg_loose_count_spec.rb +1 -0
- data/spec/extensions/pg_range_ops_spec.rb +3 -1
- data/spec/extensions/pg_range_spec.rb +9 -5
- data/spec/extensions/pg_row_ops_spec.rb +2 -1
- data/spec/extensions/pg_row_plugin_spec.rb +4 -6
- data/spec/extensions/pg_row_spec.rb +5 -3
- data/spec/extensions/pg_static_cache_updater_spec.rb +2 -1
- data/spec/extensions/pg_typecast_on_load_spec.rb +1 -1
- data/spec/extensions/prepared_statements_associations_spec.rb +1 -1
- data/spec/extensions/prepared_statements_spec.rb +12 -11
- data/spec/extensions/pretty_table_spec.rb +1 -1
- data/spec/extensions/query_spec.rb +8 -5
- data/spec/extensions/rcte_tree_spec.rb +39 -39
- data/spec/extensions/round_timestamps_spec.rb +2 -2
- data/spec/extensions/schema_dumper_spec.rb +3 -2
- data/spec/extensions/schema_spec.rb +2 -2
- data/spec/extensions/scissors_spec.rb +1 -2
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +30 -17
- data/spec/extensions/serialization_modification_detection_spec.rb +2 -2
- data/spec/extensions/serialization_spec.rb +15 -13
- data/spec/extensions/set_overrides_spec.rb +14 -8
- data/spec/extensions/sharding_spec.rb +9 -18
- data/spec/extensions/shared_caching_spec.rb +3 -4
- data/spec/extensions/single_table_inheritance_spec.rb +11 -11
- data/spec/extensions/skip_create_refresh_spec.rb +2 -1
- data/spec/extensions/spec_helper.rb +1 -1
- data/spec/extensions/split_values_spec.rb +2 -2
- data/spec/extensions/sql_comments_spec.rb +6 -0
- data/spec/extensions/static_cache_spec.rb +7 -9
- data/spec/extensions/string_agg_spec.rb +30 -29
- data/spec/extensions/tactical_eager_loading_spec.rb +4 -5
- data/spec/extensions/thread_local_timezones_spec.rb +2 -2
- data/spec/extensions/timestamps_spec.rb +28 -3
- data/spec/extensions/to_dot_spec.rb +1 -2
- data/spec/extensions/tree_spec.rb +33 -29
- data/spec/extensions/typecast_on_load_spec.rb +1 -1
- data/spec/extensions/unlimited_update_spec.rb +1 -0
- data/spec/extensions/update_primary_key_spec.rb +11 -7
- data/spec/extensions/update_refresh_spec.rb +1 -1
- data/spec/extensions/uuid_spec.rb +0 -1
- data/spec/extensions/validate_associated_spec.rb +1 -1
- data/spec/extensions/validation_class_methods_spec.rb +10 -10
- data/spec/extensions/validation_helpers_spec.rb +10 -10
- data/spec/extensions/xml_serializer_spec.rb +7 -3
- data/spec/integration/associations_test.rb +31 -31
- data/spec/integration/dataset_test.rb +17 -19
- data/spec/integration/eager_loader_test.rb +24 -24
- data/spec/integration/model_test.rb +6 -6
- data/spec/integration/plugin_test.rb +43 -43
- data/spec/integration/prepared_statement_test.rb +6 -6
- data/spec/integration/schema_test.rb +63 -52
- data/spec/integration/spec_helper.rb +6 -1
- data/spec/integration/transaction_test.rb +13 -13
- data/spec/model/association_reflection_spec.rb +17 -17
- data/spec/model/associations_spec.rb +101 -96
- data/spec/model/base_spec.rb +175 -49
- data/spec/model/class_dataset_methods_spec.rb +5 -9
- data/spec/model/dataset_methods_spec.rb +5 -5
- data/spec/model/eager_loading_spec.rb +209 -235
- data/spec/model/hooks_spec.rb +15 -15
- data/spec/model/model_spec.rb +28 -21
- data/spec/model/plugins_spec.rb +4 -5
- data/spec/model/record_spec.rb +59 -57
- data/spec/model/spec_helper.rb +1 -1
- data/spec/model/validations_spec.rb +6 -6
- data/spec/spec_config.rb +1 -1
- metadata +10 -2
data/lib/sequel/sql.rb
CHANGED
@@ -26,7 +26,7 @@ module Sequel
|
|
26
26
|
# +Object+. This allows the virtual row support to work with classes
|
27
27
|
# without prefixing them with ::, such as:
|
28
28
|
#
|
29
|
-
# DB[:bonds].
|
29
|
+
# DB[:bonds].where{maturity_date > Time.now}
|
30
30
|
class BasicObject < ::BasicObject
|
31
31
|
# Lookup missing constants in <tt>::Object</tt>
|
32
32
|
def self.const_missing(name)
|
@@ -252,7 +252,8 @@ module Sequel
|
|
252
252
|
raise(Error, "Invalid operator #{op}")
|
253
253
|
end
|
254
254
|
@op = op
|
255
|
-
@args = args
|
255
|
+
@args = args.freeze
|
256
|
+
freeze
|
256
257
|
end
|
257
258
|
|
258
259
|
to_s_method :complex_expression_sql, '@op, @args'
|
@@ -596,10 +597,10 @@ module Sequel
|
|
596
597
|
# Converts a string into a <tt>Sequel::LiteralString</tt>, in order to override string
|
597
598
|
# literalization, e.g.:
|
598
599
|
#
|
599
|
-
# DB[:items].
|
600
|
+
# DB[:items].where(:abc => 'def').sql #=>
|
600
601
|
# "SELECT * FROM items WHERE (abc = 'def')"
|
601
602
|
#
|
602
|
-
# DB[:items].
|
603
|
+
# DB[:items].where(:abc => Sequel.lit('def')).sql #=>
|
603
604
|
# "SELECT * FROM items WHERE (abc = def)"
|
604
605
|
#
|
605
606
|
# You can also provide arguments, to create a <tt>Sequel::SQL::PlaceholderLiteralString</tt>:
|
@@ -682,9 +683,9 @@ module Sequel
|
|
682
683
|
# this array as a value in a filter, but may be necessary if you are using it as a
|
683
684
|
# value with placeholder SQL:
|
684
685
|
#
|
685
|
-
# DB[:a].
|
686
|
-
# DB[:a].
|
687
|
-
# DB[:a].
|
686
|
+
# DB[:a].where([:a, :b]=>[[1, 2], [3, 4]]) # SQL: (a, b) IN ((1, 2), (3, 4))
|
687
|
+
# DB[:a].where('(a, b) IN ?', [[1, 2], [3, 4]]) # SQL: (a, b) IN ((1 = 2) AND (3 = 4))
|
688
|
+
# DB[:a].where('(a, b) IN ?', Sequel.value_list([[1, 2], [3, 4]])) # SQL: (a, b) IN ((1, 2), (3, 4))
|
688
689
|
def value_list(arg)
|
689
690
|
raise Error, 'argument to Sequel.value_list must be an array' unless arg.is_a?(Array)
|
690
691
|
SQL::ValueList.new(arg)
|
@@ -1035,6 +1036,7 @@ module Sequel
|
|
1035
1036
|
@expression = expression
|
1036
1037
|
@aliaz = aliaz
|
1037
1038
|
@columns = columns
|
1039
|
+
freeze
|
1038
1040
|
end
|
1039
1041
|
|
1040
1042
|
to_s_method :aliased_expression_sql
|
@@ -1174,7 +1176,11 @@ module Sequel
|
|
1174
1176
|
# all conditions represent their own boolean expression.
|
1175
1177
|
def initialize(conditions, default, expression=(no_expression=true; nil))
|
1176
1178
|
raise(Sequel::Error, 'CaseExpression conditions must be a hash or array of all two pairs') unless Sequel.condition_specifier?(conditions)
|
1177
|
-
@conditions
|
1179
|
+
@conditions = conditions.to_a.dup.freeze
|
1180
|
+
@default = default
|
1181
|
+
@expression = expression
|
1182
|
+
@no_expression = no_expression
|
1183
|
+
freeze
|
1178
1184
|
end
|
1179
1185
|
|
1180
1186
|
# Whether to use an expression for this CASE expression.
|
@@ -1208,6 +1214,7 @@ module Sequel
|
|
1208
1214
|
def initialize(expr, type)
|
1209
1215
|
@expr = expr
|
1210
1216
|
@type = type
|
1217
|
+
freeze
|
1211
1218
|
end
|
1212
1219
|
|
1213
1220
|
to_s_method :cast_sql, '@expr, @type'
|
@@ -1221,6 +1228,7 @@ module Sequel
|
|
1221
1228
|
# Create an object with the given table
|
1222
1229
|
def initialize(table)
|
1223
1230
|
@table = table
|
1231
|
+
freeze
|
1224
1232
|
end
|
1225
1233
|
|
1226
1234
|
to_s_method :column_all_sql
|
@@ -1257,6 +1265,7 @@ module Sequel
|
|
1257
1265
|
# Create an constant with the given value
|
1258
1266
|
def initialize(constant)
|
1259
1267
|
@constant = constant
|
1268
|
+
freeze
|
1260
1269
|
end
|
1261
1270
|
|
1262
1271
|
to_s_method :constant_sql, '@constant'
|
@@ -1303,6 +1312,7 @@ module Sequel
|
|
1303
1312
|
# Set the callable object
|
1304
1313
|
def initialize(callable)
|
1305
1314
|
@callable = callable
|
1315
|
+
freeze
|
1306
1316
|
end
|
1307
1317
|
|
1308
1318
|
# Call the underlying callable and return the result. If the
|
@@ -1337,15 +1347,11 @@ module Sequel
|
|
1337
1347
|
|
1338
1348
|
# Set the name and args for the function
|
1339
1349
|
def initialize(name, *args)
|
1340
|
-
|
1341
|
-
@args = args
|
1342
|
-
@opts = OPTS
|
1350
|
+
_initialize(name, args, OPTS)
|
1343
1351
|
end
|
1344
1352
|
|
1345
1353
|
def self.new!(name, args, opts)
|
1346
|
-
|
1347
|
-
f.instance_variable_set(:@opts, opts)
|
1348
|
-
f
|
1354
|
+
allocate.send(:_initialize, name, args, opts)
|
1349
1355
|
end
|
1350
1356
|
|
1351
1357
|
# If no arguments are given, return a new function with the wildcard prepended to the arguments.
|
@@ -1372,7 +1378,12 @@ module Sequel
|
|
1372
1378
|
#
|
1373
1379
|
# Sequel.function(:foo, :col).filter(:a=>1) # foo(col) FILTER (WHERE a = 1)
|
1374
1380
|
def filter(*args, &block)
|
1375
|
-
|
1381
|
+
if args.length == 1
|
1382
|
+
args = args.first
|
1383
|
+
else
|
1384
|
+
args.freeze
|
1385
|
+
end
|
1386
|
+
|
1376
1387
|
with_opts(:filter=>args, :filter_block=>block)
|
1377
1388
|
end
|
1378
1389
|
|
@@ -1388,7 +1399,7 @@ module Sequel
|
|
1388
1399
|
#
|
1389
1400
|
# Sequel.function(:foo, :a).order(:a, Sequel.desc(:b)) # foo(a ORDER BY a, b DESC)
|
1390
1401
|
def order(*args)
|
1391
|
-
with_opts(:order=>args)
|
1402
|
+
with_opts(:order=>args.freeze)
|
1392
1403
|
end
|
1393
1404
|
|
1394
1405
|
# Return a new function with an OVER clause (making it a window function).
|
@@ -1430,13 +1441,21 @@ module Sequel
|
|
1430
1441
|
# Sequel.function(:rank, :a).within_group(:b, :c)
|
1431
1442
|
# # rank(a) WITHIN GROUP (ORDER BY b, c)
|
1432
1443
|
def within_group(*expressions)
|
1433
|
-
with_opts(:within_group=>expressions)
|
1444
|
+
with_opts(:within_group=>expressions.freeze)
|
1434
1445
|
end
|
1435
1446
|
|
1436
1447
|
to_s_method :function_sql
|
1437
1448
|
|
1438
1449
|
private
|
1439
1450
|
|
1451
|
+
# Set args and opts
|
1452
|
+
def _initialize(name, args, opts)
|
1453
|
+
@name = name
|
1454
|
+
@args = args.freeze
|
1455
|
+
@opts = opts.freeze
|
1456
|
+
freeze
|
1457
|
+
end
|
1458
|
+
|
1440
1459
|
# Return a new function call with the given opts merged into the current opts.
|
1441
1460
|
def with_opts(opts)
|
1442
1461
|
self.class.new!(name, args, Hash[@opts].merge!(opts))
|
@@ -1468,6 +1487,7 @@ module Sequel
|
|
1468
1487
|
# Set the value to the given argument
|
1469
1488
|
def initialize(value)
|
1470
1489
|
@value = value
|
1490
|
+
freeze
|
1471
1491
|
end
|
1472
1492
|
|
1473
1493
|
# Create a Function using this identifier as the functions name, with
|
@@ -1492,6 +1512,7 @@ module Sequel
|
|
1492
1512
|
def initialize(join_type, table_expr)
|
1493
1513
|
@join_type = join_type
|
1494
1514
|
@table_expr = table_expr
|
1515
|
+
freeze
|
1495
1516
|
end
|
1496
1517
|
|
1497
1518
|
# The table/set related to the JOIN, without any alias.
|
@@ -1545,8 +1566,8 @@ module Sequel
|
|
1545
1566
|
|
1546
1567
|
# Create an object with the given USING conditions and call super
|
1547
1568
|
# with the remaining args.
|
1548
|
-
def initialize(
|
1549
|
-
@using =
|
1569
|
+
def initialize(cols, *args)
|
1570
|
+
@using = cols
|
1550
1571
|
super(*args)
|
1551
1572
|
end
|
1552
1573
|
|
@@ -1617,7 +1638,10 @@ module Sequel
|
|
1617
1638
|
#
|
1618
1639
|
# :nulls :: Can be :first/:last for NULLS FIRST/LAST.
|
1619
1640
|
def initialize(expression, descending = true, opts=OPTS)
|
1620
|
-
@expression
|
1641
|
+
@expression = expression
|
1642
|
+
@descending = descending
|
1643
|
+
@nulls = opts[:nulls]
|
1644
|
+
freeze
|
1621
1645
|
end
|
1622
1646
|
|
1623
1647
|
# Return a copy that is ordered ASC
|
@@ -1652,6 +1676,7 @@ module Sequel
|
|
1652
1676
|
def initialize(table, column)
|
1653
1677
|
@table = convert_identifier(table)
|
1654
1678
|
@column = convert_identifier(column)
|
1679
|
+
freeze
|
1655
1680
|
end
|
1656
1681
|
|
1657
1682
|
# Create a Function using this identifier as the functions name, with
|
@@ -1746,7 +1771,9 @@ module Sequel
|
|
1746
1771
|
|
1747
1772
|
# Set the array column and subscripts to the given arguments
|
1748
1773
|
def initialize(f, sub)
|
1749
|
-
@f
|
1774
|
+
@f = f
|
1775
|
+
@sub = sub
|
1776
|
+
freeze
|
1750
1777
|
end
|
1751
1778
|
|
1752
1779
|
# Create a new +Subscript+ appending the given subscript(s)
|
@@ -1781,7 +1808,7 @@ module Sequel
|
|
1781
1808
|
# the methods defined by Sequel, if you are running on ruby 1.9, or if you are not using the
|
1782
1809
|
# core extensions.
|
1783
1810
|
#
|
1784
|
-
# An instance of this class is yielded to the block supplied to <tt>Dataset#
|
1811
|
+
# An instance of this class is yielded to the block supplied to <tt>Dataset#where</tt>, <tt>Dataset#order</tt>, and <tt>Dataset#select</tt>
|
1785
1812
|
# (and the other methods that accept a block and pass it to one of those methods).
|
1786
1813
|
# If the block doesn't take an argument, the block is instance_execed in the context of
|
1787
1814
|
# an instance of this class.
|
@@ -1814,16 +1841,16 @@ module Sequel
|
|
1814
1841
|
# ds = DB[:t]
|
1815
1842
|
#
|
1816
1843
|
# # Argument yielded to block
|
1817
|
-
# ds.
|
1844
|
+
# ds.where{|r| r.name < 2} # SELECT * FROM t WHERE (name < 2)
|
1818
1845
|
#
|
1819
1846
|
# # Block without argument (instance_eval)
|
1820
|
-
# ds.
|
1847
|
+
# ds.where{name < 2} # SELECT * FROM t WHERE (name < 2)
|
1821
1848
|
#
|
1822
1849
|
# # Qualified identifiers
|
1823
|
-
# ds.
|
1850
|
+
# ds.where{table__column + 1 < 2} # SELECT * FROM t WHERE ((table.column + 1) < 2)
|
1824
1851
|
#
|
1825
1852
|
# # Functions
|
1826
|
-
# ds.
|
1853
|
+
# ds.where{is_active(1, 'arg2')} # SELECT * FROM t WHERE is_active(1, 'arg2')
|
1827
1854
|
# ds.select{version{}} # SELECT version() FROM t
|
1828
1855
|
# ds.select{count(:*){}} # SELECT count(*) FROM t
|
1829
1856
|
# ds.select{count(:distinct, col1){}} # SELECT count(DISTINCT col1) FROM t
|
@@ -1840,19 +1867,19 @@ module Sequel
|
|
1840
1867
|
# ds.select{|o| o./(4, :a).as(:b)} # SELECT (4 / a) AS b FROM t
|
1841
1868
|
#
|
1842
1869
|
# # Boolean Operators
|
1843
|
-
# ds.
|
1844
|
-
# ds.
|
1845
|
-
# ds.
|
1846
|
-
# ds.
|
1870
|
+
# ds.where{|o| o.&({:a=>1}, :b)} # SELECT * FROM t WHERE ((a = 1) AND b)
|
1871
|
+
# ds.where{|o| o.|({:a=>1}, :b)} # SELECT * FROM t WHERE ((a = 1) OR b)
|
1872
|
+
# ds.where{|o| o.~({:a=>1})} # SELECT * FROM t WHERE (a != 1)
|
1873
|
+
# ds.where{|o| o.~({:a=>1, :b=>2})} # SELECT * FROM t WHERE ((a != 1) OR (b != 2))
|
1847
1874
|
#
|
1848
1875
|
# # Inequality Operators
|
1849
|
-
# ds.
|
1850
|
-
# ds.
|
1851
|
-
# ds.
|
1852
|
-
# ds.
|
1876
|
+
# ds.where{|o| o.>(1, :a)} # SELECT * FROM t WHERE (1 > a)
|
1877
|
+
# ds.where{|o| o.<(2, :a)} # SELECT * FROM t WHERE (2 < a)
|
1878
|
+
# ds.where{|o| o.>=(3, :a)} # SELECT * FROM t WHERE (3 >= a)
|
1879
|
+
# ds.where{|o| o.<=(4, :a)} # SELECT * FROM t WHERE (4 <= a)
|
1853
1880
|
#
|
1854
1881
|
# # Literal Strings
|
1855
|
-
# ds.
|
1882
|
+
# ds.where{{a=>`some SQL`}} # SELECT * FROM t WHERE (a = some SQL)
|
1856
1883
|
#
|
1857
1884
|
# For a more detailed explanation, see the {Virtual Rows guide}[rdoc-ref:doc/virtual_rows.rdoc].
|
1858
1885
|
class VirtualRow < BasicObject
|
@@ -1869,6 +1896,10 @@ module Sequel
|
|
1869
1896
|
END
|
1870
1897
|
end
|
1871
1898
|
|
1899
|
+
def initialize
|
1900
|
+
freeze
|
1901
|
+
end
|
1902
|
+
|
1872
1903
|
# Return a literal string created with the given string.
|
1873
1904
|
def `(s)
|
1874
1905
|
Sequel::LiteralString.new(s)
|
@@ -1924,7 +1955,8 @@ module Sequel
|
|
1924
1955
|
|
1925
1956
|
# Set the options to the options given
|
1926
1957
|
def initialize(opts=OPTS)
|
1927
|
-
@opts = opts
|
1958
|
+
@opts = opts.frozen? ? opts : Hash[opts].freeze
|
1959
|
+
freeze
|
1928
1960
|
end
|
1929
1961
|
|
1930
1962
|
to_s_method :window_sql, '@opts'
|
@@ -1939,6 +1971,7 @@ module Sequel
|
|
1939
1971
|
# Set the value wrapped by the object.
|
1940
1972
|
def initialize(value)
|
1941
1973
|
@value = value
|
1974
|
+
freeze
|
1942
1975
|
end
|
1943
1976
|
|
1944
1977
|
to_s_method :literal, '@value'
|
data/lib/sequel/version.rb
CHANGED
@@ -5,7 +5,7 @@ module Sequel
|
|
5
5
|
MAJOR = 4
|
6
6
|
# The minor version of Sequel. Bumped for every non-patch level
|
7
7
|
# release, generally around once a month.
|
8
|
-
MINOR =
|
8
|
+
MINOR = 42
|
9
9
|
# The tiny version of Sequel. Usually 0, only bumped for bugfix
|
10
10
|
# releases that fix regressions from previous versions.
|
11
11
|
TINY = 0
|
data/spec/adapters/db2_spec.rb
CHANGED
@@ -118,6 +118,11 @@ describe "Sequel::IBMDB.convert_smallint_to_bool" do
|
|
118
118
|
@ds.delete
|
119
119
|
@ds << {:b=>true, :i=>1}
|
120
120
|
@ds.all.must_equal [{:b=>true, :i=>1}]
|
121
|
+
|
122
|
+
@ds = @ds.with_convert_smallint_to_bool(false)
|
123
|
+
@ds.delete
|
124
|
+
@ds << {:b=>true, :i=>10}
|
125
|
+
@ds.all.must_equal [{:b=>1, :i=>10}]
|
121
126
|
end
|
122
127
|
|
123
128
|
it "should return all smallints as integers when unset" do
|
@@ -135,6 +140,11 @@ describe "Sequel::IBMDB.convert_smallint_to_bool" do
|
|
135
140
|
@ds.delete
|
136
141
|
@ds << {:b=>0, :i=>0}
|
137
142
|
@ds.all.must_equal [{:b=>0, :i=>0}]
|
143
|
+
|
144
|
+
@ds = @ds.with_convert_smallint_to_bool(true)
|
145
|
+
@ds.delete
|
146
|
+
@ds << {:b=>true, :i=>10}
|
147
|
+
@ds.all.must_equal [{:b=>true, :i=>10}]
|
138
148
|
end
|
139
149
|
end if DB.adapter_scheme == :ibmdb
|
140
150
|
|
data/spec/adapters/mssql_spec.rb
CHANGED
@@ -352,14 +352,14 @@ describe "MSSSQL::Dataset#insert" do
|
|
352
352
|
end
|
353
353
|
|
354
354
|
it "should have insert_select return nil if disable_insert_output is used" do
|
355
|
-
@ds.disable_insert_output.insert_select(:value=>10).
|
355
|
+
@ds.disable_insert_output.insert_select(:value=>10).must_be_nil
|
356
356
|
end
|
357
357
|
|
358
358
|
it "should have insert_select return nil if the server version is not 2005+" do
|
359
|
-
@ds = @ds.with_extend
|
359
|
+
@ds = @ds.with_extend do
|
360
360
|
def server_version() 8000760 end
|
361
|
-
end
|
362
|
-
@ds.insert_select(:value=>10).
|
361
|
+
end
|
362
|
+
@ds.insert_select(:value=>10).must_be_nil
|
363
363
|
end
|
364
364
|
|
365
365
|
it "should have insert_select insert the record and return the inserted record" do
|
@@ -427,7 +427,6 @@ end
|
|
427
427
|
|
428
428
|
describe "MSSQL::Database#rename_table" do
|
429
429
|
it "should work on non-schema bound tables which need escaping" do
|
430
|
-
DB.quote_identifiers = true
|
431
430
|
DB.create_table! :'foo bar' do
|
432
431
|
text :name
|
433
432
|
end
|
data/spec/adapters/mysql_spec.rb
CHANGED
@@ -150,10 +150,10 @@ if [:mysql, :mysql2].include?(DB.adapter_scheme)
|
|
150
150
|
|
151
151
|
it "should allow disabling the conversion on a per-dataset basis" do
|
152
152
|
@db.convert_tinyint_to_bool = true
|
153
|
-
ds = @ds.with_extend
|
153
|
+
ds = @ds.with_extend do
|
154
154
|
def cast_tinyint_integer?(f) true end #mysql
|
155
155
|
def convert_tinyint_to_bool?() false end #mysql2
|
156
|
-
end
|
156
|
+
end
|
157
157
|
ds.delete
|
158
158
|
ds << {:b=>true, :i=>10}
|
159
159
|
ds.all.must_equal [{:b=>1, :i=>10}]
|
@@ -597,7 +597,7 @@ describe "A MySQL database" do
|
|
597
597
|
@db[:items].first.must_equal(:name => 'tutu', :value => 1234)
|
598
598
|
|
599
599
|
@db << 'DELETE FROM items'
|
600
|
-
@db[:items].first.
|
600
|
+
@db[:items].first.must_be_nil
|
601
601
|
end
|
602
602
|
end
|
603
603
|
|
@@ -1208,13 +1208,13 @@ if DB.adapter_scheme == :mysql
|
|
1208
1208
|
|
1209
1209
|
it "should not use a nil value bad date/time is used and convert_invalid_date_time is nil or :nil" do
|
1210
1210
|
DB.convert_invalid_date_time = nil
|
1211
|
-
DB["SELECT CAST('0000-00-00' AS date)"].single_value.
|
1212
|
-
DB["SELECT CAST('0000-00-00 00:00:00' AS datetime)"].single_value.
|
1213
|
-
DB["SELECT CAST('25:00:00' AS time)"].single_value.
|
1211
|
+
DB["SELECT CAST('0000-00-00' AS date)"].single_value.must_be_nil
|
1212
|
+
DB["SELECT CAST('0000-00-00 00:00:00' AS datetime)"].single_value.must_be_nil
|
1213
|
+
DB["SELECT CAST('25:00:00' AS time)"].single_value.must_be_nil
|
1214
1214
|
DB.convert_invalid_date_time = :nil
|
1215
|
-
DB["SELECT CAST('0000-00-00' AS date)"].single_value.
|
1216
|
-
DB["SELECT CAST('0000-00-00 00:00:00' AS datetime)"].single_value.
|
1217
|
-
DB["SELECT CAST('25:00:00' AS time)"].single_value.
|
1215
|
+
DB["SELECT CAST('0000-00-00' AS date)"].single_value.must_be_nil
|
1216
|
+
DB["SELECT CAST('0000-00-00 00:00:00' AS datetime)"].single_value.must_be_nil
|
1217
|
+
DB["SELECT CAST('25:00:00' AS time)"].single_value.must_be_nil
|
1218
1218
|
end
|
1219
1219
|
|
1220
1220
|
it "should not use a nil value bad date/time is used and convert_invalid_date_time is :string" do
|
@@ -199,12 +199,12 @@ describe "PostgreSQL", 'INSERT ON CONFLICT' do
|
|
199
199
|
@ds.insert(10, 11, 3, true)
|
200
200
|
proc{@ds.insert(1, 3, 4)}.must_raise Sequel::UniqueConstraintViolation
|
201
201
|
proc{@ds.insert(11, 12, 3, true)}.must_raise Sequel::UniqueConstraintViolation
|
202
|
-
@ds.insert_ignore.insert(1, 3, 4).
|
203
|
-
@ds.insert_conflict.insert(1, 3, 4).
|
204
|
-
@ds.insert_conflict.insert(11, 12, 3, true).
|
205
|
-
@ds.insert_conflict(:target=>:a).insert(1, 3, 4).
|
206
|
-
@ds.insert_conflict(:target=>:c, :conflict_where=>:c_is_unique).insert(11, 12, 3, true).
|
207
|
-
@ds.insert_conflict(:constraint=>:ic_test_a_uidx).insert(1, 3, 4).
|
202
|
+
@ds.insert_ignore.insert(1, 3, 4).must_be_nil
|
203
|
+
@ds.insert_conflict.insert(1, 3, 4).must_be_nil
|
204
|
+
@ds.insert_conflict.insert(11, 12, 3, true).must_be_nil
|
205
|
+
@ds.insert_conflict(:target=>:a).insert(1, 3, 4).must_be_nil
|
206
|
+
@ds.insert_conflict(:target=>:c, :conflict_where=>:c_is_unique).insert(11, 12, 3, true).must_be_nil
|
207
|
+
@ds.insert_conflict(:constraint=>:ic_test_a_uidx).insert(1, 3, 4).must_be_nil
|
208
208
|
@ds.all.must_equal [{:a=>1, :b=>2, :c=>3, :c_is_unique=>false}, {:a=>10, :b=>11, :c=>3, :c_is_unique=>true}]
|
209
209
|
end
|
210
210
|
|
@@ -221,15 +221,15 @@ describe "PostgreSQL", 'INSERT ON CONFLICT' do
|
|
221
221
|
|
222
222
|
it "Dataset#insert_conflict should handle upserts" do
|
223
223
|
@ds.insert(1, 2, 3)
|
224
|
-
@ds.insert_conflict(:target=>:a, :update=>{:b=>3}).insert(1, 3, 4).
|
224
|
+
@ds.insert_conflict(:target=>:a, :update=>{:b=>3}).insert(1, 3, 4).must_be_nil
|
225
225
|
@ds.all.must_equal [{:a=>1, :b=>3, :c=>3, :c_is_unique=>false}]
|
226
|
-
@ds.insert_conflict(:target=>[:b, :c], :update=>{:c=>5}).insert(5, 3, 3).
|
226
|
+
@ds.insert_conflict(:target=>[:b, :c], :update=>{:c=>5}).insert(5, 3, 3).must_be_nil
|
227
227
|
@ds.all.must_equal [{:a=>1, :b=>3, :c=>5, :c_is_unique=>false}]
|
228
|
-
@ds.insert_conflict(:constraint=>:ic_test_a_uidx, :update=>{:b=>4}).insert(1, 3).
|
228
|
+
@ds.insert_conflict(:constraint=>:ic_test_a_uidx, :update=>{:b=>4}).insert(1, 3).must_be_nil
|
229
229
|
@ds.all.must_equal [{:a=>1, :b=>4, :c=>5, :c_is_unique=>false}]
|
230
|
-
@ds.insert_conflict(:constraint=>:ic_test_a_uidx, :update=>{:b=>5}, :update_where=>{Sequel[:ic_test][:b]=>4}).insert(1, 3, 4).
|
230
|
+
@ds.insert_conflict(:constraint=>:ic_test_a_uidx, :update=>{:b=>5}, :update_where=>{Sequel[:ic_test][:b]=>4}).insert(1, 3, 4).must_be_nil
|
231
231
|
@ds.all.must_equal [{:a=>1, :b=>5, :c=>5, :c_is_unique=>false}]
|
232
|
-
@ds.insert_conflict(:constraint=>:ic_test_a_uidx, :update=>{:b=>6}, :update_where=>{Sequel[:ic_test][:b]=>4}).insert(1, 3, 4).
|
232
|
+
@ds.insert_conflict(:constraint=>:ic_test_a_uidx, :update=>{:b=>6}, :update_where=>{Sequel[:ic_test][:b]=>4}).insert(1, 3, 4).must_be_nil
|
233
233
|
@ds.all.must_equal [{:a=>1, :b=>5, :c=>5, :c_is_unique=>false}]
|
234
234
|
end
|
235
235
|
|
@@ -284,12 +284,12 @@ describe "A PostgreSQL database" do
|
|
284
284
|
it "should support disable_insert_returning" do
|
285
285
|
ds = @db[Sequel[:public][:testfk]].disable_insert_returning
|
286
286
|
ds.delete
|
287
|
-
ds.insert.
|
287
|
+
ds.insert.must_be_nil
|
288
288
|
id = ds.max(:id)
|
289
289
|
ds.select_order_map([:id, :i]).must_equal [[id, nil]]
|
290
|
-
ds.insert(:i=>id).
|
290
|
+
ds.insert(:i=>id).must_be_nil
|
291
291
|
ds.select_order_map([:id, :i]).must_equal [[id, nil], [id+1, id]]
|
292
|
-
ds.insert_select(:i=>ds.max(:id)).
|
292
|
+
ds.insert_select(:i=>ds.max(:id)).must_be_nil
|
293
293
|
ds.select_order_map([:id, :i]).must_equal [[id, nil], [id+1, id]]
|
294
294
|
c = Class.new(Sequel::Model(ds))
|
295
295
|
c.class_eval do
|
@@ -510,8 +510,8 @@ describe "A PostgreSQL dataset" do
|
|
510
510
|
info[:schema].must_equal 'public'
|
511
511
|
info[:table].must_equal 'atest'
|
512
512
|
info[:constraint].must_equal 'f'
|
513
|
-
info[:column].
|
514
|
-
info[:type].
|
513
|
+
info[:column].must_be_nil
|
514
|
+
info[:type].must_be_nil
|
515
515
|
|
516
516
|
begin
|
517
517
|
@db[:atest].insert(0, nil)
|
@@ -521,9 +521,9 @@ describe "A PostgreSQL dataset" do
|
|
521
521
|
info = @db.error_info(e.wrapped_exception)
|
522
522
|
info[:schema].must_equal 'public'
|
523
523
|
info[:table].must_equal 'atest'
|
524
|
-
info[:constraint].
|
524
|
+
info[:constraint].must_be_nil
|
525
525
|
info[:column].must_equal 't2'
|
526
|
-
info[:type].
|
526
|
+
info[:type].must_be_nil
|
527
527
|
end if DB.server_version >= 90300 && DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && Object.const_defined?(:PG) && ::PG.const_defined?(:Constants) && ::PG::Constants.const_defined?(:PG_DIAG_SCHEMA_NAME)
|
528
528
|
|
529
529
|
it "should support Database#do for executing anonymous code blocks" do
|
@@ -667,8 +667,8 @@ describe "A PostgreSQL dataset" do
|
|
667
667
|
end
|
668
668
|
|
669
669
|
it "#lock should return nil" do
|
670
|
-
@d.lock('EXCLUSIVE'){@d.insert(:name=>'a')}.
|
671
|
-
@db.transaction{@d.lock('EXCLUSIVE').
|
670
|
+
@d.lock('EXCLUSIVE'){@d.insert(:name=>'a')}.must_be_nil
|
671
|
+
@db.transaction{@d.lock('EXCLUSIVE').must_be_nil; @d.insert(:name=>'a')}
|
672
672
|
end
|
673
673
|
|
674
674
|
it "should raise an error if attempting to update a joined dataset with a single FROM table" do
|
@@ -817,22 +817,21 @@ describe "A PostgreSQL dataset with a timestamp field" do
|
|
817
817
|
it "should handle infinite timestamps if convert_infinite_timestamps is set" do
|
818
818
|
@d << {:time=>Sequel.cast('infinity', DateTime)}
|
819
819
|
@db.convert_infinite_timestamps = :nil
|
820
|
-
@db[:test3].get(:time).
|
820
|
+
@db[:test3].get(:time).must_be_nil
|
821
821
|
@db.convert_infinite_timestamps = :string
|
822
822
|
@db[:test3].get(:time).must_equal 'infinity'
|
823
823
|
@db.convert_infinite_timestamps = :float
|
824
824
|
@db[:test3].get(:time).must_equal 1.0/0.0
|
825
825
|
@db.convert_infinite_timestamps = 'nil'
|
826
|
-
@db[:test3].get(:time).
|
826
|
+
@db[:test3].get(:time).must_be_nil
|
827
827
|
@db.convert_infinite_timestamps = 'string'
|
828
828
|
@db[:test3].get(:time).must_equal 'infinity'
|
829
829
|
@db.convert_infinite_timestamps = 'float'
|
830
830
|
@db[:test3].get(:time).must_equal 1.0/0.0
|
831
831
|
@db.convert_infinite_timestamps = 't'
|
832
832
|
@db[:test3].get(:time).must_equal 1.0/0.0
|
833
|
-
|
834
|
-
|
835
|
-
@db.convert_infinite_timestamps = 'f'
|
833
|
+
@db.convert_infinite_timestamps = 'f'
|
834
|
+
if RUBY_VERSION >= '1.9'
|
836
835
|
proc{@db[:test3].get(:time)}.must_raise ArgumentError, Sequel::InvalidValue
|
837
836
|
@db.convert_infinite_timestamps = nil
|
838
837
|
proc{@db[:test3].get(:time)}.must_raise ArgumentError, Sequel::InvalidValue
|
@@ -842,7 +841,7 @@ describe "A PostgreSQL dataset with a timestamp field" do
|
|
842
841
|
|
843
842
|
@d.update(:time=>Sequel.cast('-infinity', DateTime))
|
844
843
|
@db.convert_infinite_timestamps = :nil
|
845
|
-
@db[:test3].get(:time).
|
844
|
+
@db[:test3].get(:time).must_be_nil
|
846
845
|
@db.convert_infinite_timestamps = :string
|
847
846
|
@db[:test3].get(:time).must_equal '-infinity'
|
848
847
|
@db.convert_infinite_timestamps = :float
|
@@ -861,7 +860,7 @@ describe "A PostgreSQL dataset with a timestamp field" do
|
|
861
860
|
it "should handle infinite dates if convert_infinite_timestamps is set" do
|
862
861
|
@d << {:date=>Sequel.cast('infinity', Date)}
|
863
862
|
@db.convert_infinite_timestamps = :nil
|
864
|
-
@db[:test3].get(:date).
|
863
|
+
@db[:test3].get(:date).must_be_nil
|
865
864
|
@db.convert_infinite_timestamps = :string
|
866
865
|
@db[:test3].get(:date).must_equal 'infinity'
|
867
866
|
@db.convert_infinite_timestamps = :float
|
@@ -869,7 +868,7 @@ describe "A PostgreSQL dataset with a timestamp field" do
|
|
869
868
|
|
870
869
|
@d.update(:date=>Sequel.cast('-infinity', :timestamp))
|
871
870
|
@db.convert_infinite_timestamps = :nil
|
872
|
-
@db[:test3].get(:date).
|
871
|
+
@db[:test3].get(:date).must_be_nil
|
873
872
|
@db.convert_infinite_timestamps = :string
|
874
873
|
@db[:test3].get(:date).must_equal '-infinity'
|
875
874
|
@db.convert_infinite_timestamps = :float
|
@@ -975,7 +974,7 @@ describe "A PostgreSQL database" do
|
|
975
974
|
|
976
975
|
it "should not raise an error if attempting to resetting the primary key sequence for a table without a primary key" do
|
977
976
|
@db.create_table(:posts){Integer :a}
|
978
|
-
@db.reset_primary_key_sequence(:posts).
|
977
|
+
@db.reset_primary_key_sequence(:posts).must_be_nil
|
979
978
|
end
|
980
979
|
|
981
980
|
it "should support opclass specification" do
|
@@ -1138,8 +1137,8 @@ describe "Postgres::Dataset#insert" do
|
|
1138
1137
|
end
|
1139
1138
|
|
1140
1139
|
it "should work with static SQL" do
|
1141
|
-
@ds.with_sql('INSERT INTO test5 (value) VALUES (10)').insert.
|
1142
|
-
@db['INSERT INTO test5 (value) VALUES (20)'].insert.
|
1140
|
+
@ds.with_sql('INSERT INTO test5 (value) VALUES (10)').insert.must_be_nil
|
1141
|
+
@db['INSERT INTO test5 (value) VALUES (20)'].insert.must_be_nil
|
1143
1142
|
@ds.all.must_equal [{:xid=>1, :value=>10}, {:xid=>2, :value=>20}]
|
1144
1143
|
end
|
1145
1144
|
|
@@ -1185,7 +1184,7 @@ describe "Postgres::Dataset#insert" do
|
|
1185
1184
|
it "should return nil if the table has no primary key" do
|
1186
1185
|
@db.create_table!(:test5){String :name; Integer :value}
|
1187
1186
|
@ds.delete
|
1188
|
-
@ds.insert(:name=>'a').
|
1187
|
+
@ds.insert(:name=>'a').must_be_nil
|
1189
1188
|
end
|
1190
1189
|
end
|
1191
1190
|
|
@@ -1202,14 +1201,14 @@ describe "Postgres::Database schema qualified tables" do
|
|
1202
1201
|
|
1203
1202
|
it "should be able to create, drop, select and insert into tables in a given schema" do
|
1204
1203
|
@db.create_table(Sequel[:schema_test][:schema_test]){primary_key :i}
|
1205
|
-
@db[Sequel[:schema_test][:schema_test]].first.
|
1204
|
+
@db[Sequel[:schema_test][:schema_test]].first.must_be_nil
|
1206
1205
|
@db[Sequel[:schema_test][:schema_test]].insert(:i=>1).must_equal 1
|
1207
1206
|
@db[Sequel[:schema_test][:schema_test]].first.must_equal(:i=>1)
|
1208
1207
|
@db.from(Sequel.lit('schema_test.schema_test')).first.must_equal(:i=>1)
|
1209
1208
|
@db.drop_table(Sequel[:schema_test][:schema_test])
|
1210
1209
|
@db.create_table(Sequel.qualify(:schema_test, :schema_test)){integer :i}
|
1211
|
-
@db[Sequel[:schema_test][:schema_test]].first.
|
1212
|
-
@db.from(Sequel.lit('schema_test.schema_test')).first.
|
1210
|
+
@db[Sequel[:schema_test][:schema_test]].first.must_be_nil
|
1211
|
+
@db.from(Sequel.lit('schema_test.schema_test')).first.must_be_nil
|
1213
1212
|
@db.drop_table(Sequel.qualify(:schema_test, :schema_test))
|
1214
1213
|
end
|
1215
1214
|
|
@@ -1727,11 +1726,11 @@ if DB.adapter_scheme == :postgres
|
|
1727
1726
|
end
|
1728
1727
|
|
1729
1728
|
it "should handle returning inside block" do
|
1730
|
-
ds = @ds.with_extend
|
1729
|
+
ds = @ds.with_extend do
|
1731
1730
|
def check_return
|
1732
1731
|
use_cursor.each{|r| return}
|
1733
1732
|
end
|
1734
|
-
end
|
1733
|
+
end
|
1735
1734
|
ds.check_return
|
1736
1735
|
ds.all.must_equal ds.use_cursor.all
|
1737
1736
|
end
|
@@ -1994,30 +1993,30 @@ if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && DB.server_versio
|
|
1994
1993
|
called2 = true
|
1995
1994
|
break
|
1996
1995
|
end
|
1997
|
-
end.
|
1996
|
+
end.must_be_nil
|
1998
1997
|
called.must_equal true
|
1999
1998
|
called2.must_equal true
|
2000
1999
|
i.must_equal 1
|
2001
2000
|
end
|
2002
2001
|
|
2003
2002
|
it "should accept a :timeout option in listen" do
|
2004
|
-
@db.listen('foo2', :timeout=>0.001).
|
2003
|
+
@db.listen('foo2', :timeout=>0.001).must_be_nil
|
2005
2004
|
called = false
|
2006
|
-
@db.listen('foo2', :timeout=>0.001){|ev, pid, payload| called = true}.
|
2005
|
+
@db.listen('foo2', :timeout=>0.001){|ev, pid, payload| called = true}.must_be_nil
|
2007
2006
|
called.must_equal false
|
2008
2007
|
i = 0
|
2009
|
-
@db.listen('foo2', :timeout=>0.001, :loop=>proc{i+=1; throw :stop if i > 3}){|ev, pid, payload| called = true}.
|
2008
|
+
@db.listen('foo2', :timeout=>0.001, :loop=>proc{i+=1; throw :stop if i > 3}){|ev, pid, payload| called = true}.must_be_nil
|
2010
2009
|
i.must_equal 4
|
2011
2010
|
|
2012
2011
|
called = false
|
2013
2012
|
i = 0
|
2014
|
-
@db.listen('foo2', :timeout=>proc{i+=1; 0.001}){|ev, pid, payload| called = true}.
|
2013
|
+
@db.listen('foo2', :timeout=>proc{i+=1; 0.001}){|ev, pid, payload| called = true}.must_be_nil
|
2015
2014
|
called.must_equal false
|
2016
2015
|
i.must_equal 1
|
2017
2016
|
|
2018
2017
|
i = 0
|
2019
2018
|
t = 0
|
2020
|
-
@db.listen('foo2', :timeout=>proc{t+=1; 0.001}, :loop=>proc{i+=1; throw :stop if i > 3}){|ev, pid, payload| called = true}.
|
2019
|
+
@db.listen('foo2', :timeout=>proc{t+=1; 0.001}, :loop=>proc{i+=1; throw :stop if i > 3}){|ev, pid, payload| called = true}.must_be_nil
|
2021
2020
|
called.must_equal false
|
2022
2021
|
t.must_equal 4
|
2023
2022
|
|
@@ -2366,7 +2365,7 @@ describe 'PostgreSQL array handling' do
|
|
2366
2365
|
@ds.call(:insert, {:i=>[1,2]}, {:i=>:$i})
|
2367
2366
|
@ds.get(:i).must_equal [1, 2]
|
2368
2367
|
@ds.filter(:i=>:$i).call(:first, :i=>[1,2]).must_equal(:i=>[1,2])
|
2369
|
-
@ds.filter(:i=>:$i).call(:first, :i=>[1,3]).
|
2368
|
+
@ds.filter(:i=>:$i).call(:first, :i=>[1,3]).must_be_nil
|
2370
2369
|
|
2371
2370
|
# NULL values
|
2372
2371
|
@ds.delete
|
@@ -2380,7 +2379,7 @@ describe 'PostgreSQL array handling' do
|
|
2380
2379
|
@ds.call(:insert, {:i=>:$i}, :i=>Sequel.pg_array(a))
|
2381
2380
|
@ds.get(:i).must_equal a
|
2382
2381
|
@ds.filter(:i=>:$i).call(:first, :i=>a).must_equal(:i=>a)
|
2383
|
-
@ds.filter(:i=>:$i).call(:first, :i=>['', nil, nil, 'a']).
|
2382
|
+
@ds.filter(:i=>:$i).call(:first, :i=>['', nil, nil, 'a']).must_be_nil
|
2384
2383
|
|
2385
2384
|
@db.create_table!(:items) do
|
2386
2385
|
column :i, 'date[]'
|
@@ -2389,7 +2388,7 @@ describe 'PostgreSQL array handling' do
|
|
2389
2388
|
@ds.call(:insert, {:i=>:$i}, :i=>Sequel.pg_array(a, 'date'))
|
2390
2389
|
@ds.get(:i).must_equal a
|
2391
2390
|
@ds.filter(:i=>:$i).call(:first, :i=>a).must_equal(:i=>a)
|
2392
|
-
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([Date.today-1], 'date')).
|
2391
|
+
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([Date.today-1], 'date')).must_be_nil
|
2393
2392
|
|
2394
2393
|
@db.create_table!(:items) do
|
2395
2394
|
column :i, 'timestamp[]'
|
@@ -2398,7 +2397,7 @@ describe 'PostgreSQL array handling' do
|
|
2398
2397
|
@ds.call(:insert, {:i=>:$i}, :i=>Sequel.pg_array(a, 'timestamp'))
|
2399
2398
|
@ds.get(:i).must_equal a
|
2400
2399
|
@ds.filter(:i=>:$i).call(:first, :i=>a).must_equal(:i=>a)
|
2401
|
-
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([a.first-1], 'timestamp')).
|
2400
|
+
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([a.first-1], 'timestamp')).must_be_nil
|
2402
2401
|
|
2403
2402
|
@db.create_table!(:items) do
|
2404
2403
|
column :i, 'boolean[]'
|
@@ -2407,7 +2406,7 @@ describe 'PostgreSQL array handling' do
|
|
2407
2406
|
@ds.call(:insert, {:i=>:$i}, :i=>Sequel.pg_array(a, 'boolean'))
|
2408
2407
|
@ds.get(:i).must_equal a
|
2409
2408
|
@ds.filter(:i=>:$i).call(:first, :i=>a).must_equal(:i=>a)
|
2410
|
-
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([false, true], 'boolean')).
|
2409
|
+
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([false, true], 'boolean')).must_be_nil
|
2411
2410
|
|
2412
2411
|
@db.create_table!(:items) do
|
2413
2412
|
column :i, 'bytea[]'
|
@@ -2416,7 +2415,7 @@ describe 'PostgreSQL array handling' do
|
|
2416
2415
|
@ds.call(:insert, {:i=>:$i}, :i=>Sequel.pg_array(a, 'bytea'))
|
2417
2416
|
@ds.get(:i).must_equal a
|
2418
2417
|
@ds.filter(:i=>:$i).call(:first, :i=>a).must_equal(:i=>a)
|
2419
|
-
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([Sequel.blob("b\0")], 'bytea')).
|
2418
|
+
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.pg_array([Sequel.blob("b\0")], 'bytea')).must_be_nil
|
2420
2419
|
end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
|
2421
2420
|
|
2422
2421
|
it 'with models' do
|
@@ -2594,7 +2593,7 @@ describe 'PostgreSQL hstore handling' do
|
|
2594
2593
|
@ds.call(:insert, {:i=>Sequel.hstore(@h)}, {:i=>:$i})
|
2595
2594
|
@ds.get(:i).must_equal @h
|
2596
2595
|
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.hstore(@h)).must_equal(:i=>@h)
|
2597
|
-
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.hstore({})).
|
2596
|
+
@ds.filter(:i=>:$i).call(:first, :i=>Sequel.hstore({})).must_be_nil
|
2598
2597
|
|
2599
2598
|
@ds.delete
|
2600
2599
|
@ds.call(:insert, {:i=>Sequel.hstore('a'=>nil)}, {:i=>:$i})
|
@@ -2604,7 +2603,7 @@ describe 'PostgreSQL hstore handling' do
|
|
2604
2603
|
@ds.call(:insert, {:i=>@h}, {:i=>:$i})
|
2605
2604
|
@ds.get(:i).must_equal @h
|
2606
2605
|
@ds.filter(:i=>:$i).call(:first, :i=>@h).must_equal(:i=>@h)
|
2607
|
-
@ds.filter(:i=>:$i).call(:first, :i=>{}).
|
2606
|
+
@ds.filter(:i=>:$i).call(:first, :i=>{}).must_be_nil
|
2608
2607
|
end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
|
2609
2608
|
|
2610
2609
|
it 'with models and associations' do
|
@@ -2712,7 +2711,7 @@ describe 'PostgreSQL hstore handling' do
|
|
2712
2711
|
h3 = Sequel.hstore(:h3)
|
2713
2712
|
|
2714
2713
|
@ds.get(h1['a']).must_equal 'b'
|
2715
|
-
@ds.get(h1['d']).
|
2714
|
+
@ds.get(h1['d']).must_be_nil
|
2716
2715
|
|
2717
2716
|
@ds.get(h2.concat(h3).keys.length).must_equal 2
|
2718
2717
|
@ds.get(h1.concat(h3).keys.length).must_equal 3
|
@@ -2735,9 +2734,9 @@ describe 'PostgreSQL hstore handling' do
|
|
2735
2734
|
@ds.get(h1.defined('c')).must_equal false
|
2736
2735
|
@ds.get(h1.defined('d')).must_equal false
|
2737
2736
|
|
2738
|
-
@ds.get(h1.delete('a')['c']).
|
2739
|
-
@ds.get(h1.delete(%w'a d')['c']).
|
2740
|
-
@ds.get(h1.delete(h2)['c']).
|
2737
|
+
@ds.get(h1.delete('a')['c']).must_be_nil
|
2738
|
+
@ds.get(h1.delete(%w'a d')['c']).must_be_nil
|
2739
|
+
@ds.get(h1.delete(h2)['c']).must_be_nil
|
2741
2740
|
|
2742
2741
|
@ds.from(Sequel.hstore('a'=>'b', 'c'=>nil).op.each).order(:key).all.must_equal [{:key=>'a', :value=>'b'}, {:key=>'c', :value=>nil}]
|
2743
2742
|
|
@@ -2766,7 +2765,7 @@ describe 'PostgreSQL hstore handling' do
|
|
2766
2765
|
|
2767
2766
|
@ds.get(h1.slice(%w'a c').keys.length).must_equal 2
|
2768
2767
|
@ds.get(h1.slice(%w'd c').keys.length).must_equal 1
|
2769
|
-
@ds.get(h1.slice(%w'd e').keys.length).
|
2768
|
+
@ds.get(h1.slice(%w'd e').keys.length).must_be_nil
|
2770
2769
|
|
2771
2770
|
@ds.from(Sequel.hstore('t'=>'s', 'a'=>'b').op.svals.as(:s)).select_order_map(:s).must_equal %w'b s'
|
2772
2771
|
|
@@ -3056,7 +3055,7 @@ describe 'PostgreSQL inet/cidr types' do
|
|
3056
3055
|
@ds.get(:i).must_equal @ipv4
|
3057
3056
|
@ds.get(:c).must_equal @ipv4nm
|
3058
3057
|
@ds.filter(:i=>:$i, :c=>:$c).call(:first, :i=>@ipv4, :c=>@ipv4nm).must_equal(:i=>@ipv4, :c=>@ipv4nm)
|
3059
|
-
@ds.filter(:i=>:$i, :c=>:$c).call(:first, :i=>@ipv6, :c=>@ipv6nm).
|
3058
|
+
@ds.filter(:i=>:$i, :c=>:$c).call(:first, :i=>@ipv6, :c=>@ipv6nm).must_be_nil
|
3060
3059
|
@ds.filter(:i=>:$i, :c=>:$c).call(:delete, :i=>@ipv4, :c=>@ipv4nm).must_equal 1
|
3061
3060
|
|
3062
3061
|
unless ipv6_broken
|
@@ -3064,14 +3063,14 @@ describe 'PostgreSQL inet/cidr types' do
|
|
3064
3063
|
@ds.get(:i).must_equal @ipv6
|
3065
3064
|
@ds.get(:c).must_equal @ipv6nm
|
3066
3065
|
@ds.filter(:i=>:$i, :c=>:$c).call(:first, :i=>@ipv6, :c=>@ipv6nm).must_equal(:i=>@ipv6, :c=>@ipv6nm)
|
3067
|
-
@ds.filter(:i=>:$i, :c=>:$c).call(:first, :i=>@ipv4, :c=>@ipv4nm).
|
3066
|
+
@ds.filter(:i=>:$i, :c=>:$c).call(:first, :i=>@ipv4, :c=>@ipv4nm).must_be_nil
|
3068
3067
|
@ds.filter(:i=>:$i, :c=>:$c).call(:delete, :i=>@ipv6, :c=>@ipv6nm).must_equal 1
|
3069
3068
|
end
|
3070
3069
|
|
3071
3070
|
@db.create_table!(:items){column :i, 'inet[]'; column :c, 'cidr[]'; column :m, 'macaddr[]'}
|
3072
3071
|
@ds.call(:insert, {:i=>[@ipv4], :c=>[@ipv4nm], :m=>['12:34:56:78:90:ab']}, {:i=>:$i, :c=>:$c, :m=>:$m})
|
3073
3072
|
@ds.filter(:i=>:$i, :c=>:$c, :m=>:$m).call(:first, :i=>[@ipv4], :c=>[@ipv4nm], :m=>['12:34:56:78:90:ab']).must_equal(:i=>[@ipv4], :c=>[@ipv4nm], :m=>['12:34:56:78:90:ab'])
|
3074
|
-
@ds.filter(:i=>:$i, :c=>:$c, :m=>:$m).call(:first, :i=>[], :c=>[], :m=>[]).
|
3073
|
+
@ds.filter(:i=>:$i, :c=>:$c, :m=>:$m).call(:first, :i=>[], :c=>[], :m=>[]).must_be_nil
|
3075
3074
|
@ds.filter(:i=>:$i, :c=>:$c, :m=>:$m).call(:delete, :i=>[@ipv4], :c=>[@ipv4nm], :m=>['12:34:56:78:90:ab']).must_equal 1
|
3076
3075
|
end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
|
3077
3076
|
|
@@ -3226,7 +3225,7 @@ describe 'PostgreSQL range types' do
|
|
3226
3225
|
@ds.first.must_be :==, @r
|
3227
3226
|
@ds.filter(h).call(:first, @r).must_be :==, @r
|
3228
3227
|
@ds.filter(h).call(:first, @pgr).must_be :==, @r
|
3229
|
-
@ds.filter(h).call(:first, r2).
|
3228
|
+
@ds.filter(h).call(:first, r2).must_be_nil
|
3230
3229
|
@ds.filter(h).call(:delete, @r).must_equal 1
|
3231
3230
|
|
3232
3231
|
@db.create_table!(:items){column :i4, 'int4range[]'; column :i8, 'int8range[]'; column :n, 'numrange[]'; column :d, 'daterange[]'; column :t, 'tsrange[]'; column :tz, 'tstzrange[]'}
|
@@ -3234,7 +3233,7 @@ describe 'PostgreSQL range types' do
|
|
3234
3233
|
@ds.call(:insert, @ra, h)
|
3235
3234
|
@ds.filter(h).call(:first, @ra).each{|k, v| v.must_be :==, @ra[k].to_a}
|
3236
3235
|
@ds.filter(h).call(:first, @pgra).each{|k, v| v.must_be :==, @ra[k].to_a}
|
3237
|
-
@ds.filter(h).call(:first, r2).
|
3236
|
+
@ds.filter(h).call(:first, r2).must_be_nil
|
3238
3237
|
@ds.filter(h).call(:delete, @ra).must_equal 1
|
3239
3238
|
end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
|
3240
3239
|
|
@@ -3409,13 +3408,13 @@ describe 'PostgreSQL interval types' do
|
|
3409
3408
|
@ds.call(:insert, {:i=>d}, {:i=>:$i})
|
3410
3409
|
@ds.get(:i).must_equal d
|
3411
3410
|
@ds.filter(:i=>:$i).call(:first, :i=>d).must_equal(:i=>d)
|
3412
|
-
@ds.filter(:i=>Sequel.cast(:$i, :interval)).call(:first, :i=>'0').
|
3411
|
+
@ds.filter(:i=>Sequel.cast(:$i, :interval)).call(:first, :i=>'0').must_be_nil
|
3413
3412
|
@ds.filter(:i=>:$i).call(:delete, :i=>d).must_equal 1
|
3414
3413
|
|
3415
3414
|
@db.create_table!(:items){column :i, 'interval[]'}
|
3416
3415
|
@ds.call(:insert, {:i=>[d]}, {:i=>:$i})
|
3417
3416
|
@ds.filter(:i=>:$i).call(:first, :i=>[d]).must_equal(:i=>[d])
|
3418
|
-
@ds.filter(:i=>:$i).call(:first, :i=>[]).
|
3417
|
+
@ds.filter(:i=>:$i).call(:first, :i=>[]).must_be_nil
|
3419
3418
|
@ds.filter(:i=>:$i).call(:delete, :i=>[d]).must_equal 1
|
3420
3419
|
end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
|
3421
3420
|
|
@@ -3529,7 +3528,7 @@ describe 'PostgreSQL row-valued/composite types' do
|
|
3529
3528
|
@ds.call(:insert, {:address=>Sequel.pg_row(['123 Sesame St', 'Somewhere', '12345'])}, {:address=>:$address, :id=>1})
|
3530
3529
|
@ds.get(:address).must_equal(:street=>'123 Sesame St', :city=>'Somewhere', :zip=>'12345')
|
3531
3530
|
@ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>Sequel.pg_row(['123 Sesame St', 'Somewhere', '12345']))[:id].must_equal 1
|
3532
|
-
@ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>Sequel.pg_row(['123 Sesame St', 'Somewhere', '12356'])).
|
3531
|
+
@ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>Sequel.pg_row(['123 Sesame St', 'Somewhere', '12356'])).must_be_nil
|
3533
3532
|
|
3534
3533
|
@ds.delete
|
3535
3534
|
@ds.call(:insert, {:address=>Sequel.pg_row([nil, nil, nil])}, {:address=>:$address, :id=>1})
|
@@ -3541,7 +3540,7 @@ describe 'PostgreSQL row-valued/composite types' do
|
|
3541
3540
|
@ds.call(:insert, {:employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row(['123 Sesame St', 'Somewhere', '12345'])])])}, {:employees=>:$employees, :id=>1})
|
3542
3541
|
@ds.get(:company).must_equal(:id=>1, :employees=>[{:id=>1, :address=>{:street=>'123 Sesame St', :city=>'Somewhere', :zip=>'12345'}}])
|
3543
3542
|
@ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row(['123 Sesame St', 'Somewhere', '12345'])])]))[:id].must_equal 1
|
3544
|
-
@ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row(['123 Sesame St', 'Somewhere', '12356'])])])).
|
3543
|
+
@ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row(['123 Sesame St', 'Somewhere', '12356'])])])).must_be_nil
|
3545
3544
|
|
3546
3545
|
@ds.delete
|
3547
3546
|
@ds.call(:insert, {:employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row([nil, nil, nil])])])}, {:employees=>:$employees, :id=>1})
|
@@ -3671,7 +3670,7 @@ describe 'PostgreSQL row-valued/composite types' do
|
|
3671
3670
|
@ds.call(:insert, {:address=>@a}, {:address=>:$address, :id=>1})
|
3672
3671
|
@ds.get(:address).must_equal @a
|
3673
3672
|
@ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>@a)[:id].must_equal 1
|
3674
|
-
@ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>Address.new(:street=>'123 Sesame St', :city=>'Somewhere', :zip=>'12356')).
|
3673
|
+
@ds.filter(:address=>Sequel.cast(:$address, :address)).call(:first, :address=>Address.new(:street=>'123 Sesame St', :city=>'Somewhere', :zip=>'12356')).must_be_nil
|
3675
3674
|
end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
|
3676
3675
|
|
3677
3676
|
it 'use arrays of model objects in bound variables' do
|
@@ -3679,7 +3678,7 @@ describe 'PostgreSQL row-valued/composite types' do
|
|
3679
3678
|
@ds.call(:insert, {:employees=>@es}, {:employees=>:$employees, :id=>1})
|
3680
3679
|
@ds.get(:company).must_equal Company.new(:id=>1, :employees=>@es)
|
3681
3680
|
@ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>@es)[:id].must_equal 1
|
3682
|
-
@ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row(['123 Sesame St', 'Somewhere', '12356'])])])).
|
3681
|
+
@ds.filter(:employees=>Sequel.cast(:$employees, 'person[]')).call(:first, :employees=>Sequel.pg_array([@db.row_type(:person, [1, Sequel.pg_row(['123 Sesame St', 'Somewhere', '12356'])])])).must_be_nil
|
3683
3682
|
end if (DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG) || DB.adapter_scheme == :jdbc
|
3684
3683
|
|
3685
3684
|
it 'model typecasting' do
|
@@ -3822,7 +3821,7 @@ describe "PostgreSQL stored procedures for datasets" do
|
|
3822
3821
|
|
3823
3822
|
it "should correctly call stored procedure for inserting record" do
|
3824
3823
|
result = @ds.call_sproc(:insert, :insert_item, 100)
|
3825
|
-
result.
|
3824
|
+
result.must_be_nil
|
3826
3825
|
|
3827
3826
|
@ds.call(:all).must_equal [{:id=>1, :numb=>100}]
|
3828
3827
|
end
|