activerecord-jdbc-adapter 1.3.25 → 5.0.pre1

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +57 -72
  3. data/Appraisals +7 -2
  4. data/Gemfile +3 -7
  5. data/History.md +0 -50
  6. data/RUNNING_TESTS.md +4 -0
  7. data/activerecord-jdbc-adapter.gemspec +2 -1
  8. data/lib/arjdbc/common_jdbc_methods.rb +89 -0
  9. data/lib/arjdbc/db2/adapter.rb +58 -69
  10. data/lib/arjdbc/db2/as400.rb +2 -13
  11. data/lib/arjdbc/db2/column.rb +1 -1
  12. data/lib/arjdbc/derby/adapter.rb +2 -6
  13. data/lib/arjdbc/firebird/adapter.rb +7 -16
  14. data/lib/arjdbc/h2/adapter.rb +4 -13
  15. data/lib/arjdbc/hsqldb/adapter.rb +5 -5
  16. data/lib/arjdbc/jdbc/adapter.rb +15 -76
  17. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  18. data/lib/arjdbc/jdbc/adapter_require.rb +12 -31
  19. data/lib/arjdbc/jdbc/base_ext.rb +6 -25
  20. data/lib/arjdbc/jdbc/column.rb +15 -1
  21. data/lib/arjdbc/jdbc/connection_methods.rb +7 -1
  22. data/lib/arjdbc/jdbc/type_cast.rb +16 -4
  23. data/lib/arjdbc/jdbc/type_converter.rb +0 -1
  24. data/lib/arjdbc/mssql/adapter.rb +9 -21
  25. data/lib/arjdbc/mysql/adapter.rb +14 -19
  26. data/lib/arjdbc/mysql/connection_methods.rb +3 -5
  27. data/lib/arjdbc/oracle/adapter.rb +4 -38
  28. data/lib/arjdbc/oracle/connection_methods.rb +0 -4
  29. data/lib/arjdbc/postgresql/adapter.rb +18 -22
  30. data/lib/arjdbc/postgresql/connection_methods.rb +2 -5
  31. data/lib/arjdbc/postgresql/oid/bytea.rb +0 -1
  32. data/lib/arjdbc/postgresql/oid_types.rb +6 -6
  33. data/lib/arjdbc/sqlite3/adapter.rb +493 -404
  34. data/lib/arjdbc/tasks/database_tasks.rb +1 -1
  35. data/lib/arjdbc/tasks/databases3.rake +1 -1
  36. data/lib/arjdbc/tasks/databases4.rake +3 -8
  37. data/lib/arjdbc/version.rb +1 -1
  38. data/rakelib/db.rake +5 -8
  39. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +102 -37
  40. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +0 -7
  41. metadata +10 -17
  42. data/lib/arjdbc/jdbc/arel_support.rb +0 -133
  43. data/lib/arjdbc/mssql/attributes_for_update.rb +0 -22
  44. data/lib/arjdbc/sqlite3/explain_support.rb +0 -29
