automodel-sqlserver 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +81 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/.yardopts +1 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +225 -0
- data/Rakefile +6 -0
- data/automodel-sqlserver.gemspec +39 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/Automodel.html +161 -0
- data/docs/Automodel/AdapterAlreadyRegistered.html +144 -0
- data/docs/Automodel/AdapterAlreadyRegisteredError.html +144 -0
- data/docs/Automodel/CannotFindOnCompoundPrimaryKey.html +144 -0
- data/docs/Automodel/Connectors.html +117 -0
- data/docs/Automodel/Error.html +140 -0
- data/docs/Automodel/FindOnCompoundPrimaryKeyError.html +144 -0
- data/docs/Automodel/Helpers.html +722 -0
- data/docs/Automodel/NameCollisionError.html +143 -0
- data/docs/Automodel/SchemaInspector.html +1046 -0
- data/docs/Automodel/UnregisteredAdapter.html +144 -0
- data/docs/_index.html +206 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.README.html +333 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +333 -0
- data/docs/js/app.js +292 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +155 -0
- data/docs/top-level-namespace.html +478 -0
- data/lib/automodel.rb +132 -0
- data/lib/automodel/automodel.rb +4 -0
- data/lib/automodel/connectors.rb +8 -0
- data/lib/automodel/errors.rb +24 -0
- data/lib/automodel/helpers.rb +141 -0
- data/lib/automodel/schema_inspector.rb +218 -0
- data/lib/automodel/version.rb +10 -0
- data/samples/database.yml +38 -0
- metadata +259 -0
@@ -0,0 +1,143 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Exception: Automodel::NameCollisionError
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.14
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Automodel::NameCollisionError";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (N)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Automodel.html" title="Automodel (module)">Automodel</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">NameCollisionError</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Exception: Automodel::NameCollisionError
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName"><span class='object_link'><a href="Error.html" title="Automodel::Error (class)">Error</a></span></span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">StandardError</li>
|
78
|
+
|
79
|
+
<li class="next"><span class='object_link'><a href="Error.html" title="Automodel::Error (class)">Error</a></span></li>
|
80
|
+
|
81
|
+
<li class="next">Automodel::NameCollisionError</li>
|
82
|
+
|
83
|
+
</ul>
|
84
|
+
<a href="#" class="inheritanceTree">show all</a>
|
85
|
+
|
86
|
+
</dd>
|
87
|
+
</dl>
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<dl>
|
100
|
+
<dt>Defined in:</dt>
|
101
|
+
<dd>lib/automodel/errors.rb</dd>
|
102
|
+
</dl>
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
<h2>Overview</h2><div class="docstring">
|
107
|
+
<div class="discussion">
|
108
|
+
|
109
|
+
<p>An error resulting from an aborted Automodel due to a class name collision.</p>
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
<div class="tags">
|
115
|
+
|
116
|
+
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<div id="footer">
|
136
|
+
Generated on Wed Jun 20 18:16:10 2018 by
|
137
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
138
|
+
0.9.14 (ruby-2.4.4).
|
139
|
+
</div>
|
140
|
+
|
141
|
+
</div>
|
142
|
+
</body>
|
143
|
+
</html>
|
@@ -0,0 +1,1046 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: Automodel::SchemaInspector
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.14
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "Automodel::SchemaInspector";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (S)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Automodel.html" title="Automodel (module)">Automodel</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">SchemaInspector</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: Automodel::SchemaInspector
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">Automodel::SchemaInspector</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/automodel/schema_inspector.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>A utility object that issues the actual database inspection commands and
|
106
|
+
returns the table, column, primary-key, and foreign-key data.</p>
|
107
|
+
|
108
|
+
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
<div class="tags">
|
112
|
+
|
113
|
+
|
114
|
+
</div>
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
<h2>
|
123
|
+
Class Method Summary
|
124
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
125
|
+
</h2>
|
126
|
+
|
127
|
+
<ul class="summary">
|
128
|
+
|
129
|
+
<li class="public ">
|
130
|
+
<span class="summary_signature">
|
131
|
+
|
132
|
+
<a href="#known_adapters-class_method" title="known_adapters (class method)">.<strong>known_adapters</strong> ⇒ Object </a>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
</span>
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
147
|
+
|
148
|
+
</li>
|
149
|
+
|
150
|
+
|
151
|
+
<li class="public ">
|
152
|
+
<span class="summary_signature">
|
153
|
+
|
154
|
+
<a href="#register_adapter-class_method" title="register_adapter (class method)">.<strong>register_adapter</strong>(adapter:, tables:, columns:, primary_key:, foreign_keys: nil) ⇒ Object </a>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
</span>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<span class="summary_desc"><div class='inline'>
|
169
|
+
<p>“Registers” an adapter with the Automodel::SchemaInspector.</p>
|
170
|
+
</div></span>
|
171
|
+
|
172
|
+
</li>
|
173
|
+
|
174
|
+
|
175
|
+
</ul>
|
176
|
+
|
177
|
+
<h2>
|
178
|
+
Instance Method Summary
|
179
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
180
|
+
</h2>
|
181
|
+
|
182
|
+
<ul class="summary">
|
183
|
+
|
184
|
+
<li class="public ">
|
185
|
+
<span class="summary_signature">
|
186
|
+
|
187
|
+
<a href="#columns-instance_method" title="#columns (instance method)">#<strong>columns</strong>(table_name) ⇒ Array<ActiveRecord::ConnectionAdapters::Column> </a>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
</span>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<span class="summary_desc"><div class='inline'>
|
202
|
+
<p>Returns a list of columns for the given table.</p>
|
203
|
+
</div></span>
|
204
|
+
|
205
|
+
</li>
|
206
|
+
|
207
|
+
|
208
|
+
<li class="public ">
|
209
|
+
<span class="summary_signature">
|
210
|
+
|
211
|
+
<a href="#foreign_keys-instance_method" title="#foreign_keys (instance method)">#<strong>foreign_keys</strong>(table_name) ⇒ Array<ActiveRecord::ConnectionAdapters::ForeignKeyDefinition> </a>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
</span>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
<span class="summary_desc"><div class='inline'>
|
226
|
+
<p>Returns a list of foreign keys for the given table.</p>
|
227
|
+
</div></span>
|
228
|
+
|
229
|
+
</li>
|
230
|
+
|
231
|
+
|
232
|
+
<li class="public ">
|
233
|
+
<span class="summary_signature">
|
234
|
+
|
235
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(connection_handler) ⇒ SchemaInspector </a>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
</span>
|
240
|
+
|
241
|
+
|
242
|
+
<span class="note title constructor">constructor</span>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
<span class="summary_desc"><div class='inline'>
|
252
|
+
<p>A new instance of SchemaInspector.</p>
|
253
|
+
</div></span>
|
254
|
+
|
255
|
+
</li>
|
256
|
+
|
257
|
+
|
258
|
+
<li class="public ">
|
259
|
+
<span class="summary_signature">
|
260
|
+
|
261
|
+
<a href="#known_adapters-instance_method" title="#known_adapters (instance method)">#<strong>known_adapters</strong> ⇒ Object </a>
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
</span>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
276
|
+
|
277
|
+
</li>
|
278
|
+
|
279
|
+
|
280
|
+
<li class="public ">
|
281
|
+
<span class="summary_signature">
|
282
|
+
|
283
|
+
<a href="#primary_key-instance_method" title="#primary_key (instance method)">#<strong>primary_key</strong>(table_name) ⇒ String<sup>+</sup> </a>
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
</span>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
<span class="summary_desc"><div class='inline'>
|
298
|
+
<p>Returns the primary key for the given table.</p>
|
299
|
+
</div></span>
|
300
|
+
|
301
|
+
</li>
|
302
|
+
|
303
|
+
|
304
|
+
<li class="public ">
|
305
|
+
<span class="summary_signature">
|
306
|
+
|
307
|
+
<a href="#tables-instance_method" title="#tables (instance method)">#<strong>tables</strong> ⇒ Array<String> </a>
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
</span>
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
<span class="summary_desc"><div class='inline'>
|
322
|
+
<p>Returns a list of table names in the target database.</p>
|
323
|
+
</div></span>
|
324
|
+
|
325
|
+
</li>
|
326
|
+
|
327
|
+
|
328
|
+
</ul>
|
329
|
+
|
330
|
+
|
331
|
+
<div id="constructor_details" class="method_details_list">
|
332
|
+
<h2>Constructor Details</h2>
|
333
|
+
|
334
|
+
<div class="method_details first">
|
335
|
+
<h3 class="signature first" id="initialize-instance_method">
|
336
|
+
|
337
|
+
#<strong>initialize</strong>(connection_handler) ⇒ <tt><span class='object_link'><a href="" title="Automodel::SchemaInspector (class)">SchemaInspector</a></span></tt>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
</h3><div class="docstring">
|
344
|
+
<div class="discussion">
|
345
|
+
|
346
|
+
<p>Returns a new instance of SchemaInspector</p>
|
347
|
+
|
348
|
+
|
349
|
+
</div>
|
350
|
+
</div>
|
351
|
+
<div class="tags">
|
352
|
+
<p class="tag_title">Parameters:</p>
|
353
|
+
<ul class="param">
|
354
|
+
|
355
|
+
<li>
|
356
|
+
|
357
|
+
<span class='name'>connection_handler</span>
|
358
|
+
|
359
|
+
|
360
|
+
<span class='type'>(<tt>ActiveRecord::ConnectionHandling</tt>)</span>
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
—
|
365
|
+
<div class='inline'>
|
366
|
+
<p>The connection pool/handler (an object that implements
|
367
|
+
ActiveRecord::ConnectionHandling) to inspect and map out.</p>
|
368
|
+
</div>
|
369
|
+
|
370
|
+
</li>
|
371
|
+
|
372
|
+
</ul>
|
373
|
+
|
374
|
+
|
375
|
+
</div><table class="source_code">
|
376
|
+
<tr>
|
377
|
+
<td>
|
378
|
+
<pre class="lines">
|
379
|
+
|
380
|
+
|
381
|
+
64
|
382
|
+
65
|
383
|
+
66
|
384
|
+
67
|
385
|
+
68
|
386
|
+
69</pre>
|
387
|
+
</td>
|
388
|
+
<td>
|
389
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 64</span>
|
390
|
+
|
391
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_connection_handler'>connection_handler</span><span class='rparen'>)</span>
|
392
|
+
<span class='ivar'>@connection</span> <span class='op'>=</span> <span class='id identifier rubyid_connection_handler'>connection_handler</span><span class='period'>.</span><span class='id identifier rubyid_connection'>connection</span>
|
393
|
+
<span class='id identifier rubyid_adapter'>adapter</span> <span class='op'>=</span> <span class='id identifier rubyid_connection_handler'>connection_handler</span><span class='period'>.</span><span class='id identifier rubyid_connection_pool'>connection_pool</span><span class='period'>.</span><span class='id identifier rubyid_spec'>spec</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:adapter</span><span class='rbracket'>]</span>
|
394
|
+
|
395
|
+
<span class='ivar'>@registration</span> <span class='op'>=</span> <span class='id identifier rubyid_known_adapters'>known_adapters</span><span class='lbracket'>[</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
396
|
+
<span class='kw'>end</span></pre>
|
397
|
+
</td>
|
398
|
+
</tr>
|
399
|
+
</table>
|
400
|
+
</div>
|
401
|
+
|
402
|
+
</div>
|
403
|
+
|
404
|
+
|
405
|
+
<div id="class_method_details" class="method_details_list">
|
406
|
+
<h2>Class Method Details</h2>
|
407
|
+
|
408
|
+
|
409
|
+
<div class="method_details first">
|
410
|
+
<h3 class="signature first" id="known_adapters-class_method">
|
411
|
+
|
412
|
+
.<strong>known_adapters</strong> ⇒ <tt>Object</tt>
|
413
|
+
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
</h3><table class="source_code">
|
419
|
+
<tr>
|
420
|
+
<td>
|
421
|
+
<pre class="lines">
|
422
|
+
|
423
|
+
|
424
|
+
18</pre>
|
425
|
+
</td>
|
426
|
+
<td>
|
427
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 18</span>
|
428
|
+
|
429
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_known_adapters'>known_adapters</span><span class='semicolon'>;</span> <span class='ivar'>@known_adapters</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
|
430
|
+
</td>
|
431
|
+
</tr>
|
432
|
+
</table>
|
433
|
+
</div>
|
434
|
+
|
435
|
+
<div class="method_details ">
|
436
|
+
<h3 class="signature " id="register_adapter-class_method">
|
437
|
+
|
438
|
+
.<strong>register_adapter</strong>(adapter:, tables:, columns:, primary_key:, foreign_keys: nil) ⇒ <tt>Object</tt>
|
439
|
+
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
|
444
|
+
</h3><div class="docstring">
|
445
|
+
<div class="discussion">
|
446
|
+
|
447
|
+
<p>“Registers” an adapter with the Automodel::SchemaInspector. This allows for
|
448
|
+
alternate mechanisms of procuring lists of tables, columns, primary keys,
|
449
|
+
and/or foreign keys from an adapter that may not itself support
|
450
|
+
<code>#tables</code>/<code>#columns</code>/<code>#primary_key</code>/<code>#foreign_keys</code>.</p>
|
451
|
+
|
452
|
+
|
453
|
+
</div>
|
454
|
+
</div>
|
455
|
+
<div class="tags">
|
456
|
+
<p class="tag_title">Parameters:</p>
|
457
|
+
<ul class="param">
|
458
|
+
|
459
|
+
<li>
|
460
|
+
|
461
|
+
<span class='name'>adapter</span>
|
462
|
+
|
463
|
+
|
464
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
—
|
469
|
+
<div class='inline'>
|
470
|
+
<p>The “adapter” value used to match that given in the connection spec. It is
|
471
|
+
with this value that the adapter being registered is matched to an existing
|
472
|
+
database pool/connection.</p>
|
473
|
+
</div>
|
474
|
+
|
475
|
+
</li>
|
476
|
+
|
477
|
+
<li>
|
478
|
+
|
479
|
+
<span class='name'>tables</span>
|
480
|
+
|
481
|
+
|
482
|
+
<span class='type'>(<tt>Proc</tt>)</span>
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
—
|
487
|
+
<div class='inline'>
|
488
|
+
<p>The Proc to <code>#call</code> to request a list of table names. The Proc
|
489
|
+
will be called with one parameter: a database connection.</p>
|
490
|
+
</div>
|
491
|
+
|
492
|
+
</li>
|
493
|
+
|
494
|
+
<li>
|
495
|
+
|
496
|
+
<span class='name'>columns</span>
|
497
|
+
|
498
|
+
|
499
|
+
<span class='type'>(<tt>Proc</tt>)</span>
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
—
|
504
|
+
<div class='inline'>
|
505
|
+
<p>The Proc to <code>#call</code> to request a list of columns for a specific
|
506
|
+
table. The Proc will be called with two parameters: a database connection
|
507
|
+
and a table name.</p>
|
508
|
+
</div>
|
509
|
+
|
510
|
+
</li>
|
511
|
+
|
512
|
+
<li>
|
513
|
+
|
514
|
+
<span class='name'>primary_key</span>
|
515
|
+
|
516
|
+
|
517
|
+
<span class='type'>(<tt>Proc</tt>)</span>
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
—
|
522
|
+
<div class='inline'>
|
523
|
+
<p>The Proc to <code>#call</code> to request the primary key for a specific
|
524
|
+
table. The Proc will be called with two parameters: a database connection
|
525
|
+
and a table name.</p>
|
526
|
+
</div>
|
527
|
+
|
528
|
+
</li>
|
529
|
+
|
530
|
+
<li>
|
531
|
+
|
532
|
+
<span class='name'>foreign_keys</span>
|
533
|
+
|
534
|
+
|
535
|
+
<span class='type'>(<tt>Proc</tt>)</span>
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
—
|
540
|
+
<div class='inline'>
|
541
|
+
<p>The Proc to <code>#call</code> to request a list of foreign keys for a
|
542
|
+
specific table. The Proc will be called with two parameters: a database
|
543
|
+
connection and a table name.</p>
|
544
|
+
</div>
|
545
|
+
|
546
|
+
</li>
|
547
|
+
|
548
|
+
</ul>
|
549
|
+
|
550
|
+
<p class="tag_title">Raises:</p>
|
551
|
+
<ul class="raise">
|
552
|
+
|
553
|
+
<li>
|
554
|
+
|
555
|
+
|
556
|
+
<span class='type'>(<tt><span class='object_link'><a href="AdapterAlreadyRegisteredError.html" title="Automodel::AdapterAlreadyRegisteredError (class)">Automodel::AdapterAlreadyRegisteredError</a></span></tt>)</span>
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
</li>
|
561
|
+
|
562
|
+
</ul>
|
563
|
+
|
564
|
+
</div><table class="source_code">
|
565
|
+
<tr>
|
566
|
+
<td>
|
567
|
+
<pre class="lines">
|
568
|
+
|
569
|
+
|
570
|
+
50
|
571
|
+
51
|
572
|
+
52
|
573
|
+
53
|
574
|
+
54
|
575
|
+
55
|
576
|
+
56
|
577
|
+
57
|
578
|
+
58</pre>
|
579
|
+
</td>
|
580
|
+
<td>
|
581
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 50</span>
|
582
|
+
|
583
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_register_adapter'>register_adapter</span><span class='lparen'>(</span><span class='label'>adapter:</span><span class='comma'>,</span> <span class='label'>tables:</span><span class='comma'>,</span> <span class='label'>columns:</span><span class='comma'>,</span> <span class='label'>primary_key:</span><span class='comma'>,</span> <span class='label'>foreign_keys:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
584
|
+
<span class='id identifier rubyid_adapter'>adapter</span> <span class='op'>=</span> <span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span>
|
585
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="../Automodel.html" title="Automodel (module)">Automodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="AdapterAlreadyRegisteredError.html" title="Automodel::AdapterAlreadyRegisteredError (class)">AdapterAlreadyRegisteredError</a></span></span><span class='comma'>,</span> <span class='id identifier rubyid_adapter'>adapter</span> <span class='kw'>if</span> <span class='id identifier rubyid_known_adapters'>known_adapters</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span> <span class='id identifier rubyid_adapter'>adapter</span>
|
586
|
+
|
587
|
+
<span class='id identifier rubyid_known_adapters'>known_adapters</span><span class='lbracket'>[</span><span class='id identifier rubyid_adapter'>adapter</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>tables:</span> <span class='id identifier rubyid_tables'>tables</span><span class='comma'>,</span>
|
588
|
+
<span class='label'>columns:</span> <span class='id identifier rubyid_columns'>columns</span><span class='comma'>,</span>
|
589
|
+
<span class='label'>primary_key:</span> <span class='id identifier rubyid_primary_key'>primary_key</span><span class='comma'>,</span>
|
590
|
+
<span class='label'>foreign_keys:</span> <span class='id identifier rubyid_foreign_keys'>foreign_keys</span> <span class='rbrace'>}</span>
|
591
|
+
<span class='kw'>end</span></pre>
|
592
|
+
</td>
|
593
|
+
</tr>
|
594
|
+
</table>
|
595
|
+
</div>
|
596
|
+
|
597
|
+
</div>
|
598
|
+
|
599
|
+
<div id="instance_method_details" class="method_details_list">
|
600
|
+
<h2>Instance Method Details</h2>
|
601
|
+
|
602
|
+
|
603
|
+
<div class="method_details first">
|
604
|
+
<h3 class="signature first" id="columns-instance_method">
|
605
|
+
|
606
|
+
#<strong>columns</strong>(table_name) ⇒ <tt>Array<ActiveRecord::ConnectionAdapters::Column></tt>
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
|
612
|
+
</h3><div class="docstring">
|
613
|
+
<div class="discussion">
|
614
|
+
|
615
|
+
<p>Returns a list of columns for the given table.</p>
|
616
|
+
|
617
|
+
<p>If a matching Automodel::SchemaInspector registration is found for the
|
618
|
+
connection's adapter, and that registration specified a
|
619
|
+
<code>:columns</code> Proc, the Proc is called. Otherwise, the standard
|
620
|
+
connection <code>#columns</code> is returned.</p>
|
621
|
+
|
622
|
+
|
623
|
+
</div>
|
624
|
+
</div>
|
625
|
+
<div class="tags">
|
626
|
+
<p class="tag_title">Parameters:</p>
|
627
|
+
<ul class="param">
|
628
|
+
|
629
|
+
<li>
|
630
|
+
|
631
|
+
<span class='name'>table_name</span>
|
632
|
+
|
633
|
+
|
634
|
+
<span class='type'>(<tt>String</tt>)</span>
|
635
|
+
|
636
|
+
|
637
|
+
|
638
|
+
—
|
639
|
+
<div class='inline'>
|
640
|
+
<p>The table whose columns should be fetched.</p>
|
641
|
+
</div>
|
642
|
+
|
643
|
+
</li>
|
644
|
+
|
645
|
+
</ul>
|
646
|
+
|
647
|
+
<p class="tag_title">Returns:</p>
|
648
|
+
<ul class="return">
|
649
|
+
|
650
|
+
<li>
|
651
|
+
|
652
|
+
|
653
|
+
<span class='type'>(<tt>Array<ActiveRecord::ConnectionAdapters::Column></tt>)</span>
|
654
|
+
|
655
|
+
|
656
|
+
|
657
|
+
</li>
|
658
|
+
|
659
|
+
</ul>
|
660
|
+
|
661
|
+
</div><table class="source_code">
|
662
|
+
<tr>
|
663
|
+
<td>
|
664
|
+
<pre class="lines">
|
665
|
+
|
666
|
+
|
667
|
+
101
|
668
|
+
102
|
669
|
+
103
|
670
|
+
104
|
671
|
+
105
|
672
|
+
106
|
673
|
+
107
|
674
|
+
108
|
675
|
+
109
|
676
|
+
110</pre>
|
677
|
+
</td>
|
678
|
+
<td>
|
679
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 101</span>
|
680
|
+
|
681
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_columns'>columns</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
682
|
+
<span class='id identifier rubyid_table_name'>table_name</span> <span class='op'>=</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
683
|
+
|
684
|
+
<span class='ivar'>@columns</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
685
|
+
<span class='ivar'>@columns</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='kw'>if</span> <span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:columns</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
686
|
+
<span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:columns</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='ivar'>@connection</span><span class='comma'>,</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
687
|
+
<span class='kw'>else</span>
|
688
|
+
<span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_columns'>columns</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
689
|
+
<span class='kw'>end</span>
|
690
|
+
<span class='kw'>end</span></pre>
|
691
|
+
</td>
|
692
|
+
</tr>
|
693
|
+
</table>
|
694
|
+
</div>
|
695
|
+
|
696
|
+
<div class="method_details ">
|
697
|
+
<h3 class="signature " id="foreign_keys-instance_method">
|
698
|
+
|
699
|
+
#<strong>foreign_keys</strong>(table_name) ⇒ <tt>Array<ActiveRecord::ConnectionAdapters::ForeignKeyDefinition></tt>
|
700
|
+
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
|
705
|
+
</h3><div class="docstring">
|
706
|
+
<div class="discussion">
|
707
|
+
|
708
|
+
<p>Returns a list of foreign keys for the given table.</p>
|
709
|
+
|
710
|
+
<p>If a matching Automodel::SchemaInspector registration is found for the
|
711
|
+
connection's adapter, and that registration specified a
|
712
|
+
<code>:foreign_keys</code> Proc, the Proc is called. Otherwise, the
|
713
|
+
standard connection <code>#foreign_keys</code> is attempted. If that call
|
714
|
+
to `<code>#foreign_keys</code> raises a ::NoMethodError or
|
715
|
+
::NotImplementedError, a best-effort attempt is made to build a list of
|
716
|
+
foreign keys based on table and column names.</p>
|
717
|
+
|
718
|
+
|
719
|
+
</div>
|
720
|
+
</div>
|
721
|
+
<div class="tags">
|
722
|
+
<p class="tag_title">Parameters:</p>
|
723
|
+
<ul class="param">
|
724
|
+
|
725
|
+
<li>
|
726
|
+
|
727
|
+
<span class='name'>table_name</span>
|
728
|
+
|
729
|
+
|
730
|
+
<span class='type'>(<tt>String</tt>)</span>
|
731
|
+
|
732
|
+
|
733
|
+
|
734
|
+
—
|
735
|
+
<div class='inline'>
|
736
|
+
<p>The table whose foreign keys should be fetched.</p>
|
737
|
+
</div>
|
738
|
+
|
739
|
+
</li>
|
740
|
+
|
741
|
+
</ul>
|
742
|
+
|
743
|
+
<p class="tag_title">Returns:</p>
|
744
|
+
<ul class="return">
|
745
|
+
|
746
|
+
<li>
|
747
|
+
|
748
|
+
|
749
|
+
<span class='type'>(<tt>Array<ActiveRecord::ConnectionAdapters::ForeignKeyDefinition></tt>)</span>
|
750
|
+
|
751
|
+
|
752
|
+
|
753
|
+
</li>
|
754
|
+
|
755
|
+
</ul>
|
756
|
+
|
757
|
+
</div><table class="source_code">
|
758
|
+
<tr>
|
759
|
+
<td>
|
760
|
+
<pre class="lines">
|
761
|
+
|
762
|
+
|
763
|
+
151
|
764
|
+
152
|
765
|
+
153
|
766
|
+
154
|
767
|
+
155
|
768
|
+
156
|
769
|
+
157
|
770
|
+
158
|
771
|
+
159
|
772
|
+
160
|
773
|
+
161
|
774
|
+
162
|
775
|
+
163
|
776
|
+
164
|
777
|
+
165
|
778
|
+
166
|
779
|
+
167
|
780
|
+
168
|
781
|
+
169
|
782
|
+
170
|
783
|
+
171
|
784
|
+
172
|
785
|
+
173
|
786
|
+
174
|
787
|
+
175
|
788
|
+
176
|
789
|
+
177
|
790
|
+
178
|
791
|
+
179
|
792
|
+
180
|
793
|
+
181
|
794
|
+
182
|
795
|
+
183
|
796
|
+
184
|
797
|
+
185
|
798
|
+
186
|
799
|
+
187
|
800
|
+
188</pre>
|
801
|
+
</td>
|
802
|
+
<td>
|
803
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 151</span>
|
804
|
+
|
805
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_foreign_keys'>foreign_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
806
|
+
<span class='id identifier rubyid_table_name'>table_name</span> <span class='op'>=</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
807
|
+
|
808
|
+
<span class='ivar'>@foreign_keys</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
809
|
+
<span class='ivar'>@foreign_keys</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='kw'>begin</span>
|
810
|
+
<span class='kw'>if</span> <span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:foreign_keys</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
811
|
+
<span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:foreign_keys</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='ivar'>@connection</span><span class='comma'>,</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
812
|
+
<span class='kw'>else</span>
|
813
|
+
<span class='kw'>begin</span>
|
814
|
+
<span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_foreign_keys'>foreign_keys</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
815
|
+
<span class='kw'>rescue</span> <span class='op'>::</span><span class='const'>NoMethodError</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>NotImplementedError</span>
|
816
|
+
<span class='comment'>## Not all ActiveRecord adapters support `#foreign_keys`. When this happens, we'll make
|
817
|
+
</span> <span class='comment'>## a best-effort attempt to intuit relationships from the table and column names.
|
818
|
+
</span> <span class='comment'>##
|
819
|
+
</span> <span class='id identifier rubyid_columns'>columns</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_column'>column</span><span class='op'>|</span>
|
820
|
+
<span class='id identifier rubyid_id_pattern'>id_pattern</span> <span class='op'>=</span> <span class='tstring'><span class='regexp_beg'>%r{</span><span class='tstring_content'>(?:_id|Id)$</span><span class='regexp_end'>}</span></span>
|
821
|
+
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>=~</span> <span class='id identifier rubyid_id_pattern'>id_pattern</span>
|
822
|
+
|
823
|
+
<span class='id identifier rubyid_target_table'>target_table</span> <span class='op'>=</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_sub'>sub</span><span class='lparen'>(</span><span class='id identifier rubyid_id_pattern'>id_pattern</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
824
|
+
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_target_table'>target_table</span><span class='period'>.</span><span class='id identifier rubyid_in?'>in?</span> <span class='id identifier rubyid_tables'>tables</span>
|
825
|
+
|
826
|
+
<span class='id identifier rubyid_target_column'>target_column</span> <span class='op'>=</span> <span class='id identifier rubyid_primary_key'>primary_key</span><span class='lparen'>(</span><span class='id identifier rubyid_qualified_name'>qualified_name</span><span class='lparen'>(</span><span class='id identifier rubyid_target_table'>target_table</span><span class='comma'>,</span> <span class='label'>context:</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
827
|
+
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_target_column'>target_column</span><span class='period'>.</span><span class='id identifier rubyid_in?'>in?</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>id</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Id</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ID</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span>
|
828
|
+
|
829
|
+
<span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>ConnectionAdapters</span><span class='op'>::</span><span class='const'>ForeignKeyDefinition</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span>
|
830
|
+
<span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='comma'>,</span>
|
831
|
+
<span class='id identifier rubyid_target_table'>target_table</span><span class='comma'>,</span>
|
832
|
+
<span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>FK_</span><span class='embexpr_beg'>#{</span><span class='const'>SecureRandom</span><span class='period'>.</span><span class='id identifier rubyid_uuid'>uuid</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>-</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span><span class='comma'>,</span>
|
833
|
+
<span class='label'>column:</span> <span class='id identifier rubyid_column'>column</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span>
|
834
|
+
<span class='label'>primary_key:</span> <span class='id identifier rubyid_target_column'>target_column</span><span class='comma'>,</span>
|
835
|
+
<span class='label'>on_update:</span> <span class='kw'>nil</span><span class='comma'>,</span>
|
836
|
+
<span class='label'>on_delete:</span> <span class='kw'>nil</span>
|
837
|
+
<span class='rparen'>)</span>
|
838
|
+
<span class='kw'>end</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span>
|
839
|
+
<span class='kw'>end</span>
|
840
|
+
<span class='kw'>end</span>
|
841
|
+
<span class='kw'>end</span>
|
842
|
+
<span class='kw'>end</span></pre>
|
843
|
+
</td>
|
844
|
+
</tr>
|
845
|
+
</table>
|
846
|
+
</div>
|
847
|
+
|
848
|
+
<div class="method_details ">
|
849
|
+
<h3 class="signature " id="known_adapters-instance_method">
|
850
|
+
|
851
|
+
#<strong>known_adapters</strong> ⇒ <tt>Object</tt>
|
852
|
+
|
853
|
+
|
854
|
+
|
855
|
+
|
856
|
+
|
857
|
+
</h3><table class="source_code">
|
858
|
+
<tr>
|
859
|
+
<td>
|
860
|
+
<pre class="lines">
|
861
|
+
|
862
|
+
|
863
|
+
19</pre>
|
864
|
+
</td>
|
865
|
+
<td>
|
866
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 19</span>
|
867
|
+
|
868
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_known_adapters'>known_adapters</span><span class='semicolon'>;</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_known_adapters'>known_adapters</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
|
869
|
+
</td>
|
870
|
+
</tr>
|
871
|
+
</table>
|
872
|
+
</div>
|
873
|
+
|
874
|
+
<div class="method_details ">
|
875
|
+
<h3 class="signature " id="primary_key-instance_method">
|
876
|
+
|
877
|
+
#<strong>primary_key</strong>(table_name) ⇒ <tt>String</tt><sup>+</sup>
|
878
|
+
|
879
|
+
|
880
|
+
|
881
|
+
|
882
|
+
|
883
|
+
</h3><div class="docstring">
|
884
|
+
<div class="discussion">
|
885
|
+
|
886
|
+
<p>Returns the primary key for the given table.</p>
|
887
|
+
|
888
|
+
<p>If a matching Automodel::SchemaInspector registration is found for the
|
889
|
+
connection's adapter, and that registration specified a
|
890
|
+
<code>:primary_key</code> Proc, the Proc is called. Otherwise, the standard
|
891
|
+
connection <code>#primary_key</code> is returned.</p>
|
892
|
+
|
893
|
+
|
894
|
+
</div>
|
895
|
+
</div>
|
896
|
+
<div class="tags">
|
897
|
+
<p class="tag_title">Parameters:</p>
|
898
|
+
<ul class="param">
|
899
|
+
|
900
|
+
<li>
|
901
|
+
|
902
|
+
<span class='name'>table_name</span>
|
903
|
+
|
904
|
+
|
905
|
+
<span class='type'>(<tt>String</tt>)</span>
|
906
|
+
|
907
|
+
|
908
|
+
|
909
|
+
—
|
910
|
+
<div class='inline'>
|
911
|
+
<p>The table whose primary key should be fetched.</p>
|
912
|
+
</div>
|
913
|
+
|
914
|
+
</li>
|
915
|
+
|
916
|
+
</ul>
|
917
|
+
|
918
|
+
<p class="tag_title">Returns:</p>
|
919
|
+
<ul class="return">
|
920
|
+
|
921
|
+
<li>
|
922
|
+
|
923
|
+
|
924
|
+
<span class='type'>(<tt>String</tt>, <tt>Array<String></tt>)</span>
|
925
|
+
|
926
|
+
|
927
|
+
|
928
|
+
</li>
|
929
|
+
|
930
|
+
</ul>
|
931
|
+
|
932
|
+
</div><table class="source_code">
|
933
|
+
<tr>
|
934
|
+
<td>
|
935
|
+
<pre class="lines">
|
936
|
+
|
937
|
+
|
938
|
+
125
|
939
|
+
126
|
940
|
+
127
|
941
|
+
128
|
942
|
+
129
|
943
|
+
130
|
944
|
+
131
|
945
|
+
132
|
946
|
+
133
|
947
|
+
134</pre>
|
948
|
+
</td>
|
949
|
+
<td>
|
950
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 125</span>
|
951
|
+
|
952
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_primary_key'>primary_key</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
953
|
+
<span class='id identifier rubyid_table_name'>table_name</span> <span class='op'>=</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
954
|
+
|
955
|
+
<span class='ivar'>@primary_keys</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
956
|
+
<span class='ivar'>@primary_keys</span><span class='lbracket'>[</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='kw'>if</span> <span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:primary_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
957
|
+
<span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:primary_key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='ivar'>@connection</span><span class='comma'>,</span> <span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
958
|
+
<span class='kw'>else</span>
|
959
|
+
<span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='lparen'>(</span><span class='id identifier rubyid_table_name'>table_name</span><span class='rparen'>)</span>
|
960
|
+
<span class='kw'>end</span>
|
961
|
+
<span class='kw'>end</span></pre>
|
962
|
+
</td>
|
963
|
+
</tr>
|
964
|
+
</table>
|
965
|
+
</div>
|
966
|
+
|
967
|
+
<div class="method_details ">
|
968
|
+
<h3 class="signature " id="tables-instance_method">
|
969
|
+
|
970
|
+
#<strong>tables</strong> ⇒ <tt>Array<String></tt>
|
971
|
+
|
972
|
+
|
973
|
+
|
974
|
+
|
975
|
+
|
976
|
+
</h3><div class="docstring">
|
977
|
+
<div class="discussion">
|
978
|
+
|
979
|
+
<p>Returns a list of table names in the target database.</p>
|
980
|
+
|
981
|
+
<p>If a matching Automodel::SchemaInspector registration is found for the
|
982
|
+
connection's adapter, and that registration specified a
|
983
|
+
<code>:tables</code> Proc, the Proc is called. Otherwise, the standard
|
984
|
+
connection <code>#tables</code> is returned.</p>
|
985
|
+
|
986
|
+
|
987
|
+
</div>
|
988
|
+
</div>
|
989
|
+
<div class="tags">
|
990
|
+
|
991
|
+
<p class="tag_title">Returns:</p>
|
992
|
+
<ul class="return">
|
993
|
+
|
994
|
+
<li>
|
995
|
+
|
996
|
+
|
997
|
+
<span class='type'>(<tt>Array<String></tt>)</span>
|
998
|
+
|
999
|
+
|
1000
|
+
|
1001
|
+
</li>
|
1002
|
+
|
1003
|
+
</ul>
|
1004
|
+
|
1005
|
+
</div><table class="source_code">
|
1006
|
+
<tr>
|
1007
|
+
<td>
|
1008
|
+
<pre class="lines">
|
1009
|
+
|
1010
|
+
|
1011
|
+
80
|
1012
|
+
81
|
1013
|
+
82
|
1014
|
+
83
|
1015
|
+
84
|
1016
|
+
85
|
1017
|
+
86</pre>
|
1018
|
+
</td>
|
1019
|
+
<td>
|
1020
|
+
<pre class="code"><span class="info file"># File 'lib/automodel/schema_inspector.rb', line 80</span>
|
1021
|
+
|
1022
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_tables'>tables</span>
|
1023
|
+
<span class='ivar'>@tables</span> <span class='op'>||=</span> <span class='kw'>if</span> <span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:tables</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
1024
|
+
<span class='ivar'>@registration</span><span class='lbracket'>[</span><span class='symbol'>:tables</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='ivar'>@connection</span><span class='rparen'>)</span>
|
1025
|
+
<span class='kw'>else</span>
|
1026
|
+
<span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_tables'>tables</span>
|
1027
|
+
<span class='kw'>end</span>
|
1028
|
+
<span class='kw'>end</span></pre>
|
1029
|
+
</td>
|
1030
|
+
</tr>
|
1031
|
+
</table>
|
1032
|
+
</div>
|
1033
|
+
|
1034
|
+
</div>
|
1035
|
+
|
1036
|
+
</div>
|
1037
|
+
|
1038
|
+
<div id="footer">
|
1039
|
+
Generated on Wed Jun 20 18:16:11 2018 by
|
1040
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1041
|
+
0.9.14 (ruby-2.4.4).
|
1042
|
+
</div>
|
1043
|
+
|
1044
|
+
</div>
|
1045
|
+
</body>
|
1046
|
+
</html>
|