rom-core 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/rom/command_compiler.rb +5 -3
- data/lib/rom/relation.rb +0 -1
- data/lib/rom/schema.rb +12 -10
- data/lib/rom/setup/finalize/finalize_relations.rb +1 -1
- data/lib/rom/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cea9b3d9020f60a964a7105e7ac77e32e954126
|
4
|
+
data.tar.gz: 1e74ac03ad226c75e291d58163ffb0e3caff57eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 776153acc7f3bce777c713d37a706456e58165e78c0c4c7ffbe598c301250de2bb93b845524fe1b6f2b04b10bfdf109e46f166e5bda33471040aaa254949130e
|
7
|
+
data.tar.gz: b1bc73e397c05f2c5372d16d5dba21f153669dde45b89a2129bf01b45adafbfbe325969d0b6cbac7c84225f7b7bfd1d5d1418decb266e601bafa0226b3a99f87
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# v4.0.2 2017-11-02
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
* Schemas have access to finalized relation registry (GustavoCaso + flash-gordon + solnic)
|
6
|
+
|
7
|
+
## Fixed
|
8
|
+
|
9
|
+
* Defining schema uses default attribute class correctly again (v-kolesnikov)
|
10
|
+
* Primary key name(s) are preserved when projecting schemas (flash-gordon + solnic)
|
11
|
+
* Global command cache was replaced with a local one (flash-gordon)
|
12
|
+
|
1
13
|
# v4.0.1 2017-10-22
|
2
14
|
|
3
15
|
## Internal
|
data/lib/rom/command_compiler.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'dry/core/inflector'
|
2
|
-
require 'dry/core/cache'
|
3
2
|
|
4
3
|
require 'rom/initializer'
|
5
4
|
require 'rom/commands'
|
@@ -14,7 +13,6 @@ module ROM
|
|
14
13
|
#
|
15
14
|
# @api private
|
16
15
|
class CommandCompiler
|
17
|
-
extend Dry::Core::Cache
|
18
16
|
extend Initializer
|
19
17
|
|
20
18
|
# @api private
|
@@ -58,6 +56,10 @@ module ROM
|
|
58
56
|
# @return [Array<Symbol>] Meta data for a command
|
59
57
|
option :meta, optional: true
|
60
58
|
|
59
|
+
# @!attribute [r] cache
|
60
|
+
# @return [Cache] local cache instance
|
61
|
+
option :cache, default: -> { Cache.new }
|
62
|
+
|
61
63
|
# Return a specific command type for a given adapter and relation AST
|
62
64
|
#
|
63
65
|
# This class holds its own registry where all generated commands are being
|
@@ -79,7 +81,7 @@ module ROM
|
|
79
81
|
#
|
80
82
|
# @api private
|
81
83
|
def call(*args)
|
82
|
-
fetch_or_store(args.hash) do
|
84
|
+
cache.fetch_or_store(args.hash) do
|
83
85
|
type, adapter, ast, plugins, meta = args
|
84
86
|
|
85
87
|
compiler = with(
|
data/lib/rom/relation.rb
CHANGED
data/lib/rom/schema.rb
CHANGED
@@ -54,6 +54,7 @@ module ROM
|
|
54
54
|
|
55
55
|
unless schema.frozen?
|
56
56
|
schema.finalize_attributes!(gateway: gateway, relations: registry)
|
57
|
+
schema.set!(:relations, registry)
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -95,11 +96,11 @@ module ROM
|
|
95
96
|
# @!attribute [r] primary_key_name
|
96
97
|
# @return [Symbol] The name of the primary key. This is set because in
|
97
98
|
# most of the cases relations don't have composite pks
|
98
|
-
|
99
|
+
option :primary_key_name, optional: true
|
99
100
|
|
100
101
|
# @!attribute [r] primary_key_names
|
101
102
|
# @return [Array<Symbol>] A list of all pk names
|
102
|
-
|
103
|
+
option :primary_key_names, optional: true
|
103
104
|
|
104
105
|
alias_method :to_ary, :attributes
|
105
106
|
|
@@ -116,6 +117,7 @@ module ROM
|
|
116
117
|
def self.define(name, attributes: EMPTY_ARRAY, attr_class: Attribute, **options)
|
117
118
|
new(
|
118
119
|
name,
|
120
|
+
attr_class: attr_class,
|
119
121
|
attributes: attributes(attributes, attr_class),
|
120
122
|
**options
|
121
123
|
) { |schema| yield(schema) if block_given? }
|
@@ -415,6 +417,12 @@ module ROM
|
|
415
417
|
[:schema, [name, attributes.map(&:to_ast)]]
|
416
418
|
end
|
417
419
|
|
420
|
+
# @api private
|
421
|
+
def set!(key, value)
|
422
|
+
instance_variable_set("@#{ key }", value)
|
423
|
+
options[key] = value
|
424
|
+
end
|
425
|
+
|
418
426
|
private
|
419
427
|
|
420
428
|
# @api private
|
@@ -443,17 +451,11 @@ module ROM
|
|
443
451
|
# @api private
|
444
452
|
def initialize_primary_key_names
|
445
453
|
if primary_key.size > 0
|
446
|
-
|
447
|
-
|
454
|
+
set!(:primary_key_name, primary_key[0].meta[:name])
|
455
|
+
set!(:primary_key_names, primary_key.map { |type| type.meta[:name] })
|
448
456
|
end
|
449
457
|
end
|
450
458
|
|
451
|
-
# @api private
|
452
|
-
def set!(key, value)
|
453
|
-
instance_variable_set("@#{ key }", value)
|
454
|
-
options[key] = value
|
455
|
-
end
|
456
|
-
|
457
459
|
memoize :count_index, :name_index, :source_index, :to_ast, :to_input_hash, :to_output_hash
|
458
460
|
end
|
459
461
|
end
|
data/lib/rom/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
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-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -107,6 +107,9 @@ dependencies:
|
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '1.0'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.0.2
|
110
113
|
type: :runtime
|
111
114
|
prerelease: false
|
112
115
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -114,6 +117,9 @@ dependencies:
|
|
114
117
|
- - "~>"
|
115
118
|
- !ruby/object:Gem::Version
|
116
119
|
version: '1.0'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.0.2
|
117
123
|
- !ruby/object:Gem::Dependency
|
118
124
|
name: rake
|
119
125
|
requirement: !ruby/object:Gem::Requirement
|