Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* Add regression for query log column

  • Loading branch information...
commit 3136814969a43b6d8df8c0bac4498d7aba5db17e 1 parent 631ef1f
@smtlaissezfaire authored
View
2  TODO
@@ -4,7 +4,7 @@ TODOs:
- [ ] Add versioning
- [ ] Only log queries over a certain time
- [ ] Better documentation. Add running unit tests section
-- [ ] EXPLAIN regression. Shouldn't create a STRING row for explain column
+- [X] Fix logging of queries
- [ ] Configurable db for unit tests.
- [ ] Can it be made database agnostic?
View
2  generators/enhanced_query_analyzer/templates/migrate/create_query_log.rb
@@ -1,7 +1,7 @@
class CreateQueryLog < ActiveRecord::Migration
def self.up
create_table :query_logs do |t|
- t.string :query
+ t.text :query
t.float :query_time
t.string :explain
t.timestamps
View
19 spec/enhanced_query_analyzer/logging_spec.rb
@@ -89,4 +89,23 @@ def read_fixture(file)
output = read_fixture("typical_output")
QueryLog.find(:first).explain.should == output
end
+
+ describe "regressions" do
+ it "should store the entire query (not a truncated version)" do
+ EnhancedQueryAnalyzer.explain_logging = true
+
+ query = <<-SQL
+ SELECT * FROM users
+ WHERE
+ first_name = 'foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz' OR
+ first_name = 'foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz' OR
+ first_name = 'somereallyreallylongname'
+ ORDER BY first_name
+ LIMIT 3
+ SQL
+
+ User.find_by_sql(query)
+ QueryLog.find(:first).query.should == query
+ end
+ end
end
View
2  spec/spec_helper.rb
@@ -25,7 +25,7 @@ def setup_database_connection
end
create_table :query_logs, :force => true do |t|
- t.string :query
+ t.text :query
t.float :query_time
t.string :explain
t.timestamps

0 comments on commit 3136814

Please sign in to comment.
Something went wrong with that request. Please try again.