@@ -1,133 +0,0 @@
1
- module ActiveRecord::ConnectionAdapters
2
- module Jdbc
3
- # AREL support for the JDBC adapter.
4
- # @see ActiveRecord::ConnectionAdapters::JdbcAdapter
5
- module ArelSupport
6
-
7
- def self.included(base)
8
- base.extend ClassMethods
9
- end
10
-
11
- module ClassMethods
12
-
13
- def arel_visitor_name(spec)
14
- if spec
15
- if spec.respond_to?(:arel_visitor_name)
16
- spec.arel_visitor_name # for AREL built-in visitors
17
- else
18
- spec.name.split('::').last.downcase # ArJdbc::PostgreSQL -> postgresql
19
- end
20
- else # AR::ConnnectionAdapters::MySQLAdapter => mysql
21
- name.split('::').last.sub('Adapter', '').downcase
22
- end
23
- end
24
-
25
- # NOTE: it's important to track our own since we might want to override
26
- # what AREL setup for us e.g. we do not want `::Arel::Visitors::MSSQL`
27
-
28
- # @private
29
- RESOLVED_VISITORS = {} # lazy filled mirror of ::Arel::Visitors::VISITORS
30
-
31
- # @todo document
32
- def resolve_visitor_type(config)
33
- raise "missing :adapter in #{config.inspect}" unless adapter = config[:adapter]
34
-
35
- unless visitor_type = RESOLVED_VISITORS[ adapter ]
36
- if adapter_spec = config[:adapter_spec]
37
- if adapter_spec.respond_to?(:arel_visitor_type)
38
- visitor_type = adapter_spec.arel_visitor_type(config)
39
- elsif adapter_spec.respond_to?(:arel2_visitors) # backwards compat
40
- visitor_type = adapter_spec.arel2_visitors(config).values.first
41
- else # auto-convention ArJdbc::MySQL -> Arel::Visitors::MySQL
42
- const_name = adapter_spec.name.split('::').last
43
- visitor_type = ::Arel::Visitors.const_get(const_name) rescue nil
44
- end
45
- elsif respond_to?(:arel_visitor_type)
46
- visitor_type = arel_visitor_type(config) # adapter_class' override
47
- end
48
-
49
- visitor_type ||= ::Arel::Visitors::VISITORS[ arel_visitor_name(adapter_spec) ]
50
- visitor_type ||= ::Arel::Visitors::ToSql # default (if nothing resolved)
51
-
52
- RESOLVED_VISITORS.to_java.synchronized do
53
- RESOLVED_VISITORS[ adapter ] = ::Arel::Visitors::VISITORS[ adapter ] = visitor_type
54
- end
55
- end
56
-
57
- visitor_type
58
- end
59
-
60
- # @note called from `ActiveRecord::ConnectionAdapters::ConnectionPool.checkout` (up till AR-3.2)
61
- # @override
62
- def visitor_for(pool)
63
- visitor = resolve_visitor_type(config = pool.spec.config)
64
- ( prepared_statements?(config) ? visitor : bind_substitution(visitor) ).new(pool)
65
- end
66
-
67
- # @private
68
- @@bind_substitutions = nil
69
-
70
- # Generates a class for the given visitor type, this new {Class} instance
71
- # is a sub-class of `Arel::Visitors::BindVisitor`.
72
- # @return [Class] class for given visitor type
73
- def bind_substitution(visitor)
74
- # NOTE: similar convention as in AR (but no base substitution type) :
75
- # class BindSubstitution < ::Arel::Visitors::ToSql
76
- # include ::Arel::Visitors::BindVisitor
77
- # end
78
- return const_get(:BindSubstitution) if const_defined?(:BindSubstitution)
79
-
80
- @@bind_substitutions ||= Java::JavaUtil::HashMap.new
81
- unless bind_visitor = @@bind_substitutions.get(visitor)
82
- @@bind_substitutions.synchronized do
83
- unless @@bind_substitutions.get(visitor)
84
- bind_visitor = Class.new(visitor) do
85
- include ::Arel::Visitors::BindVisitor
86
- end
87
- @@bind_substitutions.put(visitor, bind_visitor)
88
- end
89
- end
90
- bind_visitor = @@bind_substitutions.get(visitor)
91
- end
92
- bind_visitor
93
- end
94
-
95
- begin
96
- require 'arel/visitors/bind_visitor'
97
- rescue LoadError # AR-3.0
98
- def bind_substitution(visitor); visitor; end
99
- end
100
-
101
- end
102
-
103
- if defined? ::Arel::Visitors::VISITORS
104
-
105
- # Instantiates a new AREL visitor for this adapter.
106
- # @note On `ActiveRecord` **2.3** this method won't be used.
107
- def new_visitor
108
- visitor = self.class.resolve_visitor_type(config)
109
- ( prepared_statements? ? visitor : bind_substitution(visitor) ).new(self)
110
- end
111
- protected :new_visitor
112
-
113
- def bind_substitution(visitor); self.class.bind_substitution(visitor); end
114
- private :bind_substitution
115
-
116
- # @override ActiveRecord's convention
117
- def unprepared_visitor
118
- # super does self.class::BindSubstitution.new self
119
- # we do not require the BindSubstitution constant - auto-generated :
120
- visitor = self.class.resolve_visitor_type(config)
121
- bind_substitution(visitor).new(self)
122
- end
123
-
124
- else # NO-OP when no AREL (AR-2.3)
125
-
126
- # @private documented above
127
- def new_visitor; end
128
-
129
- end
130
-
131
- end
132
- end
133
- end
@@ -1,22 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module SQLServer
4
- module CoreExt
5
- module AttributeMethods
6
-
7
-
8
- private
9
-
10
- def attributes_for_update(attribute_names)
11
- super.reject do |name|
12
- column = self.class.columns_hash[name]
13
- column && column.respond_to?(:identity?) && column.identity?
14
- end
15
- end
16
-
17
- end
18
- end
19
- end
20
- end
21
- end
22
- ActiveRecord::Base.send :include, ActiveRecord::ConnectionAdapters::SQLServer::CoreExt::AttributeMethods
@@ -1,29 +0,0 @@
1
- module ArJdbc
2
- module SQLite3
3
- module ExplainSupport
4
- def supports_explain?
5
- true
6
- end
7
-
8
- def explain(arel, binds = [])
9
- sql = "EXPLAIN QUERY PLAN #{to_sql(arel, binds)}"
10
- result = exec_query(sql, "EXPLAIN", binds)
11
- ExplainPrettyPrinter.new.pp result
12
- end
13
-
14
- class ExplainPrettyPrinter # :nodoc:
15
- # Pretty prints the result of a EXPLAIN QUERY PLAN in a way that resembles
16
- # the output of the SQLite shell:
17
- #
18
- # 0|0|0|SEARCH TABLE users USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)
19
- # 0|1|1|SCAN TABLE posts (~100000 rows)
20
- #
21
- def pp(result)
22
- result.rows.map do |row|
23
- row.join('|')
24
- end.join("\n") + "\n"
25
- end
26
- end
27
- end
28
- end
29
- end