activerecord-jdbcnuodb-adapter 1.0.0 → 1.0.1

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.
data/README.rdoc CHANGED
@@ -17,24 +17,42 @@ An ActiveRecord JDBC Adapter for NuoDB.
17
17
  database: test
18
18
  username: cloud
19
19
  password: user
20
+ schema: test
20
21
 
21
22
  2. In the Gemfile, call the nuodb gem with:
22
23
 
23
- gem 'activerecord-jdbcnuodb-adapter'
24
+ jruby -S gem 'activerecord-jdbcnuodb-adapter'
25
+
26
+ == ENVIRONMENT SETUP
27
+
28
+ === MAC
29
+
30
+ To set up JRuby on Mac, you may optimally install RVM and use that to install
31
+ JRuby, or you may also install it from the package installer available online
32
+ which requires additional environment setup.
33
+
34
+ For Mac, run the package installer available at:
35
+
36
+ http://jruby.org.s3.amazonaws.com/downloads/1.7.2/JRuby-1.7.2.dmg
37
+
38
+ Then update your path so that the Gem from JRuby is first on your path ahead
39
+ of the system installed ruby:
40
+
41
+ export PATH=/Library/Frameworks/JRuby.framework/Versions/Current/bin:$PATH
24
42
 
25
43
  == BUILDING THE GEM
26
44
 
27
45
  To compile and test run this command:
28
46
 
29
- rake clean build rdoc spec
47
+ jruby -S rake clean build rdoc spec
30
48
 
31
49
  == INSTALLING THE GEM
32
50
 
33
- gem install activerecord-jdbcnuodb-adapter-1.0.0.gem
51
+ jruby -S gem install activerecord-jdbcnuodb-adapter-1.0.1.gem
34
52
 
35
53
  Or from the source tree:
36
54
 
37
- gem install pkg/activerecord-jdbcnuodb-adapter-1.0.0.gem
55
+ jruby -S gem install pkg/activerecord-jdbcnuodb-adapter-1.0.1.gem
38
56
 
39
57
  == TESTING THE GEM
40
58
 
@@ -52,21 +70,24 @@ Create a user in the database:
52
70
 
53
71
  Run the tests:
54
72
 
55
- rake spec
73
+ export CLASSPATH=${NUODB_ROOT}/jar/nuodbjdbc.jar
74
+ jruby -S rake spec
56
75
 
57
76
  == TRYING THE SAMPLE
58
77
 
59
78
  1. Install the NuoDB gems:
60
79
 
61
- gem install jdbc-nuodb-1.0.0.gem
62
- gem install activerecord-jdbcnuodb-adapter-1.0.0.gem
80
+ jruby -S gem install rails
81
+ jruby -S gem install jdbc-nuodb-1.0.1.gem
82
+ jruby -S gem install activerecord-jdbcnuodb-adapter-1.0.1.gem
63
83
 
64
84
  2. Verify the gems are installed:
65
85
 
66
- gem list
86
+ jruby -S gem list
67
87
 
68
88
  3. Run the sample:
69
89
 
90
+ export CLASSPATH=/path/to/nuodb/jar/nuodbjdbc.jar
70
91
  jruby samples/sample.rb
71
92
 
72
93
  == PUBLISHING THE GEM
@@ -75,25 +96,26 @@ Run the tests:
75
96
 
76
97
  Tag the product using tags per the SemVer specification; our tags have a v-prefix:
77
98
 
78
- git tag -a v1.0.0 -m "SemVer Version: v1.0.0"
99
+ git tag -a v1.0.1 -m "SemVer Version: v1.0.1"
100
+ git push --tags
79
101
 
80
102
  If you make a mistake, take it back quickly:
81
103
 
82
- git tag -d v1.0.0
83
- git push origin :refs/tags/v1.0.0
104
+ git tag -d v1.0.1
105
+ git push origin :refs/tags/v1.0.1
84
106
 
85
107
  ===PUBLISHING
86
108
 
87
109
  Here are the commands used to publish:
88
110
 
89
- gem push pkg/activerecord-jdbcnuodb-adapter-1.0.0.gem
111
+ gem push pkg/activerecord-jdbcnuodb-adapter-1.0.1.gem
90
112
 
91
113
  == INSPECTING THE GEM
92
114
 
93
115
  It is often useful to inspect the contents of a Gem before distribution.
94
116
  To do this you dump the contents of a gem thus:
