Class: Mkxms::Mssql::ClrAggregate
- Inherits:
-
Object
- Object
- Mkxms::Mssql::ClrAggregate
- Extended by:
- Utils::InitializedAttributes
- Defined in:
- lib/mkxms/mssql/clr_aggregate_handler.rb
Constant Summary collapse
- SQL_OBJECT_TYPE =
'AGGREGATE'
Instance Attribute Summary collapse
-
#clr_impl ⇒ Object
Returns the value of attribute clr_impl.
-
#execute_as ⇒ Object
Returns the value of attribute execute_as.
-
#name ⇒ Object
Returns the value of attribute name.
-
#returns ⇒ Object
Returns the value of attribute returns.
-
#schema ⇒ Object
Returns the value of attribute schema.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ ClrAggregate
constructor
A new instance of ClrAggregate.
- #param_properties_sql ⇒ Object
- #procedure_def_sql ⇒ Object
- #to_sql ⇒ Object
Methods included from Utils::InitializedAttributes
Methods included from Utils::SchemaQualifiedName
Methods included from ExtendedProperties
Methods included from Property::Hosting
Methods included from Property::SchemaScoped
#property_subject_identifiers, #subitem_extended_properties_sql
Constructor Details
#initialize(attrs) ⇒ ClrAggregate
Returns a new instance of ClrAggregate.
15 16 17 18 19 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 15 def initialize(attrs) @schema = attrs['schema'] @name = attrs['name'] @execute_as = attrs['execute-as'] end |
Instance Attribute Details
#clr_impl ⇒ Object
Returns the value of attribute clr_impl.
21 22 23 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 21 def clr_impl @clr_impl end |
#execute_as ⇒ Object
Returns the value of attribute execute_as.
21 22 23 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 21 def execute_as @execute_as end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 21 def name @name end |
#returns ⇒ Object
Returns the value of attribute returns.
21 22 23 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 21 def returns @returns end |
#schema ⇒ Object
Returns the value of attribute schema.
21 22 23 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 21 def schema @schema end |
Instance Method Details
#param_properties_sql ⇒ Object
46 47 48 49 50 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 46 def param_properties_sql params.map do |param| subitem_extended_properties_sql(param) end end |
#procedure_def_sql ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 28 def procedure_def_sql [[].tap do |lines| lines << "IF NOT EXISTS (" lines << " SELECT * FROM xmigra.ignored_clr_assemblies asm" lines << " WHERE asm.name = #{clr_impl.assembly.sql_quoted}" lines << ")" lines << "CREATE AGGREGATE [{filename}] (" lines << params.map do |param| " #{param.name} #{param.type_spec}".tap do |param_spec| param_spec << " = #{param.default_value}" if param.default_value end end.join(",\n") lines << ")" lines << "RETURNS #{returns.type_spec}" if returns lines << "EXTERNAL NAME #{clr_impl.full_specifier};" end.join("\n")] end |
#to_sql ⇒ Object
24 25 26 |
# File 'lib/mkxms/mssql/clr_aggregate_handler.rb', line 24 def to_sql (procedure_def_sql + extended_properties_sql + param_properties_sql) end |