sequel 5.0.0 → 5.1.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 +20 -0
- data/doc/advanced_associations.rdoc +5 -5
- data/doc/association_basics.rdoc +2 -2
- data/doc/release_notes/5.1.0.txt +31 -0
- data/lib/sequel/adapters/jdbc/h2.rb +2 -1
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -1
- data/lib/sequel/adapters/jdbc/postgresql.rb +6 -2
- data/lib/sequel/database/schema_generator.rb +4 -0
- data/lib/sequel/dataset/actions.rb +4 -0
- data/lib/sequel/extensions/migration.rb +4 -3
- data/lib/sequel/extensions/pg_inet.rb +1 -1
- data/lib/sequel/model/associations.rb +1 -1
- data/lib/sequel/model/base.rb +2 -53
- data/lib/sequel/plugins/class_table_inheritance.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/postgres_spec.rb +25 -1
- data/spec/core/schema_spec.rb +14 -0
- data/spec/extensions/migration_spec.rb +10 -0
- data/spec/integration/prepared_statement_test.rb +2 -2
- data/spec/integration/schema_test.rb +1 -1
- data/spec/model/model_spec.rb +5 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d380edb41288b7e5fd091c8ffd8215b9a8c0a8b2
|
4
|
+
data.tar.gz: e4c34f33035f7e2354f53e264683a60337c66d28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a18ccd0f5974af2610e2d274963b83fdba2aab99559c3e1cf2bceba99d890d6d4c0dda13c0c6b2f9fba913f41ba39983d65df52e39651e745fa86a1097c3c003
|
7
|
+
data.tar.gz: ac9efe8f2e33539d322b94b6e9e76cadf64091a2af6958bdbdd8e67bea691849382c5aae0032b29498ab4d3b9c4ddf599737be8170d6f435fd03028fbcfc1019
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
=== 5.1.0 (2017-10-01)
|
2
|
+
|
3
|
+
* Make jdbc/h2 and jdbc/hsqldb adapters respect :foreign_key_constraint_name option when adding new foreign key column (jeremyevans)
|
4
|
+
|
5
|
+
* Do not issue unnecessary query for macaddr type oid when loading the pg_inet extension (jeltz) (#1423)
|
6
|
+
|
7
|
+
* Make alter_table add_foreign_key with a column symbol reversible when using the :foreign_key_constraint_name option (jeremyevans) (#1422)
|
8
|
+
|
9
|
+
* Do not raise an error if calling Model.freeze on a frozen model (jeremyevans) (#1421)
|
10
|
+
|
11
|
+
* Make Database#copy_into in the jdbc/postgresql adapter handle multi-byte strings (ckoenig) (#1416)
|
12
|
+
|
13
|
+
* Remove deprecated Model use_after_commit_rollback class and instance methods (jeremyevans)
|
14
|
+
|
15
|
+
* Remove deprecated Model.allowed_columns method in the base model support (jeremyevans)
|
16
|
+
|
17
|
+
* Remove deprecated Model.plugin_module_defined? private method (jeremyevans)
|
18
|
+
|
19
|
+
* Remove deprecated support for Model#_before_validation private method (jeremyevans)
|
20
|
+
|
1
21
|
=== 5.0.0 (2017-09-01)
|
2
22
|
|
3
23
|
* Make bin/sequel -M option always use base 10 (jeremyevans)
|
@@ -710,14 +710,14 @@ name, with no duplicates?
|
|
710
710
|
ids = h.keys
|
711
711
|
eo[:rows].each{|r| r.associations[:songs] = []}
|
712
712
|
Song.select_all(:songs).
|
713
|
-
select_append{[lyrics[:composer_id], lyrics[:arranger_id], lyrics[:vocalist_id], lyrics[:lyricist_id]}.
|
713
|
+
select_append{[lyrics[:composer_id], lyrics[:arranger_id], lyrics[:vocalist_id], lyrics[:lyricist_id]]}.
|
714
714
|
join(:lyrics, id: :lyric_id){Sequel.or(composer_id: ids, arranger_id: ids, vocalist_id: ids, lyricist_id: ids)}.
|
715
715
|
order{songs[:name]}.all do |song|
|
716
|
-
|
717
|
-
|
718
|
-
|
716
|
+
[:composer_id, :arranger_id, :vocalist_id, :lyricist_id].each do |x|
|
717
|
+
recs = h[song.values.delete(x)]
|
718
|
+
recs.each{|r| r.associations[:songs] << song} if recs
|
719
|
+
end
|
719
720
|
end
|
720
|
-
end
|
721
721
|
eo[:rows].each{|r| r.associations[:songs].uniq!}
|
722
722
|
end)
|
723
723
|
end
|
data/doc/association_basics.rdoc
CHANGED
@@ -1551,11 +1551,11 @@ extensions.
|
|
1551
1551
|
# :id <----- :meta -------> :id
|
1552
1552
|
# :name :name
|
1553
1553
|
class Album < Sequel::Model
|
1554
|
-
many_to_many :artists, left_key: Sequel.pg_jsonb(:meta)['album_id'].cast(String).cast(Integer)
|
1554
|
+
many_to_many :artists, left_key: Sequel.pg_jsonb(:meta)['album_id'].cast(String).cast(Integer),
|
1555
1555
|
right_key: Sequel.pg_jsonb(:meta)['artist_id'].cast(String).cast(Integer)
|
1556
1556
|
end
|
1557
1557
|
class Artist < Sequel::Model
|
1558
|
-
many_to_many :albums, left_key: Sequel.pg_jsonb(:meta)['artist_id'].cast(String).cast(Integer)
|
1558
|
+
many_to_many :albums, left_key: Sequel.pg_jsonb(:meta)['artist_id'].cast(String).cast(Integer),
|
1559
1559
|
right_key: Sequel.pg_jsonb(:meta)['album_id'].cast(String).cast(Integer)
|
1560
1560
|
end
|
1561
1561
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
= Improvements
|
2
|
+
|
3
|
+
* Database#copy_into in the jdbc/postgresql adapter now works
|
4
|
+
correctly when using multibyte characters in strings.
|
5
|
+
|
6
|
+
* The alter_table add_foreign_key method is now reversible when the
|
7
|
+
:foreign_key_constraint_name option is used.
|
8
|
+
|
9
|
+
* The jdbc/h2 and jdbc/hsqldb adapters now respect the
|
10
|
+
:foreign_key_constraint_name option.
|
11
|
+
|
12
|
+
* Calling Model.freeze on an already frozen model no longer raises
|
13
|
+
an error.
|
14
|
+
|
15
|
+
* An unnecessary database query is now avoided when loading the
|
16
|
+
pg_inet extension when the pg_array extension is already loaded.
|
17
|
+
|
18
|
+
* A better exception message is now used when migrating with an
|
19
|
+
empty migration directory.
|
20
|
+
|
21
|
+
= Backwards Compatibility
|
22
|
+
|
23
|
+
* Model.allowed_columns has been removed. Use the whitelist_security
|
24
|
+
plugin if you want to call it.
|
25
|
+
|
26
|
+
* Model use_after_commit_rollback class and instance accessors have
|
27
|
+
been removed.
|
28
|
+
|
29
|
+
* Support for the Model#_before_validation method has been removed.
|
30
|
+
|
31
|
+
* The private Model.plugin_module_defined? method has been removed.
|
@@ -89,7 +89,8 @@ module Sequel
|
|
89
89
|
|
90
90
|
if ref
|
91
91
|
op[:table] = ref
|
92
|
-
|
92
|
+
constraint_name = op[:foreign_key_constraint_name]
|
93
|
+
sqls << "ALTER TABLE #{quote_schema_table(table)} ADD#{" CONSTRAINT #{quote_identifier(constraint_name)}" if constraint_name} FOREIGN KEY (#{quote_identifier(op[:name])}) #{column_references_sql(op)}"
|
93
94
|
end
|
94
95
|
|
95
96
|
sqls
|
@@ -53,7 +53,7 @@ module Sequel
|
|
53
53
|
when :add_column
|
54
54
|
if op[:table]
|
55
55
|
[super(table, op.merge(:table=>nil)),
|
56
|
-
alter_table_sql(table, op.merge(:op=>:add_constraint, :type=>:foreign_key, :name=>op[:
|
56
|
+
alter_table_sql(table, op.merge(:op=>:add_constraint, :type=>:foreign_key, :name=>op[:foreign_key_constraint_name], :columns=>[op[:name]], :table=>op[:table]))]
|
57
57
|
else
|
58
58
|
super
|
59
59
|
end
|
@@ -65,10 +65,14 @@ module Sequel
|
|
65
65
|
copier = copy_manager.copy_in(copy_into_sql(table, opts))
|
66
66
|
if block_given?
|
67
67
|
while buf = yield
|
68
|
-
|
68
|
+
java_bytes = buf.to_java_bytes
|
69
|
+
copier.writeToCopy(java_bytes, 0, java_bytes.length)
|
69
70
|
end
|
70
71
|
else
|
71
|
-
data.each
|
72
|
+
data.each do |d|
|
73
|
+
java_bytes = d.to_java_bytes
|
74
|
+
copier.writeToCopy(java_bytes, 0, java_bytes.length)
|
75
|
+
end
|
72
76
|
end
|
73
77
|
rescue Exception => e
|
74
78
|
copier.cancelCopy if copier
|
@@ -520,6 +520,10 @@ module Sequel
|
|
520
520
|
# drop_foreign_key(:artist_id) # DROP CONSTRAINT table_artist_id_fkey, DROP COLUMN artist_id
|
521
521
|
# drop_foreign_key([:name]) # DROP CONSTRAINT table_name_fkey
|
522
522
|
def drop_foreign_key(name, opts=OPTS)
|
523
|
+
if !name.is_a?(Array) && opts[:foreign_key_constraint_name]
|
524
|
+
opts = Hash[opts]
|
525
|
+
opts[:name] = opts[:foreign_key_constraint_name]
|
526
|
+
end
|
523
527
|
drop_composite_foreign_key(Array(name), opts)
|
524
528
|
drop_column(name) unless name.is_a?(Array)
|
525
529
|
end
|
@@ -494,6 +494,10 @@ module Sequel
|
|
494
494
|
# Sequel checks that the datasets using this method have an order, but it cannot
|
495
495
|
# ensure that the order is unambiguous.
|
496
496
|
#
|
497
|
+
# Note that this method is not safe to use on many adapters if you are
|
498
|
+
# running additional queries inside the provided block. If you are
|
499
|
+
# running queries inside the block, use a separate thread or shard inside +paged_each+.
|
500
|
+
#
|
497
501
|
# Options:
|
498
502
|
# :rows_per_fetch :: The number of rows to fetch per query. Defaults to 1000.
|
499
503
|
# :strategy :: The strategy to use for paging of results. By default this is :offset,
|
@@ -516,6 +516,8 @@ module Sequel
|
|
516
516
|
def initialize(db, directory, opts=OPTS)
|
517
517
|
super
|
518
518
|
@current = opts[:current] || current_migration_version
|
519
|
+
raise(Error, "No current version available") unless current
|
520
|
+
|
519
521
|
latest_version = latest_migration_version
|
520
522
|
|
521
523
|
@target = if opts[:target]
|
@@ -526,15 +528,14 @@ module Sequel
|
|
526
528
|
latest_version
|
527
529
|
end
|
528
530
|
|
531
|
+
raise(Error, "No target version available, probably because no migration files found or filenames don't follow the migration filename convention") unless target
|
532
|
+
|
529
533
|
if @target > latest_version
|
530
534
|
@target = latest_version
|
531
535
|
elsif @target < 0
|
532
536
|
@target = 0
|
533
537
|
end
|
534
538
|
|
535
|
-
raise(Error, "No current version available") unless current
|
536
|
-
raise(Error, "No target version available, probably because no migration files found or filenames don't follow the migration filename convention") unless target
|
537
|
-
|
538
539
|
@direction = current < target ? :up : :down
|
539
540
|
@migrations = get_migrations
|
540
541
|
end
|
@@ -46,7 +46,7 @@ module Sequel
|
|
46
46
|
if respond_to?(:register_array_type)
|
47
47
|
register_array_type('inet', :oid=>1041, :scalar_oid=>869)
|
48
48
|
register_array_type('cidr', :oid=>651, :scalar_oid=>650)
|
49
|
-
register_array_type('macaddr', :oid=>1040)
|
49
|
+
register_array_type('macaddr', :oid=>1040, :scalar_oid=>829)
|
50
50
|
end
|
51
51
|
@schema_type_classes[:ipaddr] = IPAddr
|
52
52
|
end
|
data/lib/sequel/model/base.rb
CHANGED
@@ -22,13 +22,6 @@ module Sequel
|
|
22
22
|
# truncate, unfiltered, ungraphed, ungrouped, union, unlimited, unordered, where, where_all,
|
23
23
|
# where_each, where_single_value, with, with_recursive, with_sql
|
24
24
|
module ClassMethods
|
25
|
-
# :nocov:
|
26
|
-
def allowed_columns
|
27
|
-
Sequel::Deprecation.deprecate("Model.allowed_columns", "It has been moved to the whitelist_security plugin")
|
28
|
-
nil
|
29
|
-
end
|
30
|
-
# :nocov:
|
31
|
-
|
32
25
|
# Whether to cache the anonymous models created by Sequel::Model(), true by default. This is
|
33
26
|
# required for reloading them correctly (avoiding the superclass mismatch).
|
34
27
|
attr_accessor :cache_anonymous_models
|
@@ -83,7 +76,7 @@ module Sequel
|
|
83
76
|
# Sequel will not check the number of rows modified (default: true).
|
84
77
|
attr_accessor :require_modification
|
85
78
|
|
86
|
-
# If true (the default),
|
79
|
+
# If true (the default), requires that all models have valid tables,
|
87
80
|
# raising exceptions if creating a model without a valid table backing it.
|
88
81
|
# Setting this to false will allow the creation of model classes where the
|
89
82
|
# underlying table doesn't exist.
|
@@ -116,17 +109,6 @@ module Sequel
|
|
116
109
|
# database to typecast the value correctly.
|
117
110
|
attr_accessor :typecast_on_assignment
|
118
111
|
|
119
|
-
# :nocov:
|
120
|
-
def use_after_commit_rollback
|
121
|
-
Sequel::Deprecation.deprecate("Model.use_after_commit_rollback", "Model transaction hooks have been removed, switch to using database transaction hooks")
|
122
|
-
false
|
123
|
-
end
|
124
|
-
def use_after_commit_rollback=(v)
|
125
|
-
Sequel::Deprecation.deprecate("Model.use_after_commit_rollback=", "Model transaction hooks have been removed, switch to using database transaction hooks")
|
126
|
-
false
|
127
|
-
end
|
128
|
-
# :nocov:
|
129
|
-
|
130
112
|
# Whether to use a transaction by default when saving/deleting records (default: true).
|
131
113
|
# If you are sending database queries in before_* or after_* hooks, you shouldn't change
|
132
114
|
# the default setting without a good reason.
|
@@ -445,6 +427,7 @@ module Sequel
|
|
445
427
|
|
446
428
|
# Freeze a model class, disallowing any further changes to it.
|
447
429
|
def freeze
|
430
|
+
return self if frozen?
|
448
431
|
dataset_module.freeze
|
449
432
|
overridable_methods_module.freeze
|
450
433
|
|
@@ -933,13 +916,6 @@ module Sequel
|
|
933
916
|
Sequel::Plugins.const_get(module_name)
|
934
917
|
end
|
935
918
|
|
936
|
-
# :nocov:
|
937
|
-
def plugin_module_defined?(plugin, submod)
|
938
|
-
Sequel::Deprecation.deprecate("Model.plugin_module_defined? (private method)", "Use const_defined?(submod, false)")
|
939
|
-
plugin.const_defined?(submod, false)
|
940
|
-
end
|
941
|
-
# :nocov:
|
942
|
-
|
943
919
|
# Find the row in the dataset that matches the primary key. Uses
|
944
920
|
# a static SQL optimization if the table and primary key are simple.
|
945
921
|
#
|
@@ -1044,17 +1020,6 @@ module Sequel
|
|
1044
1020
|
attr_writer(meth)
|
1045
1021
|
end
|
1046
1022
|
|
1047
|
-
# :nocov:
|
1048
|
-
def use_after_commit_rollback
|
1049
|
-
Sequel::Deprecation.deprecate("Model#use_after_commit_rollback", "Model transaction hooks have been removed, switch to using database transaction hooks")
|
1050
|
-
false
|
1051
|
-
end
|
1052
|
-
def use_after_commit_rollback=(v)
|
1053
|
-
Sequel::Deprecation.deprecate("Model#use_after_commit_rollback=", "Model transaction hooks have been removed, switch to using database transaction hooks")
|
1054
|
-
false
|
1055
|
-
end
|
1056
|
-
# :nocov:
|
1057
|
-
|
1058
1023
|
# The hash of attribute values. Keys are symbols with the names of the
|
1059
1024
|
# underlying database columns. The returned hash is a reference to the
|
1060
1025
|
# receiver's values hash, and modifying it will also modify the receiver's
|
@@ -1469,12 +1434,6 @@ module Sequel
|
|
1469
1434
|
def save(opts=OPTS)
|
1470
1435
|
raise Sequel::Error, "can't save frozen object" if frozen?
|
1471
1436
|
set_server(opts[:server]) if opts[:server]
|
1472
|
-
# :nocov:
|
1473
|
-
if method(:_before_validation).owner != InstanceMethods
|
1474
|
-
Sequel::Deprecation.deprecate("Using Model#_before_validation", "You should switch to using Model#before_validation")
|
1475
|
-
_before_validation
|
1476
|
-
end
|
1477
|
-
# :nocov:
|
1478
1437
|
unless checked_save_failure(opts){_valid?(opts)}
|
1479
1438
|
raise(ValidationFailed.new(self)) if raise_on_failure?(opts)
|
1480
1439
|
return
|
@@ -1622,12 +1581,6 @@ module Sequel
|
|
1622
1581
|
# artist.set(name: 'Invalid').valid? # => false
|
1623
1582
|
# artist.errors.full_messages # => ['name cannot be Invalid']
|
1624
1583
|
def valid?(opts = OPTS)
|
1625
|
-
# :nocov:
|
1626
|
-
if method(:_before_validation).owner != InstanceMethods
|
1627
|
-
Sequel::Deprecation.deprecate("Using Model#_before_validation", "You should switch to using Model#before_validation")
|
1628
|
-
_before_validation
|
1629
|
-
end
|
1630
|
-
# :nocov:
|
1631
1584
|
begin
|
1632
1585
|
_valid?(opts)
|
1633
1586
|
rescue HookFailed
|
@@ -1637,10 +1590,6 @@ module Sequel
|
|
1637
1590
|
|
1638
1591
|
private
|
1639
1592
|
|
1640
|
-
# SEQUEL51: Remove
|
1641
|
-
def _before_validation
|
1642
|
-
end
|
1643
|
-
|
1644
1593
|
# Do the deletion of the object's dataset, and check that the row
|
1645
1594
|
# was actually deleted.
|
1646
1595
|
def _delete
|
data/lib/sequel/version.rb
CHANGED
@@ -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 =
|
8
|
+
MINOR = 1
|
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
|
@@ -1748,6 +1748,31 @@ if uses_pg_or_jdbc && DB.server_version >= 90000
|
|
1748
1748
|
end
|
1749
1749
|
end
|
1750
1750
|
|
1751
|
+
describe "Postgres::Database#copy_into using UTF-8 encoding" do
|
1752
|
+
before(:all) do
|
1753
|
+
@db = DB
|
1754
|
+
@db.create_table!(:test_copy){String :t}
|
1755
|
+
@ds = @db[:test_copy].order(:t)
|
1756
|
+
end
|
1757
|
+
before do
|
1758
|
+
@db[:test_copy].delete
|
1759
|
+
end
|
1760
|
+
after(:all) do
|
1761
|
+
@db.drop_table?(:test_copy)
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
it "should work with UTF-8 characters using the :data option" do
|
1765
|
+
@db.copy_into(:test_copy, :data=>(["\u00E4\n"]*2))
|
1766
|
+
@ds.select_map([:t]).map{|a| a.map{|s| s.force_encoding('UTF-8')}}.must_equal([["\u00E4"]] * 2)
|
1767
|
+
end
|
1768
|
+
|
1769
|
+
it "should work with UTF-8 characters using a block" do
|
1770
|
+
buf = (["\u00E4\n"]*2)
|
1771
|
+
@db.copy_into(:test_copy){buf.shift}
|
1772
|
+
@ds.select_map([:t]).map{|a| a.map{|s| s.force_encoding('UTF-8')}}.must_equal([["\u00E4"]] * 2)
|
1773
|
+
end
|
1774
|
+
end
|
1775
|
+
|
1751
1776
|
describe "Postgres::Database#copy_table" do
|
1752
1777
|
before(:all) do
|
1753
1778
|
@db = DB
|
@@ -1828,7 +1853,6 @@ if uses_pg_or_jdbc && DB.server_version >= 90000
|
|
1828
1853
|
e.wrapped_exception.must_be_kind_of ArgumentError
|
1829
1854
|
e.message.must_include "foo"
|
1830
1855
|
end
|
1831
|
-
|
1832
1856
|
end
|
1833
1857
|
end
|
1834
1858
|
|
data/spec/core/schema_spec.rb
CHANGED
@@ -1204,6 +1204,20 @@ describe "DB#alter_table" do
|
|
1204
1204
|
@db.sqls.must_equal ["ALTER TABLE cats DROP CONSTRAINT cats_node_id_fkey", "ALTER TABLE cats DROP COLUMN node_id"]
|
1205
1205
|
end
|
1206
1206
|
|
1207
|
+
it "should support drop_foreign_key with :foreign_key_constraint_name option" do
|
1208
|
+
@db.alter_table(:cats) do
|
1209
|
+
drop_foreign_key :node_id, :foreign_key_constraint_name=>:foo
|
1210
|
+
end
|
1211
|
+
@db.sqls.must_equal ["ALTER TABLE cats DROP CONSTRAINT foo", "ALTER TABLE cats DROP COLUMN node_id"]
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
it "should support drop_foreign_key with :name option" do
|
1215
|
+
@db.alter_table(:cats) do
|
1216
|
+
drop_foreign_key :node_id, :name=>:foo
|
1217
|
+
end
|
1218
|
+
@db.sqls.must_equal ["ALTER TABLE cats DROP CONSTRAINT foo", "ALTER TABLE cats DROP COLUMN node_id"]
|
1219
|
+
end
|
1220
|
+
|
1207
1221
|
it "should support drop_foreign_key with composite foreign keys" do
|
1208
1222
|
def @db.foreign_key_list(table_name)
|
1209
1223
|
[{:name=>:cats_node_id_prop_id_fkey, :columns=>[:node_id, :prop_id]}]
|
@@ -195,6 +195,16 @@ describe "Reversible Migrations with Sequel.migration{change{}}" do
|
|
195
195
|
[:drop_table, :a, {:foo=>:bar}]]
|
196
196
|
end
|
197
197
|
|
198
|
+
it "should reverse add_foreign_key with :foreign_key_constraint_name option" do
|
199
|
+
Sequel.migration{change{alter_table(:t){add_foreign_key :b, :c, :foreign_key_constraint_name=>:f}}}.apply(@db, :down)
|
200
|
+
actions = @db.actions
|
201
|
+
actions.must_equal [[:alter_table, [[:drop_foreign_key, :b, {:foreign_key_constraint_name=>:f}]]]]
|
202
|
+
@db.sqls
|
203
|
+
db = Sequel.mock
|
204
|
+
db.alter_table(:t){send(*actions[0][1][0])}
|
205
|
+
db.sqls.must_equal ["ALTER TABLE t DROP CONSTRAINT f", "ALTER TABLE t DROP COLUMN b"]
|
206
|
+
end
|
207
|
+
|
198
208
|
it "should raise in the down direction if migration uses unsupported method" do
|
199
209
|
m = Sequel.migration{change{run 'SQL'}}
|
200
210
|
m.apply(@db, :up)
|
@@ -341,7 +341,7 @@ describe "Bound Argument Types" do
|
|
341
341
|
@ds.filter(:dt=>:$x).prepare(:first, :ps_datetime).call(:x=>@vs[:dt])[:dt].must_equal @vs[:dt]
|
342
342
|
end
|
343
343
|
|
344
|
-
cspecify "should handle datetime type with fractional seconds", [:jdbc, :sqlite], [:oracle] do
|
344
|
+
cspecify "should handle datetime type with fractional seconds", [:jdbc, :sqlite], [:jdbc, :mysql], [:oracle] do
|
345
345
|
Sequel.datetime_class = DateTime
|
346
346
|
fract_time = DateTime.parse('2010-10-12 13:14:15.500000')
|
347
347
|
@ds.prepare(:update, :ps_datetime_up, :dt=>:$x).call(:x=>fract_time)
|
@@ -352,7 +352,7 @@ describe "Bound Argument Types" do
|
|
352
352
|
@ds.filter(:t=>:$x).prepare(:first, :ps_time).call(:x=>@vs[:t])[:t].must_equal @vs[:t]
|
353
353
|
end
|
354
354
|
|
355
|
-
cspecify "should handle time type with fractional seconds", [:jdbc, :sqlite] do
|
355
|
+
cspecify "should handle time type with fractional seconds", [:jdbc, :sqlite], [:jdbc, :mysql] do
|
356
356
|
fract_time = @vs[:t] + 0.5
|
357
357
|
@ds.prepare(:update, :ps_time_up, :t=>:$x).call(:x=>fract_time)
|
358
358
|
@ds.literal(@ds.filter(:t=>:$x).prepare(:first, :ps_time).call(:x=>fract_time)[:t]).must_equal @ds.literal(fract_time)
|
@@ -215,7 +215,7 @@ describe "Database index parsing" do
|
|
215
215
|
DB.indexes(:items).must_equal({})
|
216
216
|
end
|
217
217
|
|
218
|
-
|
218
|
+
cspecify "should not include partial indexes", [proc{|db| db.sqlite_version < 30808}, :sqlite] do
|
219
219
|
DB.create_table!(:items){Integer :n; Integer :a; index :n, :where=>proc{n > 10}}
|
220
220
|
DB.indexes(:items).must_equal({})
|
221
221
|
end if DB.supports_partial_indexes?
|
data/spec/model/model_spec.rb
CHANGED
@@ -191,6 +191,11 @@ describe "Sequel::Model.freeze" do
|
|
191
191
|
proc{model.dataset_module{}}.must_raise RuntimeError
|
192
192
|
end
|
193
193
|
|
194
|
+
it "should work if the model is already frozen" do
|
195
|
+
model = Class.new(Sequel::Model(:items))
|
196
|
+
model.freeze.freeze
|
197
|
+
end
|
198
|
+
|
194
199
|
it "should freeze a model class without a dataset without breaking" do
|
195
200
|
model = Class.new(Sequel::Model)
|
196
201
|
model.freeze
|
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.
|
4
|
+
version: 5.1.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: 2017-
|
11
|
+
date: 2017-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -251,6 +251,7 @@ extra_rdoc_files:
|
|
251
251
|
- doc/release_notes/4.48.0.txt
|
252
252
|
- doc/release_notes/4.49.0.txt
|
253
253
|
- doc/release_notes/5.0.0.txt
|
254
|
+
- doc/release_notes/5.1.0.txt
|
254
255
|
files:
|
255
256
|
- CHANGELOG
|
256
257
|
- MIT-LICENSE
|
@@ -396,6 +397,7 @@ files:
|
|
396
397
|
- doc/release_notes/4.8.0.txt
|
397
398
|
- doc/release_notes/4.9.0.txt
|
398
399
|
- doc/release_notes/5.0.0.txt
|
400
|
+
- doc/release_notes/5.1.0.txt
|
399
401
|
- doc/schema_modification.rdoc
|
400
402
|
- doc/security.rdoc
|
401
403
|
- doc/sharding.rdoc
|
@@ -915,7 +917,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
915
917
|
version: '0'
|
916
918
|
requirements: []
|
917
919
|
rubyforge_project:
|
918
|
-
rubygems_version: 2.6.
|
920
|
+
rubygems_version: 2.6.13
|
919
921
|
signing_key:
|
920
922
|
specification_version: 4
|
921
923
|
summary: The Database Toolkit for Ruby
|