sequel 3.21.0 → 3.22.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.
- data/CHANGELOG +20 -0
- data/doc/release_notes/3.22.0.txt +39 -0
- data/lib/sequel/adapters/ado.rb +2 -1
- data/lib/sequel/adapters/jdbc.rb +5 -3
- data/lib/sequel/adapters/odbc.rb +2 -0
- data/lib/sequel/adapters/oracle.rb +12 -0
- data/lib/sequel/adapters/shared/mssql.rb +24 -3
- data/lib/sequel/adapters/tinytds.rb +4 -3
- data/lib/sequel/database/connecting.rb +1 -1
- data/lib/sequel/database/schema_methods.rb +8 -3
- data/lib/sequel/extensions/migration.rb +2 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +2 -0
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mssql_spec.rb +36 -0
- data/spec/adapters/mysql_spec.rb +6 -0
- data/spec/core/database_spec.rb +8 -0
- data/spec/core/schema_spec.rb +7 -0
- data/spec/extensions/migration_spec.rb +17 -17
- data/spec/extensions/single_table_inheritance_spec.rb +11 -0
- data/spec/integration/type_test.rb +7 -0
- metadata +6 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
=== 3.22.0 (2011-04-01)
|
2
|
+
|
3
|
+
* Add disconnect detection to tinytds adapter, though correct behavior may require an update to tiny_tds (cult_hero)
|
4
|
+
|
5
|
+
* Add Dataset/Database#mssql_unicode_strings accessor when connecting to MSSQL to control string literalization (semmons99, jeremyevans)
|
6
|
+
|
7
|
+
* Fix ODBC::Time instance handling in the odbc adapter (jeremyevans)
|
8
|
+
|
9
|
+
* Use Sequel.application_timezone when connecting in the oracle adapter to set the connection's session's timezone (jmthomas)
|
10
|
+
|
11
|
+
* In the ADO adapter, assume access to SQL Server if a :conn_string option is given that doesn't indicate Access/Jet (damir.si) (#332)
|
12
|
+
|
13
|
+
* Use the correct class when loading instances for descendents of model classes that use single table inheritance (jeremyevans)
|
14
|
+
|
15
|
+
* Support for COLLATE in column definitions (jfirebaugh)
|
16
|
+
|
17
|
+
* Don't use a schema when creating a temporary table (jeremyevans)
|
18
|
+
|
19
|
+
* Make migrator work correctly when a default_schema is set (jeremyevans) (#331)
|
20
|
+
|
1
21
|
=== 3.21.0 (2011-03-01)
|
2
22
|
|
3
23
|
* Make symbol splitting (:table__column___alias) work correctly for identifiers that are not in the \w character class (authorNari)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* Support COLLATE in column definitions. At least MySQL and Microsoft
|
4
|
+
SQL Server support them, and PostgreSQL 9.1 should as well.
|
5
|
+
|
6
|
+
* When connecting to Microsoft SQL Server, you can use the
|
7
|
+
mssql_unicode_strings accessor to turn of the default usage
|
8
|
+
of unicode strings (N'') and use regular strings (''). This
|
9
|
+
can improve performance, but changes the behavior. It's
|
10
|
+
set to true by default for backwards compatibility. You can
|
11
|
+
change it at both the dataset and database level:
|
12
|
+
|
13
|
+
DB.mssql_unicode_strings = false # default for datasets
|
14
|
+
dataset.mssql_unicode_strings = false # just this dataset
|
15
|
+
|
16
|
+
* In the oracle adapter, if Sequel.application_timezone is :utc, set
|
17
|
+
the timezone for the connection to use the 00:00 timezone.
|
18
|
+
|
19
|
+
= Other Improvements
|
20
|
+
|
21
|
+
* In the single_table_inheritance plugin, correctly handle a
|
22
|
+
multi-level class hierarchy so that loading instances from a
|
23
|
+
middle level of the hierarchy can return instances of subclasses.
|
24
|
+
|
25
|
+
* Don't use a schema when creating a temporary table, even if
|
26
|
+
default_schema is set.
|
27
|
+
|
28
|
+
* Fix the migrator when a default_schema is used.
|
29
|
+
|
30
|
+
* In the ado adapter, assume a connection to SQL Server if the
|
31
|
+
:conn_string is given and doesn't indicate Access/Jet.
|
32
|
+
|
33
|
+
* Fix fetching rows in the tinytds adapter when the
|
34
|
+
identifier_output_method is nil.
|
35
|
+
|
36
|
+
* The tinytds adapter now checks for disconnect errors, but it might
|
37
|
+
not be reliable until the next release of tiny_tds.
|
38
|
+
|
39
|
+
* The odbc adapter now handles ODBC::Time instances correctly.
|
data/lib/sequel/adapters/ado.rb
CHANGED
@@ -12,12 +12,13 @@ module Sequel
|
|
12
12
|
when /Microsoft\.(Jet|ACE)\.OLEDB/io
|
13
13
|
Sequel.ts_require 'adapters/shared/access'
|
14
14
|
extend Sequel::Access::DatabaseMethods
|
15
|
-
|
15
|
+
else
|
16
16
|
@opts[:driver] ||= 'SQL Server'
|
17
17
|
case @opts[:driver]
|
18
18
|
when 'SQL Server'
|
19
19
|
Sequel.ts_require 'adapters/ado/mssql'
|
20
20
|
extend Sequel::ADO::MSSQL::DatabaseMethods
|
21
|
+
set_mssql_unicode_strings
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
data/lib/sequel/adapters/jdbc.rb
CHANGED
@@ -55,11 +55,13 @@ module Sequel
|
|
55
55
|
:sqlserver=>proc do |db|
|
56
56
|
Sequel.ts_require 'adapters/jdbc/mssql'
|
57
57
|
db.extend(Sequel::JDBC::MSSQL::DatabaseMethods)
|
58
|
+
db.send(:set_mssql_unicode_strings)
|
58
59
|
com.microsoft.sqlserver.jdbc.SQLServerDriver
|
59
60
|
end,
|
60
61
|
:jtds=>proc do |db|
|
61
62
|
Sequel.ts_require 'adapters/jdbc/mssql'
|
62
63
|
db.extend(Sequel::JDBC::MSSQL::DatabaseMethods)
|
64
|
+
db.send(:set_mssql_unicode_strings)
|
63
65
|
JDBC.load_gem('jtds')
|
64
66
|
Java::net.sourceforge.jtds.jdbc.Driver
|
65
67
|
end,
|
@@ -101,7 +103,7 @@ module Sequel
|
|
101
103
|
# True by default, can be set to false to roughly double performance when
|
102
104
|
# fetching rows.
|
103
105
|
attr_accessor :convert_types
|
104
|
-
|
106
|
+
|
105
107
|
# Call the DATABASE_SETUP proc directly after initialization,
|
106
108
|
# so the object always uses sub adapter specific code. Also,
|
107
109
|
# raise an error immediately if the connection doesn't have a
|
@@ -530,8 +532,8 @@ module Sequel
|
|
530
532
|
# Uses the database's setting by default, can be set to false to roughly
|
531
533
|
# double performance when fetching rows.
|
532
534
|
attr_accessor :convert_types
|
533
|
-
|
534
|
-
# Use the convert_types default setting from the database
|
535
|
+
|
536
|
+
# Use the convert_types default setting from the database.
|
535
537
|
def initialize(db, opts={})
|
536
538
|
@convert_types = db.convert_types
|
537
539
|
super
|
data/lib/sequel/adapters/odbc.rb
CHANGED
@@ -15,6 +15,7 @@ module Sequel
|
|
15
15
|
when 'mssql'
|
16
16
|
Sequel.ts_require 'adapters/odbc/mssql'
|
17
17
|
extend Sequel::ODBC::MSSQL::DatabaseMethods
|
18
|
+
set_mssql_unicode_strings
|
18
19
|
when 'progress'
|
19
20
|
Sequel.ts_require 'adapters/shared/progress'
|
20
21
|
extend Sequel::Progress::DatabaseMethods
|
@@ -116,6 +117,7 @@ module Sequel
|
|
116
117
|
when ::ODBC::TimeStamp
|
117
118
|
Sequel.database_to_application_timestamp([v.year, v.month, v.day, v.hour, v.minute, v.second])
|
118
119
|
when ::ODBC::Time
|
120
|
+
now = ::Time.now
|
119
121
|
Sequel.database_to_application_timestamp([now.year, now.month, now.day, v.hour, v.minute, v.second])
|
120
122
|
when ::ODBC::Date
|
121
123
|
Date.new(v.year, v.month, v.day)
|
@@ -24,6 +24,18 @@ module Sequel
|
|
24
24
|
conn = OCI8.new(opts[:user], opts[:password], dbname, opts[:privilege])
|
25
25
|
conn.autocommit = true
|
26
26
|
conn.non_blocking = true
|
27
|
+
|
28
|
+
# The ruby-oci8 gem which retrieves oracle columns with a type of
|
29
|
+
# DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE is complex based on the
|
30
|
+
# ruby version (1.9.2 or later) and Oracle version (9 or later)
|
31
|
+
# In the now standard case of 1.9.2 and Oracle 9 or later, the timezone
|
32
|
+
# is determined by the Oracle session timezone. Thus if the user
|
33
|
+
# requests Sequel provide UTC timezone to the application,
|
34
|
+
# we need to alter the session timezone to be UTC
|
35
|
+
if Sequel.application_timezone == :utc
|
36
|
+
conn.exec("ALTER SESSION SET TIME_ZONE='-00:00'")
|
37
|
+
end
|
38
|
+
|
27
39
|
conn
|
28
40
|
end
|
29
41
|
|
@@ -11,10 +11,16 @@ module Sequel
|
|
11
11
|
SQL_ROLLBACK_TO_SAVEPOINT = 'IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION autopoint_%d'.freeze
|
12
12
|
SQL_SAVEPOINT = 'SAVE TRANSACTION autopoint_%d'.freeze
|
13
13
|
|
14
|
+
# Whether to use N'' to quote strings, which allows unicode characters inside the
|
15
|
+
# strings. True by default for compatibility, can be set to false for a possible
|
16
|
+
# performance increase. This sets the default for all datasets created from this
|
17
|
+
# Database object.
|
18
|
+
attr_accessor :mssql_unicode_strings
|
19
|
+
|
14
20
|
# The types to check for 0 scale to transform :decimal types
|
15
21
|
# to :integer.
|
16
22
|
DECIMAL_TYPE_RE = /number|numeric|decimal/io
|
17
|
-
|
23
|
+
|
18
24
|
# Microsoft SQL Server uses the :mssql type.
|
19
25
|
def database_type
|
20
26
|
:mssql
|
@@ -163,6 +169,11 @@ module Sequel
|
|
163
169
|
[m.call(row.delete(:column)), row]
|
164
170
|
end
|
165
171
|
end
|
172
|
+
|
173
|
+
# Set the mssql_unicode_strings settings from the given options.
|
174
|
+
def set_mssql_unicode_strings
|
175
|
+
@mssql_unicode_strings = typecast_value_boolean(@opts.fetch(:mssql_unicode_strings, true))
|
176
|
+
end
|
166
177
|
|
167
178
|
# MSSQL has both datetime and timestamp classes, most people are going
|
168
179
|
# to want datetime
|
@@ -211,6 +222,15 @@ module Sequel
|
|
211
222
|
WILDCARD = LiteralString.new('*').freeze
|
212
223
|
CONSTANT_MAP = {:CURRENT_DATE=>'CAST(CURRENT_TIMESTAMP AS DATE)'.freeze, :CURRENT_TIME=>'CAST(CURRENT_TIMESTAMP AS TIME)'.freeze}
|
213
224
|
|
225
|
+
# Allow overriding of the mssql_unicode_strings option at the dataset level.
|
226
|
+
attr_accessor :mssql_unicode_strings
|
227
|
+
|
228
|
+
# Copy the mssql_unicode_strings option from the +db+ object.
|
229
|
+
def initialize(db, opts={})
|
230
|
+
super
|
231
|
+
@mssql_unicode_strings = db.mssql_unicode_strings
|
232
|
+
end
|
233
|
+
|
214
234
|
# MSSQL uses + for string concatenation, and LIKE is case insensitive by default.
|
215
235
|
def complex_expression_sql(op, args)
|
216
236
|
case op
|
@@ -441,9 +461,10 @@ module Sequel
|
|
441
461
|
blob
|
442
462
|
end
|
443
463
|
|
444
|
-
#
|
464
|
+
# Optionally use unicode string syntax for all strings. Don't double
|
465
|
+
# backslashes.
|
445
466
|
def literal_string(v)
|
446
|
-
"N'#{v.gsub(/'/, "''")}'"
|
467
|
+
"#{'N' if mssql_unicode_strings}'#{v.gsub(/'/, "''")}'"
|
447
468
|
end
|
448
469
|
|
449
470
|
# Use 0 for false on MSSQL
|
@@ -13,6 +13,7 @@ module Sequel
|
|
13
13
|
opts = server_opts(server)
|
14
14
|
opts[:dataserver] = opts[:host]
|
15
15
|
opts[:username] = opts[:user]
|
16
|
+
set_mssql_unicode_strings
|
16
17
|
TinyTds::Client.new(opts)
|
17
18
|
end
|
18
19
|
|
@@ -38,7 +39,7 @@ module Sequel
|
|
38
39
|
end
|
39
40
|
yield(r) if block_given?
|
40
41
|
rescue TinyTds::Error => e
|
41
|
-
raise_error(e)
|
42
|
+
raise_error(e, :disconnect=>(c.closed? || (c.respond_to?(:dead?) && c.dead?)))
|
42
43
|
ensure
|
43
44
|
r.cancel if r && c.sqlsent?
|
44
45
|
end
|
@@ -107,7 +108,7 @@ module Sequel
|
|
107
108
|
yield r
|
108
109
|
end
|
109
110
|
else
|
110
|
-
result.each(each_opts, &
|
111
|
+
result.each(each_opts, &Proc.new)
|
111
112
|
end
|
112
113
|
end
|
113
114
|
end
|
@@ -118,7 +119,7 @@ module Sequel
|
|
118
119
|
|
119
120
|
# Properly escape the given string +v+.
|
120
121
|
def literal_string(v)
|
121
|
-
db.synchronize{|c| "N'#{c.escape(v)}'"}
|
122
|
+
s = db.synchronize{|c| "#{'N' if mssql_unicode_strings}'#{c.escape(v)}'"}
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
@@ -54,7 +54,7 @@ module Sequel
|
|
54
54
|
c = adapter_class(scheme)
|
55
55
|
uri_options = c.send(:uri_to_options, uri)
|
56
56
|
uri.query.split('&').collect{|s| s.split('=')}.each{|k,v| uri_options[k.to_sym] = v if k && !k.empty?} unless uri.query.to_s.strip.empty?
|
57
|
-
uri_options.
|
57
|
+
uri_options.to_a.each{|k,v| uri_options[k] = URI.unescape(v) if v.is_a?(String)}
|
58
58
|
opts = uri_options.merge(opts)
|
59
59
|
opts[:adapter] = scheme
|
60
60
|
end
|
@@ -21,7 +21,7 @@ module Sequel
|
|
21
21
|
UNSIGNED = ' UNSIGNED'.freeze
|
22
22
|
|
23
23
|
# The order of column modifiers to use when defining a column.
|
24
|
-
COLUMN_DEFINITION_ORDER = [:default, :null, :unique, :primary_key, :auto_increment, :references]
|
24
|
+
COLUMN_DEFINITION_ORDER = [:collate, :default, :null, :unique, :primary_key, :auto_increment, :references]
|
25
25
|
|
26
26
|
# Adds a column to the specified table. This method expects a column name,
|
27
27
|
# a datatype and optionally a hash with additional constraints and options:
|
@@ -275,7 +275,12 @@ module Sequel
|
|
275
275
|
def column_definition_auto_increment_sql(sql, column)
|
276
276
|
sql << " #{auto_increment_sql}" if column[:auto_increment]
|
277
277
|
end
|
278
|
-
|
278
|
+
|
279
|
+
# Add collate SQL fragment to column creation SQL.
|
280
|
+
def column_definition_collate_sql(sql, column)
|
281
|
+
sql << " COLLATE #{column[:collate]}" if column[:collate]
|
282
|
+
end
|
283
|
+
|
279
284
|
# Add default SQL fragment to column creation SQL.
|
280
285
|
def column_definition_default_sql(sql, column)
|
281
286
|
sql << " DEFAULT #{literal(column[:default])}" if column.include?(:default)
|
@@ -366,7 +371,7 @@ module Sequel
|
|
366
371
|
|
367
372
|
# DDL statement for creating a table with the given name, columns, and options
|
368
373
|
def create_table_sql(name, generator, options)
|
369
|
-
"CREATE #{temporary_table_sql if options[:temp]}TABLE #{quote_schema_table(name)} (#{column_list_sql(generator)})"
|
374
|
+
"CREATE #{temporary_table_sql if options[:temp]}TABLE #{options[:temp] ? quote_identifier(name) : quote_schema_table(name)} (#{column_list_sql(generator)})"
|
370
375
|
end
|
371
376
|
|
372
377
|
# Default index name for the table and columns, may be too long
|
@@ -375,7 +375,8 @@ module Sequel
|
|
375
375
|
@db = db
|
376
376
|
@directory = directory
|
377
377
|
@files = get_migration_files
|
378
|
-
|
378
|
+
schema, table = @db.send(:schema_and_table, opts[:table] || self.class.const_get(:DEFAULT_SCHEMA_TABLE))
|
379
|
+
@table = schema ? Sequel::SQL::QualifiedIdentifier.new(schema, table) : table
|
379
380
|
@column = opts[:column] || self.class.const_get(:DEFAULT_SCHEMA_COLUMN)
|
380
381
|
@ds = schema_dataset
|
381
382
|
end
|
@@ -108,8 +108,10 @@ module Sequel
|
|
108
108
|
key = skm[subclass]
|
109
109
|
sti_subclass_added(key)
|
110
110
|
ska = [key]
|
111
|
+
rp = dataset.row_proc
|
111
112
|
subclass.set_dataset(sd.filter(SQL::QualifiedIdentifier.new(table_name, sk)=>ska), :inherited=>true)
|
112
113
|
subclass.instance_eval do
|
114
|
+
dataset.row_proc = rp
|
113
115
|
@sti_key = sk
|
114
116
|
@sti_key_array = ska
|
115
117
|
@sti_dataset = sd
|
data/lib/sequel/version.rb
CHANGED
@@ -3,7 +3,7 @@ module Sequel
|
|
3
3
|
MAJOR = 3
|
4
4
|
# The minor version of Sequel. Bumped for every non-patch level
|
5
5
|
# release, generally around once a month.
|
6
|
-
MINOR =
|
6
|
+
MINOR = 22
|
7
7
|
# The tiny version of Sequel. Usually 0, only bumped for bugfix
|
8
8
|
# releases that fix regressions from previous versions.
|
9
9
|
TINY = 0
|
data/spec/adapters/mssql_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
|
2
3
|
|
3
4
|
require ENV['SEQUEL_MSSQL_SPEC_REQUIRE'] if ENV['SEQUEL_MSSQL_SPEC_REQUIRE']
|
@@ -440,3 +441,38 @@ describe "MSSQL::Dataset#count" do
|
|
440
441
|
MSSQL_DB[:items].select(:name, :value).group(:name, :value).order(:name).count.should == 1
|
441
442
|
end
|
442
443
|
end
|
444
|
+
|
445
|
+
describe "MSSQL::Database#create_table" do
|
446
|
+
specify "should support collate with various other column options" do
|
447
|
+
MSSQL_DB.create_table!(:items){ String :name, :size => 128, :collate => :sql_latin1_general_cp1_ci_as, :default => 'foo', :null => false, :unique => true}
|
448
|
+
MSSQL_DB[:items].insert
|
449
|
+
MSSQL_DB[:items].select_map(:name).should == ["foo"]
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
describe "MSSQL::Database#mssql_unicode_strings = false" do
|
454
|
+
before do
|
455
|
+
MSSQL_DB.mssql_unicode_strings = false
|
456
|
+
end
|
457
|
+
after do
|
458
|
+
MSSQL_DB.drop_table(:items)
|
459
|
+
MSSQL_DB.mssql_unicode_strings = true
|
460
|
+
end
|
461
|
+
|
462
|
+
specify "should work correctly" do
|
463
|
+
MSSQL_DB.create_table!(:items){String :name}
|
464
|
+
MSSQL_DB[:items].mssql_unicode_strings.should == false
|
465
|
+
MSSQL_DB[:items].insert(:name=>'foo')
|
466
|
+
MSSQL_DB[:items].select_map(:name).should == ['foo']
|
467
|
+
end
|
468
|
+
|
469
|
+
specify "should be overridable at the dataset level" do
|
470
|
+
MSSQL_DB.create_table!(:items){String :name}
|
471
|
+
ds = MSSQL_DB[:items]
|
472
|
+
ds.mssql_unicode_strings.should == false
|
473
|
+
ds.mssql_unicode_strings = true
|
474
|
+
ds.mssql_unicode_strings.should == true
|
475
|
+
ds.insert(:name=>'foo')
|
476
|
+
ds.select_map(:name).should == ['foo']
|
477
|
+
end
|
478
|
+
end
|
data/spec/adapters/mysql_spec.rb
CHANGED
@@ -82,6 +82,12 @@ describe "MySQL", '#create_table' do
|
|
82
82
|
end
|
83
83
|
@db.schema(:dolls).map{|k, v| v[:auto_increment]}.should == [nil, nil, true]
|
84
84
|
end
|
85
|
+
|
86
|
+
specify "should support collate with various other column options" do
|
87
|
+
@db.create_table!(:dolls){ String :name, :size=>128, :collate=>:utf8_bin, :default=>'foo', :null=>false, :unique=>true}
|
88
|
+
@db[:dolls].insert
|
89
|
+
@db[:dolls].select_map(:name).should == ["foo"]
|
90
|
+
end
|
85
91
|
end
|
86
92
|
|
87
93
|
describe "A MySQL database" do
|
data/spec/core/database_spec.rb
CHANGED
@@ -523,6 +523,14 @@ describe "Database#create_table" do
|
|
523
523
|
'CREATE UNIQUE INDEX test_tmp_name_index ON test_tmp (name)'
|
524
524
|
]
|
525
525
|
end
|
526
|
+
|
527
|
+
specify "should not use default schema when creating a temporary table" do
|
528
|
+
@db.default_schema = :foo
|
529
|
+
@db.create_table :test_tmp, :temp => true do
|
530
|
+
column :name, :text
|
531
|
+
end
|
532
|
+
@db.sqls.should == ['CREATE TEMPORARY TABLE test_tmp (name text)']
|
533
|
+
end
|
526
534
|
end
|
527
535
|
|
528
536
|
describe "Database#alter_table" do
|
data/spec/core/schema_spec.rb
CHANGED
@@ -281,6 +281,13 @@ describe "DB#create_table" do
|
|
281
281
|
@db.sqls.should == ["CREATE TABLE cats (project_id integer REFERENCES projects DEFERRABLE INITIALLY DEFERRED)"]
|
282
282
|
end
|
283
283
|
|
284
|
+
specify "should accept collation" do
|
285
|
+
@db.create_table(:cats) do
|
286
|
+
varchar :name, :collate => :utf8_bin
|
287
|
+
end
|
288
|
+
@db.sqls.should == ["CREATE TABLE cats (name varchar(255) COLLATE utf8_bin)"]
|
289
|
+
end
|
290
|
+
|
284
291
|
specify "should accept inline index definition" do
|
285
292
|
@db.create_table(:cats) do
|
286
293
|
integer :id, :index => true
|
@@ -202,7 +202,7 @@ describe "Sequel::IntegerMigrator" do
|
|
202
202
|
@drops = []
|
203
203
|
@tables_created = []
|
204
204
|
@columns_created = []
|
205
|
-
@versions = {}
|
205
|
+
@versions = Hash.new{|h,k| h[k.to_sym]}
|
206
206
|
end
|
207
207
|
|
208
208
|
def version; versions.values.first || 0; end
|
@@ -212,7 +212,7 @@ describe "Sequel::IntegerMigrator" do
|
|
212
212
|
def create_table(name, opts={}, &block)
|
213
213
|
super
|
214
214
|
@columns_created << / \(?(\w+) integer.*\)?\z/.match(sqls.last)[1].to_sym
|
215
|
-
@tables_created << name
|
215
|
+
@tables_created << name.to_sym
|
216
216
|
end
|
217
217
|
|
218
218
|
def dataset(opts={})
|
@@ -228,7 +228,7 @@ describe "Sequel::IntegerMigrator" do
|
|
228
228
|
end
|
229
229
|
|
230
230
|
def table_exists?(name)
|
231
|
-
@tables_created.include?(name)
|
231
|
+
@tables_created.include?(name.to_sym)
|
232
232
|
end
|
233
233
|
end
|
234
234
|
@db = dbc.new
|
@@ -250,7 +250,7 @@ describe "Sequel::IntegerMigrator" do
|
|
250
250
|
|
251
251
|
specify "should add a column name if it doesn't already exist in the schema_info table" do
|
252
252
|
@db.create_table(:schema_info){Integer :v}
|
253
|
-
@db.should_receive(:alter_table).with(
|
253
|
+
@db.should_receive(:alter_table).with('schema_info')
|
254
254
|
Sequel::Migrator.apply(@db, @dirname)
|
255
255
|
end
|
256
256
|
|
@@ -320,45 +320,45 @@ describe "Sequel::TimestampMigrator" do
|
|
320
320
|
@dsc = dsc = Class.new(MockDataset) do
|
321
321
|
def columns
|
322
322
|
case opts[:from].first
|
323
|
-
when :schema_info
|
323
|
+
when :schema_info, 'schema_info'
|
324
324
|
[:version]
|
325
|
-
when :schema_migrations
|
325
|
+
when :schema_migrations, 'schema_migrations'
|
326
326
|
[:filename]
|
327
|
-
when :sm
|
327
|
+
when :sm, 'sm'
|
328
328
|
[:fn]
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
332
332
|
def fetch_rows(sql)
|
333
333
|
case opts[:from].first
|
334
|
-
when :schema_info
|
334
|
+
when :schema_info, 'schema_info'
|
335
335
|
yield({:version=>$sequel_migration_version})
|
336
|
-
when :schema_migrations
|
336
|
+
when :schema_migrations, 'schema_migrations'
|
337
337
|
$sequel_migration_files.sort.each{|f| yield(:filename=>f)}
|
338
|
-
when :sm
|
338
|
+
when :sm, 'sm'
|
339
339
|
$sequel_migration_files.sort.each{|f| yield(:fn=>f)}
|
340
340
|
end
|
341
341
|
end
|
342
342
|
|
343
343
|
def insert(h={})
|
344
344
|
case opts[:from].first
|
345
|
-
when :schema_info
|
345
|
+
when :schema_info, 'schema_info'
|
346
346
|
$sequel_migration_version = h.values.first
|
347
|
-
when :schema_migrations, :sm
|
347
|
+
when :schema_migrations, :sm, 'schema_migrations', 'sm'
|
348
348
|
$sequel_migration_files << h.values.first
|
349
349
|
end
|
350
350
|
end
|
351
351
|
|
352
352
|
def update(h={})
|
353
353
|
case opts[:from].first
|
354
|
-
when :schema_info
|
354
|
+
when :schema_info, 'schema_info'
|
355
355
|
$sequel_migration_version = h.values.first
|
356
356
|
end
|
357
357
|
end
|
358
358
|
|
359
359
|
def delete
|
360
360
|
case opts[:from].first
|
361
|
-
when :schema_migrations, :sm
|
361
|
+
when :schema_migrations, :sm, 'schema_migrations', 'sm'
|
362
362
|
$sequel_migration_files.delete(opts[:where].args.last)
|
363
363
|
end
|
364
364
|
end
|
@@ -366,9 +366,9 @@ describe "Sequel::TimestampMigrator" do
|
|
366
366
|
dbc = Class.new(MockDatabase) do
|
367
367
|
tables = {}
|
368
368
|
define_method(:dataset){|*a| dsc.new(self, *a)}
|
369
|
-
define_method(:create_table){|name, *args| tables[name] = true}
|
370
|
-
define_method(:drop_table){|*names| names.each{|n| tables.delete(n)}}
|
371
|
-
define_method(:table_exists?){|name| tables.has_key?(name)}
|
369
|
+
define_method(:create_table){|name, *args| tables[name.to_sym] = true}
|
370
|
+
define_method(:drop_table){|*names| names.each{|n| tables.delete(n.to_sym)}}
|
371
|
+
define_method(:table_exists?){|name| tables.has_key?(name.to_sym)}
|
372
372
|
end
|
373
373
|
@db = dbc.new
|
374
374
|
@m = Sequel::Migrator
|
@@ -54,6 +54,17 @@ describe Sequel::Model, "#sti_key" do
|
|
54
54
|
StiTest.all.collect{|x| x.class}.should == [StiTest, StiTestSub1, StiTestSub2]
|
55
55
|
end
|
56
56
|
|
57
|
+
it "should return rows with the correct class for subclasses based on the polymorphic_key value" do
|
58
|
+
class ::StiTestSub1Sub < StiTestSub1
|
59
|
+
end
|
60
|
+
ds = StiTestSub1.dataset
|
61
|
+
def ds.fetch_rows(sql)
|
62
|
+
yield({:kind=>'StiTestSub1'})
|
63
|
+
yield({:kind=>'StiTestSub1Sub'})
|
64
|
+
end
|
65
|
+
StiTestSub1.all.collect{|x| x.class}.should == [StiTestSub1, StiTestSub1Sub]
|
66
|
+
end
|
67
|
+
|
57
68
|
it "should fallback to the main class if the given class does not exist" do
|
58
69
|
def @ds.fetch_rows(sql)
|
59
70
|
yield({:kind=>'StiTestSub3'})
|
@@ -68,6 +68,13 @@ describe "Supported types" do
|
|
68
68
|
ds.first[:dat].to_s.should == d.to_s
|
69
69
|
end
|
70
70
|
|
71
|
+
cspecify "should support generic time type", [:do], [:swift], [:odbc], [:jdbc, :mssql], [:tinytds] do
|
72
|
+
ds = create_items_table_with_column(:tim, Time, :only_time=>true)
|
73
|
+
t = Time.now
|
74
|
+
ds.insert(:tim => t)
|
75
|
+
ds.first[:tim].strftime('%H%M%S').should == t.strftime('%H%M%S')
|
76
|
+
end
|
77
|
+
|
71
78
|
cspecify "should support generic datetime type", [:do, :sqlite], [:jdbc, :sqlite] do
|
72
79
|
ds = create_items_table_with_column(:tim, DateTime)
|
73
80
|
t = DateTime.now
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 95
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
8
|
+
- 22
|
9
9
|
- 0
|
10
|
-
version: 3.
|
10
|
+
version: 3.22.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Evans
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -85,6 +85,7 @@ extra_rdoc_files:
|
|
85
85
|
- doc/release_notes/3.19.0.txt
|
86
86
|
- doc/release_notes/3.20.0.txt
|
87
87
|
- doc/release_notes/3.21.0.txt
|
88
|
+
- doc/release_notes/3.22.0.txt
|
88
89
|
files:
|
89
90
|
- MIT-LICENSE
|
90
91
|
- CHANGELOG
|
@@ -137,6 +138,7 @@ files:
|
|
137
138
|
- doc/release_notes/3.19.0.txt
|
138
139
|
- doc/release_notes/3.20.0.txt
|
139
140
|
- doc/release_notes/3.21.0.txt
|
141
|
+
- doc/release_notes/3.22.0.txt
|
140
142
|
- doc/sharding.rdoc
|
141
143
|
- doc/sql.rdoc
|
142
144
|
- doc/virtual_rows.rdoc
|