Skip to content

Commit

Permalink
**Simplify bulk insertion in table spec**
Browse files Browse the repository at this point in the history
Updated the customer initialization to use hash literals and streamlined the insertion of customer records in test setup. This change reduces repetitive code, enhancing readability and maintainability. Ensures the insertion logic is more concise and aligns with best practices for database operations.
  • Loading branch information
eliasjpr committed Aug 13, 2024
1 parent 56af82a commit 78b1aea
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spec/table_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ describe Cql::Table do
Northwind.customers.create!

customers = [
CustomerModel.new(1, "'John'", "'New York'", 100),
CustomerModel.new(2, "'Jane'", "'New York'", 200),
{:name => "John", :city => "New York", :balance => 100},
{:name => "Jane", :city => "New York", :balance => 200},
]

customers.each do |c|
Northwind.insert.into(:customers).values(id: c.id, name: c.name, city: c.city, balance: c.balance).commit
end
Northwind
.insert
.into(:customers)
.values(customers)
.commit

count_query = Northwind.query.from(:customers).count
count_query.first!(as: Int32).should eq 2
Expand Down

0 comments on commit 78b1aea

Please sign in to comment.