-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for sending queries using ActiveRecord::Base.connection.…
…execute to slaves
- Loading branch information
1 parent
bfce8ce
commit 389ca53
Showing
2 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Octopus | ||
module QueryAnalysis | ||
# Given a mysql query string, determines if it is definitely a select query. Due to the simple regex used, it will | ||
# sometimes miss detecting valid select queries, hence why it only determines if something is definitely a select. | ||
def definitely_select_query?( str ) | ||
str =~ /^\s*select/i | ||
end | ||
|
||
# Given a mysql query string, determines if the string might contain multiple queries. | ||
# We are simply checking if it contains a semi colon with non whitespace to the right of it, so this check will | ||
# sometimes falsely detect a string containing one query as sometimes having multiple queries. | ||
def possibly_multiple_queries?( str ) | ||
str =~ /;.*\S+.*$/ | ||
end | ||
end | ||
end |