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

(FM-5021) Escaping identifiers when creating a database #222

Merged
merged 1 commit into from
Jun 23, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions spec/defines/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@
end
it_behaves_like 'sqlserver_tsql command' do
let(:additional_params) { {
:filespec_filename => 'c:/test/test.mdf', :filespec_name => 'myCreCre',
:log_filename => "c:/test/logfile.ldf", :log_name => "myCrazyLog"} }
let(:should_contain_command) { [/c\:\/test\/logfile\.ldf/] }
:filespec_filename => 'c:/test/test.mdf', :filespec_name => 'myCre-Cre',
:log_filename => "c:/test/logfile.ldf", :log_name => "myCrazy_Log"} }
# Ensure that the parameters are in the TSQL and are correctly escaped
let(:should_contain_command) {[
/NAME = N'myCre-Cre'/,
/FILENAME = N'c\:\/test\/test\.mdf'/,
/NAME = N'myCrazy_Log'/,
/FILENAME = N'c\:\/test\/logfile\.ldf'/
]}
end
end
describe 'collation_name' do
Expand Down
4 changes: 2 additions & 2 deletions templates/create/database.sql.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CREATE DATABASE [<%= @db_name %>]
CONTAINMENT = <%= @containment %>
<% if @filespec_name && @filespec_filename -%>
ON (
NAME = <%= @filespec_name %>,
NAME = N'<%= @filespec_name %>',
FILENAME = N'<%= @filespec_filename %>'
<% if @filespec_size %>, SIZE = <%= @filespec_size %><% end %>
<% if @filespec_maxsize %>, MAXSIZE = <%= @filespec_maxsize %><% end %>
Expand All @@ -21,7 +21,7 @@ CREATE DATABASE [<%= @db_name %>]
<% if @log_name && @log_filename -%>
LOG ON
(
NAME = <%= @log_name %>,
NAME = N'<%= @log_name %>',
FILENAME = N'<%= @log_filename %>'
<% if @log_size %>, SIZE = <%= @log_size %> <% end %>
<% if @log_maxsize %>, MAXSIZE = <%= @log_maxsize %><% end %>
Expand Down