pg_serializable 1.3.2 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c5052008c41e4ae3e430e88499f33e520b83b1c00f5a17f05aa110d9daa2a15
4
- data.tar.gz: 2dd49fe0bc041c71ff79e82146000cf874419d2f0e3c8d8bee50e2ca89beeab5
3
+ metadata.gz: a4a5cdf3d08ff52acb34ee418e7288b830154d98c572f85cb83d07cd6c8e9d28
4
+ data.tar.gz: 075d6e05706f868bb0871201a40594c5bb85bbe80dd5fc8663308fb0a5d32f60
5
5
  SHA512:
6
- metadata.gz: 316e4f63ced201fc3513a7668150de9fb708a656c5ef970cdf947022e380f0849eb6562ff8c8ece7aa7637b67924d9e8af86602435818440346a45c30f3c95c5
7
- data.tar.gz: f2e665f2b09a3c8191424158075e08ce65f38e39117b8f7c282000a336310e0a771eb7ab967acd3c3bcf1492e44db840d4c84f22075ce51b6c87f934f7110c93
6
+ metadata.gz: ad13d0f61c3d611ec91ebc0074adcf3a49be8ca3f9ce3c5d73e8557f0b2928a3fb74c3f1ae3c9fbe17e75ec30db92af539add503189efac7dcf40bbeb32a31a9
7
+ data.tar.gz: 3f7c59fd5f2a376a4155bf4028ec82daaacfa4d2ff9f3115f39b5a6980f883955a1716a4606aa686830a509d3c7d141922f2b9041b47f55de32b31cd7c411800
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pg_serializable (1.3.1)
4
+ pg_serializable (1.4.0)
5
5
  activerecord (~> 5.2)
6
6
  activesupport (~> 5.2)
7
7
  oj (~> 3.6)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # PgSerializable
2
2
  [![codecov](https://codecov.io/gh/matthewjf/pg_serializable/branch/master/graph/badge.svg)](https://codecov.io/gh/matthewjf/pg_serializable)
3
- [![Maintainability](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability)](https://codeclimate.com/github/codeclimate/codeclimate/maintainability)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/f3450fdd21d38e2a2fe6/maintainability)](https://codeclimate.com/github/matthewjf/pg_serializable/maintainability)
4
4
 
5
5
  ## Description
6
6
 
@@ -598,6 +598,10 @@ Response:
598
598
  ]
599
599
  ```
600
600
 
601
+ ### Single Table Inheritance
602
+
603
+ It works with single table inheritance. Traits must be defined on each class individually.
604
+
601
605
  ## Without Rails
602
606
 
603
607
  Rails isn't a dependency of this gem. However, setting it up to work without Rails takes some work. The `specs/support` folder has the initialization code needed to run the gem with just `ActiveSupport` and `ActiveRecord`.
data/codecov.yml CHANGED
@@ -1,2 +1,2 @@
1
1
  ignore:
2
- - "spec"
2
+ - "spec/.*"
@@ -1,3 +1,3 @@
1
1
  module PgSerializable
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -5,20 +5,22 @@ module PgSerializable
5
5
  table_alias = next_alias!
6
6
 
7
7
  klass = subject.class
8
+ base_class = klass.base_class
8
9
  select_sql = json_build_object(visit(klass.trait_manager, trait: trait, table_alias: table_alias)).to_sql
9
- from_sql = klass.where(id: subject.id).limit(1).to_sql
10
+ from_sql = base_class.where(id: subject.id).limit(1).to_sql
10
11
 
11
- klass.select(select_sql).from("#{as(from_sql, table_alias)}")
12
+ base_class.select(select_sql).from("#{as(from_sql, table_alias)}")
12
13
  end
13
14
 
14
15
  def visit_relation(subject, table_alias: nil, trait: :default)
15
16
  table_alias ||= next_alias!
16
17
 
17
18
  klass = subject.klass
19
+ base_class = klass.base_class
18
20
  select_sql = coalesce(json_agg(json_build_object(visit(klass.trait_manager, trait: trait, table_alias: table_alias)))).to_sql
19
21
  from_sql = subject.to_sql
20
22
 
21
- klass.select(select_sql).from("#{as(from_sql, table_alias)}")
23
+ base_class.select(select_sql).from("#{as(from_sql, table_alias)}")
22
24
  end
23
25
 
24
26
  def visit_class(subject, trait: :default, **kwargs)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_serializable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - matthewjf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2019-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler