ndb-rails 1.25.0 → 1.25.1
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/lib/ndb/rails/relation.rb +14 -6
- data/lib/ndb/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f12c45cfd6db4e1cc280b045d4677761c069d21b676c27efc57876f60033da46
|
|
4
|
+
data.tar.gz: cbffdc5bc06920462c2fdad7cc23124544c0ac3345d3386dd23478cee95c24b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83e340f3b33b1513223f745812ac2ef1fbbc9cb745a7a0bd6bd36978c222164c315ed4fff20dbea4ec8444033754b05541e70f0a3bc11fadb804dc1880330048
|
|
7
|
+
data.tar.gz: a59d2c6213578b48068cf6951b4e8f3412f4d7ec5ac909b7f63ad23580b01a0ee26add121fc2625c8b02e9b2f31978190e05f4fd97be63615cb8b8f3e7599100
|
data/lib/ndb/rails/relation.rb
CHANGED
|
@@ -51,9 +51,9 @@ module Ndb
|
|
|
51
51
|
def order(*args)
|
|
52
52
|
sort = args.each_with_object(values[:order].dup) do |arg, out|
|
|
53
53
|
case arg
|
|
54
|
-
when Hash then arg.each { |f, dir| out[f
|
|
55
|
-
when String then
|
|
56
|
-
else out[arg
|
|
54
|
+
when Hash then arg.each { |f, dir| out[field_name(f)] = direction(dir) }
|
|
55
|
+
when String then parse_order(arg).each { |f, dir| out[field_name(f)] = dir }
|
|
56
|
+
else out[field_name(arg)] = 1
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
@@ -104,7 +104,7 @@ module Ndb
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def group(*fields)
|
|
107
|
-
with(group: fields.flatten.map(
|
|
107
|
+
with(group: fields.flatten.map { |field| field_name(field) })
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
# Makes the aggregates of the relation (count, sum, average, minimum,
|
|
@@ -159,7 +159,7 @@ module Ndb
|
|
|
159
159
|
|
|
160
160
|
raise ArgumentError, "select needs at least one field" if fields.empty?
|
|
161
161
|
|
|
162
|
-
with(select: fields.map(
|
|
162
|
+
with(select: fields.map { |field| field_name(field) })
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
# An empty relation: it sends no request. to_a is [], count is 0, and
|
|
@@ -449,7 +449,7 @@ module Ndb
|
|
|
449
449
|
def pluck(*fields)
|
|
450
450
|
raise ArgumentError, "pluck needs at least one field" if fields.empty?
|
|
451
451
|
|
|
452
|
-
names = fields.map(
|
|
452
|
+
names = fields.map { |field| field_name(field) }
|
|
453
453
|
rows = fetch(to_query.merge("fields" => names)).rows
|
|
454
454
|
|
|
455
455
|
plucked = rows.map do |row|
|
|
@@ -600,6 +600,14 @@ module Ndb
|
|
|
600
600
|
attrs.transform_keys { |key| key.to_s == "id" ? klass.primary_key : key }
|
|
601
601
|
end
|
|
602
602
|
|
|
603
|
+
# One field name of pluck, pick, select, order or group: id is _id here too, unless the
|
|
604
|
+
# model has its own id attribute.
|
|
605
|
+
def field_name(field)
|
|
606
|
+
name = field.to_s
|
|
607
|
+
|
|
608
|
+
name == "id" && !klass.attribute_names.include?("id") ? klass.primary_key : name
|
|
609
|
+
end
|
|
610
|
+
|
|
603
611
|
def add_clause(clause)
|
|
604
612
|
with(where: values[:where] + [clause])
|
|
605
613
|
end
|
data/lib/ndb/rails/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ndb-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.25.
|
|
4
|
+
version: 1.25.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thadeu
|
|
@@ -43,7 +43,7 @@ dependencies:
|
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 1.25.
|
|
46
|
+
version: 1.25.1
|
|
47
47
|
- - "<"
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
49
|
version: '2'
|
|
@@ -53,7 +53,7 @@ dependencies:
|
|
|
53
53
|
requirements:
|
|
54
54
|
- - ">="
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: 1.25.
|
|
56
|
+
version: 1.25.1
|
|
57
57
|
- - "<"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
59
|
version: '2'
|