sequel 5.5.0 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34e1f1ee3e3e1b863d4efbc3710cae912ae394a655b6e9fed41325f02d54f23e
4
- data.tar.gz: af6f231e63231de19bb7956ea16cff29ec2faebe379a0ba86e12df933af0b91b
3
+ metadata.gz: 22f13ee2ed2a19be6277fbe8092c8e450e241e57acac0c950aa5d8d9c8c49782
4
+ data.tar.gz: e8d0938b3a2998bb46e09bbab86c7a0e669d87b8bde8f5b39f43be9ce2cc6a41
5
5
  SHA512:
6
- metadata.gz: d2f482f59fe3bb9eb19d2fa88a6fccfdf5e259cb23a52e2d21c3bb692f4f3a04339c2011922a03ceb4593b4a2708fbafdd45dbde2a882f7f77d20a3e2048e000
7
- data.tar.gz: 19e9f635bcdb299673ab5d042159f7e76dbdee1807fd02b8e897c434e6ad11214113ac252064106507620ae3e9a19d3facb49d181ab28cc08e47c5a5b2ebfa65
6
+ metadata.gz: 48f505592a3d093fd3a355011c08c1eb971f47ef6aa56a80510c4de88009a3e52739d2294f1c03b3a60243632e53b9d4cd218c4d5f96efdce5c78bf2b029c3ba
7
+ data.tar.gz: dfb7034d9f9c358f6b8a90fd0164e4ff503571445ce3d25afc99be3e873631acc45ea3bdf964680d0a5b6bc92b58fd9807117278adea6d984f89a4368ac1a75a
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
1
+ === 5.6.0 (2018-03-01)
2
+
3
+ * Dedup :db_type strings in schema hashes on Ruby 2.5+ (jeremyevans)
4
+
5
+ * Make schema_caching extension work with :callable_default schema values (jeremyevans)
6
+
7
+ * Freeze string valuse in hashes returned by Database#schema when using the schema_caching extension (jeremyevans)
8
+
9
+ * Protect migration file loading with a mutex to not break when multiple threads load migration files simultaneously (jeremyevans)
10
+
11
+ * Respect identifier mangling rules when renaming columns on Microsoft SQL Server (jeremyevans)
12
+
1
13
  === 5.5.0 (2018-01-31)
2
14
 
3
15
  * Make Database#copy_table in the postgres adapter handle errors that occur while processing rows (jeremyevans) (#1470)
@@ -0,0 +1,31 @@
1
+ = Improvements
2
+
3
+ * Running migrations using one of the included migrators on separate
4
+ Database objects in separate threads simultaneously is now
5
+ supported. Previously, the migrators were not thread-safe.
6
+
7
+ * On Ruby 2.5+, :db_type entries in the schema hashes are now deduped
8
+ for a slight memory savings when using many columns with the same
9
+ database type.
10
+
11
+ * The schema_caching extension now freezes string values in the
12
+ resulting hashes, just as the default schema parsing code started
13
+ doing in 5.5.0.
14
+
15
+ * The schema_caching extension now supports the :callable_default
16
+ schema values used by the pg_json, pg_array, and pg_hstore
17
+ extensions, by removing the entry before caching and resetting it
18
+ after restoring the cache.
19
+
20
+ * Identifier mangling rules are now respected when renaming columns on
21
+ Microsoft SQL Server.
22
+
23
+ = Backwards Compatibility
24
+
25
+ * The migrator internals were modified in order to support
26
+ thread-safety. The private Migrator#remove_migration_classes
27
+ method has been removed, and #load_migration_file now returns the
28
+ migration object/class instead of populating Migration.descendants.
29
+ Migration.descendants is now only used for temporary storage, and
30
+ will no longer contain all migration objects/classes used by the
31
+ migrator.
@@ -260,7 +260,7 @@ module Sequel
260
260
  add_drop_default_constraint_sql(sqls, table, op[:name])
261
261
  sqls << super
262
262
  when :rename_column
