activerecord-jdbc-adapter 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,14 @@
1
+ == 0.8.2
2
+
3
+ - Added an optional config key called :dialect. Using :dialect allows you to
4
+ override the default SQL dialect for the driver class being used. There are
5
+ a few cases for this:
6
+ - Using using Sybase w/ the jTDS driver.
7
+ - Using rebranded drivers.
8
+ - It makes more sense to use :dialect, rather then :driver when using JNDI.
9
+ - JRUBY-2619: Typo with :test config causing problems with dev database (Igor Minar)
10
+ - 20524, JRUBY-2612: Since when did I think that there was a #true? method on Object?
11
+
1
12
  == 0.8.1
2
13
 
3
14
  - Now sporting a JDBC sqlite3 adapter! Thanks Joseph Athman.
data/Manifest.txt CHANGED
@@ -56,6 +56,7 @@ test/h2_simple_test.rb
56
56
  test/has_many_through.rb
57
57
  test/hsqldb_simple_test.rb
58
58
  test/jdbc_adapter/jdbc_db2_test.rb
59
+ test/jdbc_adapter/jdbc_sybase_test.rb
59
60
  test/jdbc_common.rb
60
61
  test/jndi_test.rb
61
62
  test/manualTestDatabase.rb
data/Rakefile CHANGED
@@ -89,6 +89,12 @@ Rake::TestTask.new(:test_mssql) do | t |
89
89
  t.libs << 'test'
90
90
  end
91
91
 
92
+ # Tests for JDBC adapters that don't require a database.
93
+ Rake::TestTask.new(:test_jdbc_adapters) do | t |
94
+ t.test_files = FileList[ 'test/jdbc_adapter/jdbc_sybase_test.rb' ]
95
+ t.libs << 'test'
96
+ end
97
+
92
98
  MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt",
93
99
  "Rakefile", "LICENSE.txt", "lib/**/*.rb", "lib/jdbc_adapter/jdbc_adapter_internal.jar", "test/**/*.rb",
94
100
  "lib/**/*.rake", "src/**/*.java"]
@@ -269,9 +269,9 @@ module ActiveRecord
269
269
  h[val[0]] = val[1]; h }
270
270
 
271
271
  def initialize(config, name, default, *args)
272
- ds = config[:driver].to_s
272
+ dialect = config[:dialect] || config[:driver]
273
273
  for reg, func in COLUMN_TYPES
274
- if reg === ds
274
+ if reg === dialect.to_s
275
275
  func.call(config,self)
276
276
  end
277
277
  end
@@ -445,9 +445,9 @@ module ActiveRecord
445
445
  def initialize(connection, logger, config)
446
446
  super(connection, logger)
447
447
  @config = config
448
- ds = config[:driver].to_s
448
+ dialect = config[:dialect] || config[:driver]
449
449
  for reg, func in ADAPTER_TYPES
450
- if reg === ds
450
+ if reg === dialect.to_s
451
451
  func.call(@config,self)
452
452
  end
453
453
  end
@@ -64,7 +64,7 @@ namespace :db do
64
64
  namespace :test do
65
65
  redefine_task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
66
66
  abcs = ActiveRecord::Base.configurations
67
- ActiveRecord::Base.establish_connection(abcs[:test])
67
+ ActiveRecord::Base.establish_connection(abcs["test"])
68
68
  ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') if abcs["test"]["adapter"] =~ /mysql/i
69
69
  IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
70
70
  ActiveRecord::Base.connection.execute(ddl)
@@ -73,7 +73,7 @@ namespace :db do
73
73
 
74
74
  redefine_task :purge => :environment do
75
75
  abcs = ActiveRecord::Base.configurations
76
- ActiveRecord::Base.establish_connection(abcs[:test])
76
+ ActiveRecord::Base.establish_connection(abcs["test"])
77
77
  db = ActiveRecord::Base.connection.database_name
78
78
  ActiveRecord::Base.connection.recreate_database(db)
79
79
  end
@@ -90,7 +90,7 @@ module ::JdbcSpec
90
90
  # Override default -- fix case where ActiveRecord passes :default => nil, :null => true
