activerecord-sqlserver-adapter 2.3.7 → 3.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +385 -61
  3. data/MIT-LICENSE +1 -1
  4. data/VERSION +1 -0
  5. data/lib/active_record/connection_adapters/sqlserver/core_ext/active_record.rb +42 -0
  6. data/lib/active_record/connection_adapters/sqlserver/core_ext/database_statements.rb +97 -0
  7. data/lib/active_record/connection_adapters/sqlserver/core_ext/explain.rb +41 -0
  8. data/lib/active_record/connection_adapters/sqlserver/core_ext/explain_subscriber.rb +26 -0
  9. data/lib/active_record/connection_adapters/sqlserver/core_ext/odbc.rb +38 -0
  10. data/lib/active_record/connection_adapters/sqlserver/core_ext/relation.rb +19 -0
  11. data/lib/active_record/connection_adapters/sqlserver/database_limits.rb +49 -0
  12. data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +458 -0
  13. data/lib/active_record/connection_adapters/sqlserver/errors.rb +36 -0
  14. data/lib/active_record/connection_adapters/sqlserver/quoting.rb +113 -0
  15. data/lib/active_record/connection_adapters/sqlserver/schema_cache.rb +85 -0
  16. data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +376 -0
  17. data/lib/active_record/connection_adapters/sqlserver/showplan/printer_table.rb +69 -0
  18. data/lib/active_record/connection_adapters/sqlserver/showplan/printer_xml.rb +25 -0
  19. data/lib/active_record/connection_adapters/sqlserver/showplan.rb +67 -0
  20. data/lib/active_record/connection_adapters/sqlserver/utils.rb +32 -0
  21. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +344 -1055
  22. data/lib/arel/visitors/sqlserver.rb +389 -0
  23. metadata +60 -83
  24. data/README.rdoc +0 -190
  25. data/RUNNING_UNIT_TESTS +0 -65
  26. data/Rakefile +0 -41
  27. data/autotest/discover.rb +0 -4
  28. data/autotest/railssqlserver.rb +0 -16
  29. data/autotest/sqlserver.rb +0 -54
  30. data/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/active_record.rb +0 -151
  31. data/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/odbc.rb +0 -40
  32. data/test/cases/aaaa_create_tables_test_sqlserver.rb +0 -19
  33. data/test/cases/adapter_test_sqlserver.rb +0 -756
  34. data/test/cases/attribute_methods_test_sqlserver.rb +0 -33
  35. data/test/cases/basics_test_sqlserver.rb +0 -21
  36. data/test/cases/calculations_test_sqlserver.rb +0 -20
  37. data/test/cases/column_test_sqlserver.rb +0 -285
  38. data/test/cases/connection_test_sqlserver.rb +0 -146
  39. data/test/cases/eager_association_test_sqlserver.rb +0 -42
  40. data/test/cases/execute_procedure_test_sqlserver.rb +0 -44
  41. data/test/cases/inheritance_test_sqlserver.rb +0 -28
  42. data/test/cases/method_scoping_test_sqlserver.rb +0 -28
  43. data/test/cases/migration_test_sqlserver.rb +0 -123
  44. data/test/cases/named_scope_test_sqlserver.rb +0 -21
  45. data/test/cases/offset_and_limit_test_sqlserver.rb +0 -108
  46. data/test/cases/pessimistic_locking_test_sqlserver.rb +0 -125
  47. data/test/cases/query_cache_test_sqlserver.rb +0 -24
  48. data/test/cases/schema_dumper_test_sqlserver.rb +0 -72
  49. data/test/cases/specific_schema_test_sqlserver.rb +0 -97
  50. data/test/cases/sqlserver_helper.rb +0 -127
  51. data/test/cases/table_name_test_sqlserver.rb +0 -38
  52. data/test/cases/transaction_test_sqlserver.rb +0 -93
  53. data/test/cases/unicode_test_sqlserver.rb +0 -50
  54. data/test/cases/validations_test_sqlserver.rb +0 -35
  55. data/test/connections/native_sqlserver/connection.rb +0 -25
  56. data/test/connections/native_sqlserver_odbc/connection.rb +0 -27
  57. data/test/migrations/transaction_table/1_table_will_never_be_created.rb +0 -11
  58. data/test/schema/sqlserver_specific_schema.rb +0 -94
