Sha256: 298cec51d5117f67b0555961cbb15296b929069e2270f5009e8e43bbcd185e0d

Contents?: true

Size: 927 Bytes

Versions: 4

Compression:

Stored size: 927 Bytes

Contents

require 'jdbc_adapter/tsql_helper'

module ::JdbcSpec
  module ActiveRecordExtensions
    def cachedb_connection( config )
      config[:port] ||= 1972
      config[:url] ||= "jdbc:Cache://#{config[:host]}:#{config[:port]}/#{ config[:database]}"
      config[:driver] ||= "com.intersys.jdbc.CacheDriver"
      jdbc_connection( config )
    end
  end

  module CacheDB
    include TSqlMethods

    def self.column_selector
      [ /cache/i, lambda {  | cfg, col | col.extend( ::JdbcSpec::CacheDB::Column ) } ]
    end

    def self.adapter_selector
      [ /cache/i, lambda {  | cfg, adapt | adapt.extend( ::JdbcSpec::CacheDB ) } ]
    end

    module Column
    end
    
    def create_table(name, options = { })
      super(name, options)
      primary_key = options[:primary_key] || "id"
      execute "ALTER TABLE #{name} ADD CONSTRAINT #{name}_PK PRIMARY KEY(#{primary_key})" unless options[:id] == false
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-0.9.0.1 lib/jdbc_adapter/jdbc_cachedb.rb
activerecord-jdbc-adapter-0.8.1 lib/jdbc_adapter/jdbc_cachedb.rb
activerecord-jdbc-adapter-0.8.2 lib/jdbc_adapter/jdbc_cachedb.rb
activerecord-jdbc-adapter-0.9 lib/jdbc_adapter/jdbc_cachedb.rb