91
91
  def add_column_options!(sql, options)
92
92
  options.delete(:default) if options.has_key?(:default) && options[:default].nil?
93
- options.delete(:null) if options.has_key?(:null) && (options[:null].nil? || options[:null].true?)
93
+ options.delete(:null) if options.has_key?(:null) && (options[:null].nil? || options[:null] == true)
94
94
  super
95
95
  end
96
96
 
@@ -1,5 +1,5 @@
1
1
  module JdbcAdapter
2
2
  module Version
3
- VERSION = "0.8.1"
3
+ VERSION = "0.8.2"
4
4
  end
5
5
  end
@@ -614,7 +614,7 @@ public class JdbcAdapterInternalService implements BasicLibraryService {
614
614
  Statement stmt = null;
615
615
  try {
616
616
  stmt = c.createStatement();
617
- return recv.getRuntime().newFixnum(stmt.executeUpdate(rubyApi.convertToRubyString(sql).getUnicodeValue()));
617
+ return recv.getRuntime().newFixnum((long)stmt.executeUpdate(rubyApi.convertToRubyString(sql).getUnicodeValue()));
618
618
  } finally {
619
619
  if (null != stmt) {
620
620
  try {
@@ -0,0 +1,33 @@
1
+ require 'jdbc_common'
2
+ require 'jdbc_adapter'
3
+
4
+ class MockConnection
5
+
6
+ def adapter=( adapt )
7
+ end
8
+
9
+ end
10
+
11
+ module ActiveRecord
12
+ module ConnectionAdapters
13
+
14
+ class SybaseAdapterSelectionTest < Test::Unit::TestCase
15
+
16
+ def testJtdsSelectionUsingDialect()
17
+ config = {
18
+ :driver => 'net.sourceforge.jtds.Driver',
19
+ :dialect => 'sybase'
20
+ }
21
+ adapt = JdbcAdapter.new(MockConnection.new, nil, config)
22
+ assert adapt.kind_of?(JdbcSpec::Sybase), "Should be a sybase adapter"
23
+ end
24
+
25
+ def testJtdsSelectionNotUsingDialect
26
+ config = { :driver => 'net.sourceforge.jtds.Driver' }
27
+ adapt = JdbcAdapter.new(MockConnection.new, nil, config)
28
+ assert adapt.kind_of?(JdbcSpec::MsSQL), "Should be a MsSQL apdater"
29
+ end
30
+
31
+ end
32
+ end
33
+ end
data/test/jndi_test.rb CHANGED
@@ -12,18 +12,16 @@
12
12
  #
13
13
  # Finally, you'll need the jdbc driver, which is derby, for this test.
14
14
 
15
- require 'models/auto_id'
16
- require 'models/entry'
15
+ require 'jdbc_common'
17
16
  require 'db/jndi_config'
18
- require 'simple'
19
- require 'test/unit'
20
- require 'logger'
21
17
 
22
18
  class DerbyJndiTest < Test::Unit::TestCase
23
19
  include SimpleTestMethods
24
20
  alias_method :setup_simple, :setup
25
21
  def setup
26
- ActiveRecord::Base.establish_connection({ :jndi => 'jdbc/derbydb', :adapter => 'jdbc'})
22
+ ActiveRecord::Base.establish_connection({
23
+ :jndi => 'jdbc/derbydb',
24
+ :adapter => 'jdbc'})
27
25
  logger = Logger.new('jndi_test.log')
28
26
  logger.level = Logger::DEBUG
29
27
  ActiveRecord::Base.logger = logger
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-jdbc-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger, Ola Bini and JRuby contributors
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-04 00:00:00 -05:00
12
+ date: 2008-06-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -83,6 +83,7 @@ files:
83
83
  - test/has_many_through.rb
84
84
  - test/hsqldb_simple_test.rb
85
85
  - test/jdbc_adapter/jdbc_db2_test.rb
86
+ - test/jdbc_adapter/jdbc_sybase_test.rb
86
87
  - test/jdbc_common.rb
87
88
  - test/jndi_test.rb
88
89
  - test/manualTestDatabase.rb