Module: DataMapper::Constraints::Adapters::OracleAdapter

### Home Classes Methods

### In Files

- lib/data_mapper/constraints/adapters/oracle_adapter.rb

### Methods

- #constraint_exists?
- #create_constraints_statement
- #destroy_constraints_statement

### Included Modules

- DataMapper::Constraints::Adapters::DataObjectsAdapter

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Constraints
- DataMapper::Constraints::Adapters
- DataMapper::Constraints::Adapters::AbstractAdapter
- DataMapper::Constraints::Adapters::DataObjectsAdapter
- DataMapper::Constraints::Adapters::DataObjectsAdapter::SQL
- DataMapper::Constraints::Adapters::Extension
- DataMapper::Constraints::Adapters::MysqlAdapter
- DataMapper::Constraints::Adapters::MysqlAdapter::SQL
- DataMapper::Constraints::Adapters::OracleAdapter
- DataMapper::Constraints::Adapters::PostgresAdapter
- DataMapper::Constraints::Adapters::SqliteAdapter
- DataMapper::Constraints::Adapters::SqlserverAdapter
- DataMapper::Constraints::Migrations
- DataMapper::Constraints::Migrations::Model
- DataMapper::Constraints::Migrations::Relationship
- DataMapper::Constraints::Migrations::Relationship::ManyToOne
- DataMapper::Constraints::Migrations::SingletonMethods
- DataMapper::Constraints::Relationship
- DataMapper::Constraints::Relationship::ManyToMany
- DataMapper::Constraints::Relationship::OneToMany
- DataMapper::Constraints::Resource

No matching classes.

# DataMapper::Constraints::Adapters::OracleAdapter

### Public Instance Methods

constraint_exists?(storage_name, constraint_name) click to toggle source

oracle does not provide the information_schema table To question internal state like postgres or mysql

@see DataMapper::Constraints::Adapters::DataObjectsAdapter

@api private

    # File lib/data_mapper/constraints/adapters/oracle_adapter.rb, line 16
    def constraint_exists?(storage_name, constraint_name)
      statement = DataMapper::Ext::String.compress_lines(            SELECT COUNT(*)            FROM USER_CONSTRAINTS            WHERE table_name = ?            AND constraint_name = ?)

      select(statement, oracle_upcase(storage_name)[0, self.class::IDENTIFIER_MAX_LENGTH].gsub('"', '_'), oracle_upcase(constraint_name)[0, self.class::IDENTIFIER_MAX_LENGTH].gsub('"', '_')).first > 0

    end

create_constraints_statement(constraint_name, constraint_type, source_storage_name, source_keys, target_storage_name, target_keys) click to toggle source

@see DataMapper::Constraints::Adapters::DataObjectsAdapter#create_constraints_statement

@api private

TODO: is it desirable to always set `INITIALLY DEFERRED DEFERRABLE`?

    # File lib/data_mapper/constraints/adapters/oracle_adapter.rb, line 34
    def create_constraints_statement(constraint_name, constraint_type, source_storage_name, source_keys, target_storage_name, target_keys)
      DataMapper::Ext::String.compress_lines(            ALTER TABLE #{quote_name(source_storage_name)}            ADD CONSTRAINT #{quote_name(constraint_name)}            FOREIGN KEY (#{source_keys.join(', ')})            REFERENCES #{quote_name(target_storage_name)} (#{target_keys.join(', ')})            #{"ON DELETE " + constraint_type if constraint_type && constraint_type != "NO ACTION"}            INITIALLY DEFERRED DEFERRABLE)
    end

destroy_constraints_statement(storage_name, constraint_name) click to toggle source

@api private

    # File lib/data_mapper/constraints/adapters/oracle_adapter.rb, line 46
    def destroy_constraints_statement(storage_name, constraint_name)
      DataMapper::Ext::String.compress_lines(            ALTER TABLE #{quote_name(storage_name)}            DROP CONSTRAINT #{quote_name(constraint_name)}            CASCADE)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.