mongoid-shell 0.5.0 → 0.5.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/CHANGELOG.md +4 -0
- data/README.md +10 -0
- data/lib/mongoid/shell/commands/base.rb +13 -7
- data/lib/mongoid/shell/commands/mongodump.rb +1 -1
- data/lib/mongoid/shell/commands/mongoexport.rb +1 -1
- data/lib/mongoid/shell/version.rb +1 -1
- data/lib/mongoid-shell.rb +2 -0
- 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: d151d5c6417f84292d8238f4bc5a28893815659bad5becea89130f68fa666496
|
|
4
|
+
data.tar.gz: e38a69795fe72838b6ec566d68e6f3226d24f0dad2620cd7a7d6f88b31f19465
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d874447600be8860e2cefe755d06d5ef9d3cc9787a7ae1c5903b2b677574bdd542341ef7ecd80d7674d416f32266e1a217507edaa4eb6001a90b3c3396e06c3
|
|
7
|
+
data.tar.gz: d50790638bc957f3d42344e7aa31023bde3b773735708e7358f22a89d0984f91ae17b2e297e2dc16b53b2c357638ae4cf4418eb46bd63e93e6f502e9acddb9fb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
### 0.5.1 (2026/10/15)
|
|
2
|
+
|
|
3
|
+
* [#17](https://github.com/mongoid/mongoid-shell/issues/17): Preserve Extended JSON queries through shell escaping and serialize Hash queries for `mongodump` and `mongoexport` - [@dblock](https://github.com/dblock).
|
|
4
|
+
|
|
1
5
|
### 0.5.0 (2026/10/14)
|
|
2
6
|
|
|
3
7
|
* [#25](https://github.com/mongoid/mongoid-shell/pull/25): Add SimpleCov and Coveralls reporting in CI and update status badges - [@dblock](https://github.com/dblock).
|
data/README.md
CHANGED
|
@@ -84,6 +84,16 @@ mongodump.to_s # mongodump --db test --collection test
|
|
|
84
84
|
|
|
85
85
|
The `Mongoid::Shell::Commands::Mongodump` class supports `--db`, `--host`, `--username`, `--password`, `--query`, `--out`, `--collection`, `--excludeCollection`, `--excludeCollectionsWithPrefix`, `--directoryperdb`, `--journal`, `--oplog`, `--repair`, `--forceTableScan`, `--dbpath`, `--ipv6`, `--ssl` and `--authenticationDatabase`
|
|
86
86
|
|
|
87
|
+
For `mongodump` and `mongoexport`, `query` accepts an Extended JSON string or a Hash containing Extended JSON values. Hashes are serialized as JSON and queries are shell-escaped, preserving operators such as `$eq` and `$date` literally.
|
|
88
|
+
|
|
89
|
+
```ruby
|
|
90
|
+
mongodump = Mongoid::Shell::Commands::Mongodump.new(
|
|
91
|
+
collection: 'history_trackers',
|
|
92
|
+
query: { scope: { '$eq' => 'offer' }, created_at: { '$gte' => { '$date' => '2019-12-24T09:36:56.312Z' } } }
|
|
93
|
+
)
|
|
94
|
+
system mongodump.to_s
|
|
95
|
+
```
|
|
96
|
+
|
|
87
97
|
### Mongorestore
|
|
88
98
|
|
|
89
99
|
The mongorestore tool imports content from binary database dump, created by mongodump into a specific database.
|
|
@@ -60,13 +60,7 @@ module Mongoid
|
|
|
60
60
|
when Boolean, TrueClass then key
|
|
61
61
|
when Array then value.map { |v| "#{key} #{v}" }.join(' ')
|
|
62
62
|
else
|
|
63
|
-
|
|
64
|
-
value = mask_sensitive
|
|
65
|
-
else
|
|
66
|
-
# TODO: quote other special characters?
|
|
67
|
-
value = value.to_s
|
|
68
|
-
value = "\"#{value}\"" if value.include? ' '
|
|
69
|
-
end
|
|
63
|
+
value = format_value(value, arg, mask_sensitive)
|
|
70
64
|
key ? "#{key} #{value}" : value
|
|
71
65
|
end
|
|
72
66
|
end
|
|
@@ -78,6 +72,18 @@ module Mongoid
|
|
|
78
72
|
|
|
79
73
|
private
|
|
80
74
|
|
|
75
|
+
def format_value(value, arg, mask_sensitive)
|
|
76
|
+
return mask_sensitive if mask_sensitive && arg[:sensitive]
|
|
77
|
+
|
|
78
|
+
if arg[:json]
|
|
79
|
+
value = ::JSON.generate(value) if value.is_a?(Hash)
|
|
80
|
+
Shellwords.escape(value.to_s)
|
|
81
|
+
else
|
|
82
|
+
value = value.to_s
|
|
83
|
+
value.include?(' ') ? "\"#{value}\"" : value
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
81
87
|
if ::Mongoid::Compatibility::Version.mongoid5_or_newer?
|
|
82
88
|
def default_client_or_session
|
|
83
89
|
Mongoid.default_client
|
data/lib/mongoid-shell.rb
CHANGED