95
117
 
96
- gem unpack pkg/activerecord-jdbcnuodb-adapter-1.0.0.gem
118
+ gem unpack pkg/activerecord-jdbcnuodb-adapter-1.0.1.gem
97
119
 
98
120
  == REFERENCES
99
121
 
data/Rakefile CHANGED
@@ -35,8 +35,8 @@ require 'date'
35
35
  require 'bundler'
36
36
  require 'bundler/gem_tasks'
37
37
 
38
- require File.expand_path(File.dirname(__FILE__)) + "/spec/support/config"
39
- require File.expand_path(File.dirname(__FILE__)) + "/tasks/rspec"
38
+ require File.expand_path(File.dirname(__FILE__)) + '/spec/support/config'
39
+ require File.expand_path(File.dirname(__FILE__)) + '/tasks/rspec'
40
40
 
41
41
  Bundler::GemHelper.install_tasks
42
42
 
@@ -141,25 +141,25 @@ task :default => :spec
141
141
 
142
142
  desc "Build #{gem_file} into the pkg directory"
143
143
  task :build do
144
- sh "mkdir -p pkg"
144
+ sh 'mkdir -p pkg'
145
145
  sh "gem build #{gemspec_file}"
146
146
  sh "mv #{gem_file} pkg"
147
147
  end
148
148
 
149
149
  task :install => :build do
150
- sh %{gem install pkg/#{name}-#{version}}
150
+ sh %{jruby -S gem install pkg/#{name}-#{version}}
151
151
  end
152
152
 
153
153
  task :uninstall do
154
- sh %{gem uninstall #{name} -x -v #{version}}
154
+ sh %{jruby -S gem uninstall #{name} -x -v #{version}}
155
155
  end
156
156
 
157
- desc "Tags git with the latest gem version"
157
+ desc 'Tags git with the latest gem version'
158
158
  task :tag do
159
159
  sh %{git tag v#{version}}
160
160
  end
161
161
 
162
- desc "Push gem packages"
162
+ desc 'Push gem packages'
163
163
  task :push => :build do
164
164
  sh "gem push pkg/#{name}*.gem"
165
165
  end
@@ -1,9 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $:.push lib unless $:.include?(lib)
5
+ require 'activerecord-jdbcnuodb-adapter'
6
+
3
7
  Gem::Specification.new do |spec|
4
8
  spec.name = 'activerecord-jdbcnuodb-adapter'
5
- spec.version = '1.0.0'
6
- spec.authors = ['Dave Meppelink', 'Robert Buck']
9
+ spec.version = ArJdbc::NuoDB::VERSION
10
+ spec.authors = ['Robert Buck', 'Dave Meppelink']
7
11
  spec.email = 'rbuck@nuodb.com'
8
12
  spec.description = 'ActiveRecord adapter for NuoDB. Only for use with JRuby. Requires separate Cache JDBC driver.'
9
13
  spec.summary = 'ActiveRecord adapter for NuoDB.'
@@ -18,14 +22,14 @@ Gem::Specification.new do |spec|
18
22
 
19
23
  spec.test_files = spec.files.select { |path| path =~ /^test\/.*test.*\.rb/ }
20
24
 
21
- spec.add_dependency 'jdbc-nuodb', '~> 1.0.0'
25
+ spec.add_dependency 'jdbc-nuodb', '~> 1.0.1'
22
26
  spec.add_dependency 'activerecord-jdbc-adapter', '>= 1.0.0'
23
27
 
24
28
  %w(rake).each { |gem| spec.add_development_dependency gem }
25
- %w(rspec rspec-core rspec-expectations rspec-mocks).each { |gem| spec.add_development_dependency gem, "~> 2.11.0" }
29
+ %w(rspec rspec-core rspec-expectations rspec-mocks).each { |gem| spec.add_development_dependency gem, '~> 2.11.0' }
26
30
 
27
31
  spec.rubygems_version = %q{1.3.7}
28
- spec.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if spec.respond_to? :required_rubygems_version=
32
+ spec.required_rubygems_version = Gem::Requirement.new('> 1.3.1') if spec.respond_to? :required_rubygems_version=
29
33
  if spec.respond_to? :specification_version
30
34
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
31
35
  spec.specification_version = 3
@@ -0,0 +1 @@
1
+ require 'arjdbc/nuodb'
@@ -1,5 +1,5 @@
1
1
  module ArJdbc
2
2
  module NuoDB
3
- VERSION = "1.0.0"
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -1,21 +1,20 @@
1
1
  module Arel
2
2
  module Visitors
3
3
  class NuoDB < Arel::Visitors::ToSql
4
- def visit_Arel_Nodes_Lock o
5
- visit o.expr
4
+ def visit_Arel_Nodes_SelectStatement o
5
+ [
6
+ (visit(o.with) if o.with),
7
+ o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join,
8
+ ("ORDER BY #{o.orders.map { |x| visit x }.join(', ')}" unless o.orders.empty?),
9
+ (visit(o.offset) if o.offset),
10
+ (visit(o.limit) if o.limit),
11
+ (visit(o.lock) if o.lock),
12
+ ].compact.join ' '
6
13
  end
7
14
 
8
15
  def visit_Arel_Nodes_Limit o
9
16
  "FETCH FIRST #{visit o.expr} ROWS ONLY"
10
17
  end
11
-
12
- def visit_Arel_Nodes_Matches o
13
- "#{visit o.left} LIKE #{visit o.right}"
14
- end
15
-
16
- def visit_Arel_Nodes_DoesNotMatch o
17
- "#{visit o.left} NOT LIKE #{visit o.right}"
18
- end
19
18
  end
20
19
  end
21
20
  end
data/lib/arjdbc/nuodb.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  require 'arjdbc'
2
- require 'arjdbc/nuodb/connection_methods'
2
+ require 'arel/visitors/nuodb'
3
3
  require 'arjdbc/nuodb/adapter'
4
- require 'arel/visitors/nuodb'
4
+ require 'arjdbc/nuodb/connection_methods'
@@ -1,17 +1,100 @@
1
+ require 'bigdecimal'
2
+ require 'active_record/connection_adapters/abstract/schema_definitions'
3
+
1
4
  module ::ArJdbc
2
5
  module NuoDB
3
6
 
4
7
  def self.column_selector
5
- [/nuodb/i, lambda { |cfg, col| col.extend(::ArJdbc::NuoDB::Column) }]
6
- end
7
-
8
- module Column
8
+ [/nuodb/i, lambda { |cfg, col| col.extend(::ArJdbc::NuoDB::ColumnExtensions) }]
9
9
  end
10
10
 
11
11
  def self.arel2_visitors(config)
12
12
  {}.tap { |v| %w(nuodb).each { |a| v[a] = ::Arel::Visitors::NuoDB } }
13
13
  end
14
14
 
15
+ # COLUMNS ================================================================
16
+
17
+ module ColumnExtensions
18
+
19
+ def simplified_type(field_type)
20
+ case field_type
21
+ when /bit/i then
22
+ :boolean
23
+ else
24
+ super
25
+ end
26
+ end
27
+
28
+ def extract_limit(sql_type)
29
+ case sql_type
30
+ when /^smallint/i
31
+ 2
32
+ when /^int/i
33
+ 4
34
+ when /^bigint/i
35
+ 8
36
+ else
37
+ super
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ # ADAPTER SUPPORT ========================================================
44
+
45
+ ADAPTER_NAME = 'NuoDB'
46
+
47
+ NATIVE_DATABASE_TYPES = {
48
+ # generic rails types...
49
+ :binary => {:name => 'binary'},
50
+ :boolean => {:name => 'boolean'},
51
+ :date => {:name => 'date'},
52
+ :datetime => {:name => 'datetime'},
53
+ :decimal => {:name => 'decimal'},
54
+ :float => {:name => 'float', :limit => 8},
55
+ :integer => {:name => 'integer'},
56
+ :primary_key => 'int not null generated by default as identity primary key',
57
+ :string => {:name => 'varchar', :limit => 255},
58
+ :text => {:name => 'varchar', :limit => 255},
59
+ :time => {:name => 'time'},
60
+ :timestamp => {:name => 'timestamp'},
61
+ # nuodb specific types...
62
+ :char => {:name => 'char'},
63
+ :numeric => {:name => 'numeric(20)'},
64
+ }
65
+
66
+ def native_database_types
67
+ NATIVE_DATABASE_TYPES
68
+ end
69
+
70
+ def adapter_name
71
+ ADAPTER_NAME
72
+ end
73
+
74
+ def supports_savepoints?
75
+ true
76
+ end
77
+
78
+ def supports_ddl_transactions?
79
+ true
80
+ end
81
+
82
+ def supports_index_sort_order?
83
+ true
84
+ end
85
+
86
+ def create_savepoint
87
+ execute("SAVEPOINT #{current_savepoint_name}")
88
+ end
89
+
90
+ def rollback_to_savepoint
91
+ execute("ROLLBACK TO SAVEPOINT #{current_savepoint_name}")
92
+ end
93
+
94
+ def release_savepoint
95
+ execute("RELEASE SAVEPOINT #{current_savepoint_name}")
96
+ end
97
+
15
98
  def modify_types(tp)
16
99
  tp[:primary_key] = 'int not null generated always primary key'
17
100
  tp[:boolean] = {:name => 'boolean'}
@@ -23,21 +106,7 @@ module ::ArJdbc
23
106
  tp
24
107
  end
25
108
 
26
- def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
27
- limit = nil if %w(text binary string).include? type.to_s
28
- return 'uniqueidentifier' if (type.to_s == 'uniqueidentifier')
29
- return super unless type.to_s == 'integer'
30
-
31
- if limit.nil? || limit == 4
32
- 'int'
33
- elsif limit == 2
34
- 'smallint'
35
- elsif limit == 1
36
- 'smallint'
37
- else
38
- 'bigint'
39
- end
40
- end
109
+ # QUOTING ================================================================
41
110
 
42
111
  def quote(value, column = nil)
43
112
  case value
@@ -48,26 +117,93 @@ module ::ArJdbc
48
117
  end
49
118
  end
50
119
 
120
+ def quote_column_name(name)
121
+ "`#{name.to_s.gsub('`', '``')}`"
122
+ end
123
+
124
+ def quote_table_name(name)
125
+ quote_column_name(name).gsub('.', '`.`')
126
+ end
127
+
128
+ def type_cast(value)
129
+ return super unless value == true || value == false
130
+ value ? true : false
131
+ end
132
+
133
+ def quoted_true
134
+ "'true'"
135
+ end
136
+
137
+ def quoted_false
138
+ "'false'"
139
+ end
140
+
141
+ def quoted_date(value)
142
+ if value.acts_like?(:time)
143
+ zone_conversion_method = :getutc
144
+ if value.respond_to?(zone_conversion_method)
145
+ value = value.send(zone_conversion_method)
146
+ end
147
+ end
148
+ value.to_s(:db)
149
+ end
150
+
151
+ # COMPATIBILITY ==========================================================
152
+
153
+ # SCHEMA STATEMENTS ======================================================
154
+
155
+ def columns(table_name, name=nil)
156
+ @connection.columns_internal(table_name.to_s, name, nuodb_schema)
157
+ end
158
+
159
+ # maps logical rails types to nuodb-specific data types.
160
+ def type_to_sql(type, limit = nil, precision = nil, scale = nil)
161
+ case type.to_s
162
+ when 'integer'
163
+ return 'integer' unless limit
164
+ case limit
165
+ when 1..2
166
+ 'smallint'
167
+ when 3..4
168
+ 'integer'
169
+ when 5..8
170
+ 'bigint'
171
+ else
172
+ raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.")
173
+ end
174
+ else
175
+ super
176
+ end
177
+ end
178
+
179
+ def rename_column(table_name, column_name, new_column_name)
180
+ raise NotImplementedError, "rename_column is not implemented"
181
+ end
182
+
183
+ def rename_table(table_name, new_name)
184
+ raise NotImplementedError, "rename_table is not implemented"
185
+ end
186
+
187
+ # DATABASE STATEMENTS ====================================================
188
+
51
189
  def exec_insert(sql, name, binds)
52
190
  sql = substitute_binds(sql, binds)
53
191
  @connection.execute_insert(sql)
54
192
  end
55
193
 
194
+ # CONNECTION POOL ========================================================
195
+
56
196
  def primary_keys(table)
57
197
  @connection.primary_keys(qualify_table(table))
58
198
  end
59
199
 
60
- def columns(table_name, name=nil)
61
- @connection.columns_internal(table_name.to_s, name, nuodb_schema)
62
- end
63
-
64
200
  private
65
201
 
66
202
  def qualify_table(table)
67
203
  if (table.include? '.') || @config[:schema].blank?
68
204
  table
69
205
  else
70
- nuodb_schema + "." + table
206
+ nuodb_schema + '.' + table
71
207
  end
72
208
  end
73
209
 
@@ -78,3 +214,37 @@ module ::ArJdbc
78
214
  end
79
215
 
80
216
  end
217
+
218
+ module ActiveRecord::ConnectionAdapters
219
+
220
+ class NuoDBColumn < JdbcColumn
221
+
222
+ include ArJdbc::NuoDB::ColumnExtensions
223
+
224
+ def initialize(name, *args)
225
+ if Hash === name
226
+ super
227
+ else
228
+ super(nil, name, *args)
229
+ end
230
+ end
231
+
232
+ def call_discovered_column_callbacks(*)
233
+ end
234
+ end
235
+
236
+ class NuoDBAdapter < JdbcAdapter
237
+
238
+ include ArJdbc::NuoDB
239
+
240
+ def initialize(*args)
241
+ super
242
+ end
243
+
244
+ def jdbc_column_class
245
+ ActiveRecord::ConnectionAdapters::NuoDBColumn
246
+ end
247
+
248
+ end
249
+
250
+ end
@@ -1,11 +1,13 @@
1
1
  class ActiveRecord::Base
2
2
  class << self
3
3
  def nuodb_connection(config)
4
+ config[:port] ||= 48004
4
5
  config[:schema] ||= config[:database]
5
- config[:url] ||= "jdbc:com.nuodb://#{config[:host]}/#{config[:database]}?schema=#{config[:schema]}"
6
- config[:driver] ||= "com.nuodb.jdbc.Driver"
6
+ config[:url] ||= "jdbc:com.nuodb://#{config[:host]}:#{config[:port]}/#{config[:database]}?schema=#{config[:schema]}"
7
+ config[:driver] ||= defined?(::Jdbc::NuoDB.driver_name) ? ::Jdbc::NuoDB.driver_name : 'com.nuodb.jdbc.Driver'
7
8
  config[:adapter_spec] ||= ::ArJdbc::NuoDB
8
- config[:connection_alive_sql] ||= "select 1 from system.tables fetch first 1 rows"
9
+ config[:adapter_class] = ActiveRecord::ConnectionAdapters::NuoDBAdapter
10
+ config[:connection_alive_sql] ||= 'select 1 from system.tables fetch first 1 rows'
9
11
  jdbc_connection(config)
10
12
  end
11
13
  end
data/samples/sample.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'active_record'
3
3
 
4
- puts "Connecting to database..."
4
+ puts 'Connecting to database...'
5
5
 
6
6
  ActiveRecord::Base.establish_connection(
7
7
  :adapter => 'nuodb',
@@ -10,13 +10,13 @@ ActiveRecord::Base.establish_connection(
10
10
  :password => 'user'
11
11
  )
12
12
 
13
- puts "Create tables..."
13
+ puts 'Create tables...'
14
14
 
15
15
  class User < ActiveRecord::Base
16
16
  has_one :addr, :class_name => 'Addr'
17
17
 
18
18
  def to_s
19
- "User(#{id}), Username: #{user_name}, Name: #{first_name} #{last_name}, #{admin ? "admin" : "member"}\n" +
19
+ "User(#{id}), Username: #{user_name}, Name: #{first_name} #{last_name}, #{admin ? 'admin' : 'member'}\n" +
20
20
  " Address: #{addr}\n"
21
21
  end
22
22
  end
@@ -48,48 +48,48 @@ ActiveRecord::Schema.define do
48
48
  end
49
49
  end
50
50
 
51
- puts "Create user records..."
51
+ puts 'Create user records...'
52
52
 
53
53
  user = User.create do |user_instance|
54
- user_instance.first_name = "Fred"
55
- user_instance.last_name = "Flintstone"
56
- user_instance.email = "fredf@example.com"
57
- user_instance.user_name = "fred"
54
+ user_instance.first_name = 'Fred'
55
+ user_instance.last_name = 'Flintstone'
56
+ user_instance.email = 'fredf@example.com'
57
+ user_instance.user_name = 'fred'
58
58
  user_instance.admin = true
59
59
  end
60
60
 
61
61
  user.create_addr do |address|
62
- address.street = "301 Cobblestone Way"
63
- address.city = "Bedrock"
64
- address.zip = "00001"
62
+ address.street = '301 Cobblestone Way'
63
+ address.city = 'Bedrock'
64
+ address.zip = '00001'
65
65
  end
66
66
 
67
67
  puts "Created #{user}"
68
68
 
69
69
  user = User.create do |user_instance|
70
- user_instance.first_name = "Barney"
71
- user_instance.last_name = "Rubble"
72
- user_instance.email = "barney@example.com"
73
- user_instance.user_name = "barney"
70
+ user_instance.first_name = 'Barney'
71
+ user_instance.last_name = 'Rubble'
72
+ user_instance.email = 'barney@example.com'
73
+ user_instance.user_name = 'barney'
74
74
  user_instance.admin = false
75
75
  end
76
76
 
77
77
  user.create_addr do |address|
78
- address.street = "303 Cobblestone Way"
79
- address.city = "Bedrock"
80
- address.zip = "00001"
78
+ address.street = '303 Cobblestone Way'
79
+ address.city = 'Bedrock'
80
+ address.zip = '00001'
81
81
  end
82
82
 
83
83
  puts "Created #{user}"
84
84
 
85
- puts "Print user records..."
85
+ puts 'Print user records...'
86
86
 
87
87
  puts "Found #{User.count} records:"
88
88
  User.find do |entry|
89
89
  puts entry
90
90
  end
91
91
 
92
- puts "Modify user records..."
92
+ puts 'Modify user records...'
93
93
 
94
94
  User.all.each do |entry|
95
95
  entry.first_name = entry.first_name.upcase
@@ -100,7 +100,7 @@ User.all.each do |entry|
100
100
  entry.save
101
101
  end
102
102
 
103
- puts "Print user records..."
103
+ puts 'Print user records...'
104
104
 
105
105
  puts "Found #{User.count} records:"
106
106
  User.find_each do |entry|
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+ require 'active_record'
3
+ require 'active_record/connection_adapters/jdbcnuodb_adapter'
4
+
5
+ describe ActiveRecord::ConnectionAdapters::NuoDBAdapter do
6
+ before do
7
+ end
8
+
9
+ after do
10
+ end
11
+
12
+ context 'using transactions' do
13
+
14
+ before(:each) do
15
+ end
16
+
17
+ after(:each) do
18
+ end
19
+
20
+ it 'is supported by the driver' do
21
+ lambda {
22
+ ActiveRecord::Base.establish_connection(
23
+ :adapter => 'nuodb',
24
+ :database => 'test',
25
+ :username => 'cloud',
26
+ :password => 'user'
27
+ )
28
+
29
+ ActiveRecord::Schema.define do
30
+ drop_table :tracks if self.table_exists?('tracks')
31
+ drop_table :albums if self.table_exists?('albums')
32
+ end
33
+
34
+ ActiveRecord::Schema.define do
35
+ create_table :albums do |table|
36
+ table.column :title, :string
37
+ table.column :performer, :string
38
+ end
39
+
40
+ create_table :tracks do |table|
41
+ table.column :album_id, :integer
42
+ table.column :track_number, :integer
43
+ table.column :title, :string
44
+ end
45
+ end
46
+
47
+ class Album < ActiveRecord::Base
48
+ has_many :tracks
49
+ end
50
+
51
+ class Track < ActiveRecord::Base
52
+ belongs_to :album
53
+ end
54
+
55
+ Album.transaction do
56
+ album = Album.create(:title => 'Black and Blue', :performer => 'The Rolling Stones')
57
+ album.tracks.create(:track_number => 1, :title => 'Hot Stuff')
58
+ album.tracks.create(:track_number => 2, :title => 'Hand Of Fate')
59
+ album.tracks.create(:track_number => 3, :title => 'Cherry Oh Baby ')
60
+ album.tracks.create(:track_number => 4, :title => 'Memory Motel ')
61
+ album.tracks.create(:track_number => 5, :title => 'Hey Negrita')
62
+ album.tracks.create(:track_number => 6, :title => 'Fool To Cry')
63
+ album.tracks.create(:track_number => 7, :title => 'Crazy Mama')
64
+ album.tracks.create(:track_number => 8, :title => 'Melody (Inspiration By Billy Preston)')
65
+ end
66
+
67
+ }.should_not raise_error
68
+ end
69
+
70
+ end
71
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,14 @@
1
- $:.unshift File.expand_path("../..", __FILE__)
1
+ $:.unshift File.expand_path('../..', __FILE__)
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rspec/mocks'
5
5
 
6
- $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
7
- $:.unshift(File.expand_path("../lib", __FILE__))
6
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $:.unshift(File.expand_path('../lib', __FILE__))
8
8
  $:.unshift(File.dirname(__FILE__))
9
9
 
10
10
  require 'java'
11
- require 'jdbc/nuodb'
11
+ require 'active_record/connection_adapters/jdbcnuodb_adapter'
12
12
  require 'support/config'
13
13
  require 'support/connection'
14
+ require 'active_record'
data/tasks/rspec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- GEM_ROOT ||= File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
+ GEM_ROOT ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
5
5
 
6
6
  begin
7
7
 
@@ -9,26 +9,26 @@ begin
9
9
 
10
10
  task :default => :spec
11
11
 
12
- desc "Run all specs in spec directory"
12
+ desc 'Run all specs in spec directory'
13
13
  RSpec::Core::RakeTask.new(:spec) do |t|
14
14
  t.rspec_opts = ['--options', "\"#{GEM_ROOT}/.rspec\""]
15
15
  t.pattern = FileList['spec/**/*_spec.rb']
16
16
  end
17
17
 
18
- desc "Run all rspec functional tests (in functional/ directory)"
18
+ desc 'Run all rspec functional tests (in functional/ directory)'
19
19
  RSpec::Core::RakeTask.new(:functional) do |t|
20
20
  t.rspec_opts = ['--options', "\"#{GEM_ROOT}/spec/spec.opts\""]
21
21
  t.pattern = FileList['spec/functional/**/*_spec.rb']
22
22
  end
23
23
 
24
- desc "Run all rspec unit tests (in unit/ directory)"
24
+ desc 'Run all rspec unit tests (in unit/ directory)'
25
25
  RSpec::Core::RakeTask.new(:spec_unit) do |t|
26
26
  t.rspec_opts = ['--options', "\"#{GEM_ROOT}/.rspec\""]
27
27
  t.pattern = FileList['spec/unit/**/*_spec.rb']
28
28
  end
29
29
 
30
30
  namespace :spec do
31
- desc "Print Specdoc for all specs"
31
+ desc 'Print Specdoc for all specs'
32
32
  RSpec::Core::RakeTask.new(:doc) do |t|
33
33
  t.rspec_opts = %w(--format specdoc --dry-run)
34
34
  t.pattern = FileList['spec/**/*_spec.rb']
data/tasks/stats.rb CHANGED
@@ -1,8 +1,8 @@
1
- desc "Prints lines of code metrics"
1
+ desc 'Prints lines of code metrics'
2
2
  task :stats do
3
3
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
4
4
 
5
- FileList["lib/nuodb/**/*.rb", "ext/nuodb/*.cpp"].each { |file_name|
5
+ FileList['lib/nuodb/**/*.rb', 'ext/nuodb/*.cpp'].each { |file_name|
6
6
  next if file_name =~ /vendor/
7
7
  f = File.open(file_name)
8
8
 
@@ -12,7 +12,7 @@ task :stats do
12
12
  next if line =~ /^\s*#/
13
13
  codelines += 1
14
14
  end
15
- puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
15
+ puts "L: #{sprintf('%4d', lines)}, LOC #{sprintf('%4d', codelines)} | #{file_name}"
16
16
 
17
17
  total_lines += lines
18
18
  total_codelines += codelines
metadata CHANGED
@@ -2,15 +2,15 @@
2
2
  name: activerecord-jdbcnuodb-adapter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
- - Dave Meppelink
9
8
  - Robert Buck
9
+ - Dave Meppelink
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-08 00:00:00.000000000 Z
13
+ date: 2013-02-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jdbc-nuodb
@@ -18,13 +18,13 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.0
21
+ version: 1.0.1
22
22
  none: false
23
23
  requirement: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 1.0.0
27
+ version: 1.0.1
28
28
  none: false
29
29
  prerelease: false
30
30
  type: :runtime
@@ -141,6 +141,7 @@ files:
141
141
  - README.rdoc
142
142
  - Rakefile
143
143
  - activerecord-jdbcnuodb-adapter.gemspec
144
+ - lib/active_record/connection_adapters/jdbcnuodb_adapter.rb
144
145
  - lib/active_record/connection_adapters/nuodb_adapter.rb
145
146
  - lib/activerecord-jdbcnuodb-adapter.rb
146
147
  - lib/arel/visitors/nuodb.rb