diff --git a/text_to_sql_query.rb b/text_to_sql_query.rb index f0bbce2..720a46b 100644 --- a/text_to_sql_query.rb +++ b/text_to_sql_query.rb @@ -41,8 +41,8 @@ class TextToSqlQuery raise "There should be more than 1 element for expression following NOT operator" end - not_expression = not_array.first - not_params = not_array[1..] + not_expression = not_array.shift + not_params = not_array ["NOT #{not_expression}"] + not_params @@ -74,11 +74,11 @@ class TextToSqlQuery raise 'There should be more than 1 element in second operand array' end - first_operand_expression = first_operand.first - first_operand_params = first_operand[1..] + first_operand_expression = first_operand.shift + first_operand_params = first_operand - second_operand_expression = second_operand.first - second_operand_params = second_operand[1..] + second_operand_expression = second_operand.shift + second_operand_params = second_operand ["(#{first_operand_expression} #{operator.to_s} #{second_operand_expression})"] + first_operand_params + second_operand_params end