activerecord-pg_enum 1.0.2 → 1.0.3
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/activerecord-pg_enum.gemspec +7 -0
- data/gemfiles/4.1.gemfile.lock +1 -1
- data/gemfiles/4.2.gemfile.lock +1 -1
- data/gemfiles/5.0.gemfile.lock +1 -1
- data/gemfiles/5.1.gemfile.lock +1 -1
- data/gemfiles/5.2.gemfile.lock +1 -1
- data/gemfiles/6.0.gemfile.lock +1 -1
- data/gemfiles/edge.gemfile.lock +1 -1
- data/lib/active_record/pg_enum/4.1/schema_dumper.rb +1 -1
- data/lib/active_record/pg_enum/postgresql_adapter.rb +9 -6
- data/lib/active_record/pg_enum/schema_statements.rb +1 -1
- data/lib/active_record/pg_enum/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 552cd4fa6b85fd2002965150aca5e1f92f9752bfce9ab6628241dce0ef40406f
|
4
|
+
data.tar.gz: b7915cd86940a3f2c5b2e9053712369f639073e22123b7a3a173f5403539aca1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b48750e4060fb131d1099ddf2198362e750901873e590ca488cb376e99ef30ab09c11857d9aa91ae9e0caea2903367a97bb34073f31f1ee1a9c4377cf9a27a5
|
7
|
+
data.tar.gz: 66fc8ee9467a8dc96445e5e5f8fdab62b77ad4740086b17fa1d3a673415c657f3fdccf5cc09898f8153534951ccfa88b644359b7ebb2ccb81fd187e5465b4655
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.3] - 2019-10-13
|
10
|
+
### Fixed
|
11
|
+
- Allow enum labels to contain spaces (@AndrewSpeed)
|
12
|
+
|
9
13
|
## [1.0.2] - 2019-08-29
|
10
14
|
- Move the active_record load hook to a different place to ensure things run in the correct order
|
11
15
|
|
@@ -14,6 +14,13 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/alassek/activerecord-pg_enum"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
+
spec.metadata = {
|
18
|
+
"bug_tracker_uri" => "https://github.com/alassek/activerecord-pg_enum/issues",
|
19
|
+
"changelog_uri" => "https://github.com/alassek/activerecord-pg_enum/blob/master/CHANGELOG.md",
|
20
|
+
"pgp_keys_uri" => "https://keybase.io/alassek/pgp_keys.asc",
|
21
|
+
"signatures_uri" => "https://keybase.pub/alassek/gems/"
|
22
|
+
}
|
23
|
+
|
17
24
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
25
|
f.match(%r{^(test|spec|features)/})
|
19
26
|
end
|
data/gemfiles/4.1.gemfile.lock
CHANGED
data/gemfiles/4.2.gemfile.lock
CHANGED
data/gemfiles/5.0.gemfile.lock
CHANGED
data/gemfiles/5.1.gemfile.lock
CHANGED
data/gemfiles/5.2.gemfile.lock
CHANGED
data/gemfiles/6.0.gemfile.lock
CHANGED
data/gemfiles/edge.gemfile.lock
CHANGED
@@ -19,7 +19,7 @@ module ActiveRecord
|
|
19
19
|
stream.puts " # These are custom enum types that must be created before they can be used in the schema definition"
|
20
20
|
|
21
21
|
enum_types.each do |name, definition|
|
22
|
-
stream.puts %Q{ create_enum "#{name}",
|
22
|
+
stream.puts %Q{ create_enum "#{name}", #{definition}}
|
23
23
|
end
|
24
24
|
|
25
25
|
stream.puts
|
@@ -14,7 +14,7 @@ module ActiveRecord
|
|
14
14
|
# { "foo_type" => ["foo", "bar", "baz"] }
|
15
15
|
def enum_types
|
16
16
|
res = exec_query(<<-SQL.strip_heredoc, "SCHEMA")
|
17
|
-
SELECT t.typname AS enum_name,
|
17
|
+
SELECT t.typname AS enum_name, array_agg(e.enumlabel ORDER BY e.enumsortorder) AS enum_value
|
18
18
|
FROM pg_type t
|
19
19
|
JOIN pg_enum e ON t.oid = e.enumtypid
|
20
20
|
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
|
@@ -22,14 +22,17 @@ module ActiveRecord
|
|
22
22
|
GROUP BY enum_name
|
23
23
|
SQL
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
coltype = res.column_types["enum_value"]
|
26
|
+
deserialize = if coltype.respond_to?(:deserialize)
|
27
|
+
proc { |values| coltype.deserialize(values) }
|
28
|
+
elsif coltype.respond_to?(:type_cast_from_database)
|
29
|
+
proc { |values| coltype.type_cast_from_database(values) }
|
27
30
|
else
|
28
|
-
|
31
|
+
proc { |values| coltype.type_cast(values) }
|
29
32
|
end
|
30
33
|
|
31
|
-
res.inject({}) do |memo, (name, values)|
|
32
|
-
memo[name] =
|
34
|
+
res.rows.inject({}) do |memo, (name, values)|
|
35
|
+
memo[name] = deserialize.call(values)
|
33
36
|
memo
|
34
37
|
end
|
35
38
|
end
|
@@ -10,7 +10,7 @@ module ActiveRecord
|
|
10
10
|
#
|
11
11
|
# Example:
|
12
12
|
#
|
13
|
-
# create_enum("foo_type", "foo", "bar", "baz")
|
13
|
+
# create_enum("foo_type", "foo", "bar", "baz", "foo bar")
|
14
14
|
def create_enum(name, values)
|
15
15
|
execute("CREATE TYPE #{name} AS ENUM (#{Array(values).map { |v| "'#{v}'" }.join(", ")})").tap {
|
16
16
|
reload_type_map
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-pg_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Lassek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -189,7 +189,11 @@ files:
|
|
189
189
|
homepage: https://github.com/alassek/activerecord-pg_enum
|
190
190
|
licenses:
|
191
191
|
- MIT
|
192
|
-
metadata:
|
192
|
+
metadata:
|
193
|
+
bug_tracker_uri: https://github.com/alassek/activerecord-pg_enum/issues
|
194
|
+
changelog_uri: https://github.com/alassek/activerecord-pg_enum/blob/master/CHANGELOG.md
|
195
|
+
pgp_keys_uri: https://keybase.io/alassek/pgp_keys.asc
|
196
|
+
signatures_uri: https://keybase.pub/alassek/gems/
|
193
197
|
post_install_message:
|
194
198
|
rdoc_options: []
|
195
199
|
require_paths:
|