activerecord-jdbc-adapter 70.0.pre-java → 70.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/activerecord-jdbc-adapter.gemspec +1 -3
  4. data/lib/arel/visitors/compat.rb +5 -33
  5. data/lib/arel/visitors/h2.rb +1 -13
  6. data/lib/arel/visitors/hsqldb.rb +1 -21
  7. data/lib/arel/visitors/sql_server.rb +2 -103
  8. data/lib/arjdbc/abstract/core.rb +8 -9
  9. data/lib/arjdbc/abstract/database_statements.rb +8 -0
  10. data/lib/arjdbc/discover.rb +0 -67
  11. data/lib/arjdbc/jdbc/adapter.rb +1 -1
  12. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  13. data/lib/arjdbc/jdbc/column.rb +1 -26
  14. data/lib/arjdbc/jdbc.rb +0 -7
  15. data/lib/arjdbc/mysql/adapter.rb +2 -1
  16. data/lib/arjdbc/mysql/connection_methods.rb +43 -42
  17. data/lib/arjdbc/oracle/adapter.rb +4 -23
  18. data/lib/arjdbc/postgresql/adapter.rb +152 -3
  19. data/lib/arjdbc/postgresql/oid_types.rb +155 -108
  20. data/lib/arjdbc/sqlite3/adapter.rb +54 -36
  21. data/lib/arjdbc/tasks/database_tasks.rb +0 -15
  22. data/lib/arjdbc/util/serialized_attributes.rb +0 -22
  23. data/lib/arjdbc/util/table_copier.rb +2 -1
  24. data/lib/arjdbc/version.rb +1 -1
  25. data/rakelib/02-test.rake +3 -18
  26. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1 -1
  27. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +5 -0
  28. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +6 -1
  29. metadata +6 -39
  30. data/lib/active_record/connection_adapters/as400_adapter.rb +0 -2
  31. data/lib/active_record/connection_adapters/db2_adapter.rb +0 -1
  32. data/lib/active_record/connection_adapters/derby_adapter.rb +0 -1
  33. data/lib/active_record/connection_adapters/informix_adapter.rb +0 -1
  34. data/lib/arel/visitors/db2.rb +0 -137
  35. data/lib/arel/visitors/derby.rb +0 -112
  36. data/lib/arel/visitors/firebird.rb +0 -79
  37. data/lib/arjdbc/db2/adapter.rb +0 -808
  38. data/lib/arjdbc/db2/as400.rb +0 -142
  39. data/lib/arjdbc/db2/column.rb +0 -131
  40. data/lib/arjdbc/db2/connection_methods.rb +0 -48
  41. data/lib/arjdbc/db2.rb +0 -4
  42. data/lib/arjdbc/derby/active_record_patch.rb +0 -13
  43. data/lib/arjdbc/derby/adapter.rb +0 -521
  44. data/lib/arjdbc/derby/connection_methods.rb +0 -20
  45. data/lib/arjdbc/derby/schema_creation.rb +0 -15
  46. data/lib/arjdbc/derby.rb +0 -3
  47. data/lib/arjdbc/firebird/adapter.rb +0 -413
  48. data/lib/arjdbc/firebird/connection_methods.rb +0 -23
  49. data/lib/arjdbc/firebird.rb +0 -4
  50. data/lib/arjdbc/informix/adapter.rb +0 -139
  51. data/lib/arjdbc/informix/connection_methods.rb +0 -9
  52. data/lib/arjdbc/sybase/adapter.rb +0 -47
  53. data/lib/arjdbc/sybase.rb +0 -2
  54. data/lib/arjdbc/tasks/db2_database_tasks.rb +0 -104
  55. data/lib/arjdbc/tasks/derby_database_tasks.rb +0 -95
  56. data/src/java/arjdbc/derby/DerbyModule.java +0 -178
  57. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +0 -152
  58. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +0 -174
  59. data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +0 -75
