ar_virtual_field 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/ar_virtual_field/version.rb +1 -1
- data/lib/ar_virtual_field.rb +2 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c391b47a216fd9d3f4d88fded8000f516eb80cf8bcec72261ae11aba4db36da
|
4
|
+
data.tar.gz: b2c66124f49c5ab41911619a6bb035dda7654c221b8968bbba37625ad0137351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7ff29785eeef3a6b1b1b77f7711fe0fb776304d7ab7e6f7b70028cd07f7be8d81a1b6b289c82a7be3ac852c4e41baea0cbe6f1be58a2e9ff68e1a9bde7a672a
|
7
|
+
data.tar.gz: fd45c9a488e01424d808e6b16647419eb74dc5a3094159ccce1992745f94bf03723da47849a6abe8d9bb851304d3e50949bfcbc42fe3957cbe0c2a72cd9ccb42
|
data/README.md
CHANGED
@@ -63,6 +63,9 @@ user.fullname # => value computed by database
|
|
63
63
|
User.with_total_orders.where(ArVirtualField[:total_orders] => 5)
|
64
64
|
```
|
65
65
|
|
66
|
+
> [!WARNING]
|
67
|
+
> `ArVirtualField[]` doesn't sanitize its value itself, this example relies on `#where` sanitation, use with caution
|
68
|
+
|
66
69
|
This will include the total_orders virtual field in the SQL query and allow filtering by it.
|
67
70
|
|
68
71
|
## Contributing
|
data/lib/ar_virtual_field.rb
CHANGED
@@ -13,15 +13,11 @@ module ArVirtualField
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.table_name(name)
|
16
|
-
|
16
|
+
"#{name}_outer"
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.table_with_column(name)
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.sanitize_table_name(table)
|
24
|
-
ActiveRecord::Base.connection.quote_table_name(table)
|
20
|
+
"#{name}_outer.#{name}"
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|