263
- "sp_rename #{literal("#{quote_schema_table(table)}.#{quote_identifier(op[:name])}")}, #{literal(op[:new_name].to_s)}, 'COLUMN'"
263
+ "sp_rename #{literal("#{quote_schema_table(table)}.#{quote_identifier(op[:name])}")}, #{literal(metadata_dataset.with_quote_identifiers(false).quote_identifier(op[:new_name]))}, 'COLUMN'"
264
264
  when :set_column_type
265
265
  sqls = []
266
266
  if sch = schema(table)
@@ -175,11 +175,9 @@ module Sequel
175
175
  if !c[:max_length] && c[:type] == :string && (max_length = column_schema_max_length(c[:db_type]))
176
176
  c[:max_length] = max_length
177
177
  end
178
-
179
- c.each_value do |v|
180
- v.freeze if v.is_a?(String)
181
- end
182
178
  end
179
+ schema_post_process(cols)
180
+
183
181
  Sequel.synchronize{@schemas[quoted_name] = cols} if cache_schema
184
182
  cols
185
183
  end
@@ -343,5 +341,23 @@ module Sequel
343
341
  :enum
344
342
  end
345
343
  end
344
+
345
+ # Post process the schema values.
346
+ def schema_post_process(cols)
347
+ if RUBY_VERSION >= '2.5'
348
+ cols.each do |_, h|
349
+ db_type = h[:db_type]
350
+ if db_type.is_a?(String)
351
+ h[:db_type] = -db_type
352
+ end
353
+ end
354
+ end
355
+
356
+ cols.each do |_,c|
357
+ c.each_value do |val|
358
+ val.freeze if val.is_a?(String)
359
+ end
360
+ end
361
+ end
346
362
  end
347
363
  end
@@ -352,6 +352,9 @@ module Sequel
352
352
  class Migrator
353
353
  MIGRATION_FILE_PATTERN = /\A(\d+)_.+\.rb\z/i.freeze
354
354
 
355
+ # Mutex used around migration file loading
356
+ MUTEX = Mutex.new
357
+
355
358
  # Exception class raised when there is an error with the migrator's
356
359
  # file structure, database, or arguments.
357
360
  class Error < Sequel::Error
@@ -476,19 +479,16 @@ module Sequel
476
479
  # Load the migration file, raising an exception if the file does not define
477
480
  # a single migration.
478
481
  def load_migration_file(file)
479
- n = Migration.descendants.length
480
- load(file)
481
- raise Error, "Migration file #{file.inspect} not containing a single migration detected" unless n + 1 == Migration.descendants.length
482
- end
483
-
484
- # Remove all migration classes. Done by the migrator to ensure that
485
- # the correct migration classes are picked up.
486
- def remove_migration_classes
487
- # Remove class definitions
488
- Migration.descendants.each do |c|
489
- Object.send(:remove_const, c.name) if c.is_a?(Class) && !c.name.to_s.empty? && Object.const_defined?(c.name)
482
+ MUTEX.synchronize do
483
+ n = Migration.descendants.length
484
+ load(file)
485
+ raise Error, "Migration file #{file.inspect} not containing a single migration detected" unless n + 1 == Migration.descendants.length
486
+ c = Migration.descendants.pop
487
+ if c.is_a?(Class) && !c.name.to_s.empty? && Object.const_defined?(c.name)
488
+ Object.send(:remove_const, c.name)
489
+ end
490
+ c
490
491
  end
491
- Migration.descendants.clear # remove any defined migration classes
492
492
  end
493
493
 
494
494
  # Return the integer migration version based on the filename.
@@ -597,13 +597,7 @@ module Sequel
597
597
  # Returns a list of migration classes filtered for the migration range and
598
598
  # ordered according to the migration direction.
599
599
  def get_migrations
600
- remove_migration_classes
601
-
602
- # load migration files
603
- version_numbers.each{|n| load_migration_file(files[n])}
604
-
605
- # get migration classes
606
- Migration.descendants
600
+ version_numbers.map{|n| load_migration_file(files[n])}
607
601
  end