@@ -1,521 +0,0 @@
1
- ArJdbc.load_java_part :Derby
2
-
3
- require 'arjdbc/util/table_copier'
4
- require 'arjdbc/derby/schema_creation' # AR 4.x
5
- require 'arel/visitors/derby'
6
-
7
- module ArJdbc
8
- module Derby
9
- include Util::TableCopier
10
-
11
- def self.extended(adapter)
12
- require 'arjdbc/derby/active_record_patch'
13
- end
14
-
15
- def self.included(base)
16
- require 'arjdbc/derby/active_record_patch'
17
- end
18
-
19
- # @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_connection_class
20
- def self.jdbc_connection_class
21
- ::ActiveRecord::ConnectionAdapters::DerbyJdbcConnection
22
- end
23
-
24
- # @see ActiveRecord::ConnectionAdapters::JdbcColumn#column_types
25
- def self.column_selector
26
- [ /derby/i, lambda { |config, column| column.extend(Column) } ]
27
- end
28
-
29
- # @private
30
- @@emulate_booleans = true
31
-
32
- # Boolean emulation can be disabled using :
33
- #
34
- # ArJdbc::Derby.emulate_booleans = false
35
- #
36
- def self.emulate_booleans?; @@emulate_booleans; end
37
- # @deprecated Use {#emulate_booleans?} instead.
38
- def self.emulate_booleans; @@emulate_booleans; end
39
- # @see #emulate_booleans?
40
- def self.emulate_booleans=(emulate); @@emulate_booleans = emulate; end
41
-
42
- # @note Part of this module is implemented in "native" Java.
43
- # @see ActiveRecord::ConnectionAdapters::JdbcColumn
44
- module Column
45
-
46
- private
47
-
48
- def extract_limit(sql_type)
49
- case @sql_type = sql_type.downcase
50
- when /^smallint/i then @sql_type = 'smallint'; limit = 2
51
- when /^bigint/i then @sql_type = 'bigint'; limit = 8
52
- when /^double/i then @sql_type = 'double'; limit = 8 # DOUBLE PRECISION
53
- when /^real/i then @sql_type = 'real'; limit = 4
54
- when /^integer/i then @sql_type = 'integer'; limit = 4
55
- when /^datetime/i then @sql_type = 'datetime'; limit = nil
56
- when /^timestamp/i then @sql_type = 'timestamp'; limit = nil
57
- when /^time/i then @sql_type = 'time'; limit = nil
58
- when /^date/i then @sql_type = 'date'; limit = nil
59
- when /^xml/i then @sql_type = 'xml'; limit = nil
60
- else
61
- limit = super
62
- # handle maximum length for a VARCHAR string :
63
- limit = 32672 if ! limit && @sql_type.index('varchar') == 0
64
- end
65
- limit
66
- end
67
-
68
- # Post process default value from JDBC into a Rails-friendly format (columns{-internal})
69
- def default_value(value)
70
- # JDBC returns column default strings with actual single quotes around the value.
71
- return $1 if value =~ /^'(.*)'$/
72
- return nil if value == "GENERATED_BY_DEFAULT"
73
- value
74
- end
75
-
76
- end
77
-
78
- ADAPTER_NAME = 'Derby'.freeze
79
-
80
- def adapter_name
81
- ADAPTER_NAME
82
- end
83
-
84
- def configure_connection
85
- # must be done or SELECT...FOR UPDATE won't work how we expect :
86
- if tx_isolation = config[:transaction_isolation]
87
- @connection.transaction_isolation = tx_isolation
88
- end
89
- # if a user name was specified upon connection, the user's name is the
90
- # default schema for the connection, if a schema with that name exists
91
- set_schema(config[:schema]) if config[:schema]
92
- end
93
-
94
- def index_name_length
95
- 128
96
- end
97
-
98
- NATIVE_DATABASE_TYPES = {
99
- :primary_key => "int GENERATED BY DEFAULT AS identity NOT NULL PRIMARY KEY",
100
- :string => { :name => "varchar", :limit => 255 }, # 32672
101
- :text => { :name => "clob" }, # 2,147,483,647
102
- :char => { :name => "char", :limit => 254 }, # JDBC :limit => 254
103
- :binary => { :name => "blob" }, # 2,147,483,647
104
- :float => { :name => "float", :limit => 8 }, # DOUBLE PRECISION
105
- :real => { :name => "real", :limit => 4 }, # JDBC :limit => 23
106
- :double => { :name => "double", :limit => 8 }, # JDBC :limit => 52
107
- :decimal => { :name => "decimal", :precision => 5, :scale => 0 }, # JDBC :limit => 31
108
- :numeric => { :name => "decimal", :precision => 5, :scale => 0 }, # JDBC :limit => 31
109
- :integer => { :name => "integer", :limit => 4 }, # JDBC :limit => 10
110
- :smallint => { :name => "smallint", :limit => 2 }, # JDBC :limit => 5
111
- :bigint => { :name => "bigint", :limit => 8 }, # JDBC :limit => 19
112
- :date => { :name => "date" },
113
- :time => { :name => "time" },
114
- :datetime => { :name => "timestamp" },
115
- :timestamp => { :name => "timestamp" },
116
- :xml => { :name => "xml" },
117
- :boolean => { :name => "smallint", :limit => 1 }, # TODO boolean (since 10.7)
118
- :object => { :name => "object" },
119
- }
120
-
121
- # @private
122
- def initialize_type_map(m)
123
- super
124
- m.register_type(%r(smallint)i) do |sql_type|
125
- if Derby.emulate_booleans?
126
- ActiveRecord::Type::Boolean.new
127
- else
128
- ActiveRecord::Type::Integer.new(:limit => 1)
129
- end
130
- end
131
- m.alias_type %r(real)i, 'float'
132
- end if AR42
133
-
134
- def reset_column_information
135
- initialize_type_map(type_map)
136
- end if AR42
137
-
138
- # @override
139
- def native_database_types
140
- NATIVE_DATABASE_TYPES
141
- end
142
-
143
- # UNTESTED
144
- def existing_savepoint_name?(name)
145
- (@connection.instance_variable_get('@savepoints') || {}).key? name
146
- end
147
-
148
- # Ensure the savepoint name is unused before creating it.
149
- # @override
150
- def create_savepoint(name = current_savepoint_name(true))
151
- release_savepoint(name) if existing_savepoint_name?(name)
152
- super(name)
153
- end
154
-
155
- # @override
156
- def quote(value, column = nil)
157
- return super if column && ArJdbc::AR42 && column.cast_type.is_a?(ActiveRecord::Type::Serialized)
158
- return value.quoted_id if value.respond_to?(:quoted_id)
159
- return value if sql_literal?(value)
160
- return 'NULL' if value.nil?
161
-
162
- column_type = column && column.type
163
- if column_type == :string || column_type == :text
164
- # Derby is not permissive
165
- # e.g. sending an Integer to a VARCHAR column will fail
166
- case value
167
- when BigDecimal then value = value.to_s('F')
168
- when Numeric then value = value.to_s
169
- when true, false then value = value.to_s
170
- when Date, Time then value = quoted_date(value)
171
- else # on 2.3 attribute serialization needs to_yaml here
172
- value = value.to_s if ActiveRecord::VERSION::MAJOR >= 3
173
- end
174
- end
175
-
176
- case value
177
- when String, ActiveSupport::Multibyte::Chars
178
- if column_type == :text
179
- "CAST('#{quote_string(value)}' AS CLOB)"
180
- elsif column_type == :binary
181
- "CAST(X'#{quote_binary(value)}' AS BLOB)"
182
- elsif column_type == :xml
183
- "XMLPARSE(DOCUMENT '#{quote_string(value)}' PRESERVE WHITESPACE)"
184
- elsif column_type == :integer
185
- value.to_i
186
- elsif column_type == :float
187
- value.to_f
188
- else
189
- "'#{quote_string(value)}'"
190
- end
191
- else
192
- super
193
- end
194
- end
195
-
196
- # @override
197
- def quoted_date(value)
198
- if value.acts_like?(:time) && value.respond_to?(:usec)
199
- usec = sprintf("%06d", value.usec)
200
- value = ::ActiveRecord.default_timezone == :utc ? value.getutc : value.getlocal
201
- "#{value.strftime("%Y-%m-%d %H:%M:%S")}.#{usec}"
202
- else
203
- super
204
- end
205
- end if ::ActiveRecord::VERSION::MAJOR >= 3
206
-
207
- # @private In Derby, these cannot specify a limit.
208
- NO_LIMIT_TYPES = [ :integer, :boolean, :timestamp, :datetime, :date, :time ]
209
-
210
- # Convert the specified column type to a SQL string.
211
- # @override
212
- def type_to_sql(type, limit = nil, precision = nil, scale = nil)
213
- return super unless NO_LIMIT_TYPES.include?(t = type.to_s.downcase.to_sym)
214
-
215
- native_type = NATIVE_DATABASE_TYPES[t]
216
- native_type.is_a?(Hash) ? native_type[:name] : native_type
217
- end
218
-
219
- # @private
220
- class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
221
-
222
- def xml(*args)
223
- options = args.extract_options!
224
- column(args[0], 'xml', options)
225
- end
226
-
227
- end
228
-
229
- def table_definition(*args)
230
- new_table_definition(TableDefinition, *args)
231
- end
232
-
233
- # @override
234
- def empty_insert_statement_value
235
- ::Arel::Visitors::Derby::VALUES_DEFAULT # Derby needs to know the columns
236
- end
237
-
238
- # Set the sequence to the max value of the table's column.
239
- # @override
240
- def reset_sequence!(table, column, sequence = nil)
241
- mpk = select_value("SELECT MAX(#{quote_column_name(column)}) FROM #{quote_table_name(table)}")
242
- execute("ALTER TABLE #{quote_table_name(table)} ALTER COLUMN #{quote_column_name(column)} RESTART WITH #{mpk.to_i + 1}")
243
- end
244
-
245
- def reset_pk_sequence!(table, pk = nil, sequence = nil)
246
- klasses = classes_for_table_name(table)
247
- klass = klasses.nil? ? nil : klasses.first
248
- pk = klass.primary_key unless klass.nil?
249
- if pk && klass.columns_hash[pk].type == :integer
250
- reset_sequence!(klass.table_name, pk)
251
- end
252
- end
253
-
254
- def classes_for_table_name(table)
255
- ActiveRecord::Base.send(:subclasses).select { |klass| klass.table_name == table }
256
- end
257
- private :classes_for_table_name
258
-
259
- # @override
260
- def remove_index(table_name, options)
261
- execute "DROP INDEX #{index_name(table_name, options)}"
262
- end
263
-
264
- # @override
265
- def rename_table(name, new_name)
266
- execute "RENAME TABLE #{quote_table_name(name)} TO #{quote_table_name(new_name)}"
267
- end
268
-
269
- def add_column(table_name, column_name, type, options = {})
270
- add_column_sql = "ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
271
- add_column_options!(add_column_sql, options)
272
- execute(add_column_sql)
273
- end unless const_defined? :SchemaCreation
274
-
275
- # @override fix case where AR passes `:default => nil, :null => true`
276
- def add_column_options!(sql, options)
277
- options.delete(:default) if options.has_key?(:default) && options[:default].nil?
278
- sql << " DEFAULT #{quote(options.delete(:default))}" if options.has_key?(:default)
279
- super
280
- end unless const_defined? :SchemaCreation
281
-
282
- if ActiveRecord::VERSION::MAJOR >= 4
283
-
284
- # @override
285
- def remove_column(table_name, column_name, type = nil, options = {})
286
- do_remove_column(table_name, column_name)
287
- end
288
-
289
- else
290
-
291
- # @override
292
- def remove_column(table_name, *column_names)
293
- for column_name in column_names.flatten
294
- do_remove_column(table_name, column_name)
295
- end
296
- end
297
- alias remove_columns remove_column
298
-
299
- end
300
-
301
- def do_remove_column(table_name, column_name)
302
- execute "ALTER TABLE #{quote_table_name(table_name)} DROP COLUMN #{quote_column_name(column_name)} RESTRICT"
303
- end
304
- private :do_remove_column
305
-
306
- # @override
307
- def change_column(table_name, column_name, type, options = {})
308
- # TODO this needs a review since now we're likely to be on >= 10.8
309
-
310
- # Notes about changing in Derby:
311
- # http://db.apache.org/derby/docs/10.2/ref/rrefsqlj81859.html#rrefsqlj81859__rrefsqlj37860)
312
- #
313
- # We support changing columns using the strategy outlined in:
314
- # https://issues.apache.org/jira/browse/DERBY-1515
315
- #
316
- # This feature has not made it into a formal release and is not in Java 6.
317
- # We will need to conditionally support this (supposed to arrive for 10.3.0.0).
318
-
319
- # null/not nulling is easy, handle that separately
320
- if options.include?(:null)
321
- # This seems to only work with 10.2 of Derby
322
- if options.delete(:null) == false
323
- execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} NOT NULL"
324
- else
325
- execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} NULL"
326
- end
327
- end
328
-
329
- # anything left to do?
330
- unless options.empty?
331
- begin
332
- execute "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN " <<
333
- " #{quote_column_name(column_name)} SET DATA TYPE #{type_to_sql(type, options[:limit])}"
334
- rescue
335
- transaction do
336
- temp_new_column_name = "#{column_name}_newtype"
337
- # 1) ALTER TABLE t ADD COLUMN c1_newtype NEWTYPE;
338
- add_column table_name, temp_new_column_name, type, options
339
- # 2) UPDATE t SET c1_newtype = c1;
340
- execute "UPDATE #{quote_table_name(table_name)} SET " <<
341
- " #{quote_column_name(temp_new_column_name)} = " <<
342
- " CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit])})"
343
- # 3) ALTER TABLE t DROP COLUMN c1;
344
- remove_column table_name, column_name
345
- # 4) ALTER TABLE t RENAME COLUMN c1_newtype to c1;
346
- rename_column table_name, temp_new_column_name, column_name
347
- end
348
- end
349
- end
350
- end
351
-
352
- # @override
353
- def rename_column(table_name, column_name, new_column_name)
354
- execute "RENAME COLUMN #{quote_table_name(table_name)}.#{quote_column_name(column_name)} " <<
355
- " TO #{quote_column_name(new_column_name)}"
356
- end
357
-
358
- # SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause.
359
- #
360
- # Derby requires the ORDER BY columns in the select list for distinct queries, and
361
- # requires that the ORDER BY include the distinct column.
362
- # ```
363
- # distinct("posts.id", "posts.created_at desc")
364
- # ```
365
- # @note This is based on distinct method for the PostgreSQL Adapter.
366
- # @override
367
- def distinct(columns, order_by)
368
- "DISTINCT #{columns_for_distinct(columns, order_by)}"
369
- end
370
-
371
- # @override Since AR 4.0 (on 4.1 {#distinct} is gone and won't be called).
372
- def columns_for_distinct(columns, orders)
373
- return columns if orders.blank?
374
-
375
- # construct a clean list of column names from the ORDER BY clause,
376
- # removing any ASC/DESC modifiers
377
- order_columns = [ orders ]; order_columns.flatten! # AR 3.x vs 4.x
378
- order_columns.map! do |column|
379
- column = column.to_sql unless column.is_a?(String) # handle AREL node
380
- column.split(',').collect! { |s| s.split.first }
381
- end.flatten!
382
- order_columns.reject!(&:blank?)
383
- order_columns = order_columns.zip (0...order_columns.size).to_a
384
- order_columns = order_columns.map { |s, i| "#{s} AS alias_#{i}" }
385
-
386
- columns = [ columns ]; columns.flatten!
387
- columns.push( *order_columns ).join(', ')
388
- # return a DISTINCT clause that's distinct on the columns we want but
389
- # includes all the required columns for the ORDER BY to work properly
390
- end
391
-
392
- # @override
393
- def primary_keys(table_name)
394
- @connection.primary_keys table_name.to_s.upcase
395
- end
396
-
397
- # @override
398
- def tables(name = nil)
399
- @connection.tables(nil, current_schema)
400
- end
401
-
402
- # @override
403
- def supports_ddl_transactions?; true end
404
-
405
- # @override
406
- def supports_foreign_keys?; true end
407
-
408
- def truncate(table_name, name = nil)
409
- execute "TRUNCATE TABLE #{quote_table_name(table_name)}", name
410
- end
411
-
412
- # @return [String] the current schema name
413
- def current_schema
414
- @current_schema ||=
415
- select_value "SELECT CURRENT SCHEMA FROM SYS.SYSSCHEMAS FETCH FIRST 1 ROWS ONLY", 'SCHEMA'
416
- end
417
-
418
- # Change the current (implicit) Derby schema to be used for this connection.
419
- def set_schema(schema)
420
- @current_schema = nil
421
- execute "SET SCHEMA #{schema}", 'SCHEMA'
422
- end
423
- alias_method :current_schema=, :set_schema
424
-
425
- # Creates a new Derby schema.
426
- # @see #set_schema
427
- def create_schema(schema)
428
- execute "CREATE SCHEMA #{schema}", 'Create Schema'
429
- end
430
-
431
- # Drops an existing schema, needs to be empty (no DB objects).
432
- def drop_schema(schema)
433
- execute "DROP SCHEMA #{schema} RESTRICT", 'Drop Schema'
434
- end
435
-
436
- # @private
437
- def recreate_database(name = nil, options = {})
438
- drop_database(name)
439
- create_database(name, options)
440
- end
441
-
442
- # @private
443
- def create_database(name = nil, options = {}); end
444
-
445
- # @private
446
- def drop_database(name = nil)
447
- tables.each { |table| drop_table(table) }
448
- end
449
-
450
- # @override
451
- def quote_column_name(name)
452
- %Q{"#{name.to_s.upcase.gsub('"', '""')}"}
453
- end
454
-
455
- # @override
456
- def quote_table_name_for_assignment(table, attr)
457
- quote_column_name(attr)
458
- end if ::ActiveRecord::VERSION::MAJOR > 3
459
-
460
- # @note Only used with (non-AREL) ActiveRecord **2.3**.
461
- # @see Arel::Visitors::Derby
462
- def add_limit_offset!(sql, options)
463
- sql << " OFFSET #{options[:offset]} ROWS" if options[:offset]
464
- # ROWS/ROW and FIRST/NEXT mean the same
465
- sql << " FETCH FIRST #{options[:limit]} ROWS ONLY" if options[:limit]
466
- end if ::ActiveRecord::VERSION::MAJOR < 3
467
-
468
- # @override
469
- def execute(sql, name = nil, binds = [])
470
- sql = to_sql(sql, binds)
471
- insert = self.class.insert?(sql)
472
- update = ! insert && ! self.class.select?(sql)
473
- sql = correct_is_null(sql, insert || update)
474
- super(sql, name, binds)
475
- end
476
-
477
- # Returns the value of an identity column of the last *INSERT* statement
478
- # made over this connection.
479
- # @note Check the *IDENTITY_VAL_LOCAL* function for documentation.
480
- # @return [Fixnum]
481
- def last_insert_id
482
- @connection.identity_val_local
483
- end
484
-
485
- private
486
-
487
- def correct_is_null(sql, insert_or_update = false)
488
- if insert_or_update
489
- if ( i = sql =~ /\sWHERE\s/im )
490
- where_part = sql[i..-1]; sql = sql.dup
491
- where_part.gsub!(/!=\s*NULL/i, 'IS NOT NULL')
492
- where_part.gsub!(/=\sNULL/i, 'IS NULL')
493
- sql[i..-1] = where_part
494
- end
495
- sql
496
- else
497
- sql.gsub(/=\sNULL/i, 'IS NULL')
498
- end
499
- end
500
-
501
- # NOTE: only setup query analysis on AR <= 3.0 since on 3.1 {#exec_query},
502
- # {#exec_insert} will be used for AR generated queries/inserts etc.
503
- # Also there's prepared statement support and {#execute} is meant to stay
504
- # as a way of running non-prepared SQL statements (returning raw results).
505
- if ActiveRecord::VERSION::MAJOR < 3 ||
506
- ( ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 1 )
507
-
508
- def _execute(sql, name = nil)
509
- if self.class.insert?(sql)
510
- @connection.execute_insert(sql)
511
- elsif self.class.select?(sql)
512
- @connection.execute_query_raw(sql)
513
- else
514
- @connection.execute_update(sql)
515
- end
516
- end
517
-
518
- end
519
-
520
- end
521
- end
@@ -1,20 +0,0 @@
1
- ArJdbc::ConnectionMethods.module_eval do
2
- def derby_connection(config)
3
- config[:adapter_spec] ||= ::ArJdbc::Derby
4
-
5
- return jndi_connection(config) if jndi_config?(config)
6
-
7
- begin
8
- require 'jdbc/derby'
9
- ::Jdbc::Derby.load_driver(:require) if defined?(::Jdbc::Derby.load_driver)
10
- rescue LoadError # assuming driver.jar is on the class-path
11
- end
12
-
13
- config[:url] ||= "jdbc:derby:#{config[:database]};create=true"
14
- config[:driver] ||= defined?(::Jdbc::Derby.driver_name) ?
15
- ::Jdbc::Derby.driver_name : 'org.apache.derby.jdbc.EmbeddedDriver'
16
-
17
- embedded_driver(config)
18
- end
19
- alias_method :jdbcderby_connection, :derby_connection
20
- end
@@ -1,15 +0,0 @@
1
- module ArJdbc
2
- module Derby
3
- # @private
4
- class SchemaCreation < ::ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation
5
-
6
- private
7
-
8
- end
9
- end
10
-
11
- def schema_creation
12
- SchemaCreation.new self
13
- end
14
-
15
- end if ::ActiveRecord::ConnectionAdapters::AbstractAdapter.const_defined? :SchemaCreation
data/lib/arjdbc/derby.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'arjdbc'
2
- require 'arjdbc/derby/connection_methods'
3
- require 'arjdbc/derby/adapter'