Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qualify statement bug fixes #34

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
query_helper (0.2.30)
query_helper (0.3.1)
activerecord (> 5)
activesupport (> 5)
sqlite3
Expand Down Expand Up @@ -43,13 +43,13 @@ GEM
i18n (>= 0.7)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
loofah (2.12.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (1.0.0)
mini_portile2 (2.8.0)
minitest (5.14.4)
nokogiri (1.13.3)
nokogiri (1.13.8)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
racc (1.6.0)
Expand All @@ -59,7 +59,7 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (6.1.4.1)
actionpack (= 6.1.4.1)
Expand Down Expand Up @@ -89,7 +89,7 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
sqlite3 (1.4.2)
sqlite3 (1.4.4)
thor (1.1.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
Expand Down
4 changes: 2 additions & 2 deletions lib/query_helper/sql_manipulator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def initialize(
end

def build
insert_having_clauses()
insert_qualify_clauses()
insert_having_clauses()
insert_where_clauses()
insert_select_clauses()
insert_order_by_and_limit_clause()
Expand All @@ -49,7 +49,7 @@ def count_sql

def qualify_clauses(index)
if index == 0
"qualified_results AS ( "
"WITH qualified_results AS ( "
else
", qualified_results AS ( "
end
Expand Down
2 changes: 1 addition & 1 deletion lib/query_helper/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class QueryHelper
VERSION = "0.2.30"
VERSION = "0.3.1"
end
4 changes: 2 additions & 2 deletions spec/query_helper/sql_manipulator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@
let(:sql) { "qualified_results AS ( SELECT report.* FROM report qualify percentage > 1.0 limit :limit offset :offset ) SELECT qualified_results.*, count(*) over () as _query_full_count FROM qualified_results" }

it "adds qualify clause to query" do
expect(manipulator).to eq(sql)
expect(manipulator).to eq("WITH qualified_results AS ( SELECT report.* FROM report qualify percentage > 1.0 limit :limit offset :offset ) SELECT qualified_results.*, count(*) over () as _query_full_count FROM qualified_results")
end
end

context "when using single query" do
let(:sql) { "SELECT * FROM TESTING" }

it "adds qualify clause to query" do
expect(manipulator).to eq("qualified_results AS ( SELECT * FROM TESTING qualify percentage > 1.0 limit :limit offset :offset ) SELECT qualified_results.*, count(*) over () as _query_full_count FROM qualified_results")
expect(manipulator).to eq("WITH qualified_results AS ( SELECT * FROM TESTING qualify percentage > 1.0 limit :limit offset :offset ) SELECT qualified_results.*, count(*) over () as _query_full_count FROM qualified_results")
end
end
end
Expand Down