activeset 0.8.0 → 0.8.1

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
  SHA1:
3
- metadata.gz: b7d4ed6e6770fc71dc3a001a2dc9c19a871445e3
4
- data.tar.gz: c1db7e7e4a0b3942563018e2404af6e645bcd68e
3
+ metadata.gz: bbf4217bf27e15473b352948d99a734ccb9e8c7f
4
+ data.tar.gz: 420ef8ce849ce5dd0a7539533609eb56e474ccb8
5
5
  SHA512:
6
- metadata.gz: fd2718bbacff6f512f9ad90cb33e87a1b14eaadbe85774949e2df5b02439836e1e58a5b21286f6c9481b5efdb6239715d35465ab8341b5be2e907e2007f941c0
7
- data.tar.gz: 833e98c0cf55ef9dc7229922070ba6e02f35ce2801728489f968ee08efaf689b62242592a22ca8cc23012263af4003c6f8de1213e6317b1c224e788919c9ff31
6
+ metadata.gz: c507ef02f81b2d5ecbae34eb69cbf852fab01177b37c48bc16d6badee56b969a5a904cae488d7becf6fe59272435b4984446445caaffa8158a96f86eed538c7f
7
+ data.tar.gz: 79e30270feda953162ee11a03a096fd142c5c4f0b0cbfd5a76bfdfc4af315cdfe85379b732d351efed9b07e261d797650488bbda366e3485bd9d8751e5906a10
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v 0.8.1
2
+ - fix a small bug when doing ARel filtering against binary fields
3
+ - add the ARel operators to the README
4
+ - update the ARel operator spec
1
5
  v 0.8.0
2
6
  - simplify the `inspect` method for ActiveSet instances, only showing the instructions
3
7
  - split the strategy files from the operation files
data/README.md CHANGED
@@ -41,7 +41,13 @@ The syntax for the instructions hash is relatively simple:
41
41
  attribute: 'value',
42
42
  association: {
43
43
  field: 'value'
44
- }
44
+ },
45
+ 'association.field' => 'value',
46
+ 'attribute(operator)' => 1.0,
47
+ association: {
48
+ 'field(operator)': 'value'
49
+ },
50
+ 'association.field(operator)' => 'value',
45
51
  }
46
52
  ```
47
53
 
@@ -49,7 +55,40 @@ Every entry in the instructions hash is treated and processed as an independent
49
55
 
50
56
  The logic of this method is to attempt to process every instruction with the ActiveRecordStrategy, marking all successful attempts. If we successfully processed every instruction, we simply returned the processed result. If there are any instructions that went unprocessed, we take only those instructions and process them against the set processed by the ActiveRecordStrategy.
51
57
 
52
- This filtering operation does not preserve the order of the filters, enforces conjunction, and will functionally discard any unprocessable instruction.
58
+ This filtering operation does not preserve the order of the filters, enforces conjunction, and will discard any unprocessable instruction.
59
+
60
+ For ActiveRecord sets, the various [ARel predicate methods](https://www.rubydoc.info/github/rails/arel/Arel/Predications) are available as operators:
61
+
62
+ - `eq`
63
+ - `not_eq`
64
+ - `eq_any`
65
+ - `not_eq_any`
66
+ - `eq_all`
67
+ - `not_eq_all`
68
+ - `in`
69
+ - `not_in`
70
+ - `in_any`
71
+ - `not_in_any`
72
+ - `in_all`
73
+ - `not_in_all`
74
+ - `lt`
75
+ - `lteq`
76
+ - `lt_any`
77
+ - `lteq_any`
78
+ - `lt_all`
79
+ - `lteq_all`
80
+ - `gt`
81
+ - `gteq`
82
+ - `gt_any`
83
+ - `gteq_any`
84
+ - `gt_all`
85
+ - `gteq_all`
86
+ - `matches`
87
+ - `does_not_match`
88
+ - `matches_any`
89
+ - `does_not_match_any`
90
+ - `matches_all`
91
+ - `does_not_match_all`
53
92
 
54
93
  ## Sorting
55
94
 
@@ -6,7 +6,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
  Gem::Specification.new do |spec|
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.name = 'activeset'
9
- spec.version = '0.8.0'
9
+ spec.version = '0.8.1'
10
10
  spec.authors = ['Stephen Margheim']
11
11
  spec.email = ['stephen.margheim@gmail.com']
12
12
 
@@ -43,9 +43,6 @@ class ActiveSet
43
43
  end
44
44
 
45
45
  def where_operation
46
- arel_table = Arel::Table.new(attribute_model.table_name)
47
- arel_column = arel_table[@attribute_instruction.attribute]
48
-
49
46
  initial_relation
50
47
  .where(
51
48
  arel_column.send(
@@ -71,6 +68,19 @@ class ActiveSet
71
68
  @set.eager_load(@attribute_instruction.associations_hash)
72
69
  end
73
70
 
71
+ def arel_column
72
+ attribute_type = attribute_model.columns_hash[@attribute_instruction.attribute].type
73
+
74
+ # This is to work around an bug in ActiveRecord,
75
+ # where BINARY fields aren't found properly when using the `arel_table` class method
76
+ # to build an ARel::Node
77
+ if attribute_type == :binary
78
+ Arel::Table.new(attribute_model.table_name)[@attribute_instruction.attribute]
79
+ else
80
+ attribute_model.arel_table[@attribute_instruction.attribute]
81
+ end
82
+ end
83
+
74
84
  def attribute_model
75
85
  return @set.klass if @attribute_instruction.associations_array.empty?
76
86
  return @attribute_model if defined? @attribute_model
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2018-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport