Class: Mkxms::Mssql::Index
- Inherits:
-
Object
- Object
- Mkxms::Mssql::Index
- Extended by:
- Utils::FlagsQueries
- Includes:
- ExtendedProperties, Property::Hosting
- Defined in:
- lib/mkxms/mssql/index_handler.rb
Instance Attribute Summary collapse
-
#cells_per_object ⇒ Object
Returns the value of attribute cells_per_object.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#fill_factor ⇒ Object
Returns the value of attribute fill_factor.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#included_columns ⇒ Object
readonly
Returns the value of attribute included_columns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#relation ⇒ Object
Returns the value of attribute relation.
-
#schema ⇒ Object
Returns the value of attribute schema.
-
#spatial_index_geometry ⇒ Object
Returns the value of attribute spatial_index_geometry.
-
#storage ⇒ Object
Returns the value of attribute storage.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Index
constructor
A new instance of Index.
- #property_subject_identifiers ⇒ Object
- #qualified_relation ⇒ Object
- #to_sql ⇒ Object
Methods included from Utils::FlagsQueries
Methods included from ExtendedProperties
Methods included from Property::Hosting
Constructor Details
#initialize(attrs) ⇒ Index
Returns a new instance of Index.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mkxms/mssql/index_handler.rb', line 11 def initialize(attrs) @schema = attrs['schema'] @relation = attrs['relation'] @name = attrs['name'] @fill_factor = attrs['fill-factor'] @spatial_index_geometry = attrs['spatial-index-over'] @cells_per_object = attrs['cells-per-object'] @storage = attrs['stored-on'] @columns = [] @included_columns = [] @flags = [] @flags << :unique if attrs['unique'] @flags << :padded if attrs['padded'] @flags << :disabled if attrs['disabled'] @flags << :ignore_duplicates if attrs['ignore-duplicates'] @flags << :row_locks_prohibited if attrs['no-row-locks'] @flags << :page_locks_prohibited if attrs['no-page-locks'] end |
Instance Attribute Details
#cells_per_object ⇒ Object
Returns the value of attribute cells_per_object.
31 32 33 |
# File 'lib/mkxms/mssql/index_handler.rb', line 31 def cells_per_object @cells_per_object end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
32 33 34 |
# File 'lib/mkxms/mssql/index_handler.rb', line 32 def columns @columns end |
#fill_factor ⇒ Object
Returns the value of attribute fill_factor.
31 32 33 |
# File 'lib/mkxms/mssql/index_handler.rb', line 31 def fill_factor @fill_factor end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
32 33 34 |
# File 'lib/mkxms/mssql/index_handler.rb', line 32 def flags @flags end |
#included_columns ⇒ Object (readonly)
Returns the value of attribute included_columns.
32 33 34 |
# File 'lib/mkxms/mssql/index_handler.rb', line 32 def included_columns @included_columns end |
#name ⇒ Object
Returns the value of attribute name.
31 32 33 |
# File 'lib/mkxms/mssql/index_handler.rb', line 31 def name @name end |
#relation ⇒ Object
Returns the value of attribute relation.
31 32 33 |
# File 'lib/mkxms/mssql/index_handler.rb', line 31 def relation @relation end |
#schema ⇒ Object
Returns the value of attribute schema.
31 32 33 |
# File 'lib/mkxms/mssql/index_handler.rb', line 31 def schema @schema end |
#spatial_index_geometry ⇒ Object
Returns the value of attribute spatial_index_geometry.
31 32 33 |
# File 'lib/mkxms/mssql/index_handler.rb', line 31 def spatial_index_geometry @spatial_index_geometry end |
#storage ⇒ Object
Returns the value of attribute storage.
31 32 33 |
# File 'lib/mkxms/mssql/index_handler.rb', line 31 def storage @storage end |
Instance Method Details
#property_subject_identifiers ⇒ Object
64 65 66 |
# File 'lib/mkxms/mssql/index_handler.rb', line 64 def property_subject_identifiers ['SCHEMA', @schema, 'TABLE', @relation, 'INDEX', @name].map {|n| Utils.unquoted_name(n)} end |
#qualified_relation ⇒ Object
68 69 70 |
# File 'lib/mkxms/mssql/index_handler.rb', line 68 def qualified_relation [@schema, @relation].join '.' end |
#to_sql ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/mkxms/mssql/index_handler.rb', line 36 def to_sql if @spatial_index_geometry else [].tap do |parts| parts << "CREATE #{'UNIQUE ' if unique?}INDEX #@name ON #{qualified_relation} (\n" + @columns.map(&:to_sql).join(', ') + "\n)" parts << "INCLUDE (\n" + @included_columns.map(&:name).join(', ') + "\n)" unless @included_columns.empty? # TODO: "WHERE" clause = [] << "PAD_INDEX = ON" if padded? << "FILLFACTOR = #@fill_factor" if @fill_factor << "IGNORE_DUP_KEY = ON" if ignore_duplicates? << "ALLOW_ROW_LOCKS = OFF" if row_locks_prohibited? << "ALLOW_PAGE_LOCKS = OFF" if page_locks_prohibited? parts << "WITH (#{.join(', ')})" unless .empty? parts << "ON #@storage" if @storage end.join(' ') + ';' + extended_properties_sql.joined_on_new_lines end end |