bitfields 0.8.0 → 0.9.0

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: 233507e37878a02a78985dee4d2eb03d2cbeaa56
4
- data.tar.gz: c78ab2f292b25e1b630d669b2d97771781a4d057
3
+ metadata.gz: 939266628011b67c0f2be460620f9306aaa6188c
4
+ data.tar.gz: f11a3ea44453406f0da4fe7a2c7c291e629b812d
5
5
  SHA512:
6
- metadata.gz: b24a6df7be0f2a1c76d9e19aa8aebd34c72220dc6bfe91d1aa03242daa2921d401fa652587024c43ef10c64844413d3fb34bdab03328695c6df8440515329f37
7
- data.tar.gz: 629bf10a3e5b9476c4b96d316b0c84ab79f4ced827d0d25bd7aa9dbc45a4554b390267bcdb5e4593ea5d56c3a37d8c47924dd6375b79acc5b7e26c0ae8ff0fa2
6
+ metadata.gz: 0f5ca7fe2654bb9ca3f4f6bd2bad9c74f060c8209cff1858a4f4a4967ec9f2568c9aa7060f29f48e70d908df28b71ae725f5c997ee3caceb0540b824b0af7011
7
+ data.tar.gz: fbdc57f7aaa4bfed52dda1a86af01955c48db32d271711bee6b1fa7541781f9b2c164ffdbf48e5e9cfdd6ac03f9eee127243298796d3c06ffe2cea59067c6c94
data/Readme.md CHANGED
@@ -17,6 +17,7 @@ user.my_bits # => 3
17
17
  - Individual added methods (i.e, `seller_was`, `seller_changed?`, etc..) can be deactivated with `bitfield ..., added_instance_methods: false`
18
18
  - adds scopes `User.seller.sensible.first` (deactivate with `bitfield ..., scopes: false`)
19
19
  - builds sql `User.bitfield_sql(insane: true, sensible: false) # => '(users.my_bits & 6) = 1'`
20
+ - builds sql with OR condition `User.bitfield_sql({ insane: true, sensible: true }, query_mode: :bit_operator_or) # => '(users.my_bits & 2) = 2 OR (users.bits & 4) = 4'`
20
21
  - builds index-using sql with `bitfield ... , query_mode: :in_list` and `User.bitfield_sql(insane: true, sensible: false) # => 'users.my_bits IN (2, 3)'` (2 and 1+2) often slower than :bit_operator sql especially for high number of bits
21
22
  - builds update sql `User.set_bitfield_sql(insane: true, sensible: false) == 'my_bits = (my_bits | 6) - 4'`
22
23
  - **faster sql than any other bitfield lib** through combination of multiple bits into a single sql statement
@@ -101,9 +102,9 @@ Authors
101
102
  - [PeppyHeppy](https://github.com/peppyheppy)
102
103
  - [kmcbride](https://github.com/kmcbride)
103
104
  - [Justin Aiken](https://github.com/JustinAiken)
105
+ - [szTheory](https://github.com/szTheory)
104
106
 
105
107
  [Michael Grosser](http://grosser.it)<br/>
106
108
  michael@grosser.it<br/>
107
109
  License: MIT<br/>
108
110
  [![Build Status](https://travis-ci.org/grosser/bitfields.png)](https://travis-ci.org/grosser/bitfields)
109
-
@@ -125,6 +125,13 @@ module Bitfields
125
125
  when :bit_operator
126
126
  on, off = bit_values_to_on_off(column, bit_values)
127
127
  "(#{table_name}.#{column} & #{on+off}) = #{on}"
128
+ when :bit_operator_or
129
+ result = []
130
+ bit_values.each do |bit_name, value|
131
+ bit = bitfields[column][bit_name]
132
+ result << "(#{table_name}.#{column} & #{bit}) = #{bit}" if value
133
+ end
134
+ result.join(' OR ')
128
135
  else raise("bitfields: unknown query mode #{mode.inspect}")
129
136
  end
130
137
  end
@@ -1,3 +1,3 @@
1
1
  module Bitfields
2
- Version = VERSION = "0.8.0"
2
+ Version = VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-26 00:00:00.000000000 Z
11
+ date: 2019-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wwtd
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 2.0.0
119
+ version: 2.2.0
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="