dm-do-adapter 1.0.2 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,44 +1,46 @@
1
+ require 'pathname'
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
- DATAMAPPER = 'git://github.com/datamapper'
4
- DM_VERSION = '~> 1.0.2'
5
- DO_VERSION = '~> 0.10.2'
5
+ SOURCE = ENV.fetch('SOURCE', :git).to_sym
6
+ REPO_POSTFIX = SOURCE == :path ? '' : '.git'
7
+ DATAMAPPER = SOURCE == :path ? Pathname(__FILE__).dirname.parent : 'http://github.com/datamapper'
8
+ DM_VERSION = '~> 1.1.0.rc1'
9
+ DO_VERSION = '~> 0.10.2'
6
10
 
7
- group :runtime do # Runtime dependencies (as in the gemspec)
11
+ group :runtime do
8
12
 
9
13
  do_options = {}
10
- do_options[:git] = "#{DATAMAPPER}/do.git" if ENV['DO_GIT'] == 'true'
14
+ do_options[:git] = "#{DATAMAPPER}/do#{REPO_POSTFIX}" if ENV['DO_GIT'] == 'true'
11
15
 
12
- gem 'data_objects', DO_VERSION, do_options.dup
13
- gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
16
+ gem 'data_objects', DO_VERSION, do_options.dup
17
+ gem 'dm-core', DM_VERSION, SOURCE => "#{DATAMAPPER}/dm-core#{REPO_POSTFIX}"
14
18
 
15
19
  end
16
20
 
17
- group(:development) do # Development dependencies
21
+ group :development do
18
22
 
19
- gem 'rake', '~> 0.8.7'
20
- gem 'rspec', '~> 1.3', :git => 'git://github.com/snusnu/rspec', :branch => 'heckle_fix_plus_gemfile'
21
- gem 'jeweler', '~> 1.4'
23
+ gem 'jeweler', '~> 1.5.2'
24
+ gem 'rake', '~> 0.8.7'
25
+ gem 'rspec', '~> 1.3.1'
22
26
 
23
27
  end
24
28
 
25
- group :datamapper do # We need this because we want to pin these dependencies to their git master sources
29
+ group :quality do
26
30
 
27
- if ENV['EXTLIB']
28
- gem 'extlib', '~> 0.9.15', :git => "#{DATAMAPPER}/extlib.git", :require => nil
29
- else
30
- gem 'activesupport', '~> 3.0.0', :git => 'git://github.com/rails/rails.git', :branch => '3-0-stable', :require => nil
31
- end
31
+ gem 'rcov', '~> 0.9.9', :platforms => :mri_18
32
+ gem 'yard', '~> 0.6'
33
+ gem 'yardstick', '~> 0.2'
32
34
 
33
35
  end
34
36
 
35
- group :quality do # These gems contain rake tasks that check the quality of the source code
37
+ group :datamapper do
36
38
 
37
- gem 'metric_fu', '~> 1.3'
38
- gem 'rcov', '~> 0.9.7'
39
- gem 'reek', '~> 1.2.7'
40
- gem 'roodi', '~> 2.1'
41
- gem 'yard', '~> 0.5'
42
- gem 'yardstick', '~> 0.1'
39
+ if ENV['EXTLIB']
40
+ gem 'extlib', '~> 0.9.15', SOURCE => "#{DATAMAPPER}/extlib#{REPO_POSTFIX}", :require => nil
41
+ else
42
+ gem 'i18n', '~> 0.5.0'
43
+ gem 'activesupport', '~> 3.0.3', :require => nil
44
+ end
43
45
 
44
46
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Dan Kubb
1
+ Copyright (c) 2011 Dan Kubb
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
- gem 'jeweler', '~> 1.4'
5
+ gem 'jeweler', '~> 1.5.2'
6
6
  require 'jeweler'
7
7
 
8
8
  Jeweler::Tasks.new do |gem|
@@ -15,11 +15,6 @@ begin
15
15
  gem.has_rdoc = 'yard'
16
16
 
17
17
  gem.rubyforge_project = 'datamapper'
18
-
19
- gem.add_dependency 'data_objects', '~> 0.10.2'
20
- gem.add_dependency 'dm-core', '~> 1.0.2'
21
-
22
- gem.add_development_dependency 'rspec', '~> 1.3'
23
18
  end
24
19
 
25
20
  Jeweler::GemcutterTasks.new
@@ -29,4 +24,4 @@ rescue LoadError
29
24
  puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
30
25
  end
31
26
 
