Sha256: 603cec2d86a420fb7fa2cc3ba0e86b0e2d38dc93eefd3c69b15e4eff1e712735
Contents?: true
Size: 1010 Bytes
Versions: 1
Compression:
Stored size: 1010 Bytes
Contents
module ActiveRecord module Schemas module ConnectionAdapters module SqlserverAdapter def default_schema unless sqlserver_2000? @default_schema ||= select_values("SELECT default_schema_name FROM sys.database_principals WHERE type = 'S' and name = '#{self.quote_string(@connection_options[:username])}'").first end @default_schema ||= 'dbo' end attr_writer :default_schema def unqualify_schema_name(table_name) parts = table_name.to_s.split('.') parts.length == 1 || parts[parts.length - 2].blank? ? default_schema : parts[parts.length - 2].gsub(/[\[\]]/,'') end def unqualify_table_name_if_default_schema(table_name) schema = unqualify_schema_name(table_name) schema == default_schema ? unqualify_table_name(table_name) : table_name end # override index name so that if there is a schema, rename it schema_table instead of schema.table def index_name(table_name, options) #:nodoc: super table_name.tr('.', '_'), options end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-sqlserver-adapter-schemas-1.0.2 | lib/active_record/schemas/connection_adapters/sqlserver_adapter.rb |