sunstone 6.0.0.5 → 6.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/ext/active_record/associations.rb +2 -2
  3. data/ext/active_record/attribute_methods.rb +2 -2
  4. data/ext/active_record/callbacks.rb +1 -1
  5. data/ext/active_record/finder_methods.rb +42 -36
  6. data/ext/active_record/persistence.rb +2 -0
  7. data/ext/active_record/relation/calculations.rb +2 -2
  8. data/ext/active_record/statement_cache.rb +9 -5
  9. data/ext/active_record/transactions.rb +8 -15
  10. data/ext/arel/attributes/empty_relation.rb +31 -31
  11. data/ext/arel/nodes/select_statement.rb +1 -1
  12. data/lib/active_record/connection_adapters/sunstone/column.rb +3 -3
  13. data/lib/active_record/connection_adapters/sunstone/database_statements.rb +5 -5
  14. data/lib/active_record/connection_adapters/sunstone/schema_statements.rb +18 -8
  15. data/lib/active_record/connection_adapters/sunstone/type/binary.rb +34 -0
  16. data/lib/active_record/connection_adapters/sunstone_adapter.rb +39 -26
  17. data/lib/arel/visitors/sunstone.rb +13 -15
  18. data/lib/sunstone.rb +16 -2
  19. data/lib/sunstone/connection.rb +1 -1
  20. data/lib/sunstone/version.rb +1 -1
  21. metadata +40 -64
  22. data/.gitignore +0 -31
  23. data/.tm_properties +0 -1
  24. data/.travis.yml +0 -49
  25. data/Gemfile +0 -4
  26. data/README.md +0 -10
  27. data/Rakefile +0 -37
  28. data/TODO.md +0 -89
  29. data/ext/arel/attributes/relation.rb +0 -31
  30. data/sunstone.gemspec +0 -39
  31. data/test/active_record/associations/belongs_to_test.rb +0 -162
  32. data/test/active_record/associations/has_and_belongs_to_many_test.rb +0 -125
  33. data/test/active_record/associations/has_many_test.rb +0 -244
  34. data/test/active_record/eager_loading_test.rb +0 -62
  35. data/test/active_record/persistance_test.rb +0 -159
  36. data/test/active_record/preload_test.rb +0 -51
  37. data/test/active_record/query/all_test.rb +0 -33
  38. data/test/active_record/query/count_test.rb +0 -51
  39. data/test/active_record/query/distinct_test.rb +0 -30
  40. data/test/active_record/query/find_test.rb +0 -37
  41. data/test/active_record/query/limit_test.rb +0 -19
  42. data/test/active_record/query/order_test.rb +0 -27
  43. data/test/active_record/query/where_test.rb +0 -79
  44. data/test/active_record/query_test.rb +0 -123
  45. data/test/active_record/rpc_test.rb +0 -30
  46. data/test/schema_mock.rb +0 -117
  47. data/test/sunstone/connection/configuration_test.rb +0 -44
  48. data/test/sunstone/connection/cookie_store_test.rb +0 -37
  49. data/test/sunstone/connection/request_helper_test.rb +0 -105
  50. data/test/sunstone/connection/send_request_test.rb +0 -164
  51. data/test/sunstone/connection_test.rb +0 -23
  52. data/test/test_helper.rb +0 -152
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Sunstone::ConnectionTest < ActiveSupport::TestCase
4
-
5
- # #ping =====================================================================
6
-
7
- test '#ping' do
8
- connection = Sunstone::Connection.new(url: "http://testhost.com")
9
- stub_request(:get, "http://testhost.com/ping").to_return(:body => 'pong')
10
-
11
- assert_equal( 'pong', connection.ping )
12
- end
13
-
14
- # #server_config ===========================================================
15
-
16
- test '#config' do
17
- connection = Sunstone::Connection.new(url: "http://testhost.com")
18
- stub_request(:get, "http://testhost.com/config").to_return(:body => '{"server": "configs"}')
19
-
20
- assert_equal( {:server => "configs"}, connection.server_config )
21
- end
22
-
23
- end
data/test/test_helper.rb DELETED
@@ -1,152 +0,0 @@
1
- # To make testing/debugging easier, test within this source tree versus an
2
- # installed gem
3
- $LOAD_PATH << File.expand_path('../lib', __FILE__)
4
-
5
- require 'simplecov'
6
- SimpleCov.start do
7
- add_group 'lib', 'sunstone/lib'
8
- add_group 'ext', 'sunstone/ext'
9
- end
10
-
11
- require 'rgeo'
12
- require 'byebug'
13
- require "minitest/autorun"
14
- require 'minitest/unit'
15
- require 'minitest/reporters'
16
- require 'webmock/minitest'
17
- require 'mocha/minitest'
18
-
19
- require 'sunstone'
20
- require File.expand_path('../schema_mock.rb', __FILE__)
21
-
22
- Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
23
-
24
- $debugging = false
25
-
26
- # File 'lib/active_support/testing/declarative.rb', somewhere in rails....
27
- class ActiveSupport::TestCase
28
- include WebMock::API
29
-
30
- # File 'lib/active_support/testing/declarative.rb'
31
- def self.test(name, &block)
32
- test_name = "test_#{name.gsub(/\s+/, '_')}".to_sym
33
- defined = method_defined? test_name
34
- raise "#{test_name} is already defined in #{self}" if defined
35
- if block_given?
36
- define_method(test_name, &block)
37
- else
38
- define_method(test_name) do
39
- skip "No implementation provided for #{name}"
40
- end
41
- end
42
- end
43
-
44
- def pack(data)
45
-
46
- end
47
-
48
- def unpack(data)
49
- MessagePack.unpack(CGI::unescape(data))
50
- end
51
-
52
- def deep_transform_query(object)
53
- case object
54
- when Hash
55
- object.each_with_object({}) do |(key, value), result|
56
- result[key.to_s] = deep_transform_query(value)
57
- end
58
- when Array
59
- object.map {|e| deep_transform_query(e) }
60
- when Symbol
61
- object.to_s
62
- else
63
- object
64
- end
65
- end
66
-
67
- def webmock(method, path, query=nil)
68
- query = deep_transform_query(query) if query
69
-
70
- stub_request(method, /^#{ActiveRecord::Base.connection.instance_variable_get(:@connection).url}/).with do |req|
71
- if query
72
- req&.uri&.path == path && req.uri.query && unpack(req.uri.query.sub(/=true$/, '')) == query
73
- else
74
- req&.uri&.path == path && req.uri.query.nil?
75
- end
76
- end
77
- end
78
-
79
- def debug
80
- ActiveRecord::Base.logger = Logger.new(STDOUT)
81
- $debugging = true
82
- yield
83
- ensure
84
- ActiveRecord::Base.logger = nil
85
- $debugging = false
86
- end
87
-
88
-
89
- class SQLLogger
90
- class << self
91
- attr_accessor :ignored_sql, :log, :log_all
92
- def clear_log; self.log = []; self.log_all = []; end
93
- end
94
-
95
- self.clear_log
96
-
97
- self.ignored_sql = [/^PRAGMA/i, /^SELECT currval/i, /^SELECT CAST/i, /^SELECT @@IDENTITY/i, /^SELECT @@ROWCOUNT/i, /^SAVEPOINT/i, /^ROLLBACK TO SAVEPOINT/i, /^RELEASE SAVEPOINT/i, /^SHOW max_identifier_length/i, /^BEGIN/i, /^COMMIT/i]
98
-
99
- # FIXME: this needs to be refactored so specific database can add their own
100
- # ignored SQL, or better yet, use a different notification for the queries
101
- # instead examining the SQL content.
102
- oracle_ignored = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO/, /^\s*select .* from all_triggers/im, /^\s*select .* from all_constraints/im, /^\s*select .* from all_tab_cols/im]
103
- mysql_ignored = [/^SHOW FULL TABLES/i, /^SHOW FULL FIELDS/, /^SHOW CREATE TABLE /i, /^SHOW VARIABLES /, /^\s*SELECT (?:column_name|table_name)\b.*\bFROM information_schema\.(?:key_column_usage|tables)\b/im]
104
- postgresql_ignored = [/^\s*select\b.*\bfrom\b.*pg_namespace\b/im, /^\s*select tablename\b.*from pg_tables\b/im, /^\s*select\b.*\battname\b.*\bfrom\b.*\bpg_attribute\b/im, /^SHOW search_path/i]
105
- sqlite3_ignored = [/^\s*SELECT name\b.*\bFROM sqlite_master/im, /^\s*SELECT sql\b.*\bFROM sqlite_master/im]
106
-
107
- [oracle_ignored, mysql_ignored, postgresql_ignored, sqlite3_ignored].each do |db_ignored_sql|
108
- ignored_sql.concat db_ignored_sql
109
- end
110
-
111
- attr_reader :ignore
112
-
113
- def initialize(ignore = Regexp.union(self.class.ignored_sql))
114
- @ignore = ignore
115
- end
116
-
117
- def call(name, start, finish, message_id, values)
118
- sql = values[:sql]
119
-
120
- # FIXME: this seems bad. we should probably have a better way to indicate
121
- # the query was cached
122
- return if 'CACHE' == values[:name]
123
-
124
- self.class.log_all << sql
125
- unless ignore =~ sql
126
- if $debugging
127
- puts caller.select { |l| l.starts_with?(File.expand_path('../../lib', __FILE__)) }
128
- puts "\n\n"
129
- end
130
- end
131
- self.class.log << sql unless ignore =~ sql
132
- end
133
- end
134
- ActiveSupport::Notifications.subscribe('sql.active_record', SQLLogger.new)
135
-
136
- # test/unit backwards compatibility methods
137
- alias :assert_raise :assert_raises
138
- alias :assert_not_empty :refute_empty
139
- alias :assert_not_equal :refute_equal
140
- alias :assert_not_in_delta :refute_in_delta
141
- alias :assert_not_in_epsilon :refute_in_epsilon
142
- alias :assert_not_includes :refute_includes
143
- alias :assert_not_instance_of :refute_instance_of
144
- alias :assert_not_kind_of :refute_kind_of
145
- alias :assert_no_match :refute_match
146
- alias :assert_not_nil :refute_nil
147
- alias :assert_not_operator :refute_operator
148
- alias :assert_not_predicate :refute_predicate
149
- alias :assert_not_respond_to :refute_respond_to
150
- alias :assert_not_same :refute_same
151
-
152
- end