32
- task(:spec) {} # this adapter only provides shared specs that are excercised by real adapters
27
+ task(:spec) {} # this adapter only provides shared specs that are exercised by real adapters
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.1.0.rc1
@@ -1,61 +1,62 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dm-do-adapter}
8
- s.version = "1.0.2"
8
+ s.version = "1.1.0.rc1"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Kubb"]
12
- s.date = %q{2010-09-07}
12
+ s.date = %q{2011-02-28}
13
13
  s.description = %q{DataObjects Adapter for DataMapper}
14
14
  s.email = %q{dan.kubb@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
- ".gitignore",
21
- "Gemfile",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "dm-do-adapter.gemspec",
27
- "lib/dm-do-adapter.rb",
28
- "lib/dm-do-adapter/adapter.rb",
29
- "lib/dm-do-adapter/spec/shared_spec.rb",
30
- "tasks/local_gemfile.rake",
31
- "tasks/yard.rake",
32
- "tasks/yardstick.rake"
20
+ "Gemfile",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "dm-do-adapter.gemspec",
26
+ "lib/dm-do-adapter.rb",
27
+ "lib/dm-do-adapter/adapter.rb",
28
+ "lib/dm-do-adapter/spec/shared_spec.rb",
29
+ "tasks/yard.rake",
30
+ "tasks/yardstick.rake"
33
31
  ]