608
602
 
609
603
  # Returns the latest version available in the specified directory.
@@ -740,7 +734,6 @@ module Sequel
740
734
 
741
735
  # Returns tuples of migration, filename, and direction
742
736
  def get_migration_tuples
743
- remove_migration_classes
744
737
  up_mts = []
745
738
  down_mts = []
746
739
  ms = Migration.descendants
@@ -750,16 +743,13 @@ module Sequel
750
743
  if target
751
744
  if migration_version_from_file(f) > target
752
745
  if applied_migrations.include?(fi)
753
- load_migration_file(path)
754
- down_mts << [ms.last, f, :down]
746
+ down_mts << [load_migration_file(path), f, :down]
755
747
  end
756
748
  elsif !applied_migrations.include?(fi)
757
- load_migration_file(path)
758
- up_mts << [ms.last, f, :up]
749
+ up_mts << [load_migration_file(path), f, :up]
759
750
  end
760
751
  elsif !applied_migrations.include?(fi)
761
- load_migration_file(path)
762
- up_mts << [ms.last, f, :up]
752
+ up_mts << [load_migration_file(path), f, :up]
763
753
  end
764
754
  end
765
755
  up_mts + down_mts.reverse
@@ -254,7 +254,7 @@ module Sequel
254
254
  end
255
255
 
256
256
  # Set the :callable_default value if the default value is recognized as an empty array.
257
- def schema_parse_table(*)
257
+ def schema_post_process(_)
258
258
  super.each do |a|
259
259
  h = a[1]
260
260
  if h[:default] =~ /\A(?:'\{\}'|ARRAY\[\])::([\w ]+)\[\]\z/
@@ -131,7 +131,7 @@ module Sequel
131
131
 
132
132
  # For schema entries that are enums, set the type to
133
133
  # :enum and add a :enum_values entry with the enum values.
134
- def schema_parse_table(*)
134
+ def schema_post_process(_)
135
135
  super.each do |_, s|
136
136
  if values = @enum_labels[s[:oid]]
137
137
  s[:type] = :enum
@@ -155,7 +155,7 @@ module Sequel
155
155
  end
156
156
 
157
157
  # Set the :callable_default value if the default value is recognized as an empty hstore.
158
- def schema_parse_table(*)
158
+ def schema_post_process(_)
159
159
  super.each do |a|
160
160
  h = a[1]
161
161
  if h[:type] == :hstore && h[:default] =~ /\A''::hstore\z/
@@ -86,7 +86,7 @@ module Sequel
86
86
  end
87
87
 
88
88
  # Set the :ruby_default value if the default value is recognized as an ip address.
89
- def schema_parse_table(*)
89
+ def schema_post_process(_)
90
90
  super.each do |a|
91
91
  h = a[1]
92
92
  if h[:type] == :ipaddr && h[:default] =~ /\A'([:a-fA-F0-9\.\/]+)'::(?:inet|cidr)\z/
@@ -147,7 +147,7 @@ module Sequel
147
147
  end
148
148
 
149
149
  # Set the :ruby_default value if the default value is recognized as an interval.
150
- def schema_parse_table(*)
150
+ def schema_post_process(_)
151
151
  super.each do |a|
152
152
  h = a[1]
153
153
  if h[:type] == :interval && h[:default] =~ /\A'([\w ]+)'::interval\z/
@@ -215,7 +215,7 @@ module Sequel
215
215
  end
216
216
 
217
217
  # Set the :callable_default value if the default value is recognized as an empty json/jsonb array/hash.
218
- def schema_parse_table(*)
218
+ def schema_post_process(_)
219
219
  super.each do |a|
220
220
  h = a[1]
221
221
  if (h[:type] == :json || h[:type] == :jsonb) && h[:default] =~ /\A'(\{\}|\[\])'::jsonb?\z/
@@ -263,14 +263,14 @@ module Sequel
263
263
  end
