activerecord-pg_enum 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '068a2c10c5375f5842445a5bff077ec28e14cd633d99dd7b8ef98690b28b2d2b'
4
- data.tar.gz: aca6f592f676a8f6cd866a3bb1b3ca0eb0081976e8c1bbb99c71b25f5fc5192b
3
+ metadata.gz: 552cd4fa6b85fd2002965150aca5e1f92f9752bfce9ab6628241dce0ef40406f
4
+ data.tar.gz: b7915cd86940a3f2c5b2e9053712369f639073e22123b7a3a173f5403539aca1
5
5
  SHA512:
6
- metadata.gz: 8c10ce8c87fada1997551cc9257cfd1cf7a8af5182f048c0b4f8fc56738e8bfe6fdda0bd88bd4e5126dba8102d9f1107cd1c1c40a5693fc8e860b190935c673d
7
- data.tar.gz: ef59bbe1f7ea8dba8191c40c74aa703e1a00de17b26457ee26b4b73bf95fe24ceb2f85f105d480f6e49877d2bf466dfed39dfd323c8643e7cb35ddeb79737eb3
6
+ metadata.gz: 5b48750e4060fb131d1099ddf2198362e750901873e590ca488cb376e99ef30ab09c11857d9aa91ae9e0caea2903367a97bb34073f31f1ee1a9c4377cf9a27a5
7
+ data.tar.gz: 66fc8ee9467a8dc96445e5e5f8fdab62b77ad4740086b17fa1d3a673415c657f3fdccf5cc09898f8153534951ccfa88b644359b7ebb2ccb81fd187e5465b4655
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (1.0.1)
4
+ activerecord-pg_enum (1.0.3)
5
5
  activerecord (>= 4.1.0)
6
6
  activesupport
7
7
  pg
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (1.0.1)
4
+ activerecord-pg_enum (1.0.3)
5
5
  activerecord (>= 4.1.0)
6
6
  activesupport
7
7
  pg
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (1.0.1)
4
+ activerecord-pg_enum (1.0.3)
5
5
  activerecord (>= 4.1.0)
6
6
  activesupport
7
7
  pg
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (1.0.1)
4
+ activerecord-pg_enum (1.0.3)
5
5
  activerecord (>= 4.1.0)
6
6
  activesupport
7
7
  pg
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (1.0.1)
4
+ activerecord-pg_enum (1.0.3)
5
5
  activerecord (>= 4.1.0)
6
6
  activesupport
7
7
  pg
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- activerecord-pg_enum (1.0.1)
4
+ activerecord-pg_enum (1.0.3)
5
5
  activerecord (>= 4.1.0)
6
6
  activesupport
7
7
  pg
@@ -66,7 +66,7 @@ GIT
66
66
  PATH
67
67
  remote: ..
68
68
  specs:
69
- activerecord-pg_enum (1.0.1)
69
+ activerecord-pg_enum (1.0.3)
70
70
  activerecord (>= 4.1.0)
71
71
  activesupport
72
72
  pg
@@ -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}", %w[#{definition.join(" ")}]}
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, string_agg(e.enumlabel, ' ' ORDER BY e.enumsortorder) AS enum_value
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
- if res.respond_to?(:cast_values)
26
- res = res.cast_values
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
- res = res.rows
31
+ proc { |values| coltype.type_cast(values) }
29
32
  end
30
33
 
31
- res.inject({}) do |memo, (name, values)|
32
- memo[name] = values.split(" ")
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
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module PGEnum
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
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.2
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-08-29 00:00:00.000000000 Z
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: