rails-pg-procs 1.0.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.
Files changed (51) hide show
  1. data/.document +5 -0
  2. data/.gitignore +5 -0
  3. data/LICENSE +20 -0
  4. data/README +15 -0
  5. data/README.rdoc +18 -0
  6. data/Rakefile +60 -0
  7. data/VERSION +1 -0
  8. data/docs/classes/ActiveRecord.html +117 -0
  9. data/docs/classes/ActiveRecord/ConnectionAdapters.html +113 -0
  10. data/docs/classes/ActiveRecord/ConnectionAdapters/PostgreSQLAdapter.html +589 -0
  11. data/docs/classes/ActiveRecord/ConnectionAdapters/ProcedureDefinition.html +110 -0
  12. data/docs/classes/ActiveRecord/ConnectionAdapters/TriggerDefinition.html +519 -0
  13. data/docs/classes/ActiveRecord/ConnectionAdapters/TypeDefinition.html +110 -0
  14. data/docs/classes/ActiveRecord/SchemaDumper.html +371 -0
  15. data/docs/classes/Inflector.html +164 -0
  16. data/docs/classes/SchemaProcs.html +211 -0
  17. data/docs/classes/SqlFormat.html +139 -0
  18. data/docs/classes/String.html +117 -0
  19. data/docs/classes/Symbol.html +117 -0
  20. data/docs/created.rid +1 -0
  21. data/docs/fr_class_index.html +36 -0
  22. data/docs/fr_method_index.html +63 -0
  23. data/docs/index.html +22 -0
  24. data/docs/rdoc-style.css +208 -0
  25. data/init.rb +3 -0
  26. data/install.rb +1 -0
  27. data/lib/connection_adapters/aggregagtes_definition.rb +1 -0
  28. data/lib/connection_adapters/connection_adapters.rb +8 -0
  29. data/lib/connection_adapters/index_definition.rb +24 -0
  30. data/lib/connection_adapters/postgresql_adapter.rb +256 -0
  31. data/lib/connection_adapters/procedure_definition.rb +6 -0
  32. data/lib/connection_adapters/schema_definition.rb +24 -0
  33. data/lib/connection_adapters/schema_statements.rb +11 -0
  34. data/lib/connection_adapters/trigger_definition.rb +114 -0
  35. data/lib/connection_adapters/type_definition.rb +17 -0
  36. data/lib/connection_adapters/view_definition.rb +34 -0
  37. data/lib/inflector.rb +10 -0
  38. data/lib/rails_pg_procs.rb +8 -0
  39. data/lib/schema_dumper.rb +96 -0
  40. data/lib/schema_procs.rb +19 -0
  41. data/lib/sql_format.rb +17 -0
  42. data/tasks/rails_pg_procs.rake +4 -0
  43. data/test/connection.rb +16 -0
  44. data/test/procedure_test.rb +78 -0
  45. data/test/rails_pg_procs_test.rb +246 -0
  46. data/test/test_helper.rb +41 -0
  47. data/test/trigger_test.rb +87 -0
  48. data/test/type_test.rb +46 -0
  49. data/test/view_test.rb +36 -0
  50. data/uninstall.rb +1 -0
  51. metadata +112 -0
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Scott Noel-Hemming
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,15 @@
1
+ RailsPgProcs
2
+ =============
3
+
4
+ Author Scott Noel-Hemming
5
+ Copyright 2008 QualitySmith, Inc.
6
+ License MIT License - http://www.opensource.org/licenses/mit-license.php
7
+
8
+
9
+ Description goes here
10
+ This is a rails plugin intended to implement PostgreSQL's
11
+ stored procedures and trigger functions. It is intended to
12
+ be used in rails migrations and in db schema files.
13
+
14
+ It was written to test a ror re-implementation to an existing
15
+ legacy schema.
@@ -0,0 +1,18 @@
1
+ = rails-pg-procs
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 Scott Noel-Hemming. See LICENSE for details.
@@ -0,0 +1,60 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "rails-pg-procs"
8
+ gem.summary = %Q{PostgreSQL Stored Proc/Trigger/View/User defined Type/Aggregate Type for Ruby Schema dump in Rails}
9
+ gem.description = %Q{PostgreSQL Stored Proc/Trigger/View/User defined Type/Aggregate Type for Ruby Schema dump in Rails}
10
+ gem.email = "frogstarr78@gmail.com"
11
+ gem.homepage = "http://github.com/frogstarr78/rails-pg-procs"
12
+ gem.authors = ["Scott Noel-Hemming"]
13
+ gem.rubyforge_project = "railspgprocs"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ Jeweler::RubyforgeTasks.new do |rubyforge|
18
+ rubyforge.doc_task = "rdoc"
19
+ end
20
+ rescue LoadError
21
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
22
+ end
23
+
24
+ require 'rake/testtask'
25
+ Rake::TestTask.new(:test) do |test|
26
+ test.libs << 'lib' << 'test'
27
+ test.pattern = 'test/**/*_test.rb'
28
+ test.verbose = true
29
+ end
30
+
31
+ begin
32
+ require 'rcov/rcovtask'
33
+ Rcov::RcovTask.new do |test|
34
+ test.libs << 'test'
35
+ test.pattern = 'test/**/*_test.rb'
36
+ test.verbose = true
37
+ end
38
+ rescue LoadError
39
+ task :rcov do
40
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
41
+ end
42
+ end
43
+
44
+ task :test => :check_dependencies
45
+
46
+ task :default => :test
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ if File.exist?('VERSION')
51
+ version = File.read('VERSION')
52
+ else
53
+ version = ""
54
+ end
55
+
56
+ rdoc.rdoc_dir = 'rdoc'
57
+ rdoc.title = "rails-pg-procs #{version}"
58
+ rdoc.rdoc_files.include('README*')
59
+ rdoc.rdoc_files.include('lib/**/*.rb')
60
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,117 @@
1
+ <!DOCTYPE html
2
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <title>Module: ActiveRecord</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
10
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
11
+ <script type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function popupCode( url ) {
15
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
16
+ }
17
+
18
+ function toggleCode( id ) {
19
+ if ( document.getElementById )
20
+ elem = document.getElementById( id );
21
+ else if ( document.all )
22
+ elem = eval( "document.all." + id );
23
+ else
24
+ return false;
25
+
26
+ elemStyle = elem.style;
27
+
28
+ if ( elemStyle.display != "block" ) {
29
+ elemStyle.display = "block"
30
+ } else {
31
+ elemStyle.display = "none"
32
+ }
33
+
34
+ return true;
35
+ }
36
+
37
+ // Make codeblocks hidden by default
38
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
39
+
40
+ // ]]>
41
+ </script>
42
+
43
+ </head>
44
+ <body>
45
+
46
+
47
+
48
+ <div id="classHeader">
49
+ <table class="header-table">
50
+ <tr class="top-aligned-row">
51
+ <td><strong>Module</strong></td>
52
+ <td class="class-name-in-header">ActiveRecord</td>
53
+ </tr>
54
+ <tr class="top-aligned-row">
55
+ <td><strong>In:</strong></td>
56
+ <td>
57
+ <a href="../files/lib/rails_pg_procs_rb.html">
58
+ lib/rails_pg_procs.rb
59
+ </a>
60
+ <br />
61
+ </td>
62
+ </tr>
63
+
64
+ </table>
65
+ </div>
66
+ <!-- banner header -->
67
+
68
+ <div id="bodyContent">
69
+
70
+
71
+
72
+ <div id="contextContent">
73
+
74
+ <div id="description">
75
+ <p>
76
+ RailsPgProcs
77
+ </p>
78
+
79
+ </div>
80
+
81
+
82
+ </div>
83
+
84
+
85
+ </div>
86
+
87
+
88
+ <!-- if includes -->
89
+
90
+ <div id="section">
91
+
92
+ <div id="class-list">
93
+ <h3 class="section-bar">Classes and Modules</h3>
94
+
95
+ Module <a href="ActiveRecord/ConnectionAdapters.html" class="link">ActiveRecord::ConnectionAdapters</a><br />
96
+ Class <a href="ActiveRecord/SchemaDumper.html" class="link">ActiveRecord::SchemaDumper</a><br />
97
+
98
+ </div>
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+ <!-- if method_list -->
107
+
108
+
109
+ </div>
110
+
111
+
112
+ <div id="validator-badges">
113
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
114
+ </div>
115
+
116
+ </body>
117
+ </html>
@@ -0,0 +1,113 @@
1
+ <!DOCTYPE html
2
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <title>Module: ActiveRecord::ConnectionAdapters</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ <script type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function popupCode( url ) {
15
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
16
+ }
17
+
18
+ function toggleCode( id ) {
19
+ if ( document.getElementById )
20
+ elem = document.getElementById( id );
21
+ else if ( document.all )
22
+ elem = eval( "document.all." + id );
23
+ else
24
+ return false;
25
+
26
+ elemStyle = elem.style;
27
+
28
+ if ( elemStyle.display != "block" ) {
29
+ elemStyle.display = "block"
30
+ } else {
31
+ elemStyle.display = "none"
32
+ }
33
+
34
+ return true;
35
+ }
36
+
37
+ // Make codeblocks hidden by default
38
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
39
+
40
+ // ]]>
41
+ </script>
42
+
43
+ </head>
44
+ <body>
45
+
46
+
47
+
48
+ <div id="classHeader">
49
+ <table class="header-table">
50
+ <tr class="top-aligned-row">
51
+ <td><strong>Module</strong></td>
52
+ <td class="class-name-in-header">ActiveRecord::ConnectionAdapters</td>
53
+ </tr>
54
+ <tr class="top-aligned-row">
55
+ <td><strong>In:</strong></td>
56
+ <td>
57
+ <a href="../../files/lib/rails_pg_procs_rb.html">
58
+ lib/rails_pg_procs.rb
59
+ </a>
60
+ <br />
61
+ </td>
62
+ </tr>
63
+
64
+ </table>
65
+ </div>
66
+ <!-- banner header -->
67
+
68
+ <div id="bodyContent">
69
+
70
+
71
+
72
+ <div id="contextContent">
73
+
74
+
75
+
76
+ </div>
77
+
78
+
79
+ </div>
80
+
81
+
82
+ <!-- if includes -->
83
+
84
+ <div id="section">
85
+
86
+ <div id="class-list">
87
+ <h3 class="section-bar">Classes and Modules</h3>
88
+
89
+ Class <a href="ConnectionAdapters/PostgreSQLAdapter.html" class="link">ActiveRecord::ConnectionAdapters::PostgreSQLAdapter</a><br />
90
+ Class <a href="ConnectionAdapters/ProcedureDefinition.html" class="link">ActiveRecord::ConnectionAdapters::ProcedureDefinition</a><br />
91
+ Class <a href="ConnectionAdapters/TriggerDefinition.html" class="link">ActiveRecord::ConnectionAdapters::TriggerDefinition</a><br />
92
+ Class <a href="ConnectionAdapters/TypeDefinition.html" class="link">ActiveRecord::ConnectionAdapters::TypeDefinition</a><br />
93
+
94
+ </div>
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ <!-- if method_list -->
103
+
104
+
105
+ </div>
106
+
107
+
108
+ <div id="validator-badges">
109
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
110
+ </div>
111
+
112
+ </body>
113
+ </html>
@@ -0,0 +1,589 @@
1
+ <!DOCTYPE html
2
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <title>Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ <script type="text/javascript">
12
+ // <![CDATA[
13
+
14
+ function popupCode( url ) {
15
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
16
+ }
17
+
18
+ function toggleCode( id ) {
19
+ if ( document.getElementById )
20
+ elem = document.getElementById( id );
21
+ else if ( document.all )
22
+ elem = eval( "document.all." + id );
23
+ else
24
+ return false;
25
+
26
+ elemStyle = elem.style;
27
+
28
+ if ( elemStyle.display != "block" ) {
29
+ elemStyle.display = "block"
30
+ } else {
31
+ elemStyle.display = "none"
32
+ }
33
+
34
+ return true;
35
+ }
36
+
37
+ // Make codeblocks hidden by default
38
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
39
+
40
+ // ]]>
41
+ </script>
42
+
43
+ </head>
44
+ <body>
45
+
46
+
47
+
48
+ <div id="classHeader">
49
+ <table class="header-table">
50
+ <tr class="top-aligned-row">
51
+ <td><strong>Class</strong></td>
52
+ <td class="class-name-in-header">ActiveRecord::ConnectionAdapters::PostgreSQLAdapter</td>
53
+ </tr>
54
+ <tr class="top-aligned-row">
55
+ <td><strong>In:</strong></td>
56
+ <td>
57
+ <a href="../../../files/lib/rails_pg_procs_rb.html">
58
+ lib/rails_pg_procs.rb
59
+ </a>
60
+ <br />
61
+ </td>
62
+ </tr>
63
+
64
+ <tr class="top-aligned-row">
65
+ <td><strong>Parent:</strong></td>
66
+ <td>
67
+ AbstractAdapter
68
+ </td>
69
+ </tr>
70
+ </table>
71
+ </div>
72
+ <!-- banner header -->
73
+
74
+ <div id="bodyContent">
75
+
76
+
77
+
78
+ <div id="contextContent">
79
+
80
+ <div id="description">
81
+ <p>
82
+ TODO &#8212; Add Aggregates ability
83
+ </p>
84
+
85
+ </div>
86
+
87
+
88
+ </div>
89
+
90
+ <div id="method-list">
91
+ <h3 class="section-bar">Methods</h3>
92
+
93
+ <div class="name-list">
94
+ <a href="#M000017">add_trigger</a>&nbsp;&nbsp;
95
+ <a href="#M000019">create_proc</a>&nbsp;&nbsp;
96
+ <a href="#M000015">create_type</a>&nbsp;&nbsp;
97
+ <a href="#M000023">delim</a>&nbsp;&nbsp;
98
+ <a href="#M000020">drop_proc</a>&nbsp;&nbsp;
99
+ <a href="#M000016">drop_type</a>&nbsp;&nbsp;
100
+ <a href="#M000024">get_proc_query</a>&nbsp;&nbsp;
101
+ <a href="#M000022">get_trigger_query</a>&nbsp;&nbsp;
102
+ <a href="#M000025">get_type_query</a>&nbsp;&nbsp;
103
+ <a href="#M000012">procedures</a>&nbsp;&nbsp;
104
+ <a href="#M000018">remove_trigger</a>&nbsp;&nbsp;
105
+ <a href="#M000021">trigger_name</a>&nbsp;&nbsp;
106
+ <a href="#M000013">triggers</a>&nbsp;&nbsp;
107
+ <a href="#M000014">types</a>&nbsp;&nbsp;
108
+ </div>
109
+ </div>
110
+
111
+ </div>
112
+
113
+
114
+ <!-- if includes -->
115
+ <div id="includes">
116
+ <h3 class="section-bar">Included Modules</h3>
117
+
118
+ <div id="includes-list">
119
+ <span class="include-name"><a href="../../SchemaProcs.html">SchemaProcs</a></span>
120
+ </div>
121
+ </div>
122
+
123
+ <div id="section">
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ <!-- if method_list -->
133
+ <div id="methods">
134
+ <h3 class="section-bar">Public Instance methods</h3>
135
+
136
+ <div id="method-M000017" class="method-detail">
137
+ <a name="M000017"></a>
138
+
139
+ <div class="method-heading">
140
+ <a href="#M000017" class="method-signature">
141
+ <span class="method-name">add_trigger</span><span class="method-args">(table, events, options={})</span>
142
+ </a>
143
+ </div>
144
+
145
+ <div class="method-description">
146
+ <p>
147
+ Add a trigger to a table
148
+ </p>
149
+ <p><a class="source-toggle" href="#"
150
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
151
+ <div class="method-source-code" id="M000017-source">
152
+ <pre>
153
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 314</span>
154
+ 314: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_trigger</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">events</span>, <span class="ruby-identifier">options</span>={})
155
+ 315: <span class="ruby-identifier">events</span> <span class="ruby-operator">+=</span> [<span class="ruby-identifier">:row</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:row</span>)
156
+ 316: <span class="ruby-identifier">events</span> <span class="ruby-operator">+=</span> [<span class="ruby-identifier">:before</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:before</span>)
157
+ 317: <span class="ruby-identifier">trigger</span> = <span class="ruby-constant">TriggerDefinition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">table</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:name</span>], <span class="ruby-identifier">events</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:function</span>])
158
+ 318: <span class="ruby-identifier">execute</span> <span class="ruby-identifier">trigger</span>.<span class="ruby-identifier">to_sql_create</span>
159
+ 319: <span class="ruby-comment cmt"># execute get_trigger_query(table, events, options)</span>
160
+ 320: <span class="ruby-keyword kw">end</span>
161
+ </pre>
162
+ </div>
163
+ </div>
164
+ </div>
165
+
166
+ <div id="method-M000019" class="method-detail">
167
+ <a name="M000019"></a>
168
+
169
+ <div class="method-heading">
170
+ <a href="#M000019" class="method-signature">
171
+ <span class="method-name">create_proc</span><span class="method-args">(name, columns=[], options={}) {|| ...}</span>
172
+ </a>
173
+ </div>
174
+
175
+ <div class="method-description">
176
+ <p>
177
+ Create a stored procedure
178
+ </p>
179
+ <p><a class="source-toggle" href="#"
180
+ onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
181
+ <div class="method-source-code" id="M000019-source">
182
+ <pre>
183
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 329</span>
184
+ 329: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_proc</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">columns</span>=[], <span class="ruby-identifier">options</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
185
+ 330: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">select_value</span>(<span class="ruby-value str">&quot;SELECT count(oid) FROM pg_language WHERE lanname = 'plpgsql' &quot;</span>,<span class="ruby-value str">&quot;count&quot;</span>).<span class="ruby-identifier">to_i</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
186
+ 331: <span class="ruby-identifier">execute</span>(<span class="ruby-value str">&quot;CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER plpgsql_call_handler&quot;</span>)
187
+ 332: <span class="ruby-keyword kw">end</span>
188
+ 333:
189
+ 334: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:force</span>]
190
+ 335: <span class="ruby-identifier">drop_proc</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">columns</span>) <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
191
+ 336: <span class="ruby-keyword kw">end</span>
192
+ 337:
193
+ 338: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
194
+ 339: <span class="ruby-identifier">execute</span> <span class="ruby-identifier">get_proc_query</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">columns</span>, <span class="ruby-identifier">options</span>) { <span class="ruby-keyword kw">yield</span> }
195
+ 340: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:resource</span>]
196
+ 341: <span class="ruby-identifier">execute</span> <span class="ruby-identifier">get_proc_query</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">columns</span>, <span class="ruby-identifier">options</span>)
197
+ 342: <span class="ruby-keyword kw">else</span>
198
+ 343: <span class="ruby-identifier">raise</span> <span class="ruby-constant">StatementInvalid</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;Missing function source&quot;</span>)
199
+ 344: <span class="ruby-keyword kw">end</span>
200
+ 345: <span class="ruby-keyword kw">end</span>
201
+ </pre>
202
+ </div>
203
+ </div>
204
+ </div>
205
+
206
+ <div id="method-M000015" class="method-detail">
207
+ <a name="M000015"></a>
208
+
209
+ <div class="method-heading">
210
+ <a href="#M000015" class="method-signature">
211
+ <span class="method-name">create_type</span><span class="method-args">(name, *columns)</span>
212
+ </a>
213
+ </div>
214
+
215
+ <div class="method-description">
216
+ <p><a class="source-toggle" href="#"
217
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
218
+ <div class="method-source-code" id="M000015-source">
219
+ <pre>
220
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 304</span>
221
+ 304: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_type</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">columns</span>)
222
+ 305: <span class="ruby-identifier">drop_type</span>(<span class="ruby-identifier">name</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">types</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">typ</span><span class="ruby-operator">|</span> <span class="ruby-identifier">typ</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span> }
223
+ 306: <span class="ruby-identifier">execute</span> <span class="ruby-identifier">get_type_query</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">columns</span>)
224
+ 307: <span class="ruby-keyword kw">end</span>
225
+ </pre>
226
+ </div>
227
+ </div>
228
+ </div>
229
+
230
+ <div id="method-M000020" class="method-detail">
231
+ <a name="M000020"></a>
232
+
233
+ <div class="method-heading">
234
+ <a href="#M000020" class="method-signature">
235
+ <span class="method-name">drop_proc</span><span class="method-args">(name, columns=[], cascade=false)</span>
236
+ </a>
237
+ </div>
238
+
239
+ <div class="method-description">
240
+ <pre>
241
+ DROP FUNCTION name ( [ type [, ...] ] ) [ CASCADE | RESTRICT ]
242
+ </pre>
243
+ <p>
244
+ default RESTRICT
245
+ </p>
246
+ <p><a class="source-toggle" href="#"
247
+ onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
248
+ <div class="method-source-code" id="M000020-source">
249
+ <pre>
250
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 349</span>
251
+ 349: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">drop_proc</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">columns</span>=[], <span class="ruby-identifier">cascade</span>=<span class="ruby-keyword kw">false</span>)
252
+ 350: <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;DROP FUNCTION #{name.to_sql_name}(#{columns.collect {|column| column}.join(&quot;, &quot;)}) #{cascade_or_restrict(cascade)};&quot;</span>
253
+ 351: <span class="ruby-keyword kw">end</span>
254
+ </pre>
255
+ </div>
256
+ </div>
257
+ </div>
258
+
259
+ <div id="method-M000016" class="method-detail">
260
+ <a name="M000016"></a>
261
+
262
+ <div class="method-heading">
263
+ <a href="#M000016" class="method-signature">
264
+ <span class="method-name">drop_type</span><span class="method-args">(name, cascade=false)</span>
265
+ </a>
266
+ </div>
267
+
268
+ <div class="method-description">
269
+ <p><a class="source-toggle" href="#"
270
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
271
+ <div class="method-source-code" id="M000016-source">
272
+ <pre>
273
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 309</span>
274
+ 309: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">drop_type</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">cascade</span>=<span class="ruby-keyword kw">false</span>)
275
+ 310: <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;DROP TYPE #{name} #{cascade_or_restrict(cascade)}&quot;</span>
276
+ 311: <span class="ruby-keyword kw">end</span>
277
+ </pre>
278
+ </div>
279
+ </div>
280
+ </div>
281
+
282
+ <div id="method-M000012" class="method-detail">
283
+ <a name="M000012"></a>
284
+
285
+ <div class="method-heading">
286
+ <a href="#M000012" class="method-signature">
287
+ <span class="method-name">procedures</span><span class="method-args">(lang=nil)</span>
288
+ </a>
289
+ </div>
290
+
291
+ <div class="method-description">
292
+ <p><a class="source-toggle" href="#"
293
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
294
+ <div class="method-source-code" id="M000012-source">
295
+ <pre>
296
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 259</span>
297
+ 259: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">procedures</span>(<span class="ruby-identifier">lang</span>=<span class="ruby-keyword kw">nil</span>)
298
+ 260: <span class="ruby-identifier">query</span> <span class="ruby-value str">&quot;SELECT P.oid, proname, pronamespace, proowner, lanname, proisagg, prosecdef, proisstrict, proretset, provolatile, pronargs, prorettype, proargtypes, proargnames, prosrc, probin, proacl\nFROM pg_proc P\nJOIN pg_language L ON (P.prolang = L.oid)\nWHERE P.oid &gt; \#{self.class.first_proc_oid}\nAND (proisagg = 'f')\n\#{'AND (lanname ' + lang + ')'unless lang.nil?}\n&quot;</span>
299
+ 261: <span class="ruby-keyword kw">end</span>
300
+ </pre>
301
+ </div>
302
+ </div>
303
+ </div>
304
+
305
+ <div id="method-M000018" class="method-detail">
306
+ <a name="M000018"></a>
307
+
308
+ <div class="method-heading">
309
+ <a href="#M000018" class="method-signature">
310
+ <span class="method-name">remove_trigger</span><span class="method-args">(table, name, options={})</span>
311
+ </a>
312
+ </div>
313
+
314
+ <div class="method-description">
315
+ <p>
316
+ DROP TRIGGER name ON table [ CASCADE | RESTRICT ]
317
+ </p>
318
+ <p><a class="source-toggle" href="#"
319
+ onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
320
+ <div class="method-source-code" id="M000018-source">
321
+ <pre>
322
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 323</span>
323
+ 323: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_trigger</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span>={})
324
+ 324: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:name</span>] = <span class="ruby-identifier">name</span>
325
+ 325: <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;DROP TRIGGER #{trigger_name(table, [], options).to_sql_name} ON #{table} #{cascade_or_restrict(options[:deep])};&quot;</span>
326
+ 326: <span class="ruby-keyword kw">end</span>
327
+ </pre>
328
+ </div>
329
+ </div>
330
+ </div>
331
+
332
+ <div id="method-M000013" class="method-detail">
333
+ <a name="M000013"></a>
334
+
335
+ <div class="method-heading">
336
+ <a href="#M000013" class="method-signature">
337
+ <span class="method-name">triggers</span><span class="method-args">(table_name)</span>
338
+ </a>
339
+ </div>
340
+
341
+ <div class="method-description">
342
+ <p><a class="source-toggle" href="#"
343
+ onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
344
+ <div class="method-source-code" id="M000013-source">
345
+ <pre>
346
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 271</span>
347
+ 271: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">triggers</span>(<span class="ruby-identifier">table_name</span>)
348
+ 272: <span class="ruby-identifier">query</span>(<span class="ruby-value str">&quot;SELECT T.oid, C.relname, T.tgname, T.tgtype, P.proname\nFROM pg_trigger T\nJOIN pg_class C ON (T.tgrelid = C.OID AND C.relname = '\#{table_name}' AND T.tgisconstraint = 'f')\nJOIN pg_proc P ON (T.tgfoid = P.OID)\n&quot;</span>).<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span> <span class="ruby-constant">TriggerDefinition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">row</span>) }
349
+ 273: <span class="ruby-keyword kw">end</span>
350
+ </pre>
351
+ </div>
352
+ </div>
353
+ </div>
354
+
355
+ <div id="method-M000014" class="method-detail">
356
+ <a name="M000014"></a>
357
+
358
+ <div class="method-heading">
359
+ <a href="#M000014" class="method-signature">
360
+ <span class="method-name">types</span><span class="method-args">()</span>
361
+ </a>
362
+ </div>
363
+
364
+ <div class="method-description">
365
+ <p><a class="source-toggle" href="#"
366
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
367
+ <div class="method-source-code" id="M000014-source">
368
+ <pre>
369
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 281</span>
370
+ 281: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">types</span>
371
+ 282: <span class="ruby-identifier">result</span> = <span class="ruby-identifier">query</span>(<span class="ruby-value str">&quot;SELECT T.oid, T.typname, A.attname, format_type(A.atttypid, A.atttypmod) AS type\nFROM pg_type T\nJOIN pg_class C ON (T.typrelid = C.oid)\nJOIN pg_attribute A ON (A.attrelid = C.oid AND C.relkind = 'c')\n&quot;</span>)
372
+ 283:
373
+ 284: <span class="ruby-identifier">type_id</span> = <span class="ruby-keyword kw">nil</span>
374
+ 285: <span class="ruby-identifier">types</span> = []
375
+ 286: <span class="ruby-identifier">result</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
376
+ 287: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type_id</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">row</span>[<span class="ruby-value">0</span>]
377
+ 288: <span class="ruby-identifier">types</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">TypeDefinition</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">row</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">row</span>[<span class="ruby-value">1</span>], [])
378
+ 289: <span class="ruby-identifier">type_id</span> = <span class="ruby-identifier">row</span>[<span class="ruby-value">0</span>]
379
+ 290: <span class="ruby-keyword kw">end</span>
380
+ 291:
381
+ 292: <span class="ruby-identifier">types</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">columns</span> <span class="ruby-operator">&lt;&lt;</span> [<span class="ruby-identifier">row</span>[<span class="ruby-value">2</span>], <span class="ruby-identifier">row</span>[<span class="ruby-value">3</span>]]
382
+ 293: }
383
+ 294:
384
+ 295: <span class="ruby-identifier">types</span>
385
+ 296: <span class="ruby-keyword kw">end</span>
386
+ </pre>
387
+ </div>
388
+ </div>
389
+ </div>
390
+
391
+ <h3 class="section-bar">Private Instance methods</h3>
392
+
393
+ <div id="method-M000023" class="method-detail">
394
+ <a name="M000023"></a>
395
+
396
+ <div class="method-heading">
397
+ <a href="#M000023" class="method-signature">
398
+ <span class="method-name">delim</span><span class="method-args">(name, options)</span>
399
+ </a>
400
+ </div>
401
+
402
+ <div class="method-description">
403
+ <p>
404
+ Helper function that builds the sql query used to create a stored
405
+ procedure. Mostly this is here so we can unit test the generated sql.
406
+ Either an option[:resource] or block must be defined for this method.
407
+ Otherwise an ActiveRecord::StatementInvalid exception is raised. Defaults
408
+ are:
409
+ </p>
410
+ <pre>
411
+ RETURNS (no default -- which is cheap since that means you have to call this method w/ the options Hash) TODO: fix this
412
+ LANGUAGE = plpgsql (The plugin will add this if you don't have it added already)
413
+ behavior = VOLATILE (Don't specify IMMUTABLE or STABLE and this will be added for you)
414
+ strict = CALLED ON NULL INPUT (Otherwise STRICT, According to the 8.0 manual STRICT and RETURNS NULL ON NULL INPUT (RNONI)
415
+ behave the same so I didn't make a case for RNONI)
416
+ user = INVOKER
417
+ </pre>
418
+ <p><a class="source-toggle" href="#"
419
+ onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
420
+ <div class="method-source-code" id="M000023-source">
421
+ <pre>
422
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 378</span>
423
+ 378: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delim</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span>)
424
+ 379: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:delim</span>] <span class="ruby-operator">||</span> <span class="ruby-node">&quot;$#{Inflector.underscore(name)}_body$&quot;</span>
425
+ 380: <span class="ruby-keyword kw">end</span>
426
+ </pre>
427
+ </div>
428
+ </div>
429
+ </div>
430
+
431
+ <div id="method-M000024" class="method-detail">
432
+ <a name="M000024"></a>
433
+
434
+ <div class="method-heading">
435
+ <a href="#M000024" class="method-signature">
436
+ <span class="method-name">get_proc_query</span><span class="method-args">(name, columns=[], options={}, &amp;block)</span>
437
+ </a>
438
+ </div>
439
+
440
+ <div class="method-description">
441
+ <pre>
442
+ From PostgreSQL
443
+ CREATE [ OR REPLACE ] FUNCTION
444
+ name ( [ [ argmode ] [ argname ] argtype [, ...] ] )
445
+ [ RETURNS rettype ]
446
+ { LANGUAGE langname
447
+ | IMMUTABLE | STABLE | VOLATILE
448
+ | CALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT
449
+ | [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
450
+ | AS 'definition'
451
+ | AS 'obj_file', 'link_symbol'
452
+ } ...
453
+ [ WITH ( isStrict &amp;| isCacheable ) ]
454
+ </pre>
455
+ <p>
456
+ TODO Implement [ [ argmode ] [ argname ] argtype ]
457
+ </p>
458
+ <p><a class="source-toggle" href="#"
459
+ onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
460
+ <div class="method-source-code" id="M000024-source">
461
+ <pre>
462
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 395</span>
463
+ 395: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_proc_query</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">columns</span>=[], <span class="ruby-identifier">options</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
464
+ 396: <span class="ruby-identifier">returns</span> = <span class="ruby-value str">''</span>
465
+ 397: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">:return</span>)
466
+ 398: <span class="ruby-identifier">returns</span> = <span class="ruby-node">&quot;RETURNS#{' SETOF' if options[:set]} #{options[:return] || 'VOID'}&quot;</span>
467
+ 399: <span class="ruby-keyword kw">end</span>
468
+ 400: <span class="ruby-identifier">lang</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:lang</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;plpgsql&quot;</span>
469
+ 401:
470
+ 402: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
471
+ 403: <span class="ruby-identifier">body</span> = <span class="ruby-node">&quot;#{delim(name, options)}\n#{yield}\n#{delim(name, options)}&quot;</span>
472
+ 404: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:resource</span>]
473
+ 405: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:resource</span>] <span class="ruby-operator">+=</span> [<span class="ruby-identifier">name</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:resource</span>].<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
474
+ 406: <span class="ruby-identifier">body</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:resource</span>].<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">res</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;'#{res}'&quot;</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;, &quot;</span>)
475
+ 407: <span class="ruby-keyword kw">else</span>
476
+ 408: <span class="ruby-identifier">raise</span> <span class="ruby-constant">StatementInvalid</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;Missing function source&quot;</span>)
477
+ 409: <span class="ruby-keyword kw">end</span>
478
+ 410:
479
+ 411: <span class="ruby-identifier">result</span> = <span class="ruby-node">&quot;
480
+ 412: CREATE OR REPLACE FUNCTION #{name.to_sql_name}(#{columns.collect{|column| column}.join(&quot;, &quot;)}) #{returns} AS
481
+ 413: #{body}
482
+ 414: LANGUAGE #{lang}
483
+ 415: #{ behavior(options[:behavior] || 'v').upcase }
484
+ 416: #{ strict_or_null(options[:strict]) }
485
+ 417: EXTERNAL SECURITY #{ definer_or_invoker(options[:definer]) }
486
+ 418: &quot;</span>
487
+ 419: <span class="ruby-keyword kw">end</span>
488
+ </pre>
489
+ </div>
490
+ </div>
491
+ </div>
492
+
493
+ <div id="method-M000022" class="method-detail">
494
+ <a name="M000022"></a>
495
+
496
+ <div class="method-heading">
497
+ <a href="#M000022" class="method-signature">
498
+ <span class="method-name">get_trigger_query</span><span class="method-args">(table, events, options={})</span>
499
+ </a>
500
+ </div>
501
+
502
+ <div class="method-description">
503
+ <p>
504
+ CREATE TRIGGER name { BEFORE | AFTER } { event [ OR &#8230; ] } ON table [
505
+ FOR [ EACH ] { ROW | STATEMENT } ] EXECUTE PROCEDURE funcname ( arguments )
506
+ </p>
507
+ <p><a class="source-toggle" href="#"
508
+ onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
509
+ <div class="method-source-code" id="M000022-source">
510
+ <pre>
511
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 361</span>
512
+ 361: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_trigger_query</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">events</span>, <span class="ruby-identifier">options</span>={})
513
+ 362: <span class="ruby-identifier">event_str</span> = <span class="ruby-identifier">events</span>.<span class="ruby-identifier">collect</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">event</span><span class="ruby-operator">|</span> <span class="ruby-identifier">event</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">upcase</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot; OR &quot;</span>)
514
+ 363: <span class="ruby-identifier">func_name</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:function</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">trigger_name</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">events</span>, <span class="ruby-identifier">options</span>)
515
+ 364: <span class="ruby-identifier">result</span> = <span class="ruby-node">&quot;CREATE TRIGGER #{trigger_name(table, events, options).to_sql_name} #{(options[:before] ? &quot;BEFORE&quot; : &quot;AFTER&quot;)} #{event_str} ON #{table} FOR EACH #{(options[:row] ? &quot;ROW&quot; : &quot;STATEMENT&quot;)} EXECUTE PROCEDURE #{func_name.to_sql_name}();&quot;</span>
516
+ 365: <span class="ruby-keyword kw">end</span>
517
+ </pre>
518
+ </div>
519
+ </div>
520
+ </div>
521
+
522
+ <div id="method-M000025" class="method-detail">
523
+ <a name="M000025"></a>
524
+
525
+ <div class="method-heading">
526
+ <a href="#M000025" class="method-signature">
527
+ <span class="method-name">get_type_query</span><span class="method-args">(name, *columns)</span>
528
+ </a>
529
+ </div>
530
+
531
+ <div class="method-description">
532
+ <p><a class="source-toggle" href="#"
533
+ onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
534
+ <div class="method-source-code" id="M000025-source">
535
+ <pre>
536
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 421</span>
537
+ 421: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_type_query</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">columns</span>)
538
+ 422: <span class="ruby-identifier">raise</span> <span class="ruby-constant">StatementInvalid</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">columns</span>.<span class="ruby-identifier">empty?</span>
539
+ 423: <span class="ruby-node">&quot;CREATE TYPE #{quote_column_name(name)} AS (
540
+ 424: #{columns.collect{|column,type|
541
+ 425: if column.is_a?(Hash)
542
+ 426: column.collect { |column, type| &quot;#{quote_column_name(column)} #{type}&quot; }
543
+ 427: else
544
+ 428: &quot;#{quote_column_name(column)} #{type}&quot;
545
+ 429: end
546
+ 430: }.join(&quot;,\n&quot;)}
547
+ 431: )&quot;</span>
548
+ 432: <span class="ruby-keyword kw">end</span>
549
+ </pre>
550
+ </div>
551
+ </div>
552
+ </div>
553
+
554
+ <div id="method-M000021" class="method-detail">
555
+ <a name="M000021"></a>
556
+
557
+ <div class="method-heading">
558
+ <a href="#M000021" class="method-signature">
559
+ <span class="method-name">trigger_name</span><span class="method-args">(table, events=[], options={})</span>
560
+ </a>
561
+ </div>
562
+
563
+ <div class="method-description">
564
+ <p><a class="source-toggle" href="#"
565
+ onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
566
+ <div class="method-source-code" id="M000021-source">
567
+ <pre>
568
+ <span class="ruby-comment cmt"># File lib/rails_pg_procs.rb, line 354</span>
569
+ 354: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">trigger_name</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">events</span>=[], <span class="ruby-identifier">options</span>={})
570
+ 355: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:name</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Inflector</span>.<span class="ruby-identifier">triggerize</span>(<span class="ruby-identifier">table</span>, <span class="ruby-identifier">events</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:before</span>])
571
+ 356: <span class="ruby-keyword kw">end</span>
572
+ </pre>
573
+ </div>
574
+ </div>
575
+ </div>
576
+
577
+
578
+ </div>
579
+
580
+
581
+ </div>
582
+
583
+
584
+ <div id="validator-badges">
585
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
586
+ </div>
587
+
588
+ </body>
589
+ </html>