264
264
 
265
265
  # Set the :ruby_default value if the default value is recognized as a range.
266
- def schema_parse_table(*)
266
+ def schema_post_process(_)
267
267
  super.each do |a|
268
268
  h = a[1]
269
269
  db_type = h[:db_type]
270
270
  if @pg_range_schema_types[db_type] && h[:default] =~ /\A'([^']+)'::#{db_type}\z/
271
271
  default = $1
272
272
  if convertor = conversion_procs[h[:oid]]
273
- h[:ruby_default] = convertor.call($1)
273
+ h[:ruby_default] = convertor.call(default)
274
274
  end
275
275
  end
276
276
  end
@@ -51,7 +51,15 @@ module Sequel
51
51
  module SchemaCaching
52
52
  # Dump the cached schema to the filename given in Marshal format.
53
53
  def dump_schema_cache(file)
54
- File.open(file, 'wb'){|f| f.write(Marshal.dump(@schemas))}
54
+ sch = {}
55
+ @schemas.each do |k,v|
56
+ sch[k] = v.map do |c, h|
57
+ h = Hash[h]
58
+ h.delete(:callable_default)
59
+ [c, h]
60
+ end
61
+ end
62
+ File.open(file, 'wb'){|f| f.write(Marshal.dump(sch))}
55
63
  nil
56
64
  end
57
65
 
@@ -65,6 +73,7 @@ module Sequel
65
73
  # should be in Marshal format.
66
74
  def load_schema_cache(file)
67
75
  @schemas = Marshal.load(File.read(file))
76
+ @schemas.each_value{|v| schema_post_process(v)}
68
77
  nil
69
78
  end
70
79
 
@@ -5,7 +5,7 @@ module Sequel
5
5
  MAJOR = 5
6
6
  # The minor version of Sequel. Bumped for every non-patch level
7
7
  # release, generally around once a month.
8
- MINOR = 5
8
+ MINOR = 6
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
@@ -788,7 +788,7 @@ describe "A PostgreSQL dataset with a timestamp field" do
788
788
  @db.convert_infinite_timestamps = :string
789
789
  @db[:test3].get(:time).must_equal '-infinity'
790
790
  @db.convert_infinite_timestamps = :date
791
- @db[:test3].get(:time).must_equal -Date::Infinity.new
791
+ @db[:test3].get(:time).must_equal(-Date::Infinity.new)
792
792
  @db.convert_infinite_timestamps = :float
793
793
  @db[:test3].get(:time).must_equal(-1.0/0.0)
794
794
  end
@@ -354,16 +354,16 @@ ThreadedConnectionPoolSpecs = shared_description do
354
354
  @pool.disconnect
355
355
  b = @icpp
356
356
 
357
- t = Time.now
357
+ time = Time.now
358
358
  cc = {}
359
359
  threads = []
360
360
  results = []
361
- i = 0
361
+ j = 0
362
362
  q, q1, q2, q3, q4 = Queue.new, Queue.new, Queue.new, Queue.new, Queue.new
363
363
  m = @m
364
364
  @pool.db.define_singleton_method(:connect) do |server|
365
365
  q1.pop
366
- m.synchronize{q3.push(i += 1)}
366
+ m.synchronize{q3.push(j += 1)}
367
367
  q4.pop
368
368
  b.call
369
369
  end
@@ -375,7 +375,7 @@ ThreadedConnectionPoolSpecs = shared_description do
375
375
  5.times{|i| q.pop}
376
376
  results.sort.must_equal (1..5).to_a
377
377
  threads.each(&:join)
378
- (Time.now - t).must_be :<, 0.75
378
+ (Time.now - time).must_be :<, 0.75
379
379
 
380
380
  threads.each{|t| t.wont_be :alive?}
381
381
  cc.size.must_equal 5
@@ -1672,6 +1672,15 @@ describe "Schema Parser" do
1672
1672
  @sqls.must_equal ['x', 'x']
1673
1673
  end
