Method: NoSE::Random::StatementGenerator#random_insert
- Defined in:
- lib/nose/random.rb
#random_insert(connect = true) ⇒ Insert
Generate a new random insertion to entities in the model
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/nose/random.rb', line 132 def random_insert(connect = true) entity = @model.entities.values.sample settings = entity.fields.each_value.map do |field| "#{field.name}=?" end.join ', ' insert = "INSERT INTO #{entity.name} SET #{settings} " # Optionally add connections to other entities insert += random_connection(entity) if connect Statement.parse insert, @model end |