@@ -1,123 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
- require 'models/person'
3
-
4
- class MigrationTestSqlserver < ActiveRecord::TestCase
5
-
6
- def setup
7
- @connection = ActiveRecord::Base.connection
8
- end
9
-
10
- context 'For transactions' do
11
-
12
- setup do
13
- @trans_test_table1 = 'sqlserver_trans_table1'
14
- @trans_test_table2 = 'sqlserver_trans_table2'
15
- @trans_tables = [@trans_test_table1,@trans_test_table2]
16
- end
17
-
18
- teardown do
19
- @trans_tables.each do |table_name|
20
- ActiveRecord::Migration.drop_table(table_name) if @connection.tables.include?(table_name)
21
- end
22
- end
23
-
24
- should 'not create a tables if error in migrations' do
25
- begin
26
- ActiveRecord::Migrator.up(SQLSERVER_MIGRATIONS_ROOT+'/transaction_table')
27
- rescue Exception => e
28
- assert_match %r|this and all later migrations canceled|, e.message
29
- end
30
- assert_does_not_contain @trans_test_table1, @connection.tables
31
- assert_does_not_contain @trans_test_table2, @connection.tables
32
- end
33
-
34
- end
35
-
36
- context 'For changing column' do
37
-
38
- should 'not raise exception when column contains default constraint' do
39
- lock_version_column = Person.columns_hash['lock_version']
40
- assert_equal :integer, lock_version_column.type
41
- assert lock_version_column.default.present?
42
- assert_nothing_raised { @connection.change_column 'people', 'lock_version', :string }
43
- Person.reset_column_information
44
- lock_version_column = Person.columns_hash['lock_version']
45
- assert_equal :string, lock_version_column.type
46
- assert lock_version_column.default.nil?
47
- end
48
-
49
- should 'not drop the default contraint if just renaming' do
50
- find_default = lambda do
51
- @connection.select_all("EXEC sp_helpconstraint 'defaults','nomsg'").select do |row|
52
- row['constraint_type'] == "DEFAULT on column decimal_number"
53
- end.last
54
- end
55
- default_before = find_default.call
56
- @connection.change_column :defaults, :decimal_number, :decimal, :precision => 4
57
- default_after = find_default.call
58
- assert default_after
59
- assert_equal default_before['constraint_keys'], default_after['constraint_keys']
60
- end
61
-
62
- end
63
-
64
- end
65
-
66
-
67
- class MigrationTest < ActiveRecord::TestCase
68
-
69
- COERCED_TESTS = [:test_add_column_not_null_without_default]
70
-
71
- include SqlserverCoercedTest
72
-
73
- def test_coerced_test_add_column_not_null_without_default
74
- Person.connection.create_table :testings do |t|
75
- t.column :foo, :string
76
- t.column :bar, :string, :null => false
77
- end
78
- assert_raises(ActiveRecord::StatementInvalid) do
79
- Person.connection.execute "INSERT INTO [testings] ([foo], [bar]) VALUES ('hello', NULL)"
80
- end
81
- ensure
82
- Person.connection.drop_table :testings rescue nil
83
- end
84
-
85
- end
86
-
87
- class ChangeTableMigrationsTest < ActiveRecord::TestCase
88
-
89
- COERCED_TESTS = [:test_string_creates_string_column]
90
-
91
- include SqlserverCoercedTest
92
-
93
- def setup
94
- @connection = Person.connection
95
- @connection.create_table :delete_me, :force => true do |t|
96
- end
97
- end
98
-
99
- def teardown
100
- @connection.drop_table :delete_me rescue nil
101
- end
102
-
103
- def test_coerced_string_creates_string_column
104
- with_sqlserver_change_table do |t|
105
- @connection.expects(:add_column).with(:delete_me, :foo, sqlserver_string_column, {})
106
- @connection.expects(:add_column).with(:delete_me, :bar, sqlserver_string_column, {})
107
- t.string :foo, :bar
108
- end
109
- end
110
-
111
- protected
112
-
113
- def with_sqlserver_change_table
114
- @connection.change_table :delete_me do |t|
115
- yield t
116
- end
117
- end
118
-
119
- def sqlserver_string_column
120
- "#{@connection.native_string_database_type}(255)"
121
- end
122
-
123
- end
@@ -1,21 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
-
3
- class NamedScopeTestSqlserver < ActiveRecord::TestCase
4
- end
5
-
6
- class NamedScopeTest < ActiveRecord::TestCase
7
-
8
- COERCED_TESTS = [:test_named_scopes_honor_current_scopes_from_when_defined]
9
-
10
- include SqlserverCoercedTest
11
-
12
- # See: http://github.com/rails/rails/commit/0dd2f96f5c90f8abacb0fe0757ef7e5db4a4d501#comment_37025
13
- # The orig test is a little brittle and fails on other adapters that do not explicitly fall back to a secondary
14
- # sort of id ASC. Since there are duplicate records with comments_count equal to one another. I have found that
15
- # named_scope :ranked_by_comments, :order => "comments_count DESC, id ASC" fixes the ambiguity.
16
- def test_coerced_test_named_scopes_honor_current_scopes_from_when_defined
17
- assert true
18
- end
19
-
20
-
21
- end
@@ -1,108 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
- require 'models/book'
3
-
4
- class OffsetAndLimitTestSqlserver < ActiveRecord::TestCase
5
-
6
- class Account < ActiveRecord::Base; end
7
-
8
- def setup
9
- @connection = ActiveRecord::Base.connection
10
- end
11
-
12
- context 'When selecting with limit' do
13
-
14
- setup do
15
- @select_sql = 'SELECT * FROM schema'
16
- end
17
-
18
- should 'alter SQL to limit number of records returned' do
19
- options = { :limit => 10 }
20
- assert_equal('SELECT TOP 10 * FROM schema', @connection.add_limit_offset!(@select_sql, options))
21
- end
22
-
23
- should 'only allow integers for limit' do
24
- options = { :limit => 'ten' }
25
- assert_raise(ArgumentError) {@connection.add_limit_offset!(@select_sql, options) }
26
- end
27
-
28
- should 'convert strings which look like integers to integers' do
29
- options = { :limit => '42' }
30
- assert_nothing_raised(ArgumentError) {@connection.add_limit_offset!(@select_sql, options)}
31
- end
32
-
33
- should 'not allow sql injection via limit' do
34
- options = { :limit => '1 * FROM schema; DELETE * FROM table; SELECT TOP 10 *'}
35
- assert_raise(ArgumentError) { @connection.add_limit_offset!(@select_sql, options) }
36
- end
37
-
38
- end
39
-
40
- context 'When selecting with limit and offset' do
41
-
42
- setup do
43
- @select_sql = 'SELECT * FROM books'
44
- @subquery_select_sql = 'SELECT *, (SELECT TOP 1 id FROM books) AS book_id FROM books'
45
- @books = (1..10).map {|i| Book.create!}
46
- end
47
-
48
- teardown do
49
- @books.each {|b| b.destroy}
50
- end
51
-
52
- should 'have limit if offset is passed' do
53
- options = { :offset => 1 }
54
- assert_raise(ArgumentError) { @connection.add_limit_offset!(@select_sql, options) }
55
- end
56
-
57
- should 'only allow integers for offset' do
58
- options = { :limit => 10, :offset => 'five' }
59
- assert_raise(ArgumentError) { @connection.add_limit_offset!(@select_sql, options)}
60
- end
61
-
62
- should 'convert strings which look like integers to integers' do
63
- options = { :limit => 10, :offset => '5' }
64
- assert_nothing_raised(ArgumentError) {@connection.add_limit_offset!(@select_sql, options)}
65
- end
66
-
67
- should 'alter SQL to limit number of records returned offset by specified amount' do
68
- options = { :limit => 3, :offset => 5 }
69
- expected_sql = "SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 8 * FROM books) AS tmp1) AS tmp2"
70
- assert_equal(expected_sql, @connection.add_limit_offset!(@select_sql, options))
71
- end
72
-
73
- should 'add locks to deepest sub select in limit offset sql that has a limited tally' do
74
- options = { :limit => 3, :offset => 5, :lock => 'WITH (NOLOCK)' }
75
- expected_sql = "SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 8 * FROM books WITH (NOLOCK)) AS tmp1) AS tmp2"
76
- @connection.add_limit_offset! @select_sql, options
77
- assert_equal expected_sql, @connection.add_lock!(@select_sql,options)
78
- end
79
-
80
- # Not really sure what an offset sql injection might look like
81
- should 'not allow sql injection via offset' do
82
- options = { :limit => 10, :offset => '1 * FROM schema; DELETE * FROM table; SELECT TOP 10 *'}
83
- assert_raise(ArgumentError) { @connection.add_limit_offset!(@select_sql, options) }
84
- end
85
-
86
- should 'not create invalid SQL with subquery SELECTs with TOP' do
87
- options = { :limit => 5, :offset => 1 }
88
- expected_sql = "SELECT * FROM (SELECT TOP 5 * FROM (SELECT TOP 6 *, (SELECT TOP 1 id FROM books) AS book_id FROM books) AS tmp1) AS tmp2"
89
- assert_equal expected_sql, @connection.add_limit_offset!(@subquery_select_sql,options)
90
- end
91
-
92
- should 'add lock hints to tally sql if :lock option is present' do
93
- assert_sql %r|SELECT TOP 1000000000 \* FROM \[people\] WITH \(NOLOCK\)| do
94
- Person.all :limit => 5, :offset => 1, :lock => 'WITH (NOLOCK)'
95
- end
96
- end
97
-
98
- should 'not add lock hints to tally sql if there is no :lock option' do
99
- assert_sql %r|\(SELECT TOP 1000000000 \* FROM \[people\] \)| do
100
- Person.all :limit => 5, :offset => 1
101
- end
102
- end
103
-
104
- end
105
-
106
-
107
- end
108
-
@@ -1,125 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
- require 'models/person'
3
- require 'models/reader'
4
-
5
- class PessimisticLockingTestSqlserver < ActiveRecord::TestCase
6
-
7
- self.use_transactional_fixtures = false
8
- fixtures :people, :readers
9
-
10
- def setup
11
- Person.columns; Reader.columns # Avoid introspection queries during tests.
12
- end
13
-
14
- context 'For simple finds with default lock option' do
15
-
16
- should 'lock with simple find' do
17
- assert_nothing_raised do
18
- Person.transaction do
19
- Person.find 1, :lock => true
20
- end
21
- end
22
- end
23
-
24
- should 'lock with scoped find' do
25
- assert_nothing_raised do
26
- Person.transaction do
27
- Person.with_scope(:find => { :lock => true }) do
28
- Person.find 1
29
- end
30
- end
31
- end
32
- end
33
-
34
- should 'lock with eager find' do
35
- assert_nothing_raised do
36
- Person.transaction do
37
- Person.find 1, :include => :readers, :lock => true
38
- end
39
- end
40
- end
41
-
42
- should 'reload with lock when #lock! called' do
43
- assert_nothing_raised do
44
- Person.transaction do
45
- person = Person.find 1
46
- old, person.first_name = person.first_name, 'fooman'
47
- person.lock!
48
- assert_equal old, person.first_name
49
- end
50
- end
51
- end
52
-
53
- should 'simply add lock to find all' do
54
- assert_sql %r|SELECT \* FROM \[people\] WITH \(NOLOCK\)| do
55
- Person.all(:lock => 'WITH (NOLOCK)')
56
- end
57
- end
58
-
59
- end
60
-
61
- context 'For paginated finds' do
62
-
63
- setup do
64
- 20.times { |n| Person.create!(:first_name => "Thing_#{n}") }
65
- end
66
-
67
- should 'cope with un-locked paginated results' do
68
- tally_not_locked = %r|SELECT count\(\*\) as TotalRows from \(SELECT TOP 1000000000 \* FROM \[people\]\s+WITH \(NOLOCK\) \) tally|
69
- inner_tmp_not_locked = %r|SELECT TOP 15 \* FROM \[people\] WITH \(NOLOCK\)|
70
- # Currently association limiting is not locked like the parent.
71
- association_limiting_not_locked = %r|SELECT \[readers\]\.\* FROM \[readers\] WITH \(NOLOCK\) WHERE \(\[readers\]\.person_id IN \(1,2,3,4,5\)\)|
72
- assert_sql(tally_not_locked,inner_tmp_not_locked) do
73
- Person.all(:include => :readers, :lock => 'WITH (NOLOCK)', :limit => 5, :offset => 10)
74
- end
75
- end
76
-
77
- end
78
-
79
-
80
- context 'For dueling concurrent connections' do
81
-
82
- use_concurrent_connections
83
-
84
- should 'no locks does not wait' do
85
- first, second = duel { Person.find 1 }
86
- assert first.end > second.end
87
- end
88
-
89
- should 'that second lock waits' do
90
- assert [0.2, 1, 5].any? { |zzz|
91
- first, second = duel(zzz) { Person.find 1, :lock => true }
92
- second.end > first.end
93
- }
94
- end
95
-
96
- end
97
-
98
-
99
- protected
100
-
101
- def duel(zzz = 5)
102
- t0, t1, t2, t3 = nil, nil, nil, nil
103
- a = Thread.new do
104
- t0 = Time.now
105
- Person.transaction do
106
- yield
107
- sleep zzz # block thread 2 for zzz seconds
108
- end
109
- t1 = Time.now
110
- end
111
- b = Thread.new do
112
- sleep zzz / 2.0 # ensure thread 1 tx starts first
113
- t2 = Time.now
114
- Person.transaction { yield }
115
- t3 = Time.now
116
- end
117
- a.join
118
- b.join
119
- assert t1 > t0 + zzz
120
- assert t2 > t0
121
- assert t3 > t2
122
- [t0.to_f..t1.to_f, t2.to_f..t3.to_f]
123
- end
124
-
125
- end
@@ -1,24 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
- require 'models/task'
3
-
4
- class QueryCacheTestSqlserver < ActiveRecord::TestCase
5
- end
6
-
7
- class QueryCacheTest < ActiveRecord::TestCase
8
-
9
- COERCED_TESTS = [:test_cache_does_not_wrap_string_results_in_arrays]
10
-
11
- include SqlserverCoercedTest
12
-
13
- fixtures :tasks
14
-
15
-
16
- def test_coerced_test_cache_does_not_wrap_string_results_in_arrays
17
- Task.cache do
18
- assert_instance_of Fixnum, Task.connection.select_value("SELECT count(*) AS count_all FROM tasks")
19
- end
20
- end
21
-
22
- end
23
-
24
-
@@ -1,72 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
-
3
- class SchemaDumperTestSqlserver < ActiveRecord::TestCase
4
-
5
- setup :find_all_tables
6
-
7
- context 'For primary keys' do
8
-
9
- should 'honor nonstandards' do
10
- table_dump('movies') do |output|
11
- match = output.match(%r{create_table "movies"(.*)do})
12
- assert_not_nil(match, "nonstandardpk table not found")
13
- assert_match %r(:primary_key => "movieid"), match[1], "non-standard primary key not preserved"
14
- end
15
- end
16
-
17
- end
18
-
19
- context 'For integers' do
20
-
21
- should 'include limit constraint that match logic for smallint and bigint in #extract_limit' do
22
- table_dump('integer_limits') do |output|
23
- assert_match %r{c_int_1.*:limit => 2}, output
24
- assert_match %r{c_int_2.*:limit => 2}, output
25
- assert_match %r{c_int_3.*}, output
26
- assert_match %r{c_int_4.*}, output
27
- assert_no_match %r{c_int_3.*:limit}, output
28
- assert_no_match %r{c_int_4.*:limit}, output
29
- assert_match %r{c_int_5.*:limit => 8}, output
30
- assert_match %r{c_int_6.*:limit => 8}, output
31
- assert_match %r{c_int_7.*:limit => 8}, output
32
- assert_match %r{c_int_8.*:limit => 8}, output
33
- end
34
- end
35
-
36
- end
37
-
38
- context 'For strings' do
39
-
40
- should 'have varchar(max) dumped as text' do
41
- table_dump('sql_server_strings') do |output|
42
- assert_match %r{t.text.*varchar_max}, output
43
- end
44
- end if sqlserver_2005? || sqlserver_2008?
45
-
46
- end
47
-
48
-
49
-
50
-
51
- private
52
-
53
- def find_all_tables
54
- @all_tables ||= ActiveRecord::Base.connection.tables
55
- end
56
-
57
- def standard_dump(ignore_tables = [])
58
- stream = StringIO.new
59
- ActiveRecord::SchemaDumper.ignore_tables = [*ignore_tables]
60
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
61
- stream.string
62
- end
63
-
64
- def table_dump(*table_names)
65
- stream = StringIO.new
66
- ActiveRecord::SchemaDumper.ignore_tables = @all_tables-table_names
67
- ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream)
68
- yield stream.string
69
- stream.string
70
- end
71
-
72
- end
@@ -1,97 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
-
3
- class StringDefault < ActiveRecord::Base; end;
4
- class SqlServerEdgeSchema < ActiveRecord::Base; end;
5
-
6
- class SpecificSchemaTestSqlserver < ActiveRecord::TestCase
7
-
8
- should 'cope with multi line defaults' do
9
- default = StringDefault.new
10
- assert_equal "Some long default with a\nnew line.", default.string_with_multiline_default
11
- end
12
-
13
- should 'default strings before save' do
14
- default = StringDefault.new
15
- assert_equal nil, default.string_with_null_default
16
- assert_equal 'null', default.string_with_pretend_null_one
17
- assert_equal '(null)', default.string_with_pretend_null_two
18
- assert_equal 'NULL', default.string_with_pretend_null_three
19
- assert_equal '(NULL)', default.string_with_pretend_null_four
20
- assert_equal '(3)', default.string_with_pretend_paren_three
21
- end
22
-
23
- should 'default strings after save' do
24
- default = StringDefault.create
25
- assert_equal nil, default.string_with_null_default
26
- assert_equal 'null', default.string_with_pretend_null_one
27
- assert_equal '(null)', default.string_with_pretend_null_two
28
- assert_equal 'NULL', default.string_with_pretend_null_three
29
- assert_equal '(NULL)', default.string_with_pretend_null_four
30
- end
31
-
32
- context 'Testing edge case schemas' do
33
-
34
- setup do
35
- @edge_class = SqlServerEdgeSchema
36
- end
37
-
38
- context 'with description column' do
39
-
40
- setup do
41
- @da = @edge_class.create! :description => 'A'
42
- @db = @edge_class.create! :description => 'B'
43
- @dc = @edge_class.create! :description => 'C'
44
- end
45
-
46
- teardown { @edge_class.delete_all }
47
-
48
- should 'allow all sorts of ordering without adapter munging it up' do
49
- assert_equal ['A','B','C'], @edge_class.all(:order => 'description').map(&:description)
50
- assert_equal ['A','B','C'], @edge_class.all(:order => 'description asc').map(&:description)
51
- assert_equal ['A','B','C'], @edge_class.all(:order => 'description ASC').map(&:description)
52
- assert_equal ['C','B','A'], @edge_class.all(:order => 'description desc').map(&:description)
53
- assert_equal ['C','B','A'], @edge_class.all(:order => 'description DESC').map(&:description)
54
- end
55
-
56
- end
57
-
58
- context 'with bigint column' do
59
-
60
- setup do
61
- @b5k = 5000
62
- @bi5k = @edge_class.create! :bigint => @b5k, :description => 'Five Thousand'
63
- @bnum = 9_000_000_000_000_000_000
64
- @bimjr = @edge_class.create! :bigint => @bnum, :description => 'Close to max bignum'
65
- end
66
-
67
- should 'can find by biginit' do
68
- assert_equal @bi5k, @edge_class.find_by_bigint(@b5k)
69
- assert_equal @b5k, @edge_class.find(:first, :select => 'bigint', :conditions => {:bigint => @b5k}).bigint
70
- assert_equal @bimjr, @edge_class.find_by_bigint(@bnum)
71
- assert_equal @bnum, @edge_class.find(:first, :select => 'bigint', :conditions => {:bigint => @bnum}).bigint
72
- end
73
-
74
- end
75
-
76
- context 'with tinyint column' do
77
-
78
- setup do
79
- @tiny1 = @edge_class.create! :tinyint => 1
80
- @tiny255 = @edge_class.create! :tinyint => 255
81
- end
82
-
83
- should 'not treat tinyint like boolean as mysql does' do
84
- assert_equal 1, @edge_class.find_by_tinyint(1).tinyint
85
- assert_equal 255, @edge_class.find_by_tinyint(255).tinyint
86
- end
87
-
88
- should 'throw an error when going out of our tiny int bounds' do
89
- assert_raise(ActiveRecord::StatementInvalid) { @edge_class.create! :tinyint => 256 }
90
- end
91
-
92
- end
93
-
94
- end
95
-
96
-
97
- end