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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2a4c8714fe895573999dae43b0e441852c8baccba4657f49aa9330db61e020d
4
- data.tar.gz: 175c040d61f8152437c15db6f4a38fa0941239f7615cf27aa1d752c57ffdbb5d
3
+ metadata.gz: 9a046b3aea1b09b90d510fa29ffd79df71e678101e081c72a4f1d419869eecca
4
+ data.tar.gz: 6d49dc0c48eb9c143842839697399afbdcf706c03d9164e86e15efad0a75499d
5
5
  SHA512:
6
- metadata.gz: 427ec05a9b68db21101fdf293093dff447635e9b326dfd400e3d7ba69afe3a3344bfa4c97778a8c56f2158529460df9f2e1cbc62a5b9ad86e7d659498e9da37d
7
- data.tar.gz: 2288cfb2559bc3b6eefeb28f066cb06e6ed2e0c624e5287755314e41e67a611341d90c4c9d08f97d7a724882b294bdc3dbb53ebfbe4ac431f06a078ed1ea76fc
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 = model_class.column_names.map { |c| connection.quote_column_name(c) }.join(', ')
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(', ')})")
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EvilSeed
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
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.3.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-03-14 00:00:00.000000000 Z
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.2.22
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