nobrainer 0.33.0 → 0.36.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 +5 -5
- data/CHANGELOG.md +142 -0
- data/lib/no_brainer/config.rb +5 -2
- data/lib/no_brainer/connection.rb +2 -2
- data/lib/no_brainer/criteria/where.rb +8 -0
- data/lib/no_brainer/document/association/core.rb +2 -1
- data/lib/no_brainer/document/association/eager_loader.rb +6 -2
- data/lib/no_brainer/document/table_config.rb +2 -2
- data/lib/no_brainer/document/types/array.rb +90 -0
- data/lib/no_brainer/document/types.rb +9 -3
- data/lib/no_brainer/query_runner/table_on_demand.rb +10 -0
- data/lib/no_brainer/symbol_decoration.rb +1 -1
- data/lib/no_brainer/system/table_config.rb +1 -0
- data/lib/nobrainer.rb +4 -0
- metadata +21 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 61c15de4e6f0d6ede87a2db309ff25a79d36d61befdfcd280815925d0f66bb68
|
4
|
+
data.tar.gz: f1516356fe4f53577a744dfacca6a8143d98844aee540e8c0290950113bedd88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fabd4ff40209300d3630cee18bd27115d77f6c157b6d9f910ac93896ef11487f1cf1cb116fb7a98ef356e3c78033412c05ddf06d60ed473b753a26a9aab4ab2
|
7
|
+
data.tar.gz: 9d3299f45f30001d6856ea015b15c19a9f5b7ec5642337c3416da160468deb5f00b5714f54eb3837b0af716c1a61fc817963280830bffa6b09bf15775624590f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
|
10
|
+
## [0.36.0] - 2021-08-08
|
11
|
+
### Added
|
12
|
+
- Array and TypedArray types for validation and serialization
|
13
|
+
|
14
|
+
## [0.35.0] - 2021-08-08
|
15
|
+
### Added
|
16
|
+
- Dockerfile, docker-compose and Earthfile
|
17
|
+
- Test Ruby 3 + Rails 6 on Travis CI
|
18
|
+
- Implements the ReQL `during` command
|
19
|
+
|
20
|
+
## [0.34.1] - 2021-02-18
|
21
|
+
### Fixed
|
22
|
+
- Defining attributes at class level (Rails 6.1 compatibity)
|
23
|
+
- Ruby 2.7 support
|
24
|
+
|
25
|
+
## [0.34.0] - 2019-10-15
|
26
|
+
### Added
|
27
|
+
- Rails 6 support
|
28
|
+
- Support for the nonvoting_replica_tags table option
|
29
|
+
|
30
|
+
## [0.33.0] - 2016-11-27
|
31
|
+
### Added
|
32
|
+
- Allow a run_options to be configured globally
|
33
|
+
- Support for username and password authentication
|
34
|
+
|
35
|
+
### Changed
|
36
|
+
- Use URI.decode() for user and password in the RethinkDB URL
|
37
|
+
- Also comment active_record lines in the config/initializers/*.rb on gem installation
|
38
|
+
- Removed .unscoped when fetching belongs_to associations
|
39
|
+
- update_all() operates without ordering
|
40
|
+
- has_many dependent refactoring
|
41
|
+
- Default logger should be STDERR if the rails logger is not initialized
|
42
|
+
- Locking: changes lock key type from string to text in order to support more than 255 characters keys by default, the key type needs to be Text.
|
43
|
+
- field type for rql_function to :text
|
44
|
+
|
45
|
+
### Fixed
|
46
|
+
- Model reloading with Rails5
|
47
|
+
- Rails 5 Strong Parameters: Strong parameters are not a Hash anymore in Rails 5, but support transforming into a hash
|
48
|
+
|
49
|
+
## [0.32.0] - 2016-06-05
|
50
|
+
### Added
|
51
|
+
- Compatiblity with Rails5
|
52
|
+
- order() as an alias of order_by()
|
53
|
+
- Provide attribute_will_change!() for compatibility
|
54
|
+
|
55
|
+
### Changed
|
56
|
+
- Comments more active_record related configs during install
|
57
|
+
|
58
|
+
### Fixed
|
59
|
+
- Rails 5 deprecation: Using ActiveSupport::Reloader instead of ActionDispatch::Reloader to be ready when Rails 5 hits
|
60
|
+
- config syntax
|
61
|
+
|
62
|
+
### Removed
|
63
|
+
- JRuby and Rbx in travis-ci
|
64
|
+
|
65
|
+
## [0.31.0] - 2016-02-07
|
66
|
+
### Added
|
67
|
+
- Allow belongs_to association names to be used in upsert params
|
68
|
+
- `uniq` shorthand for the belongs_to association
|
69
|
+
- Allow self-referential belongs_to
|
70
|
+
- Prevent double loading of the same model
|
71
|
+
- Use index for where(XXX.defined => true)
|
72
|
+
- Guard against bad virtual attribute expressions
|
73
|
+
- Allow non existing attributes to be lazy fetched
|
74
|
+
- Added back update_attributes()
|
75
|
+
|
76
|
+
### Fixed
|
77
|
+
- Fix join on keys that are undefined
|
78
|
+
|
79
|
+
### Changed
|
80
|
+
- where() leverages the association translation abstraction
|
81
|
+
- Primary keys time offset should operate on fixed timezone
|
82
|
+
|
83
|
+
### Removed
|
84
|
+
- Removing locking around sync_table_config
|
85
|
+
|
86
|
+
## [0.30.0] - 2015-10-03
|
87
|
+
### Added
|
88
|
+
- Add rbx-2 to .travis.yml
|
89
|
+
- Add the virtual attribute feature
|
90
|
+
- Lock: Allow find() to get locks by key
|
91
|
+
- Locks: Allow default expire/timeout values to be passed in new()
|
92
|
+
- NoBrainer::ReentrantLock implementation
|
93
|
+
- Allow compound indexes to be declared with an implicit name
|
94
|
+
- Allow polymorphic queries with first_or_create under certain conditions
|
95
|
+
|
96
|
+
### Changed
|
97
|
+
- Prevent first_or_create() to accept block with arguments
|
98
|
+
|
99
|
+
### Fixed
|
100
|
+
- Fix rails issue with tests and profiler
|
101
|
+
- Fix where() .include modifier with type checking
|
102
|
+
- Virtual attribute option fix
|
103
|
+
- Discard documents when join() encounter a nil join key
|
104
|
+
- Locks: bug fix: allow small timeouts in lock()
|
105
|
+
- Fix reentrant lock counter on steals
|
106
|
+
|
107
|
+
[Unreleased]: https://github.com/nobrainerorm/nobrainer/compare/v0.36.0...HEAD
|
108
|
+
[0.36.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.35.0...v0.36.0
|
109
|
+
[0.35.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.34.1...v0.35.0
|
110
|
+
[0.34.1]: https://github.com/nobrainerorm/nobrainer/compare/v0.34.0...v0.34.1
|
111
|
+
[0.34.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.33.0...v0.34.0
|
112
|
+
[0.33.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.32.0...v0.33.0
|
113
|
+
[0.32.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.31.0...v0.32.0
|
114
|
+
[0.31.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.30.0...v0.31.0
|
115
|
+
[0.30.0]: https://github.com/nobrainerorm/nobrainer/compare/v0.29.0...v0.30.0
|
116
|
+
[0.29.0]: https://github.com/nobrainerorm/nobrainer/compare/0.28.0...0.29.0
|
117
|
+
[0.28.0]: https://github.com/nobrainerorm/nobrainer/compare/0.27.0...0.28.0
|
118
|
+
[0.27.0]: https://github.com/nobrainerorm/nobrainer/compare/0.26.0...0.27.0
|
119
|
+
[0.26.0]: https://github.com/nobrainerorm/nobrainer/compare/0.25.1...0.26.0
|
120
|
+
[0.25.1]: https://github.com/nobrainerorm/nobrainer/compare/0.25.0...0.25.1
|
121
|
+
[0.25.0]: https://github.com/nobrainerorm/nobrainer/compare/0.24.0...0.25.0
|
122
|
+
[0.24.0]: https://github.com/nobrainerorm/nobrainer/compare/0.23.0...0.24.0
|
123
|
+
[0.23.0]: https://github.com/nobrainerorm/nobrainer/compare/0.22.0...0.23.0
|
124
|
+
[0.22.0]: https://github.com/nobrainerorm/nobrainer/compare/0.21.0...0.22.0
|
125
|
+
[0.21.0]: https://github.com/nobrainerorm/nobrainer/compare/0.20.0...0.21.0
|
126
|
+
[0.20.0]: https://github.com/nobrainerorm/nobrainer/compare/0.19.0...0.20.0
|
127
|
+
[0.19.0]: https://github.com/nobrainerorm/nobrainer/compare/0.18.1...0.19.0
|
128
|
+
[0.18.1]: https://github.com/nobrainerorm/nobrainer/compare/0.18.0...0.18.1
|
129
|
+
[0.18.0]: https://github.com/nobrainerorm/nobrainer/compare/0.17.0...0.18.0
|
130
|
+
[0.17.0]: https://github.com/nobrainerorm/nobrainer/compare/0.16.0...0.17.0
|
131
|
+
[0.16.0]: https://github.com/nobrainerorm/nobrainer/compare/0.15.0...0.16.0
|
132
|
+
[0.15.0]: https://github.com/nobrainerorm/nobrainer/compare/0.14.0...0.15.0
|
133
|
+
[0.15.0]: https://github.com/nobrainerorm/nobrainer/compare/0.14.0...0.15.0
|
134
|
+
[0.14.0]: https://github.com/nobrainerorm/nobrainer/compare/0.13.1...0.14.0
|
135
|
+
[0.13.1]: https://github.com/nobrainerorm/nobrainer/compare/0.13.0...0.13.1
|
136
|
+
[0.13.0]: https://github.com/nobrainerorm/nobrainer/compare/0.12.0...0.13.0
|
137
|
+
[0.12.0]: https://github.com/nobrainerorm/nobrainer/compare/0.11.0...0.12.0
|
138
|
+
[0.11.0]: https://github.com/nobrainerorm/nobrainer/compare/0.10.0...0.11.0
|
139
|
+
[0.10.0]: https://github.com/nobrainerorm/nobrainer/compare/0.9.1...0.10.0
|
140
|
+
[0.9.1]: https://github.com/nobrainerorm/nobrainer/compare/0.9.0...0.9.1
|
141
|
+
[0.9.0]: https://github.com/nobrainerorm/nobrainer/compare/0.8.0...0.9.0
|
142
|
+
[0.8.0]: https://github.com/nobrainerorm/nobrainer/releases/tag/0.8.0
|
data/lib/no_brainer/config.rb
CHANGED
@@ -12,7 +12,7 @@ module NoBrainer::Config
|
|
12
12
|
:warn_on_active_record => { :default => ->{ true }, :valid_values => [true, false] },
|
13
13
|
:durability => { :default => ->{ nil } }, # legacy
|
14
14
|
:table_options => { :default => ->{ {:shards => 1, :replicas => 1, :write_acks => :majority} },
|
15
|
-
:valid_keys => [:shards, :replicas, :primary_replica_tag, :
|
15
|
+
:valid_keys => [:durability, :shards, :replicas, :primary_replica_tag, :nonvoting_replica_tags, :write_acks] },
|
16
16
|
:run_options => { :default => ->{ {:durability => default_durability} } },
|
17
17
|
:max_string_length => { :default => ->{ 255 } },
|
18
18
|
:user_timezone => { :default => ->{ :local }, :valid_values => [:unchanged, :utc, :local] },
|
@@ -107,7 +107,10 @@ module NoBrainer::Config
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def default_app_name
|
110
|
-
defined?(Rails)
|
110
|
+
return unless defined?(Rails)
|
111
|
+
NoBrainer.rails6? ?
|
112
|
+
Rails.application.class.module_parent_name.underscore.presence :
|
113
|
+
Rails.application.class.parent_name.underscore.presence rescue nil
|
111
114
|
end
|
112
115
|
|
113
116
|
def default_environment
|
@@ -19,8 +19,8 @@ class NoBrainer::Connection
|
|
19
19
|
end
|
20
20
|
|
21
21
|
{
|
22
|
-
:user => uri.user &&
|
23
|
-
:password => uri.password &&
|
22
|
+
:user => uri.user && CGI.unescape(uri.user),
|
23
|
+
:password => uri.password && CGI.unescape(uri.password),
|
24
24
|
:host => uri.host,
|
25
25
|
:port => uri.port || 28015,
|
26
26
|
:db => uri.path.gsub(/^\//, ''),
|
@@ -104,6 +104,7 @@ module NoBrainer::Criteria::Where
|
|
104
104
|
when :between then [key_modifier, op, (cast_value(value.min)..cast_value(value.max))]
|
105
105
|
when :include then ensure_scalar_for(op); [:any, :eq, cast_value(value)]
|
106
106
|
when :defined, :undefined then ensure_scalar_for(op); [key_modifier, op, cast_value(value)]
|
107
|
+
when :during then [key_modifier, op, [cast_value(value.first), cast_value(value.last)]]
|
107
108
|
else [key_modifier, op, cast_value(value)]
|
108
109
|
end
|
109
110
|
BinaryOperator.new(new_key_path, new_key_modifier, new_op, new_value, model, true)
|
@@ -132,6 +133,7 @@ module NoBrainer::Criteria::Where
|
|
132
133
|
when :between then (lvalue >= value.min) & (lvalue <= value.max)
|
133
134
|
when :in then RethinkDB::RQL.new.expr(value).contains(lvalue)
|
134
135
|
when :intersects then lvalue.intersects(value.to_rql)
|
136
|
+
when :during then lvalue.during(value.first, value.last)
|
135
137
|
when :near
|
136
138
|
# XXX options[:max_results] is not used, seems to be a workaround of rethinkdb index implementation.
|
137
139
|
circle = value[:circle]
|
@@ -244,6 +246,7 @@ module NoBrainer::Criteria::Where
|
|
244
246
|
when Symbol::Decoration
|
245
247
|
case clause.args.size
|
246
248
|
when 1 then parse_clause_stub(clause, clause.args.first, options)
|
249
|
+
when 2 then parse_clause_stub(clause, clause.args, options)
|
247
250
|
else raise "Invalid argument: #{clause}"
|
248
251
|
end
|
249
252
|
else raise "Invalid clause: #{clause}"
|
@@ -263,6 +266,11 @@ module NoBrainer::Criteria::Where
|
|
263
266
|
else instantiate_binary_op(key.to_sym, :eq, value, options)
|
264
267
|
end
|
265
268
|
when Symbol::Decoration then
|
269
|
+
# The :eq operator can have only one arg
|
270
|
+
if key.decorator == :eq && value.is_a?(Array) && value.size > 1
|
271
|
+
raise "Invalid key: #{key}"
|
272
|
+
end
|
273
|
+
|
266
274
|
case key.decorator
|
267
275
|
when :any, :all, :not then instantiate_binary_op(key, :eq, value, options)
|
268
276
|
when :gte then instantiate_binary_op(key.symbol, :ge, value, options)
|
@@ -51,7 +51,8 @@ module NoBrainer::Document::Association::Core
|
|
51
51
|
return model_name if model_name.is_a?(Module)
|
52
52
|
|
53
53
|
model_name = model_name.to_s
|
54
|
-
current_module = @owner_model.parent
|
54
|
+
current_module = NoBrainer.rails6? ? @owner_model.module_parent : @owner_model.parent
|
55
|
+
|
55
56
|
return model_name.constantize if current_module == Object
|
56
57
|
return model_name.constantize if model_name =~ /^::/
|
57
58
|
return model_name.constantize if !current_module.const_defined?(model_name)
|
@@ -33,8 +33,12 @@ module NoBrainer::Document::Association::EagerLoader
|
|
33
33
|
def eager_load_association(docs, association_name, criteria=nil)
|
34
34
|
docs = docs.compact
|
35
35
|
return [] if docs.empty?
|
36
|
-
|
37
|
-
|
36
|
+
|
37
|
+
meta = docs.first.class.association_metadata
|
38
|
+
root_meta = docs.first.root_class.association_metadata
|
39
|
+
association = meta[association_name.to_sym] || root_meta[association_name.to_sym] ||
|
40
|
+
meta[association_name.to_s.singularize.to_sym] || root_meta[association_name.to_s.singularize.to_sym]
|
41
|
+
|
38
42
|
raise "Unknown association #{association_name}" unless association
|
39
43
|
association.eager_load(docs, criteria)
|
40
44
|
end
|
@@ -6,7 +6,7 @@ module NoBrainer::Document::TableConfig
|
|
6
6
|
|
7
7
|
autoload :Synchronizer
|
8
8
|
|
9
|
-
VALID_TABLE_CONFIG_OPTIONS = [:name, :durability, :shards, :replicas, :primary_replica_tag, :write_acks]
|
9
|
+
VALID_TABLE_CONFIG_OPTIONS = [:name, :durability, :shards, :replicas, :primary_replica_tag, :nonvoting_replica_tags, :write_acks]
|
10
10
|
|
11
11
|
included do
|
12
12
|
cattr_accessor :table_config_options, :instance_accessor => false
|
@@ -78,7 +78,7 @@ module NoBrainer::Document::TableConfig
|
|
78
78
|
def sync_table_config(options={})
|
79
79
|
c = table_create_options
|
80
80
|
table_config.update!(c.slice(:durability, :primary_key, :write_acks))
|
81
|
-
NoBrainer.run { rql_table.reconfigure(c.slice(:shards, :replicas, :primary_replica_tag)) }
|
81
|
+
NoBrainer.run { rql_table.reconfigure(c.slice(:shards, :replicas, :primary_replica_tag, :nonvoting_replica_tags)) }
|
82
82
|
true
|
83
83
|
end
|
84
84
|
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'active_support/core_ext/array/wrap'
|
2
|
+
|
3
|
+
module NoBrainer
|
4
|
+
class Array < ::Array
|
5
|
+
# delegate cast to each array element
|
6
|
+
def self.nobrainer_cast_user_to_model(values)
|
7
|
+
::Array.wrap(values).map do |value|
|
8
|
+
if value.class.respond_to?(:nobrainer_cast_user_to_model)
|
9
|
+
value.class.nobrainer_cast_user_to_model(value)
|
10
|
+
else
|
11
|
+
value
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# delegate cast to each array element
|
17
|
+
def self.nobrainer_cast_model_to_db(values)
|
18
|
+
::Array.wrap(values).map do |value|
|
19
|
+
if value.class.respond_to?(:nobrainer_cast_model_to_db)
|
20
|
+
value.class.nobrainer_cast_model_to_db(value)
|
21
|
+
else
|
22
|
+
value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# delegate cast to each array element
|
28
|
+
def self.nobrainer_cast_db_to_model(values)
|
29
|
+
::Array.wrap(values).map do |value|
|
30
|
+
if value.class.respond_to?(:nobrainer_cast_db_to_model)
|
31
|
+
value.class.nobrainer_cast_db_to_model(method, value)
|
32
|
+
else
|
33
|
+
value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# convenience method to create a TypedArray
|
39
|
+
def self.of(object_type = nil, **options)
|
40
|
+
NoBrainer::TypedArray.of(object_type, **options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class TypedArray < Array
|
45
|
+
def self.of(object_type, allow_nil: false)
|
46
|
+
NoBrainer::Document::Types.load_type_extensions(object_type)
|
47
|
+
::Class.new(TypedArray) do
|
48
|
+
define_singleton_method(:object_type) { object_type }
|
49
|
+
define_singleton_method(:allow_nil?) { allow_nil }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.name
|
54
|
+
str = String.new "Array"
|
55
|
+
str += "(#{object_type.name})" if respond_to?(:object_type)
|
56
|
+
str
|
57
|
+
end
|
58
|
+
|
59
|
+
# delegate cast methods to object_type cast methods, if defined
|
60
|
+
def self.nobrainer_cast_user_to_model(values)
|
61
|
+
cast_type = object_type.respond_to?(:nobrainer_cast_user_to_model) && object_type
|
62
|
+
values = ::Array.wrap(values).map do |value|
|
63
|
+
value = cast_type.nobrainer_cast_user_to_model(value) if cast_type
|
64
|
+
unless (value.nil? && allow_nil?) || value.is_a?(object_type)
|
65
|
+
raise NoBrainer::Error::InvalidType, type: object_type.name, value: value
|
66
|
+
end
|
67
|
+
value
|
68
|
+
end
|
69
|
+
new(values)
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.nobrainer_cast_model_to_db(values)
|
73
|
+
values = ::Array.wrap(values)
|
74
|
+
if object_type.respond_to?(:nobrainer_cast_model_to_db)
|
75
|
+
values.map { |value| object_type.nobrainer_cast_model_to_db(value) }
|
76
|
+
else
|
77
|
+
values
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.nobrainer_cast_db_to_model(values)
|
82
|
+
values = ::Array.wrap(values)
|
83
|
+
if object_type.respond_to?(:nobrainer_cast_db_to_model)
|
84
|
+
values.map { |value| object_type.nobrainer_cast_db_to_model(value) }
|
85
|
+
else
|
86
|
+
values
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module NoBrainer::Document::Types
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
+
mattr_accessor :loaded_extensions
|
5
|
+
self.loaded_extensions = Set.new
|
6
|
+
|
4
7
|
included { before_validation :add_type_errors }
|
5
8
|
|
6
9
|
def add_type_errors
|
@@ -59,6 +62,11 @@ module NoBrainer::Document::Types
|
|
59
62
|
end
|
60
63
|
|
61
64
|
def field(attr, options={})
|
65
|
+
if (type = options[:type]).is_a?(::Array)
|
66
|
+
raise ArgumentError, "Expected Array type to have single element, got #{types.inspect}" unless type.length == 1
|
67
|
+
options[:type] = NoBrainer::TypedArray.of(type.first)
|
68
|
+
end
|
69
|
+
|
62
70
|
super
|
63
71
|
|
64
72
|
type = options[:type]
|
@@ -105,14 +113,12 @@ module NoBrainer::Document::Types
|
|
105
113
|
end
|
106
114
|
end
|
107
115
|
|
108
|
-
%w(binary boolean text geo enum).each do |type|
|
116
|
+
%w(array binary boolean text geo enum).each do |type|
|
109
117
|
require File.join(File.dirname(__FILE__), 'types', type)
|
110
118
|
const_set(type.camelize, NoBrainer.const_get(type.camelize))
|
111
119
|
end
|
112
120
|
|
113
121
|
class << self
|
114
|
-
mattr_accessor :loaded_extensions
|
115
|
-
self.loaded_extensions = Set.new
|
116
122
|
def load_type_extensions(model)
|
117
123
|
unless loaded_extensions.include?(model)
|
118
124
|
begin
|
@@ -34,6 +34,16 @@ class NoBrainer::QueryRunner::TableOnDemand < NoBrainer::QueryRunner::Middleware
|
|
34
34
|
r.table_create(table_name, create_options.reject { |k,_| k.in? [:name, :write_acks] })
|
35
35
|
end
|
36
36
|
|
37
|
+
# Prevent duplicate table errors on a cluster.
|
38
|
+
# Workaround from https://github.com/rethinkdb/rethinkdb/issues/4898#issuecomment-270267740
|
39
|
+
NoBrainer.run(:db => 'rethinkdb') do |r|
|
40
|
+
r.table('table_config')
|
41
|
+
.filter({db: db_name, name: table_name})
|
42
|
+
.order_by('id')
|
43
|
+
.slice(1)
|
44
|
+
.delete
|
45
|
+
end
|
46
|
+
|
37
47
|
if create_options[:write_acks] && create_options[:write_acks] != 'single'
|
38
48
|
NoBrainer.run(:db => db_name) do |r|
|
39
49
|
r.table(table_name).config().update(:write_acks => create_options[:write_acks])
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module NoBrainer::SymbolDecoration
|
2
|
-
NON_CHAINABLE_OPERATORS = %w(in eq gt ge gte lt le lte defined undefined near intersects include).map(&:to_sym)
|
2
|
+
NON_CHAINABLE_OPERATORS = %w(in eq gt ge gte lt le lte defined undefined near intersects include during).map(&:to_sym)
|
3
3
|
CHAINABLE_OPERATORS = %w(not any all).map(&:to_sym)
|
4
4
|
OPERATORS = CHAINABLE_OPERATORS + NON_CHAINABLE_OPERATORS
|
5
5
|
|
data/lib/nobrainer.rb
CHANGED
@@ -41,6 +41,10 @@ module NoBrainer
|
|
41
41
|
Gem.loaded_specs['activesupport'].version >= Gem::Version.new('5.0.0.beta')
|
42
42
|
end
|
43
43
|
|
44
|
+
def rails6?
|
45
|
+
Gem.loaded_specs['activesupport'].version >= Gem::Version.new('6.0.0')
|
46
|
+
end
|
47
|
+
|
44
48
|
def eager_load!
|
45
49
|
# XXX This forces all the NoBrainer code to be loaded in memory.
|
46
50
|
# Not to be confused with eager_load() that operates on documents.
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nobrainer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.36.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Viennot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,33 +39,33 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: middleware
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.1.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rethinkdb
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.3.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.3.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: symbol_decoration
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,13 +80,15 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.1'
|
83
|
-
description:
|
83
|
+
description: The goal of NoBrainer is to provide a similar interface compared to ActiveRecord
|
84
|
+
and Mongoid to build data models on top of RethinkDB while providing precise semantics.
|
84
85
|
email:
|
85
86
|
- nicolas@viennot.biz
|
86
87
|
executables: []
|
87
88
|
extensions: []
|
88
89
|
extra_rdoc_files: []
|
89
90
|
files:
|
91
|
+
- CHANGELOG.md
|
90
92
|
- LICENSE
|
91
93
|
- README.md
|
92
94
|
- lib/no_brainer/autoload.rb
|
@@ -152,6 +154,7 @@ files:
|
|
152
154
|
- lib/no_brainer/document/table_config/synchronizer.rb
|
153
155
|
- lib/no_brainer/document/timestamps.rb
|
154
156
|
- lib/no_brainer/document/types.rb
|
157
|
+
- lib/no_brainer/document/types/array.rb
|
155
158
|
- lib/no_brainer/document/types/binary.rb
|
156
159
|
- lib/no_brainer/document/types/boolean.rb
|
157
160
|
- lib/no_brainer/document/types/date.rb
|
@@ -236,10 +239,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
239
|
- !ruby/object:Gem::Version
|
237
240
|
version: '0'
|
238
241
|
requirements: []
|
239
|
-
|
240
|
-
rubygems_version: 2.5.1
|
242
|
+
rubygems_version: 3.1.6
|
241
243
|
signing_key:
|
242
244
|
specification_version: 4
|
243
|
-
summary: ORM for RethinkDB
|
245
|
+
summary: A Ruby ORM for RethinkDB
|
244
246
|
test_files: []
|
245
|
-
has_rdoc: false
|