rails_select_on_includes 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/vcs.xml +1 -1
- data/.idea/workspace.xml +107 -39
- data/README.md +47 -1
- data/lib/rails_select_on_includes/version.rb +1 -1
- data/lib/rails_select_on_includes.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4f4d9699deab6b6086b8ae38613b3a81b3bf867
|
4
|
+
data.tar.gz: bebae8e1b9173d9c71260c1155f5a496b2769f0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaed79ccfd13e69123b1d8d38570a8590526d33ea03e9de0e38c35bea50a7b86cd653811d0a95bc4635c9f898cfa05c3511e34a68b5b8432a007b7c6ee40b3d3
|
7
|
+
data.tar.gz: 971ce04337f5d281bc555006db4aae3c27aa766ee2700633a09f04e8f0e6d40f72c8c1132545c5dd0b307788a9b0bd1da8d9dda5ec6bb97c822ec83be87d2408
|
data/.idea/vcs.xml
CHANGED
data/.idea/workspace.xml
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<project version="4">
|
3
3
|
<component name="ChangeListManager">
|
4
|
-
<list default="true" id="e9b8aeec-46b7-4241-ab0a-cc8285e66518" name="Default" comment=""
|
4
|
+
<list default="true" id="e9b8aeec-46b7-4241-ab0a-cc8285e66518" name="Default" comment="">
|
5
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/.name" />
|
6
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/bin/console" />
|
7
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
|
8
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/modules.xml" />
|
9
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/rails_select_on_includes.iml" />
|
10
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/bin/setup" />
|
11
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/vcs.xml" />
|
12
|
+
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
13
|
+
</list>
|
5
14
|
<ignored path="rails_select_on_includes.iws" />
|
6
15
|
<ignored path=".idea/workspace.xml" />
|
7
16
|
<ignored path=".idea/dataSources.local.xml" />
|
@@ -26,20 +35,17 @@
|
|
26
35
|
<entry file="file://$PROJECT_DIR$/lib/rails_select_on_includes.rb">
|
27
36
|
<provider selected="true" editor-type-id="text-editor">
|
28
37
|
<state vertical-scroll-proportion="0.0">
|
29
|
-
<caret line="
|
30
|
-
<folding
|
31
|
-
<element signature="e#87#2283#0" expanded="false" />
|
32
|
-
<element signature="e#2284#3676#0" expanded="false" />
|
33
|
-
</folding>
|
38
|
+
<caret line="25" column="25" selection-start-line="22" selection-start-column="8" selection-end-line="25" selection-end-column="25" />
|
39
|
+
<folding />
|
34
40
|
</state>
|
35
41
|
</provider>
|
36
42
|
</entry>
|
37
43
|
</file>
|
38
|
-
<file leaf-file-name="rails_select_on_includes.gemspec" pinned="false" current-in-tab="
|
44
|
+
<file leaf-file-name="rails_select_on_includes.gemspec" pinned="false" current-in-tab="false">
|
39
45
|
<entry file="file://$PROJECT_DIR$/rails_select_on_includes.gemspec">
|
40
46
|
<provider selected="true" editor-type-id="text-editor">
|
41
|
-
<state vertical-scroll-proportion="0.
|
42
|
-
<caret line="
|
47
|
+
<state vertical-scroll-proportion="0.0">
|
48
|
+
<caret line="19" column="35" selection-start-line="19" selection-start-column="35" selection-end-line="19" selection-end-column="35" />
|
43
49
|
<folding />
|
44
50
|
</state>
|
45
51
|
</provider>
|
@@ -55,15 +61,15 @@
|
|
55
61
|
</provider>
|
56
62
|
</entry>
|
57
63
|
</file>
|
58
|
-
<file leaf-file-name="README.md" pinned="false" current-in-tab="
|
64
|
+
<file leaf-file-name="README.md" pinned="false" current-in-tab="true">
|
59
65
|
<entry file="file://$PROJECT_DIR$/README.md">
|
60
66
|
<provider editor-type-id="MultiMarkdownFxPreviewEditor">
|
61
67
|
<state />
|
62
68
|
</provider>
|
63
69
|
<provider selected="true" editor-type-id="split-provider[text-editor;MultiMarkdownPreviewEditor]">
|
64
70
|
<state split_layout="FIRST">
|
65
|
-
<first_editor vertical-scroll-proportion="0.
|
66
|
-
<caret line="
|
71
|
+
<first_editor vertical-scroll-proportion="0.24799082">
|
72
|
+
<caret line="14" column="44" selection-start-line="14" selection-start-column="44" selection-end-line="14" selection-end-column="44" />
|
67
73
|
<folding />
|
68
74
|
</first_editor>
|
69
75
|
<second_editor />
|
@@ -93,13 +99,16 @@
|
|
93
99
|
</file>
|
94
100
|
</leaf>
|
95
101
|
</component>
|
102
|
+
<component name="Git.Settings">
|
103
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
104
|
+
</component>
|
96
105
|
<component name="IdeDocumentHistory">
|
97
106
|
<option name="CHANGED_PATHS">
|
98
107
|
<list>
|
99
108
|
<option value="$PROJECT_DIR$/.gitignore" />
|
100
109
|
<option value="$PROJECT_DIR$/lib/rails_select_on_includes.rb" />
|
101
|
-
<option value="$PROJECT_DIR$/README.md" />
|
102
110
|
<option value="$PROJECT_DIR$/rails_select_on_includes.gemspec" />
|
111
|
+
<option value="$PROJECT_DIR$/README.md" />
|
103
112
|
</list>
|
104
113
|
</option>
|
105
114
|
</component>
|
@@ -112,11 +121,11 @@
|
|
112
121
|
</component>
|
113
122
|
<component name="ProjectFrameBounds">
|
114
123
|
<option name="x" value="65" />
|
115
|
-
<option name="y" value="
|
124
|
+
<option name="y" value="-4" />
|
116
125
|
<option name="width" value="1855" />
|
117
|
-
<option name="height" value="
|
126
|
+
<option name="height" value="1084" />
|
118
127
|
</component>
|
119
|
-
<component name="ProjectLevelVcsManager" settingsEditedManually="
|
128
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
120
129
|
<OptionsSetting value="true" id="Add" />
|
121
130
|
<OptionsSetting value="true" id="Remove" />
|
122
131
|
<OptionsSetting value="true" id="Checkout" />
|
@@ -139,8 +148,6 @@
|
|
139
148
|
<sortByType />
|
140
149
|
</navigator>
|
141
150
|
<panes>
|
142
|
-
<pane id="Scratches" />
|
143
|
-
<pane id="Scope" />
|
144
151
|
<pane id="ProjectPane">
|
145
152
|
<subPane>
|
146
153
|
<PATH>
|
@@ -189,6 +196,8 @@
|
|
189
196
|
</PATH>
|
190
197
|
</subPane>
|
191
198
|
</pane>
|
199
|
+
<pane id="Scope" />
|
200
|
+
<pane id="Scratches" />
|
192
201
|
</panes>
|
193
202
|
</component>
|
194
203
|
<component name="PropertiesComponent">
|
@@ -334,14 +343,22 @@
|
|
334
343
|
<option name="number" value="Default" />
|
335
344
|
<updated>1474649042660</updated>
|
336
345
|
</task>
|
346
|
+
<task id="LOCAL-00001" summary="initial commit">
|
347
|
+
<created>1474656316766</created>
|
348
|
+
<option name="number" value="00001" />
|
349
|
+
<option name="project" value="LOCAL" />
|
350
|
+
<updated>1474656316766</updated>
|
351
|
+
</task>
|
352
|
+
<option name="localTasksCounter" value="2" />
|
337
353
|
<servers />
|
338
354
|
</component>
|
339
355
|
<component name="ToolWindowManager">
|
340
|
-
<frame x="65" y="
|
356
|
+
<frame x="65" y="-4" width="1855" height="1084" extended-state="6" />
|
341
357
|
<editor active="true" />
|
342
358
|
<layout>
|
343
359
|
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.20066334" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
344
360
|
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3294979" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
361
|
+
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32881" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
|
345
362
|
<window_info id="Event Log" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.35102266" sideWeight="0.5002764" order="4" side_tool="false" content_ui="tabs" />
|
346
363
|
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
347
364
|
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32946378" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
@@ -351,7 +368,6 @@
|
|
351
368
|
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
352
369
|
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3294979" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
|
353
370
|
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
354
|
-
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32881" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
|
355
371
|
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
356
372
|
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
357
373
|
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
@@ -366,19 +382,74 @@
|
|
366
382
|
<component name="VcsContentAnnotationSettings">
|
367
383
|
<option name="myLimit" value="2678400000" />
|
368
384
|
</component>
|
385
|
+
<component name="VcsManagerConfiguration">
|
386
|
+
<MESSAGE value="initial commit" />
|
387
|
+
<option name="LAST_COMMIT_MESSAGE" value="initial commit" />
|
388
|
+
</component>
|
369
389
|
<component name="XDebuggerManager">
|
370
390
|
<breakpoint-manager />
|
371
391
|
<watches-manager />
|
372
392
|
</component>
|
373
393
|
<component name="editorHistoryManager">
|
374
394
|
<entry file="file://$PROJECT_DIR$/lib/rails_select_on_includes.rb">
|
395
|
+
<provider selected="true" editor-type-id="text-editor">
|
396
|
+
<state vertical-scroll-proportion="0.0">
|
397
|
+
<caret line="25" column="25" selection-start-line="22" selection-start-column="8" selection-end-line="25" selection-end-column="25" />
|
398
|
+
<folding />
|
399
|
+
</state>
|
400
|
+
</provider>
|
401
|
+
</entry>
|
402
|
+
<entry file="file://$PROJECT_DIR$/rails_select_on_includes.gemspec">
|
403
|
+
<provider selected="true" editor-type-id="text-editor">
|
404
|
+
<state vertical-scroll-proportion="0.0">
|
405
|
+
<caret line="19" column="35" selection-start-line="19" selection-start-column="35" selection-end-line="19" selection-end-column="35" />
|
406
|
+
<folding />
|
407
|
+
</state>
|
408
|
+
</provider>
|
409
|
+
</entry>
|
410
|
+
<entry file="file://$PROJECT_DIR$/.gitignore">
|
411
|
+
<provider selected="true" editor-type-id="text-editor">
|
412
|
+
<state vertical-scroll-proportion="0.0">
|
413
|
+
<caret line="0" column="6" selection-start-line="0" selection-start-column="6" selection-end-line="0" selection-end-column="6" />
|
414
|
+
<folding />
|
415
|
+
</state>
|
416
|
+
</provider>
|
417
|
+
</entry>
|
418
|
+
<entry file="file://$PROJECT_DIR$/README.md">
|
419
|
+
<provider editor-type-id="MultiMarkdownFxPreviewEditor">
|
420
|
+
<state />
|
421
|
+
</provider>
|
422
|
+
<provider selected="true" editor-type-id="split-provider[text-editor;MultiMarkdownPreviewEditor]">
|
423
|
+
<state split_layout="FIRST">
|
424
|
+
<first_editor vertical-scroll-proportion="0.0">
|
425
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
426
|
+
<folding />
|
427
|
+
</first_editor>
|
428
|
+
<second_editor />
|
429
|
+
</state>
|
430
|
+
</provider>
|
431
|
+
</entry>
|
432
|
+
<entry file="file://$PROJECT_DIR$/bin/console">
|
433
|
+
<provider selected="true" editor-type-id="text-editor">
|
434
|
+
<state vertical-scroll-proportion="0.0">
|
435
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
436
|
+
<folding />
|
437
|
+
</state>
|
438
|
+
</provider>
|
439
|
+
</entry>
|
440
|
+
<entry file="file://$PROJECT_DIR$/bin/setup">
|
375
441
|
<provider selected="true" editor-type-id="text-editor">
|
376
442
|
<state vertical-scroll-proportion="0.0">
|
377
443
|
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
378
|
-
<folding
|
379
|
-
|
380
|
-
|
381
|
-
|
444
|
+
<folding />
|
445
|
+
</state>
|
446
|
+
</provider>
|
447
|
+
</entry>
|
448
|
+
<entry file="file://$PROJECT_DIR$/lib/rails_select_on_includes.rb">
|
449
|
+
<provider selected="true" editor-type-id="text-editor">
|
450
|
+
<state vertical-scroll-proportion="0.0">
|
451
|
+
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
452
|
+
<folding />
|
382
453
|
</state>
|
383
454
|
</provider>
|
384
455
|
</entry>
|
@@ -444,14 +515,19 @@
|
|
444
515
|
</state>
|
445
516
|
</provider>
|
446
517
|
</entry>
|
518
|
+
<entry file="file://$PROJECT_DIR$/rails_select_on_includes.gemspec">
|
519
|
+
<provider selected="true" editor-type-id="text-editor">
|
520
|
+
<state vertical-scroll-proportion="0.0">
|
521
|
+
<caret line="19" column="35" selection-start-line="19" selection-start-column="35" selection-end-line="19" selection-end-column="35" />
|
522
|
+
<folding />
|
523
|
+
</state>
|
524
|
+
</provider>
|
525
|
+
</entry>
|
447
526
|
<entry file="file://$PROJECT_DIR$/lib/rails_select_on_includes.rb">
|
448
527
|
<provider selected="true" editor-type-id="text-editor">
|
449
528
|
<state vertical-scroll-proportion="0.0">
|
450
|
-
<caret line="
|
451
|
-
<folding
|
452
|
-
<element signature="e#87#2283#0" expanded="false" />
|
453
|
-
<element signature="e#2284#3676#0" expanded="false" />
|
454
|
-
</folding>
|
529
|
+
<caret line="25" column="25" selection-start-line="22" selection-start-column="8" selection-end-line="25" selection-end-column="25" />
|
530
|
+
<folding />
|
455
531
|
</state>
|
456
532
|
</provider>
|
457
533
|
</entry>
|
@@ -461,21 +537,13 @@
|
|
461
537
|
</provider>
|
462
538
|
<provider selected="true" editor-type-id="split-provider[text-editor;MultiMarkdownPreviewEditor]">
|
463
539
|
<state split_layout="FIRST">
|
464
|
-
<first_editor vertical-scroll-proportion="0.
|
465
|
-
<caret line="
|
540
|
+
<first_editor vertical-scroll-proportion="0.24799082">
|
541
|
+
<caret line="14" column="44" selection-start-line="14" selection-start-column="44" selection-end-line="14" selection-end-column="44" />
|
466
542
|
<folding />
|
467
543
|
</first_editor>
|
468
544
|
<second_editor />
|
469
545
|
</state>
|
470
546
|
</provider>
|
471
547
|
</entry>
|
472
|
-
<entry file="file://$PROJECT_DIR$/rails_select_on_includes.gemspec">
|
473
|
-
<provider selected="true" editor-type-id="text-editor">
|
474
|
-
<state vertical-scroll-proportion="0.64008623">
|
475
|
-
<caret line="33" column="51" selection-start-line="33" selection-start-column="51" selection-end-line="33" selection-end-column="51" />
|
476
|
-
<folding />
|
477
|
-
</state>
|
478
|
-
</provider>
|
479
|
-
</entry>
|
480
548
|
</component>
|
481
549
|
</project>
|
data/README.md
CHANGED
@@ -26,6 +26,36 @@ post = Post.includes(:comments).select("posts.*, 1 as testval").where( SOME_COND
|
|
26
26
|
post.comments.first.testval # Undefined method!
|
27
27
|
```
|
28
28
|
|
29
|
+
# RailsSelectOnIncludes (Рус)
|
30
|
+
|
31
|
+
Данный gem решает проблему в рельсах с виртуальными аттрибутами при использовании includes,
|
32
|
+
когда рельсы собирают в запрос в joins с алиасами на все аттрибуты. В настоящий момент в модель не собираются
|
33
|
+
никаким боком виртуальные аттрибуты.
|
34
|
+
|
35
|
+
В частности проблема описана здесь: https://github.com/rails/rails/issues/15185
|
36
|
+
|
37
|
+
В коде примера по ссылке выше это выглядит так:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
post = Post.includes(:comments).select("posts.*, 1 as testval").where( SOME_CONDITION ).first
|
41
|
+
post.testval # Undefined method!
|
42
|
+
```
|
43
|
+
|
44
|
+
Данный gem решает эту проблему для базового класса, т.е.:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
post = Post.includes(:comments).select("posts.*, 1 as testval").where( SOME_CONDITION ).first
|
48
|
+
post.testval # 1
|
49
|
+
```
|
50
|
+
|
51
|
+
Но это не касается, объектов попадающих под инклюд:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
post = Post.includes(:comments).select("posts.*, 1 as testval").where( SOME_CONDITION ).first
|
55
|
+
post.comments.first.testval # Undefined method!
|
56
|
+
```
|
57
|
+
|
58
|
+
|
29
59
|
## Installation
|
30
60
|
|
31
61
|
Add this line to your application's Gemfile:
|
@@ -44,7 +74,23 @@ Or install it yourself as:
|
|
44
74
|
|
45
75
|
## Usage
|
46
76
|
|
47
|
-
Works out of the box, gently monkey-patching base-class alias columns. It not affecting query creation,
|
77
|
+
Works out of the box, gently monkey-patching base-class alias columns. It not affecting query creation,
|
78
|
+
since query already contains all columns, i.e. to_sql returns same string.
|
79
|
+
Works with selection in all formats:
|
80
|
+
|
81
|
+
1 'table_name.column' or 'table_name.column as column_1' with distinct on also
|
82
|
+
2 { table_name: column } or { table_name: [column1, column2] }
|
83
|
+
3 { table_name: 2 } where 2 relates to upper syntax
|
84
|
+
|
85
|
+
## Usage (рус)
|
86
|
+
|
87
|
+
Работает из коробки, нежно манки-патча алиасы прямо перед инстанцированием коллекции, не влияет на создаваемый запрос в БД т.е to_sql не меняется.
|
88
|
+
|
89
|
+
Поддерживает select в следующих форматах :
|
90
|
+
|
91
|
+
1 'table_name.column' or 'table_name.column as column_1' with distinct on also
|
92
|
+
2 { table_name: column } or { table_name: [column1, column2] }
|
93
|
+
3 { table_name: 2 } where 2 relates to upper syntax
|
48
94
|
|
49
95
|
## Contributing
|
50
96
|
|
@@ -48,7 +48,7 @@ module ActiveRecord
|
|
48
48
|
|
49
49
|
private
|
50
50
|
def flatten_hash_values( some_hash )
|
51
|
-
some_hash.values.map{ |value| value.is_a?(Hash) ?
|
51
|
+
some_hash.values.map{ |value| value.is_a?(Hash) ? flatten_hash_values( value ) : value }.flatten!
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_select_on_includes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alekseyl
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|