rom-repository 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile +1 -0
- data/lib/rom/open_struct.rb +35 -0
- data/lib/rom/repository/relation_proxy.rb +0 -11
- data/lib/rom/repository/struct_builder.rb +8 -3
- data/lib/rom/repository/version.rb +1 -1
- data/rom-repository.gemspec +1 -1
- data/spec/integration/repository_spec.rb +6 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d1abbcf0ab779840aaf19b899c6e5b725c8621e
|
4
|
+
data.tar.gz: b4cfd46194e94c7509c920c21f54e4d317ace881
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d96d070cf7eaf2729c8ebd1b78ed8cc9aebfc128d01c81211eca941fd53ad3f84d6be86ab2ba62e6ef9d1cbf97d4c1eaf299906bb7f0aac26842c070ac9f8c69
|
7
|
+
data.tar.gz: b82756a5892e7d62c5ce822372f51bd2b8af2e76d28b0e8dde4b01a9e798460bafac9b23ce511fbe761350c598b240024a0f6203e4946f784cb595d0df917c0d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# v1.2.0 2017-03-01
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Support for `#read` in rom-sql was restored via mapping to `ROM::OpenStruct` (solnic)
|
6
|
+
* Using `#nodes` no longer executes redundant query with deeply nested aggregates (solnic)
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
|
10
|
+
* Depends on rom >= 3.0.4 now as it provides `Relation::Graph#with_nodes` which is needed here (solnic)
|
11
|
+
|
12
|
+
[Compare v1.1.0...v1.2.0](https://github.com/rom-rb/rom-repository/compare/v1.1.0...v1.2.0)
|
13
|
+
|
1
14
|
# v1.1.0 2017-02-16
|
2
15
|
|
3
16
|
### Added
|
data/Gemfile
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module ROM
|
2
|
+
# ROM's open structs are used for relations with empty schemas.
|
3
|
+
# Such relations may exist in cases like using raw SQL strings
|
4
|
+
# where schema was not explicitly defined using `view` DSL.
|
5
|
+
#
|
6
|
+
# @api public
|
7
|
+
class OpenStruct
|
8
|
+
IVAR = -> v { :"@#{v}" }
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
def initialize(attributes)
|
12
|
+
attributes.each do |key, value|
|
13
|
+
instance_variable_set(IVAR[key], value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
def respond_to_missing?(meth, include_private = false)
|
19
|
+
super || instance_variables.include?(IVAR[meth])
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# @api private
|
25
|
+
def method_missing(meth, *args, &block)
|
26
|
+
ivar = IVAR[meth]
|
27
|
+
|
28
|
+
if instance_variables.include?(ivar)
|
29
|
+
instance_variable_get(ivar)
|
30
|
+
else
|
31
|
+
super
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -215,17 +215,6 @@ module ROM
|
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
|
-
# TODO: add a proper interface to `Relation::Graph` and `Relation::Curried` to rom core
|
219
|
-
#
|
220
|
-
# @api private
|
221
|
-
def with_nodes(nodes)
|
222
|
-
if relation.curried?
|
223
|
-
__new__(relation.send(:__new__, relation.relation.class.new(relation.root, nodes)))
|
224
|
-
else
|
225
|
-
__new__(relation.class.new(relation.root, nodes))
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
218
|
# @api private
|
230
219
|
def respond_to_missing?(meth, _include_private = false)
|
231
220
|
relation.respond_to?(meth) || super
|
@@ -3,6 +3,7 @@ require 'dry/core/cache'
|
|
3
3
|
require 'dry/core/class_builder'
|
4
4
|
|
5
5
|
require 'rom/struct'
|
6
|
+
require 'rom/open_struct'
|
6
7
|
require 'rom/schema/attribute'
|
7
8
|
|
8
9
|
module ROM
|
@@ -16,9 +17,13 @@ module ROM
|
|
16
17
|
name, header = args
|
17
18
|
attributes = visit(header).compact
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
if attributes.empty?
|
21
|
+
ROM::OpenStruct
|
22
|
+
else
|
23
|
+
build_class(name, ROM::Struct) do |klass|
|
24
|
+
attributes.each do |(name, type)|
|
25
|
+
klass.attribute(name, type)
|
26
|
+
end
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
data/rom-repository.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
16
16
|
gem.license = 'MIT'
|
17
17
|
|
18
|
-
gem.add_runtime_dependency 'rom', '~> 3.
|
18
|
+
gem.add_runtime_dependency 'rom', '~> 3.1'
|
19
19
|
gem.add_runtime_dependency 'rom-mapper', '~> 0.5'
|
20
20
|
gem.add_runtime_dependency 'dry-core', '~> 0.2', '>= 0.2.1'
|
21
21
|
gem.add_runtime_dependency 'dry-struct', '~> 0.1'
|
@@ -336,4 +336,10 @@ RSpec.describe 'ROM repository' do
|
|
336
336
|
expect(jane.post.body).to eql('Jane Post')
|
337
337
|
end
|
338
338
|
end
|
339
|
+
|
340
|
+
it 'loads structs using plain SQL' do
|
341
|
+
jane = repo.users.read("SELECT name FROM users WHERE name = 'Jane'").one
|
342
|
+
|
343
|
+
expect(jane.name).to eql('Jane')
|
344
|
+
end
|
339
345
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rom
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rom-mapper
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- README.md
|
118
118
|
- Rakefile
|
119
119
|
- lib/rom-repository.rb
|
120
|
+
- lib/rom/open_struct.rb
|
120
121
|
- lib/rom/repository.rb
|
121
122
|
- lib/rom/repository/changeset.rb
|
122
123
|
- lib/rom/repository/changeset/associated.rb
|