1674
1674
 
1675
+ it "should dedup :db_type strings" do
1676
+ @db.define_singleton_method(:schema_parse_table) do |t, opts|
1677
+ [[:a, {:db_type=>t.to_s.dup}], [:b, {:db_type=>t.to_s.dup}]]
1678
+ end
1679
+ sch = @db.schema(:x)
1680
+ sch.must_equal [[:a, {:db_type=>"x", :ruby_default=>nil}], [:b, {:db_type=>"x", :ruby_default=>nil}]]
1681
+ sch[0][1][:db_type].must_be_same_as(sch[1][1][:db_type])
1682
+ end if RUBY_VERSION >= '2.5'
1683
+
1675
1684
  it "should set :auto_increment to true by default if unset and a single integer primary key is used" do
1676
1685
  @db.define_singleton_method(:schema_parse_table){|*| [[:a, {:primary_key=>true, :db_type=>'integer'}]]}
1677
1686
  @db.schema(:x).first.last[:auto_increment].must_equal true
@@ -1,3 +1,5 @@
1
+ require_relative "sequel_warning"
2
+
1
3
  if ENV['COVERAGE']
2
4
  require_relative "sequel_coverage"
3
5
  SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/extensions/core_extensions\.rb\z})
@@ -266,7 +266,7 @@ describe "Sequel::Plugins::AssociationPks" do
266
266
  it "should not automatically convert keys to numbers if the primary key is an integer for many_to_many associations" do
267
267
  @Tag.db_schema[:id][:type] = :string
268
268
  @Album.load(:id=>2).tag_pks = %w'1 3'
