Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [#820](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/820) Enable frozen strings for tests
- [#821](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/821) Enable frozen strings - part 1
- [#822](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/822) Enable frozen strings - part 2
- [#823](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/823) Enable frozen strings - final

#### Added

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down Expand Up @@ -342,7 +344,7 @@ def sp_executesql_sql(sql, types, params, name)
types = quote(types.join(', '))
params = params.map.with_index{ |p, i| "@#{i} = #{p}" }.join(', ') # Only p is needed, but with @i helps explain regexp.
sql = "EXEC sp_executesql #{quote(sql)}"
sql << ", #{types}, #{params}" unless params.empty?
sql += ", #{types}, #{params}" unless params.empty?
end
sql
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver/errors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord

class DeadlockVictim < WrappedDatabaseException
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver/quoting.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down Expand Up @@ -152,8 +154,9 @@ def change_column(table_name, column_name, type, options = {})
remove_indexes(table_name, column_name)
end
sql_commands << "UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote_default_expression(options[:default], column_object)} WHERE #{quote_column_name(column_name)} IS NULL" if !options[:null].nil? && options[:null] == false && !options[:default].nil?
sql_commands << "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, limit: options[:limit], precision: options[:precision], scale: options[:scale])}"
sql_commands.last << ' NOT NULL' if !options[:null].nil? && options[:null] == false
alter_command = "ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, limit: options[:limit], precision: options[:precision], scale: options[:scale])}"
alter_command += ' NOT NULL' if !options[:null].nil? && options[:null] == false
sql_commands << alter_command
if without_constraints
default = quote_default_expression(default, column_object || column_for(table_name, column_name))
sql_commands << "ALTER TABLE #{quote_table_name(table_name)} ADD CONSTRAINT #{default_constraint_name(table_name, column_name)} DEFAULT #{default} FOR #{quote_column_name(column_name)}"
Expand Down Expand Up @@ -267,7 +270,7 @@ def change_column_null(table_name, column_name, allow_null, default = nil)
do_execute("UPDATE #{table_id} SET #{column_id}=#{quote(default)} WHERE #{column_id} IS NULL")
end
sql = "ALTER TABLE #{table_id} ALTER COLUMN #{column_id} #{type_to_sql column.type, limit: column.limit, precision: column.precision, scale: column.scale}"
sql << ' NOT NULL' if !allow_null.nil? && allow_null == false
sql += ' NOT NULL' if !allow_null.nil? && allow_null == false
do_execute sql
end

Expand All @@ -281,12 +284,12 @@ def data_source_sql(name = nil, type: nil)
scope = quoted_scope name, type: type
table_name = lowercase_schema_reflection_sql 'TABLE_NAME'
sql = "SELECT #{table_name}"
sql << ' FROM INFORMATION_SCHEMA.TABLES WITH (NOLOCK)'
sql << ' WHERE TABLE_CATALOG = DB_NAME()'
sql << " AND TABLE_SCHEMA = #{quote(scope[:schema])}"
sql << " AND TABLE_NAME = #{quote(scope[:name])}" if scope[:name]
sql << " AND TABLE_TYPE = #{quote(scope[:type])}" if scope[:type]
sql << " ORDER BY #{table_name}"
sql += ' FROM INFORMATION_SCHEMA.TABLES WITH (NOLOCK)'
sql += ' WHERE TABLE_CATALOG = DB_NAME()'
sql += " AND TABLE_SCHEMA = #{quote(scope[:schema])}"
sql += " AND TABLE_NAME = #{quote(scope[:name])}" if scope[:name]
sql += " AND TABLE_TYPE = #{quote(scope[:type])}" if scope[:type]
sql += " ORDER BY #{table_name}"
sql
end

Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver/showplan.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_record/connection_adapters/sqlserver/showplan/printer_table'
require 'active_record/connection_adapters/sqlserver/showplan/printer_xml'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_record/connection_adapters/abstract/transaction'

module ActiveRecord
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver/type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_record/type'
# Behaviors
require 'active_record/connection_adapters/sqlserver/type/data'
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver/utils.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'strscan'

module ActiveRecord
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
module SQLServer
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver_adapter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'base64'
require 'active_record'
require 'arel_sqlserver'
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/connection_adapters/sqlserver_column.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionAdapters
class SQLServerColumn < Column
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/sqlserver_base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActiveRecord
module ConnectionHandling
def sqlserver_connection(config) #:nodoc:
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/tasks/sqlserver_database_tasks.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_record/tasks/database_tasks'
require 'shellwords'
require 'ipaddr'
Expand Down
2 changes: 2 additions & 0 deletions lib/activerecord-sqlserver-adapter.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# frozen_string_literal: true

require 'active_record/connection_adapters/sqlserver_adapter'
2 changes: 2 additions & 0 deletions lib/arel/visitors/sqlserver.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Arel
module Visitors
class SQLServer < Arel::Visitors::ToSql
Expand Down
2 changes: 2 additions & 0 deletions lib/arel_sqlserver.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

require 'arel'
require 'arel/visitors/sqlserver'