File tree 3 files changed +40
-1
lines changed
3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,10 @@ def evaluate(*traits, **attrs)
80
80
# @api private
81
81
def evaluate_values ( attrs )
82
82
attributes . values . tsort . each_with_object ( { } ) do |attr , h |
83
- deps = attr . dependency_names . map { |k | h [ k ] } . compact
83
+ deps = attr . dependency_names . map do |key |
84
+ h [ remove_underscore ( key ) ]
85
+ end . compact
86
+
84
87
result = attr . ( attrs , *deps )
85
88
86
89
if result
@@ -89,6 +92,16 @@ def evaluate_values(attrs)
89
92
end
90
93
end
91
94
95
+ # Extract underscore from end of symbol
96
+ #
97
+ # @param key [Symbol]
98
+ # @return [Symbol]
99
+ #
100
+ # @api private
101
+ def remove_underscore ( key )
102
+ key . to_s . chomp ( '_' ) . to_sym
103
+ end
104
+
92
105
def evaluate_traits ( *traits , **attrs )
93
106
return { } if traits . empty?
94
107
Original file line number Diff line number Diff line change 150
150
151
151
expect ( user . email ) . to eql ( "#{ user . first_name } .#{ user . last_name } @test-1.org" )
152
152
end
153
+
154
+ it 'allows to access reserve keywords by apending an underscore at the end' do
155
+ factories . define ( :announcement ) do |f |
156
+ f . when { ROM ::SQL ::Postgres ::Values ::Range . new ( 3 , 9 , :'[]' ) }
157
+ f . begin { |when_ | when_ . lower }
158
+ f . end { |when_ | when_ . upper }
159
+ end
160
+
161
+ announcement = factories [ :announcement ]
162
+
163
+ expect ( announcement . begin ) . to eq 3
164
+ expect ( announcement . end ) . to eq 9
165
+ end
153
166
end
154
167
155
168
context 'incomplete schema' do
Original file line number Diff line number Diff line change 2
2
include_context 'database'
3
3
4
4
before do
5
+ conn . extension ( :pg_range )
5
6
conn . create_table ( :users ) do
6
7
primary_key :id
7
8
column :last_name , String , null : false
18
19
column :title , String , null : false
19
20
end
20
21
22
+ conn . create_table ( :announcements ) do
23
+ primary_key :id
24
+ numrange :when , null : false
25
+ column :begin , Integer , null : false
26
+ column :end , Integer , null : false
27
+ end
28
+
29
+ conf . relation ( :announcements ) do
30
+ schema ( infer : true )
31
+ end
32
+
21
33
conf . relation ( :tasks ) do
22
34
schema ( infer : true ) do
23
35
associations do
38
50
after do
39
51
conn . drop_table ( :tasks )
40
52
conn . drop_table ( :users )
53
+ conn . drop_table ( :announcements )
41
54
end
42
55
end
You can’t perform that action at this time.
0 commit comments