Class: Fx::Adapters::Sqlserver
- Inherits:
-
Object
- Object
- Fx::Adapters::Sqlserver
- Defined in:
- lib/fx/adapters/sqlserver.rb,
lib/fx/adapters/sqlserver/triggers.rb,
lib/fx/adapters/sqlserver/functions.rb,
lib/fx/adapters/sqlserver/connection.rb
Overview
Sqlserver adapter class to be used with F(x)
Defined Under Namespace
Classes: Connection, Functions, Triggers
Instance Method Summary collapse
-
#create_function(sql_definition) ⇒ void
Creates a function in the database.
-
#create_trigger(sql_definition) ⇒ void
Creates a trigger in the database.
-
#drop_function(name, *_opts, on: '', **_options) ⇒ void
Drops the function from the database.
-
#drop_trigger(name, *_opts, on: '', **_options) ⇒ void
Drops the trigger from the database.
-
#functions ⇒ Array<Fx::Function>
Returns an array of functions in the database.
-
#initialize(connectable = ActiveRecord::Base) ⇒ Sqlserver
constructor
Creates an instance of the F(x) Sqlserver adapter.
-
#triggers ⇒ Array<Fx::Trigger>
Returns an array of triggers in the database.
-
#update_function(name, sql_definition) ⇒ void
Updates a function in the database.
-
#update_trigger(name, on:, sql_definition:) ⇒ void
Updates a trigger in the database.
Constructor Details
#initialize(connectable = ActiveRecord::Base) ⇒ Sqlserver
Creates an instance of the F(x) Sqlserver adapter.
To use this adapter is required to configure via Fx.configure, explicitly setting it accordingly with the example below.
26 27 28 |
# File 'lib/fx/adapters/sqlserver.rb', line 26 def initialize(connectable = ActiveRecord::Base) @connectable = connectable end |
Instance Method Details
#create_function(sql_definition) ⇒ void
This method returns an undefined value.
Creates a function in the database.
This is typically called in a migration via Statements::Function#create_function.
58 59 60 |
# File 'lib/fx/adapters/sqlserver.rb', line 58 def create_function(sql_definition) execute sql_definition end |
#create_trigger(sql_definition) ⇒ void
This method returns an undefined value.
Creates a trigger in the database.
This is typically called in a migration via Statements::Trigger#create_trigger.
70 71 72 |
# File 'lib/fx/adapters/sqlserver.rb', line 70 def create_trigger(sql_definition) execute sql_definition end |
#drop_function(name, *_opts, on: '', **_options) ⇒ void
This method returns an undefined value.
Drops the function from the database
This is typically called in a migration via Statements::Function#drop_function.
114 115 116 117 118 119 |
# File 'lib/fx/adapters/sqlserver.rb', line 114 def drop_function(name, *_opts, on: '', **) execute <<~SQL DROP FUNCTION IF EXISTS #{name}; DROP PROCEDURE IF EXISTS #{name}; SQL end |
#drop_trigger(name, *_opts, on: '', **_options) ⇒ void
This method returns an undefined value.
Drops the trigger from the database
This is typically called in a migration via Statements::Trigger#drop_trigger.
130 131 132 133 134 |
# File 'lib/fx/adapters/sqlserver.rb', line 130 def drop_trigger(name, *_opts, on: '', **) execute <<~SQL DROP TRIGGER IF EXISTS #{name}; SQL end |
#functions ⇒ Array<Fx::Function>
Returns an array of functions in the database.
This collection of functions is used by the [Fx::SchemaDumper] to populate the ‘schema.rb` file.
36 37 38 |
# File 'lib/fx/adapters/sqlserver.rb', line 36 def functions Functions.all(connection) end |
#triggers ⇒ Array<Fx::Trigger>
Returns an array of triggers in the database.
This collection of triggers is used by the [Fx::SchemaDumper] to populate the ‘schema.rb` file.
46 47 48 |
# File 'lib/fx/adapters/sqlserver.rb', line 46 def triggers Triggers.all(connection) end |
#update_function(name, sql_definition) ⇒ void
This method returns an undefined value.
Updates a function in the database.
This is typically called in a migration via Statements::Function#update_function.
83 84 85 86 |
# File 'lib/fx/adapters/sqlserver.rb', line 83 def update_function(name, sql_definition) drop_function(name) create_function(sql_definition) end |
#update_trigger(name, on:, sql_definition:) ⇒ void
This method returns an undefined value.
Updates a trigger in the database.
The existing trigger is dropped and recreated using the supplied ‘on` and `version` parameter.
This is typically called in a migration via Statements::Function#update_trigger.
101 102 103 104 |
# File 'lib/fx/adapters/sqlserver.rb', line 101 def update_trigger(name, on:, sql_definition:) drop_trigger(name, on: on) create_trigger(sql_definition) end |