Class: Og::SqlserverStore
Overview
A Store that persists objects into a Sqlserver database. To read documentation about the methods, consult the documentation for SqlStore and Store.
Instance Attribute Summary
Attributes inherited from SqlStore
Attributes inherited from Store
#options, #transaction_nesting
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #enchant(klass, manager) ⇒ Object
- #exec(sql) ⇒ Object
-
#initialize(options) ⇒ SqlserverStore
constructor
A new instance of SqlserverStore.
- #query(sql) ⇒ Object
Methods included from SqlserverUtils
Methods included from SqlUtils
#blob, #build_join_name, #create_join_table_sql, #date, #escape, #join_class_ordering, #join_object_ordering, #join_table, #join_table_index, #join_table_info, #join_table_key, #join_table_keys, #ordered_join_table_keys, #parse_blob, #parse_boolean, #parse_date, #parse_float, #parse_int, #parse_timestamp, #quote, #quote_array, #table, #tableize, #timestamp
Methods inherited from SqlStore
#aggregate, #commit, #count, #delete_all, #enable_logging, #find, #find_one, #join, #load, #managed_tables, #reload, #rollback, #select, #select_one, #sql_update, #start, #type_cast, #unjoin, #unmanaged_tables, #update, #update_by_sql, #update_properties
Methods inherited from Store
#commit, #count, #delete, #find, for_name, #force_save!, #insert, #load, #reload, #rollback, #save, #start, #transaction, #update, #update_properties
Constructor Details
#initialize(options) ⇒ SqlserverStore
Returns a new instance of SqlserverStore.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/og/store/alpha/sqlserver.rb', line 85 def initialize() super begin @conn = DBI.connect("DBI:ADO:Provider=SQLOLEDB;Data Source=#{[:address]};Initial Catalog=#{[:name]};User Id=#{[:user]};Password=#{[:password]};") rescue => ex # gmosx, FIXME: drak, fix this! if ex.to_s =~ /database .* does not exist/i Logger.info "Database '#{[:name]}' not found!" self.class.create() retry end raise end end |
Class Method Details
.create(options) ⇒ Object
77 78 79 |
# File 'lib/og/store/alpha/sqlserver.rb', line 77 def self.create() raise 'Not implemented' end |
.destroy(options) ⇒ Object
81 82 83 |
# File 'lib/og/store/alpha/sqlserver.rb', line 81 def self.destroy() raise 'Not implemented' end |
Instance Method Details
#close ⇒ Object
101 102 103 104 |
# File 'lib/og/store/alpha/sqlserver.rb', line 101 def close @conn.disconnect super end |
#enchant(klass, manager) ⇒ Object
106 107 108 109 |
# File 'lib/og/store/alpha/sqlserver.rb', line 106 def enchant(klass, manager) klass.property :oid, Fixnum, :sql => 'integer AUTO_INCREMENT PRIMARY KEY' super end |
#exec(sql) ⇒ Object
118 119 120 121 122 123 |
# File 'lib/og/store/alpha/sqlserver.rb', line 118 def exec(sql) # Logger.debug sql if $DBG @conn.execute(sql).finish rescue => ex handle_sql_exception(ex, sql) end |
#query(sql) ⇒ Object
111 112 113 114 115 116 |
# File 'lib/og/store/alpha/sqlserver.rb', line 111 def query(sql) # Logger.debug sql if $DBG return @conn.select_all(sql) rescue => ex handle_sql_exception(ex, sql) end |