34
- s.has_rdoc = %q{yard}
35
32
  s.homepage = %q{http://github.com/datamapper/dm-do-adapter}
36
- s.rdoc_options = ["--charset=UTF-8"]
37
33
  s.require_paths = ["lib"]
38
34
  s.rubyforge_project = %q{datamapper}
39
- s.rubygems_version = %q{1.3.7}
35
+ s.rubygems_version = %q{1.5.2}
40
36
  s.summary = %q{DataObjects Adapter for DataMapper}
41
37
 
42
38
  if s.respond_to? :specification_version then
43
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
39
  s.specification_version = 3
45
40
 
46
41
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
42
  s.add_runtime_dependency(%q<data_objects>, ["~> 0.10.2"])
48
- s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.2"])
49
- s.add_development_dependency(%q<rspec>, ["~> 1.3"])
43
+ s.add_runtime_dependency(%q<dm-core>, ["~> 1.1.0.rc1"])
44
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
45
+ s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 1.3.1"])
50
47
  else
51
48
  s.add_dependency(%q<data_objects>, ["~> 0.10.2"])
52
- s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
53
- s.add_dependency(%q<rspec>, ["~> 1.3"])
49
+ s.add_dependency(%q<dm-core>, ["~> 1.1.0.rc1"])
50
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
51
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
52
+ s.add_dependency(%q<rspec>, ["~> 1.3.1"])
54
53
  end
55
54
  else
56
55
  s.add_dependency(%q<data_objects>, ["~> 0.10.2"])
57
- s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
58
- s.add_dependency(%q<rspec>, ["~> 1.3"])
56
+ s.add_dependency(%q<dm-core>, ["~> 1.1.0.rc1"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
58
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
59
+ s.add_dependency(%q<rspec>, ["~> 1.3.1"])
59
60
  end
60
61
  end
61
62
 
@@ -109,7 +109,10 @@ module DataMapper
109
109
  end
110
110
 
111
111
  statement = insert_statement(model, properties, serial)
112
- result = execute(statement, *bind_values)
112
+
113
+ result = with_connection do |connection|
114
+ connection.create_command(statement).execute_non_query(*bind_values)
115
+ end
113
116
 
114
117
  if result.affected_rows == 1 && serial
115
118
  serial.set!(resource, result.insert_id)
@@ -139,7 +142,12 @@ module DataMapper
139
142
  command = connection.create_command(statement)
140
143
  command.set_types(types)
141
144
 
142
- reader = command.execute_reader(*bind_values)
145
+ # Handle different splat semantics for nil on 1.8 and 1.9
146
+ reader = if bind_values
147
+ command.execute_reader(*bind_values)
148
+ else
149
+ command.execute_reader
150
+ end
143
151
 
144
152
  begin
145
153
  while reader.next!
@@ -182,7 +190,9 @@ module DataMapper
182
190
 
183
191
  bind_values.concat(conditions_bind_values)
184
192
 
185
- execute(statement, *bind_values).affected_rows
193
+ with_connection do |connection|
194
+ connection.create_command(statement).execute_non_query(*bind_values)
195
+ end.affected_rows
186
196
  end
187
197
 
188
198
  # Constructs and executes DELETE statement for given query
@@ -197,7 +207,10 @@ module DataMapper
197
207
  def delete(collection)
198
208
  query = collection.query
199
209
  statement, bind_values = delete_statement(query)
200
- execute(statement, *bind_values).affected_rows
210
+
211
+ with_connection do |connection|
212
+ connection.create_command(statement).execute_non_query(*bind_values)
213
+ end.affected_rows
201
214
  end
202
215
 
203
216
  protected
@@ -474,6 +487,7 @@ module DataMapper
474
487
  seen = { target_alias => 0 }
475
488
 
476
489
  query.links.reverse_each do |relationship|
490
+ target_alias = relationship.target_model.storage_name(name)
477
491
  storage_name = relationship.source_model.storage_name(name)
478
492
  source_alias = storage_name
479
493
 
@@ -491,8 +505,6 @@ module DataMapper
491
505
 
492
506
  add_join_conditions(relationship, target_alias, source_alias, statements)
493
507
  add_extra_join_conditions(relationship, target_alias, statements, join_bind_values)
494
-
495
- target_alias = source_alias
496
508
  end
497
509
 
498
510
  # prepend the join bind values to the statement bind values
@@ -29,7 +29,11 @@ share_examples_for 'A DataObjects Adapter' do
29
29
 
30
30
  def log_output
31
31
  @log.rewind
32
- @log.read.chomp.gsub(/^\s+~ \(\d+\.?\d*\)\s+/, '').split("\n")
32
+ output = @log.read
33
+ output.chomp!
34
+ output.gsub!(/\A\s+~ \(\d+\.?\d*\)\s+/, '')
35
+ output.gsub!(/\Acom\.\w+\.jdbc\.JDBC4PreparedStatement@[^:]+:\s+/, '') if @jruby
36
+ output.split($/)
33
37
  end
34
38
 
35
39
  def supports_default_values?
@@ -95,7 +99,7 @@ share_examples_for 'A DataObjects Adapter' do
95
99
  elsif @sql_server
96
100
  /^SET IDENTITY_INSERT \"articles\" ON INSERT INTO "articles" \("id"\) VALUES \(.{1,2}\) SET IDENTITY_INSERT \"articles\" OFF $/i
97
101
  else
98
- /^INSERT INTO "articles" \("id"\) VALUES \(.{1,2}\)$/i
102
+ /^INSERT INTO "articles" \("id"\) VALUES \(('.{1,2}'|.{1,2})\)$/i
99
103
  end
100
104
 
101
105
  log_output.first.should =~ regexp
@@ -207,7 +211,28 @@ share_examples_for 'A DataObjects Adapter' do
207
211
  auto_migrate!
208
212
  end
209
213
 
210
- @article_model = Article
214
+ class ::Publisher
215
+ include DataMapper::Resource
216
+
217
+ property :name, String, :key => true
218
+
219
+ auto_migrate!
220
+ end
221
+
222
+ class ::Author
223
+ include DataMapper::Resource
224
+
225
+ property :name, String, :key => true
226
+
227
+ belongs_to :article
228
+ belongs_to :publisher
229
+
230
+ auto_migrate!
231
+ end
232
+
233
+ @article_model = Article
234
+ @publisher_model = Publisher
235
+ @author_model = Author
211
236
  end
212
237
 
213
238
  describe 'with a raw query' do
@@ -366,5 +391,25 @@ share_examples_for 'A DataObjects Adapter' do
366
391
  end
367
392
 
368
393
  end
394
+
395
+ describe 'with a Query Path' do
396
+ subject { @author_model.all(query).to_a }
397
+
398
+ let(:article_name) { 'DataMapper Rocks!' }
399
+ let(:publisher_name) { 'Unbiased Press' }
400
+ let(:query) { { 'article.name' => article_name, 'publisher.name' => publisher_name } }
401
+
402
+ before do
403
+ @author = @author_model.first_or_create(
404
+ :name => 'Dan Kubb',
405
+ :article => { :name => article_name },
406
+ :publisher => { :name => publisher_name }
407
+ )
408
+ end
409
+
410
+ specify { expect { subject }.to_not raise_error }
411
+
412
+ it { should == [ @author ] }
413
+ end
369
414
  end
370
415
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-do-adapter
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 2
9
- version: 1.0.2
4
+ prerelease: 6
5
+ version: 1.1.0.rc1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Dan Kubb
@@ -14,53 +10,64 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-09-07 00:00:00 -07:00
13
+ date: 2011-02-28 00:00:00 -08:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
17
  name: data_objects
22
- prerelease: false
23
18
  requirement: &id001 !ruby/object:Gem::Requirement
24
19
  none: false
25
20
  requirements:
26
21
  - - ~>
27
22
  - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 10
31
- - 2
32
23
  version: 0.10.2
33
24
  type: :runtime
25
+ prerelease: false
34
26
  version_requirements: *id001
35
27
  - !ruby/object:Gem::Dependency
36
28
  name: dm-core
37
- prerelease: false
38
29
  requirement: &id002 !ruby/object:Gem::Requirement
39
30
  none: false
40
31
  requirements:
41
32
  - - ~>
42
33
  - !ruby/object:Gem::Version
43
- segments:
44
- - 1
45
- - 0
46
- - 2
47
- version: 1.0.2
34
+ version: 1.1.0.rc1
48
35
  type: :runtime
36
+ prerelease: false
49
37
  version_requirements: *id002
50
38
  - !ruby/object:Gem::Dependency
51
- name: rspec
52
- prerelease: false
39
+ name: jeweler
53
40
  requirement: &id003 !ruby/object:Gem::Requirement
54
41
  none: false
55
42
  requirements:
56
43
  - - ~>
57
44
  - !ruby/object:Gem::Version
58
- segments:
59
- - 1
60
- - 3
61
- version: "1.3"
45
+ version: 1.5.2
62
46
  type: :development
47
+ prerelease: false
63
48
  version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 0.8.7
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 1.3.1
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
64
71
  description: DataObjects Adapter for DataMapper
65
72
  email: dan.kubb@gmail.com
66
73
  executables: []
@@ -71,7 +78,6 @@ extra_rdoc_files:
71
78
  - LICENSE
72
79
  - README.rdoc
73
80
  files:
74
- - .gitignore
75
81
  - Gemfile
76
82
  - LICENSE
77
83
  - README.rdoc
@@ -81,16 +87,15 @@ files:
81
87
  - lib/dm-do-adapter.rb
82
88
  - lib/dm-do-adapter/adapter.rb
83
89
  - lib/dm-do-adapter/spec/shared_spec.rb
84
- - tasks/local_gemfile.rake
85
90
  - tasks/yard.rake
86
91
  - tasks/yardstick.rake
87
- has_rdoc: yard
92
+ has_rdoc: true
88
93
  homepage: http://github.com/datamapper/dm-do-adapter
89
94
  licenses: []
90
95
 
91
96
  post_install_message:
92
- rdoc_options:
93
- - --charset=UTF-8
97
+ rdoc_options: []
98
+
94
99
  require_paths:
95
100
  - lib
96
101
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -98,21 +103,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
103
  requirements:
99
104
  - - ">="
100
105
  - !ruby/object:Gem::Version
101
- segments:
102
- - 0
103
106
  version: "0"
104
107
  required_rubygems_version: !ruby/object:Gem::Requirement
105
108
  none: false
106
109
  requirements:
107
- - - ">="
110
+ - - ">"
108
111
  - !ruby/object:Gem::Version
109
- segments:
110
- - 0
111
- version: "0"
112
+ version: 1.3.1
112
113
  requirements: []
113
114
 
114
115
  rubyforge_project: datamapper
115
- rubygems_version: 1.3.7
116
+ rubygems_version: 1.5.2
116
117
  signing_key:
117
118
  specification_version: 3
118
119
  summary: DataObjects Adapter for DataMapper
data/.gitignore DELETED
@@ -1,37 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## Rubinius
17
- *.rbc
18
-
19
- ## PROJECT::GENERAL
20
- *.gem
21
- coverage
22
- rdoc
23
- pkg
24
- tmp
25
- doc
26
- log
27
- .yardoc
28
- measurements
29
-
30
- ## BUNDLER
31
- .bundle
32
- Gemfile.local
33
- Gemfile.lock
34
- Gemfile.local.lock
35
-
36
- ## PROJECT::SPECIFIC
37
- spec/db/
@@ -1,16 +0,0 @@
1
- desc "Support bundling from local source code (allows BUNDLE_GEMFILE=Gemfile.local bundle foo)"
2
- task :local_gemfile do |t|
3
-
4
- root = Pathname(__FILE__).dirname.parent
5
- datamapper = root.parent
6
-
7
- root.join('Gemfile.local').open('w') do |f|
8
- root.join('Gemfile').open.each do |line|
9
- line.sub!(/DATAMAPPER = 'git:\/\/github.com\/datamapper'/, "DATAMAPPER = '#{datamapper}'")
10
- line.sub!(/:git => \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, ':path => "#{DATAMAPPER}/\1"')
11
- line.sub!(/do_options\[:git\] = \"#\{DATAMAPPER\}\/(.+?)(?:\.git)?\"/, 'do_options[:path] = "#{DATAMAPPER}/\1"')
12
- f.puts line
13
- end
14
- end
15
-
16
- end