269
- sqls = @db.sqls.must_equal [
269
+ @db.sqls.must_equal [
270
270
  "DELETE FROM albums_tags WHERE ((album_id = 2) AND (tag_id NOT IN ('1', '3')))",
271
271
  'SELECT tag_id FROM albums_tags WHERE (album_id = 2)',
272
272
  'BEGIN',
@@ -463,11 +463,10 @@ end
463
463
 
464
464
  describe "Sequel::TimestampMigrator" do
465
465
  before do
466
- sequel_migration_version = 0
467
466
  @dsc = dsc = Class.new(Sequel::Mock::Dataset) do
468
- self::FILES =[]
469
- define_method(:sequel_migration_version){sequel_migration_version}
470
- define_method(:sequel_migration_version=){|v| sequel_migration_version = v}
467
+ def files
468
+ db.files
469
+ end
471
470
 
472
471
  def columns
473
472
  super
@@ -485,11 +484,11 @@ describe "Sequel::TimestampMigrator" do
485
484
  super
486
485
  case opts[:from].first
487
486
  when :schema_info, 'schema_info'
488
- yield({:version=>sequel_migration_version})
487
+ yield({:version=>db.sequel_migration_version})
489
488
  when :schema_migrations, 'schema_migrations'
490
- self.class::FILES.sort.each{|f| yield(:filename=>f)}
489
+ files.sort.each{|f| yield(:filename=>f)}
491
490
  when :sm, 'sm'
492
- self.class::FILES.sort.each{|f| yield(:fn=>f)}
491
+ files.sort.each{|f| yield(:fn=>f)}
493
492
  end
494
493
  end
495
494
 
@@ -497,9 +496,9 @@ describe "Sequel::TimestampMigrator" do
497
496
  super
498
497
  case opts[:from].first
499
498
  when :schema_info, 'schema_info'
500
- self.sequel_migration_version = h.values.first
499
+ db.sequel_migration_version = h.values.first
501
500
  when :schema_migrations, :sm, 'schema_migrations', 'sm'
502
- self.class::FILES << h.values.first
501
+ files << h.values.first
503
502
  end
504
503
  end
505
504
 
@@ -507,7 +506,7 @@ describe "Sequel::TimestampMigrator" do
507
506
  super
508
507
  case opts[:from].first
509
508
  when :schema_info, 'schema_info'
510
- self.sequel_migration_version = h.values.first
509
+ db.sequel_migration_version = h.values.first
511
510
  end
512
511
  end
513
512
 
@@ -515,15 +514,27 @@ describe "Sequel::TimestampMigrator" do
515
514
  super
516
515
  case opts[:from].first
517
516
  when :schema_migrations, :sm, 'schema_migrations', 'sm'
518
- self.class::FILES.delete(opts[:where].args.last)
517
+ files.delete(opts[:where].args.last)
519
518
  end
520
519
  end
521
520
  end
522
521
  dbc = Class.new(Sequel::Mock::Database) do
523
- self::Tables = tables= {}
522
+ def files
523
+ @files ||= []
524
+ end
525
+
526
+ def tables
527
+ @tables ||= {}
528
+ end
529
+
530
+ def sequel_migration_version
531
+ @sequel_migration_version ||= 0
532
+ end
533
+ attr_writer :sequel_migration_version
534
+
524
535
  def create_table(name, *args, &block)
525
536
  super
526
- self.class::Tables[name.to_sym] = true
537
+ tables[name.to_sym] = true
527
538
  end
528
539
  define_method(:drop_table){|*names| super(*names); names.each{|n| tables.delete(n.to_sym)}}
529
540
  define_method(:table_exists?){|name| super(name); tables.has_key?(name.to_sym)}
@@ -569,6 +580,31 @@ describe "Sequel::TimestampMigrator" do
569
580
  @db[:schema_migrations].select_order_map(:filename).must_equal %w'1273253849_create_sessions.rb'
570
581
  end
571
582
 
583
+ it "should work correctly when multithreaded" do
584
+ range = 0..4
585
+ dbs = range.map do
586
+ db = @db.class.new
587
+ db.dataset_class = @db.dataset_class
588
+ db
589
+ end
590
+
591
+ q1, q2 = Queue.new, Queue.new
592
+ @dir = 'spec/files/timestamped_migrations'
593
+ threads = dbs.map do |db|
594
+ Thread.new do
595
+ q1.pop
596
+ @m.apply(db, @dir)
597
+ [:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| _(db.table_exists?(n)).must_equal true}
598
+ _(db[:schema_migrations].select_order_map(:filename)).must_equal %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb 1273253853_3_create_users.rb'
599
+ q2.push db
600
+ end
601
+ end
602
+
603
+ range.each{q1.push nil}
604
+ (dbs - range.map{q2.pop}).must_be :empty?
605
+ threads.each(&:join)
606
+ end
607
+
572
608
  it "should not be current when there are migrations to apply" do
573
609
  @dir = 'spec/files/timestamped_migrations'
574
610
  @m.apply(@db, @dir)
@@ -53,16 +53,16 @@ describe "pg_extended_date_support extension" do
53
53
  @db.convert_infinite_timestamps = v
54
54
  d.(pi).must_equal Date::Infinity.new
55
55
  t.(pi).must_equal Date::Infinity.new
56
- d.(ni).must_equal -Date::Infinity.new
57
- t.(ni).must_equal -Date::Infinity.new
56
+ d.(ni).must_equal(-Date::Infinity.new)
57
+ t.(ni).must_equal(-Date::Infinity.new)
58
58
  end
59
59
 
60
60
  [:float, 'float', 't', true].each do |v|
61
61
  @db.convert_infinite_timestamps = v
62
62
  d.(pi).must_equal 1.0/0.0
63
63
  t.(pi).must_equal 1.0/0.0
64
- d.(ni).must_equal -1.0/0.0
65
- t.(ni).must_equal -1.0/0.0
64
+ d.(ni).must_equal(-1.0/0.0)
65
+ t.(ni).must_equal(-1.0/0.0)
66
66
  end
67
67
 
68
68
  ['f', false].each do |v|
@@ -91,7 +91,7 @@ describe "pg_json extension" do
91
91
  @db.literal(Sequel.pg_json('a'=>'b')).must_equal "'{\"a\":\"b\"}'::json"
92
92
  end
93
93
 
94
- it "should literalize JSONHash and JSONArray to strings correctly" do
94
+ it "should literalize JSONBHash and JSONBArray to strings correctly" do
95
95
  @db.literal(Sequel.pg_jsonb([])).must_equal "'[]'::jsonb"
96
96
  @db.literal(Sequel.pg_jsonb([1, [2], {'a'=>'b'}])).must_equal "'[1,[2],{\"a\":\"b\"}]'::jsonb"
97
97
  @db.literal(Sequel.pg_jsonb({})).must_equal "'{}'::jsonb"
@@ -18,6 +18,18 @@ describe "schema_caching extension" do
18
18
  File.size(@filename).must_be :>, 0
19
19
  end
20
20
 
21
+ it "Database#dump_schema_cache/load_schema_cache should work with :callable_default values set in schema_post_process" do
22
+ @schemas['"table"'][0][1][:callable_default] = lambda{1}
23
+ @schemas['"table"'][0][1][:default] = 'call_1'
24
+ @db.dump_schema_cache(@filename)
25
+ db = Sequel.mock(:host=>'postgres').extension(:schema_caching)
26
+ def db.schema_post_process(_)
27
+ super.each{|_, c| c[:callable_default] = lambda{1} if c[:default] == 'call_1'}
28
+ end
29
+ db.load_schema_cache(@filename)
30
+ db.schema(:table)[0][1][:callable_default].call.must_equal 1
31
+ end
32
+
21
33
  it "Database#load_schema_cache should load cached schema from the given file dumped by #dump_schema_cache" do
22
34
  @db.dump_schema_cache(@filename)
23
35
  db = Sequel::Database.new.extension(:schema_caching)
@@ -25,6 +37,17 @@ describe "schema_caching extension" do
25
37
  @db.instance_variable_get(:@schemas).must_equal @schemas
26
38
  end
27
39
 
40
+ it "Database#load_schema_cache should have frozen string values in the schema caches" do
41
+ @db.dump_schema_cache(@filename)
42
+ db = Sequel.mock(:host=>'postgres').extension(:schema_caching)
43
+ db.load_schema_cache(@filename)
44
+ h = db.schema(:table)[0][1]
45
+ h[:db_type].must_equal 'integer'
46
+ h[:db_type].frozen?.must_equal true
47
+ h[:default].must_equal "nextval('table_id_seq'::regclass)"
48
+ h[:default].frozen?.must_equal true
49
+ end
50
+
28
51
  it "Database#dump_schema_cache? should dump cached schema to the given file unless the file exists" do
29
52
  File.open(@filename, 'wb'){|f|}
30
53
  File.size(@filename).must_equal 0
@@ -28,7 +28,7 @@ describe "synchronize_sql extension" do
28
28
  end
29
29
 
30
30
  it 'does not checkout a connection if SQL is given as a string' do
31
- extds = @ds.extension(:synchronize_sql).with_sql('SELECT 1').sql
31
+ @ds.extension(:synchronize_sql).with_sql('SELECT 1').sql
32
32
  @db.pool.times_connection_acquired.must_equal 0
33
33
  end
34
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -256,6 +256,7 @@ extra_rdoc_files:
256
256
  - doc/release_notes/5.3.0.txt
257
257
  - doc/release_notes/5.4.0.txt
258
258
  - doc/release_notes/5.5.0.txt
259
+ - doc/release_notes/5.6.0.txt
259
260
  files:
260
261
  - CHANGELOG
261
262
  - MIT-LICENSE
@@ -406,6 +407,7 @@ files:
406
407
  - doc/release_notes/5.3.0.txt
407
408
  - doc/release_notes/5.4.0.txt
408
409
  - doc/release_notes/5.5.0.txt
410
+ - doc/release_notes/5.6.0.txt
409
411
  - doc/schema_modification.rdoc
410
412
  - doc/security.rdoc
411
413
  - doc/sharding.rdoc