pg_saurus 3.2.0 → 3.2.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd0811441685f917cb3168ca74b10c369d4917e8
|
4
|
+
data.tar.gz: aa68ee31da068a3279300beba063e66654dd6e97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e739fd484fec7e22d448a573d741b4b035c58de4ad7050de42c6b9883e0b46db9836e512ed1f01dd01e38aab9bc0f90dbc091a9ef08586a6c904445a67c42ff6
|
7
|
+
data.tar.gz: 818e66c4fe2e89e5953bab2d700aa4c751ad76a043e5c62f7ef94c20afb3ab9761033eaa4dd380876464376a3cd0360ea60b0772981aecac2753a7c7eb32289c
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# Methods to extend {ActiveRecord::ConnectionAdapters::PostgreSQLAdapter}
|
2
2
|
# to support database functions.
|
3
3
|
module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::FunctionMethods
|
4
|
+
# Regular expression used in function signature parsing:
|
5
|
+
FUNCTION_PARSE_REGEXP = /^CREATE[\s\S]+FUNCTION /
|
4
6
|
|
5
7
|
# Return +true+.
|
6
8
|
def supports_functions?
|
@@ -82,7 +84,10 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::FunctionMethods
|
|
82
84
|
|
83
85
|
# Retrieve the function name from the function SQL.
|
84
86
|
def parse_function_name(function_str)
|
85
|
-
function_str.
|
87
|
+
function_str.
|
88
|
+
split("\n").
|
89
|
+
find { |line| line =~ FUNCTION_PARSE_REGEXP }.
|
90
|
+
sub(FUNCTION_PARSE_REGEXP, '')
|
86
91
|
end
|
87
92
|
private :parse_function_name
|
88
93
|
|
@@ -12,7 +12,7 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::TriggerMethods
|
|
12
12
|
proc_name = "#{proc_name}"
|
13
13
|
proc_name = "#{proc_name}()" unless proc_name.end_with?(')')
|
14
14
|
|
15
|
-
for_each
|
15
|
+
for_each = options[:for_each] || 'ROW'
|
16
16
|
constraint = options[:constraint]
|
17
17
|
|
18
18
|
sql = if constraint
|
@@ -97,26 +97,31 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::TriggerMethods
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
# Parse the condition from the trigger definition.
|
100
101
|
def parse_condition(trigger_definition)
|
101
102
|
trigger_definition[/WHEN[\s](.*?)[\s]EXECUTE[\s]PROCEDURE/m, 1]
|
102
103
|
end
|
103
104
|
private :parse_condition
|
104
105
|
|
106
|
+
# Parse the event from the trigger definition.
|
105
107
|
def parse_event(trigger_definition, trigger_name)
|
106
108
|
trigger_definition[/^CREATE[\sA-Z]+TRIGGER[\s]#{Regexp.escape(trigger_name)}[\s](.*?)[\s]ON[\s]/m, 1]
|
107
109
|
end
|
108
110
|
private :parse_event
|
109
111
|
|
112
|
+
# Parse the procedure name from the trigger definition.
|
110
113
|
def parse_proc_name(trigger_definition)
|
111
114
|
trigger_definition[/EXECUTE[\s]PROCEDURE[\s](.*?)$/m,1]
|
112
115
|
end
|
113
116
|
private :parse_proc_name
|
114
117
|
|
118
|
+
# Whether the trigger is a constraint.
|
115
119
|
def is_constraint?(trigger_definition)
|
116
120
|
!!(trigger_definition =~ /^CREATE CONSTRAINT TRIGGER/)
|
117
121
|
end
|
118
122
|
private :is_constraint?
|
119
123
|
|
124
|
+
# Properly quote the table name or view name.
|
120
125
|
def quote_table_or_view(name, options)
|
121
126
|
schema = options[:schema]
|
122
127
|
if schema
|
@@ -127,6 +132,7 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::TriggerMethods
|
|
127
132
|
end
|
128
133
|
private :quote_table_or_view
|
129
134
|
|
135
|
+
# The name provided in the options, or constructed from the procedure name.
|
130
136
|
def trigger_name(proc_name, options)
|
131
137
|
if name = options[:name]
|
132
138
|
name
|
data/lib/pg_saurus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_saurus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Potapov Sergey
|
@@ -13,22 +13,22 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2018-03-30 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: pg
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- - "
|
22
|
+
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '0'
|
24
|
+
version: '1.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
|
-
- - "
|
29
|
+
- - "<"
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: '0'
|
31
|
+
version: '1.0'
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: railties
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
275
|
rubyforge_project:
|
276
|
-
rubygems_version: 2.6.
|
276
|
+
rubygems_version: 2.6.14
|
277
277
|
signing_key:
|
278
278
|
specification_version: 4
|
279
279
|
summary: ActiveRecord extensions for PostgreSQL.
|