mongery 1.0.2 → 1.0.3
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/mongery.rb +21 -0
- data/lib/mongery/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aeb64347aabfea21e8a23c2160e10256404f948
|
4
|
+
data.tar.gz: 60d53661a827f430c4dfe6bd34466deab7b1168f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e3a644c5a6c6409c2923f7c1a228fd5f287011f94134b460b4adcff86076fecc4ce990fd0d38e04263b61e6166627f739dbb73c558af6018371677eef40c858
|
7
|
+
data.tar.gz: 2112b7028f0c874bc3e8024d668ae0b254e34116ca1464b8fe4fecc09c8ac5fd6ae33e61e3ef9f874218391f019fd328b7eae02f2321608b28cfeb24d1fa47c3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 1.0.3 (2015/01/09)
|
2
|
+
- Support index method to create expression indexes
|
3
|
+
|
1
4
|
## 1.0.2 (2015/01/09)
|
2
5
|
- Support mapped_properties to map system columns on Postgres
|
3
6
|
- Look up all values using string keys rather than symbol. Make sure you use indifferent_access, or stringify_key before passing the value hash to Mongery
|
data/lib/mongery.rb
CHANGED
@@ -29,6 +29,10 @@ module Mongery
|
|
29
29
|
def insert(*args)
|
30
30
|
Query.new(table, schema, mapped_properties).insert(*args)
|
31
31
|
end
|
32
|
+
|
33
|
+
def index(*args)
|
34
|
+
Query.new(table, schema, mapped_properties).index(*args)
|
35
|
+
end
|
32
36
|
end
|
33
37
|
|
34
38
|
class Query
|
@@ -81,6 +85,18 @@ module Mongery
|
|
81
85
|
self
|
82
86
|
end
|
83
87
|
|
88
|
+
def sql_json_exp(col)
|
89
|
+
if schema && numeric?(col)
|
90
|
+
sql_json_path(col) + "::numeric"
|
91
|
+
else
|
92
|
+
sql_json_path(col)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def index(col)
|
97
|
+
Arel.sql(%Q[CREATE INDEX "#{table.name}_#{col}_idx" ON "#{table.name}" ((#{sql_json_exp(col)}))])
|
98
|
+
end
|
99
|
+
|
84
100
|
def mapped_values(args)
|
85
101
|
pairs = []
|
86
102
|
mapped_properties.each do |key, column|
|
@@ -288,6 +304,11 @@ module Mongery
|
|
288
304
|
end
|
289
305
|
end
|
290
306
|
|
307
|
+
def numeric?(col)
|
308
|
+
type = schema.column_type(col.to_s)
|
309
|
+
["number", "integer"].include?(type)
|
310
|
+
end
|
311
|
+
|
291
312
|
def compare_schema(col, val, type, op)
|
292
313
|
case type
|
293
314
|
when "string"
|
data/lib/mongery/version.rb
CHANGED