evil-seed 0.3.0 → 0.4.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 +1 -1
- data/lib/evil_seed/record_dumper.rb +10 -1
- data/lib/evil_seed/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: 9a046b3aea1b09b90d510fa29ffd79df71e678101e081c72a4f1d419869eecca
|
4
|
+
data.tar.gz: 6d49dc0c48eb9c143842839697399afbdcf706c03d9164e86e15efad0a75499d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b9f060b074653b5d6bfc942ff60d90d378fd114b7efaf5100037ab75c8f49bf1fa9b7301c19df0649fc41c3545862811183bda4095efb5bbd90339332e11d35
|
7
|
+
data.tar.gz: 42369aa53c56fd5200ef78269d6379a7d454a27a1e37941e3503c4498e1e13fee7b1f85b4dd80b2679526c97d289f757babacaa81424109427d9a7a4372bf52a
|
data/README.md
CHANGED
@@ -83,7 +83,7 @@ EvilSeed.configure do |config|
|
|
83
83
|
|
84
84
|
# Anonymization is a handy DSL for transformations allowing you to transform model attributes in declarative fashion
|
85
85
|
# Please note that model setters will NOT be called: results of the blocks will be assigned to
|
86
|
-
config.anonymize("User")
|
86
|
+
config.anonymize("User") do
|
87
87
|
name { Faker::Name.name }
|
88
88
|
email { Faker::Internet.email }
|
89
89
|
login { |login| "#{login}-test" }
|
@@ -50,14 +50,23 @@ module EvilSeed
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
def insertable_column_names
|
54
|
+
model_class.columns_hash.reject do |k,v|
|
55
|
+
v.respond_to?(:virtual?) ? v.virtual? : false
|
56
|
+
end.keys
|
57
|
+
end
|
58
|
+
|
53
59
|
def insert_statement
|
54
60
|
connection = model_class.connection
|
55
61
|
table_name = connection.quote_table_name(model_class.table_name)
|
56
|
-
columns =
|
62
|
+
columns = insertable_column_names.map { |c| connection.quote_column_name(c) }.join(', ')
|
57
63
|
"INSERT INTO #{table_name} (#{columns}) VALUES\n"
|
58
64
|
end
|
59
65
|
|
60
66
|
def write!(attributes)
|
67
|
+
# Remove non-insertable columns from attributes
|
68
|
+
attributes = attributes.slice(*insertable_column_names)
|
69
|
+
|
61
70
|
@output.write("-- #{relation_dumper.association_path}\n") && @header_written = true unless @header_written
|
62
71
|
@output.write(@tuples_written.zero? ? insert_statement : ",\n")
|
63
72
|
@output.write(" (#{prepare(attributes).join(', ')})")
|
data/lib/evil_seed/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evil-seed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Novikov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-12-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
213
|
+
rubygems_version: 3.1.6
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: Create partial and anonymized production database dumps for use in development
|