我是红宝石的新手。 当我使用.empty吗?它给我错误NoMethodError:未定义的方法“空?” 20:整数,但是如果我使用.nil?/。blank?我的考试通过了。 我实际上是想做源减目标查询。 20是我的原始记录。
def self.diff()
if targetcheck.empty?
puts "Target table is empty for #{@tableName}"
elsif sourcecheck.empty?
puts "Source table is empty for #{@tableName}"
else
# minus_result = Netezzasalesmiqueries.source_target_diff(dataone, datatwo)
@source_minus_target_result = Generalqueries.source_target_diff(@source,@target)
@target_minus_source_result = Generalqueries.source_target_diff(@target,@source)
end
end
def self.source_target_diff(data_one, data_two)
puts "(#{data_one}) minus (#{data_two})"
# database = $dif_env.teradata.execute("(#{data_one}) minus (#{data_two})")
# database.as_json
# database
end
def self.reporting()
@error_token = false
if @source_minus_target_result.empty?
puts "Target matches with the Source for #{@tableName}"
else
puts "There are #{@source_minus_target_result.size} records that are in the Source but not the Target for #{@tableName}"
#below is for detailed view of missing records
# @source_minus_target_result.each{|rec| puts "#{rec}\n"}
@error_token = true
end
if @target_minus_source_result.empty?
puts "Source matches with the Target for #{@tableName}"
else
puts "There are #{@target_minus_source_result.size} records that are in the Target but not the Source for #{@tableName}"
#below is for detailed view of missing records
# @target_minus_source_result.each{|rec| puts "#{rec}\n"}
@error_token = true
end
if @error_token
fail("There were mismatches for #{@tableName}")
end
end
堆栈跟踪
NoMethodError: undefined method `empty?' for 20:Integer
./features/pages/utility.rb:23:in `diff'
./features/step_definitions/general_steps.rb:48:in `/^I have a query to compare Source and Target$/'
./features/scenarios/general_file.feature:20:in `When I have a query to compare Source and Target'
./features/scenarios/general_file.feature:16:in `When I have a query to compare Source and Target'
感谢Advnace。
答案 0 :(得分:0)
空吗?是字符串的方法。您可以尝试使用nil吗?或零?用于整数。