-
Notifications
You must be signed in to change notification settings - Fork 21
(FM-2577) Minor SQL server connection building refactorings #105
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
Merged
cyberious
merged 3 commits into
puppetlabs:master
from
Iristyle:ticket/master/FM-2577-remove-sqlcmd-remnants
May 13, 2015
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
|
@@ -6,12 +6,6 @@ module Sqlserver | |
class SqlConnection | ||
attr_reader :exception_caught | ||
|
||
|
||
def initialize | ||
@connection = nil | ||
@data = nil | ||
end | ||
|
||
def open_and_run_command(query, config) | ||
begin | ||
open(config) | ||
|
@@ -34,19 +28,19 @@ def open(config) | |
end | ||
|
||
def get_connection_string(config) | ||
config = {'database' => 'master'}.merge(config) | ||
# Open ADO connection to the SQL Server database | ||
connection_string = "Provider=SQLOLEDB.1;" | ||
connection_string << "Persist Security Info=False;" | ||
connection_string << "User ID=#{config['admin']};" | ||
connection_string << "password=#{config['pass']};" | ||
connection_string << "Initial Catalog=#{config['database']};" | ||
connection_string << "Application Name=Puppet;" | ||
params = { | ||
'Provider' => 'SQLOLEDB.1', | ||
'User ID' => config['admin'], | ||
'Password' => config['pass'], | ||
'Initial Catalog' => config['database'] || 'master', | ||
'Application Name' => 'Puppet', | ||
'Data Source' => 'localhost' | ||
} | ||
if config['instance'] !~ /^MSSQLSERVER$/ | ||
connection_string << "Data Source=localhost\\#{config['instance']};" | ||
else | ||
connection_string << "Data Source=localhost;" | ||
params['Data Source'] = "localhost\\#{config['instance']}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this line was lost, never to be found again. @Iristyle @cyberious was that intentional? |
||
end | ||
|
||
params.map { |k, v| "#{k}=#{v}" }.join(';') | ||
end | ||
|
||
def command(sql) | ||
|
@@ -80,8 +74,6 @@ def close | |
end | ||
|
||
def reset_instance | ||
@data = nil | ||
@fields = nil | ||
@exception_caught = nil | ||
end | ||
|
||
|
@@ -106,10 +98,6 @@ def parse_column_names(result) | |
def win32_exception | ||
::WIN32OLERuntimeError | ||
end | ||
|
||
def connection=(conn) | ||
@connection = conn | ||
end | ||
end | ||
|
||
class ResultOutput | ||
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Persist Security Info and tests failing as a result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha - will fixup test. Note that I removed
Persist Security Info
since it has been the default for a long time.