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,127 +0,0 @@
1
- require 'rubygems'
2
- require 'shoulda'
3
- require 'mocha'
4
- [ File.expand_path(File.join(File.dirname(__FILE__),'..','..','test')),
5
- File.expand_path(File.join(File.dirname(__FILE__),'..','..','test','connections','native_sqlserver_odbc')),
6
- File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','..','..','rails','activerecord','test'))
7
- ].each{ |lib| $:.unshift(lib) unless $:.include?(lib) } if ENV['TM_DIRECTORY']
8
- require 'cases/helper'
9
- require 'models/topic'
10
- require 'active_record/version'
11
-
12
- SQLSERVER_TEST_ROOT = File.expand_path(File.join(File.dirname(__FILE__),'..'))
13
- SQLSERVER_ASSETS_ROOT = SQLSERVER_TEST_ROOT + "/assets"
14
- SQLSERVER_FIXTURES_ROOT = SQLSERVER_TEST_ROOT + "/fixtures"
15
- SQLSERVER_MIGRATIONS_ROOT = SQLSERVER_TEST_ROOT + "/migrations"
16
- SQLSERVER_SCHEMA_ROOT = SQLSERVER_TEST_ROOT + "/schema"
17
- ACTIVERECORD_TEST_ROOT = File.expand_path(SQLSERVER_TEST_ROOT + "/../../../../rails/activerecord/test/")
18
-
19
- ActiveRecord::Migration.verbose = false
20
-
21
- # Defining our classes in one place as well as soem core tests that need coercing date/time types.
22
-
23
- class TableWithRealColumn < ActiveRecord::Base; end
24
- class FkTestHasFk < ActiveRecord::Base ; end
25
- class FkTestHasPk < ActiveRecord::Base ; end
26
- class NumericData < ActiveRecord::Base ; self.table_name = 'numeric_data' ; end
27
- class CustomersView < ActiveRecord::Base ; self.table_name = 'customers_view' ; end
28
- class StringDefaultsView < ActiveRecord::Base ; self.table_name = 'string_defaults_view' ; end
29
- class StringDefaultsBigView < ActiveRecord::Base ; self.table_name = 'string_defaults_big_view' ; end
30
- class SqlServerUnicode < ActiveRecord::Base ; end
31
- class SqlServerString < ActiveRecord::Base ; end
32
- class SqlServerChronic < ActiveRecord::Base
33
- coerce_sqlserver_date :date
34
- coerce_sqlserver_time :time
35
- default_timezone = :utc
36
- end
37
- class Topic < ActiveRecord::Base
38
- coerce_sqlserver_date :last_read
39
- coerce_sqlserver_time :bonus_time
40
- end
41
- class Person < ActiveRecord::Base
42
- coerce_sqlserver_date :favorite_day
43
- end
44
-
45
- # A module that we can include in classes where we want to override an active record test.
46
-
47
- module SqlserverCoercedTest
48
- def self.included(base)
49
- base.extend ClassMethods
50
- end
51
- module ClassMethods
52
- def coerced_tests
53
- self.const_get(:COERCED_TESTS) rescue nil
54
- end
55
- def method_added(method)
56
- if coerced_tests && coerced_tests.include?(method)
57
- undef_method(method)
58
- STDOUT.puts("Undefined coerced test: #{self.name}##{method}")
59
- end
60
- end
61
- end
62
- end
63
-
64
- # Set weather to test unicode string defaults or not. Used from rake task.
65
-
66
- if ENV['ENABLE_DEFAULT_UNICODE_TYPES'] == 'true'
67
- puts "With enabled unicode string types"
68
- ActiveRecord::ConnectionAdapters::SQLServerAdapter.enable_default_unicode_types = true
69
- end
70
-
71
- # Change the text database type to support ActiveRecord's tests for = on text columns which
72
- # is not supported in SQL Server text columns, so use varchar(8000) instead.
73
-
74
- if ActiveRecord::Base.connection.sqlserver_2000?
75
- if ActiveRecord::ConnectionAdapters::SQLServerAdapter.enable_default_unicode_types
76
- ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'nvarchar(4000)'
77
- else
78
- ActiveRecord::ConnectionAdapters::SQLServerAdapter.native_text_database_type = 'varchar(8000)'
79
- end
80
- end
81
-
82
- # Our changes/additions to ActiveRecord test helpers specific for SQL Server.
83
-
84
- ActiveRecord::Base.connection.class.class_eval do
85
- IGNORED_SQL << %r|SELECT SCOPE_IDENTITY| << %r{INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS)}
86
- IGNORED_SQL << %r|SELECT @@IDENTITY| << %r|SELECT @@ROWCOUNT| << %r|SELECT @@version| << %r|SELECT @@TRANCOUNT|
87
- end
88
-
89
- ActiveRecord::ConnectionAdapters::SQLServerAdapter.class_eval do
90
- def raw_select_with_query_record(sql, name = nil)
91
- $queries_executed ||= []
92
- $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
93
- raw_select_without_query_record(sql,name)
94
- end
95
- alias_method_chain :raw_select, :query_record
96
- end
97
-
98
- module ActiveRecord
99
- class TestCase < ActiveSupport::TestCase
100
- class << self
101
- def sqlserver_2000? ; ActiveRecord::Base.connection.sqlserver_2000? ; end
102
- def sqlserver_2005? ; ActiveRecord::Base.connection.sqlserver_2005? ; end
103
- def sqlserver_2008? ; ActiveRecord::Base.connection.sqlserver_2008? ; end
104
- def active_record_2_point_2? ; ActiveRecord::VERSION::MAJOR == 2 && ActiveRecord::VERSION::MINOR == 2 ; end
105
- def active_record_2_point_3? ; ActiveRecord::VERSION::MAJOR == 2 && ActiveRecord::VERSION::MINOR == 3 ; end
106
- def ruby_19? ; RUBY_VERSION >= '1.9' ; end
107
- end
108
- def assert_sql(*patterns_to_match)
109
- $queries_executed = []
110
- yield
111
- ensure
112
- failed_patterns = []
113
- patterns_to_match.each do |pattern|
114
- failed_patterns << pattern unless $queries_executed.any?{ |sql| pattern === sql }
115
- end
116
- assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found in:\n#{$queries_executed.inspect}"
117
- end
118
- def sqlserver_2000? ; self.class.sqlserver_2000? ; end
119
- def sqlserver_2005? ; self.class.sqlserver_2005? ; end
120
- def sqlserver_2008? ; self.class.sqlserver_2008? ; end
121
- def active_record_2_point_2? ; self.class.active_record_2_point_2? ; end
122
- def active_record_2_point_3? ; self.class.active_record_2_point_3? ; end
123
- def ruby_19? ; self.class.ruby_19? ; end
124
- end
125
- end
126
-
127
-
@@ -1,38 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
- require 'models/order'
3
-
4
- class SqlServerRailsOrders < ActiveRecord::Base
5
- set_table_name 'rails.orders'
6
- end
7
-
8
- class TableNameTestSqlserver < ActiveRecord::TestCase
9
-
10
- self.use_transactional_fixtures = false
11
-
12
- def setup
13
- Order.table_name = '[orders]'
14
- Order.reset_column_information
15
- end
16
-
17
- should 'load columns with escaped table name for model' do
18
- assert_equal 4, Order.columns.length
19
- end
20
-
21
- should 'not re-escape table name if it is escaped already for SQL queries' do
22
- assert_sql(/SELECT \* FROM \[orders\]/) { Order.all }
23
- end
24
-
25
- context 'Table scoped to user.table_name' do
26
-
27
- setup do
28
- @klass = SqlServerRailsOrders
29
- end
30
-
31
- should 'have no issue doing basic column reflection' do
32
- assert_nothing_raised() { @klass.columns }
33
- end
34
-
35
- end
36
-
37
-
38
- end
@@ -1,93 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
- require 'models/ship'
3
- require 'models/developer'
4
-
5
- class TransactionTestSqlserver < ActiveRecord::TestCase
6
-
7
- self.use_transactional_fixtures = false
8
-
9
- setup :delete_ships
10
-
11
- context 'Testing transaction basics' do
12
-
13
- should 'allow ActiveRecord::Rollback to work in 1 transaction block' do
14
- Ship.transaction do
15
- Ship.create! :name => 'Black Pearl'
16
- raise ActiveRecord::Rollback
17
- end
18
- assert_no_ships
19
- end
20
-
21
- should 'allow nested transactions to totally rollback' do
22
- begin
23
- Ship.transaction do
24
- Ship.create! :name => 'Black Pearl'
25
- Ship.transaction do
26
- Ship.create! :name => 'Flying Dutchman'
27
- raise 'HELL'
28
- end
29
- end
30
- rescue Exception => e
31
- assert_no_ships
32
- end
33
- end
34
-
35
- end
36
-
37
- context 'Testing #outside_transaction?' do
38
-
39
- should 'work in simple usage' do
40
- assert Ship.connection.outside_transaction?
41
- Ship.connection.begin_db_transaction
42
- assert !Ship.connection.outside_transaction?
43
- Ship.connection.rollback_db_transaction
44
- assert Ship.connection.outside_transaction?
45
- end
46
-
47
- should 'work inside nested transactions' do
48
- assert Ship.connection.outside_transaction?
49
- Ship.transaction do
50
- assert !Ship.connection.outside_transaction?
51
- Ship.transaction do
52
- assert !Ship.connection.outside_transaction?
53
- end
54
- end
55
- assert Ship.connection.outside_transaction?
56
- end
57
-
58
- should 'not call rollback if no transaction is active' do
59
- assert_raise RuntimeError do
60
- Ship.transaction do
61
- Ship.connection.rollback_db_transaction
62
- Ship.connection.expects(:rollback_db_transaction).never
63
- raise "Rails doesn't scale!"
64
- end
65
- end
66
- end
67
-
68
- should 'test_open_transactions_count_is_reset_to_zero_if_no_transaction_active' do
69
- Ship.transaction do
70
- Ship.transaction do
71
- Ship.connection.rollback_db_transaction
72
- end
73
- assert_equal 0, Ship.connection.open_transactions
74
- end
75
- assert_equal 0, Ship.connection.open_transactions
76
- end
77
-
78
- end unless active_record_2_point_2?
79
-
80
-
81
-
82
- protected
83
-
84
- def delete_ships
85
- Ship.delete_all
86
- end
87
-
88
- def assert_no_ships
89
- assert Ship.count.zero?, "Expected Ship to have no models but it did have:\n#{Ship.all.inspect}"
90
- end
91
-
92
- end
93
-
@@ -1,50 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
-
3
- class UnicodeTestSqlserver < ActiveRecord::TestCase
4
-
5
-
6
- context 'Testing basic saves and unicode limits' do
7
-
8
- should 'save and reload simple nchar string' do
9
- assert nchar_data = SqlServerUnicode.create!(:nchar => 'A')
10
- assert_equal 'A', SqlServerUnicode.find(nchar_data.id).nchar
11
- end
12
-
13
- should 'save and reload simple nvarchar(max) string' do
14
- test_string = 'Ken Collins'
15
- assert nvarcharmax_data = SqlServerUnicode.create!(:nvarchar_max => test_string)
16
- assert_equal test_string, SqlServerUnicode.find(nvarcharmax_data.id).nvarchar_max
17
- end if sqlserver_2005? || sqlserver_2008?
18
-
19
- should 'enforce default nchar_10 limit of 10' do
20
- assert_raise(ActiveRecord::StatementInvalid) { SqlServerUnicode.create!(:nchar => '01234567891') }
21
- end
22
-
23
- should 'enforce default nvarchar_100 limit of 100' do
24
- assert_raise(ActiveRecord::StatementInvalid) { SqlServerUnicode.create!(:nvarchar_100 => '0123456789'*10+'1') }
25
- end
26
-
27
- end
28
-
29
- context 'Testing unicode data' do
30
-
31
- setup do
32
- @unicode_data = "\344\270\200\344\272\21434\344\272\224\345\205\255"
33
- @encoded_unicode_data = "\344\270\200\344\272\21434\344\272\224\345\205\255".force_encoding('UTF-8') if ruby_19?
34
- end
35
-
36
- should 'insert into nvarchar field' do
37
- assert data = SqlServerUnicode.create!(:nvarchar => @unicode_data)
38
- assert_equal @unicode_data, data.reload.nvarchar
39
- end
40
-
41
- should 're-encode data on DB reads' do
42
- assert data = SqlServerUnicode.create!(:nvarchar => @unicode_data)
43
- assert_equal @encoded_unicode_data, data.reload.nvarchar
44
- end if ruby_19?
45
-
46
- end
47
-
48
-
49
-
50
- end
@@ -1,35 +0,0 @@
1
- require 'cases/sqlserver_helper'
2
-
3
- class ValidationsTestSqlserver < ActiveRecord::TestCase
4
- end
5
-
6
- class ValidationsTest < ActiveRecord::TestCase
7
-
8
- COERCED_TESTS = [:test_validate_uniqueness_with_limit_and_utf8]
9
-
10
- include SqlserverCoercedTest
11
-
12
- # This test is tricky to pass. The validation SQL would generate something like this:
13
- #
14
- # SELECT TOP 1 [events].id FROM [events] WHERE ([events].[title] COLLATE Latin1_General_CS_AS = '一二三四五')
15
- #
16
- # The problem is that we can not change the adapters quote method from this:
17
- #
18
- # elsif column && column.respond_to?(:is_utf8?) && column.is_utf8?
19
- # quoted_utf8_value(value)
20
- #
21
- # To something like this for all quoting like blind bind vars:
22
- #
23
- # elsif value.is_utf8?
24
- # quoted_utf8_value(value)
25
- #
26
- # As it would cause way more errors, sure this piggybacks on ActiveSupport's 1.8/1.9 abstract
27
- # code to infer if the passed in string is indeed a national/unicde type. Perhaps in rails 3
28
- # and using AREL this might get better, but I do not see a solution right now.
29
- #
30
- def test_coerced_test_validate_uniqueness_with_limit_and_utf8
31
- assert true
32
- end
33
-
34
- end
35
-
@@ -1,25 +0,0 @@
1
- print "Using SQLServer via ADONET\n"
2
- require_dependency 'models/course'
3
- require 'logger'
4
-
5
- ActiveRecord::Base.logger = Logger.new("debug.log")
6
-
7
- ActiveRecord::Base.configurations = {
8
- 'arunit' => {
9
- :adapter => 'sqlserver',
10
- :mode => 'ADONET',
11
- :host => 'localhost',
12
- :username => 'rails',
13
- :database => 'activerecord_unittest'
14
- },
15
- 'arunit2' => {
16
- :adapter => 'sqlserver',
17
- :mode => 'ADONET',
18
- :host => 'localhost',
19
- :username => 'rails',
20
- :database => 'activerecord_unittest2'
21
- }
22
- }
23
-
24
- ActiveRecord::Base.establish_connection 'arunit'
25
- Course.establish_connection 'arunit2'
@@ -1,27 +0,0 @@
1
- print "Using SQLServer via ODBC\n"
2
- require_dependency 'models/course'
3
- require 'logger'
4
-
5
- ActiveRecord::Base.logger = Logger.new("debug.log")
6
-
7
- ActiveRecord::Base.configurations = {
8
- 'arunit' => {
9
- :adapter => 'sqlserver',
10
- :mode => 'ODBC',
11
- :host => 'localhost',
12
- :username => 'rails',
13
- :dsn => 'activerecord_unittest',
14
- :database => 'activerecord_unittest'
15
- },
16
- 'arunit2' => {
17
- :adapter => 'sqlserver',
18
- :mode => 'ODBC',
19
- :host => 'localhost',
20
- :username => 'rails',
21
- :dsn => 'activerecord_unittest2',
22
- :database => 'activerecord_unittest2'
23
- }
24
- }
25
-
26
- ActiveRecord::Base.establish_connection 'arunit'
27
- Course.establish_connection 'arunit2'
@@ -1,11 +0,0 @@
1
- class TableWillNeverBeCreated < ActiveRecord::Migration
2
-
3
- def self.up
4
- create_table(:sqlserver_trans_table1) { }
5
- create_table(:sqlserver_trans_table2) { raise ActiveRecord::StatementInvalid }
6
- end
7
-
8
- def self.down
9
- end
10
-
11
- end
@@ -1,94 +0,0 @@
1
- ActiveRecord::Schema.define do
2
-
3
- create_table :table_with_real_columns, :force => true do |t|
4
- t.column :real_number, :real
5
- end
6
-
7
- create_table :defaults, :force => true do |t|
8
- t.column :positive_integer, :integer, :default => 1
9
- t.column :negative_integer, :integer, :default => -1
10
- t.column :decimal_number, :decimal, :precision => 3, :scale => 2, :default => 2.78
11
- end
12
-
13
- create_table :string_defaults, :force => true do |t|
14
- t.column :string_with_null_default, :string, :default => nil
15
- t.column :string_with_pretend_null_one, :string, :default => 'null'
16
- t.column :string_with_pretend_null_two, :string, :default => '(null)'
17
- t.column :string_with_pretend_null_three, :string, :default => 'NULL'
18
- t.column :string_with_pretend_null_four, :string, :default => '(NULL)'
19
- t.column :string_with_pretend_paren_three, :string, :default => '(3)'
20
- t.column :string_with_multiline_default, :string, :default => "Some long default with a\nnew line."
21
- end
22
-
23
- create_table :sql_server_chronics, :force => true do |t|
24
- t.column :date, :date
25
- t.column :time, :time
26
- t.column :datetime, :datetime
27
- t.column :timestamp, :timestamp
28
- t.column :smalldatetime, :smalldatetime
29
- end
30
-
31
- create_table(:fk_test_has_fks, :force => true) { |t| t.column(:fk_id, :integer, :null => false) }
32
- create_table(:fk_test_has_pks, :force => true) { }
33
- execute <<-ADDFKSQL
34
- ALTER TABLE fk_test_has_fks
35
- ADD CONSTRAINT FK__fk_test_has_fk_fk_id
36
- FOREIGN KEY (#{quote_column_name('fk_id')})
37
- REFERENCES #{quote_table_name('fk_test_has_pks')} (#{quote_column_name('id')})
38
- ADDFKSQL
39
-
40
- create_table :sql_server_unicodes, :force => true do |t|
41
- t.column :nchar, :nchar
42
- t.column :nvarchar, :nvarchar
43
- t.column :ntext, :ntext
44
- t.column :ntext_10, :ntext, :limit => 10
45
- t.column :nchar_10, :nchar, :limit => 10
46
- t.column :nvarchar_100, :nvarchar, :limit => 100
47
- if ActiveRecord::Base.connection.sqlserver_2005? || ActiveRecord::Base.connection.sqlserver_2008?
48
- t.column :nvarchar_max, :nvarchar_max
49
- t.column :nvarchar_max_10, :nvarchar_max, :limit => 10
50
- end
51
- end
52
-
53
- create_table :sql_server_strings, :force => true do |t|
54
- t.column :char, :char
55
- t.column :char_10, :char, :limit => 10
56
- if ActiveRecord::Base.connection.sqlserver_2005? || ActiveRecord::Base.connection.sqlserver_2008?
57
- t.column :varchar_max, :varchar_max
58
- t.column :varchar_max_10, :varchar_max, :limit => 10
59
- end
60
- end
61
-
62
- create_table :sql_server_binary_types, :force => true do |t|
63
- # TODO: Add some different native binary types and test.
64
- end
65
-
66
- create_table :sql_server_edge_schemas, :force => true do |t|
67
- t.string :description
68
- t.column :bigint, :bigint
69
- t.column :tinyint, :tinyint
70
- end
71
-
72
- execute "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'customers_view') DROP VIEW customers_view"
73
- execute <<-CUSTOMERSVIEW
74
- CREATE VIEW customers_view AS
75
- SELECT id, name, balance
76
- FROM customers
77
- CUSTOMERSVIEW
78
-
79
- execute "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'string_defaults_view') DROP VIEW string_defaults_view"
80
- execute <<-STRINGDEFAULTSVIEW
81
- CREATE VIEW string_defaults_view AS
82
- SELECT id, string_with_pretend_null_one as pretend_null
83
- FROM string_defaults
84
- STRINGDEFAULTSVIEW
85
-
86
- execute "IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'string_defaults_big_view') DROP VIEW string_defaults_big_view"
87
- execute <<-STRINGDEFAULTSBIGVIEW
88
- CREATE VIEW string_defaults_big_view AS
89
- SELECT id, string_with_pretend_null_one as pretend_null
90
- /*#{'x'*4000}}*/
91
- FROM string_defaults
92
- STRINGDEFAULTSBIGVIEW
93
-
94
- end