nobrainer 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/no_brainer/autoload.rb +2 -2
- data/lib/no_brainer/criteria.rb +3 -2
- data/lib/no_brainer/criteria/after_find.rb +1 -1
- data/lib/no_brainer/criteria/aggregate.rb +25 -0
- data/lib/no_brainer/criteria/core.rb +15 -1
- data/lib/no_brainer/criteria/count.rb +1 -1
- data/lib/no_brainer/criteria/delete.rb +2 -2
- data/lib/no_brainer/criteria/index.rb +37 -0
- data/lib/no_brainer/criteria/order_by.rb +53 -13
- data/lib/no_brainer/criteria/pluck.rb +81 -0
- data/lib/no_brainer/criteria/raw.rb +12 -4
- data/lib/no_brainer/criteria/scope.rb +11 -6
- data/lib/no_brainer/criteria/update.rb +12 -4
- data/lib/no_brainer/criteria/where.rb +133 -64
- data/lib/no_brainer/document.rb +4 -3
- data/lib/no_brainer/document/aliases.rb +55 -0
- data/lib/no_brainer/document/association.rb +1 -1
- data/lib/no_brainer/document/association/belongs_to.rb +2 -2
- data/lib/no_brainer/document/attributes.rb +26 -8
- data/lib/no_brainer/document/criteria.rb +7 -4
- data/lib/no_brainer/document/dirty.rb +21 -4
- data/lib/no_brainer/document/dynamic_attributes.rb +4 -1
- data/lib/no_brainer/document/index.rb +47 -12
- data/lib/no_brainer/document/lazy_fetch.rb +72 -0
- data/lib/no_brainer/document/missing_attributes.rb +73 -0
- data/lib/no_brainer/document/persistance.rb +57 -8
- data/lib/no_brainer/document/polymorphic.rb +14 -8
- data/lib/no_brainer/document/types.rb +5 -2
- data/lib/no_brainer/document/types/binary.rb +23 -0
- data/lib/no_brainer/document/uniqueness.rb +1 -1
- data/lib/no_brainer/error.rb +16 -0
- data/lib/no_brainer/index_manager.rb +1 -0
- data/lib/no_brainer/query_runner.rb +3 -1
- data/lib/no_brainer/query_runner/connection_lock.rb +7 -0
- data/lib/no_brainer/query_runner/database_on_demand.rb +6 -3
- data/lib/no_brainer/query_runner/logger.rb +22 -6
- data/lib/no_brainer/query_runner/missing_index.rb +5 -3
- data/lib/no_brainer/query_runner/table_on_demand.rb +6 -3
- data/lib/no_brainer/railtie.rb +1 -1
- metadata +12 -4
@@ -2,14 +2,17 @@ class NoBrainer::QueryRunner::TableOnDemand < NoBrainer::QueryRunner::Middleware
|
|
2
2
|
def call(env)
|
3
3
|
@runner.call(env)
|
4
4
|
rescue RuntimeError => e
|
5
|
-
if
|
6
|
-
|
7
|
-
auto_create_table(env, $1, $2)
|
5
|
+
if table_info = table_on_demand_exception?(e)
|
6
|
+
auto_create_table(env, *table_info)
|
8
7
|
retry
|
9
8
|
end
|
10
9
|
raise
|
11
10
|
end
|
12
11
|
|
12
|
+
def table_on_demand_exception?(e)
|
13
|
+
NoBrainer::Config.auto_create_tables && e.message =~ /^Table `(.+)\.(.+)` does not exist\.$/ && [$1, $2]
|
14
|
+
end
|
15
|
+
|
13
16
|
private
|
14
17
|
|
15
18
|
def auto_create_table(env, database_name, table_name)
|
data/lib/no_brainer/railtie.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nobrainer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.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: 2014-
|
11
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rethinkdb
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.14.0.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: 1.
|
26
|
+
version: 1.14.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,14 +80,17 @@ files:
|
|
80
80
|
- lib/no_brainer/connection.rb
|
81
81
|
- lib/no_brainer/criteria.rb
|
82
82
|
- lib/no_brainer/criteria/after_find.rb
|
83
|
+
- lib/no_brainer/criteria/aggregate.rb
|
83
84
|
- lib/no_brainer/criteria/cache.rb
|
84
85
|
- lib/no_brainer/criteria/core.rb
|
85
86
|
- lib/no_brainer/criteria/count.rb
|
86
87
|
- lib/no_brainer/criteria/delete.rb
|
87
88
|
- lib/no_brainer/criteria/enumerable.rb
|
88
89
|
- lib/no_brainer/criteria/first.rb
|
90
|
+
- lib/no_brainer/criteria/index.rb
|
89
91
|
- lib/no_brainer/criteria/limit.rb
|
90
92
|
- lib/no_brainer/criteria/order_by.rb
|
93
|
+
- lib/no_brainer/criteria/pluck.rb
|
91
94
|
- lib/no_brainer/criteria/preload.rb
|
92
95
|
- lib/no_brainer/criteria/raw.rb
|
93
96
|
- lib/no_brainer/criteria/scope.rb
|
@@ -95,6 +98,7 @@ files:
|
|
95
98
|
- lib/no_brainer/criteria/where.rb
|
96
99
|
- lib/no_brainer/decorated_symbol.rb
|
97
100
|
- lib/no_brainer/document.rb
|
101
|
+
- lib/no_brainer/document/aliases.rb
|
98
102
|
- lib/no_brainer/document/association.rb
|
99
103
|
- lib/no_brainer/document/association/belongs_to.rb
|
100
104
|
- lib/no_brainer/document/association/core.rb
|
@@ -112,6 +116,8 @@ files:
|
|
112
116
|
- lib/no_brainer/document/id.rb
|
113
117
|
- lib/no_brainer/document/index.rb
|
114
118
|
- lib/no_brainer/document/injection_layer.rb
|
119
|
+
- lib/no_brainer/document/lazy_fetch.rb
|
120
|
+
- lib/no_brainer/document/missing_attributes.rb
|
115
121
|
- lib/no_brainer/document/persistance.rb
|
116
122
|
- lib/no_brainer/document/polymorphic.rb
|
117
123
|
- lib/no_brainer/document/readonly.rb
|
@@ -119,6 +125,7 @@ files:
|
|
119
125
|
- lib/no_brainer/document/store_in.rb
|
120
126
|
- lib/no_brainer/document/timestamps.rb
|
121
127
|
- lib/no_brainer/document/types.rb
|
128
|
+
- lib/no_brainer/document/types/binary.rb
|
122
129
|
- lib/no_brainer/document/types/boolean.rb
|
123
130
|
- lib/no_brainer/document/types/date.rb
|
124
131
|
- lib/no_brainer/document/types/float.rb
|
@@ -134,6 +141,7 @@ files:
|
|
134
141
|
- lib/no_brainer/loader.rb
|
135
142
|
- lib/no_brainer/locale/en.yml
|
136
143
|
- lib/no_brainer/query_runner.rb
|
144
|
+
- lib/no_brainer/query_runner/connection_lock.rb
|
137
145
|
- lib/no_brainer/query_runner/database_on_demand.rb
|
138
146
|
- lib/no_brainer/query_runner/driver.rb
|
139
147
|
- lib/no_brainer/query_runner/logger.rb
|