Skip to content

Commit

Permalink
Get mysql, postgresql, sqlite3 tests running on AR 3.0.0.beta2
Browse files Browse the repository at this point in the history
Merges mkristian's patch from http://gist.github.com/354617
  • Loading branch information
nicksieger committed Apr 5, 2010
1 parent 0bf965d commit f6118bc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
15 changes: 8 additions & 7 deletions lib/active_record/connection_adapters/jdbc_adapter.rb
Expand Up @@ -61,14 +61,15 @@ def embedded_driver(config)
module ActiveRecord
class Base
extend JdbcSpec::ActiveRecordExtensions

alias :attributes_with_quotes_pre_oracle :attributes_with_quotes
def attributes_with_quotes(include_primary_key = true, *args) #:nodoc:
aq = attributes_with_quotes_pre_oracle(include_primary_key, *args)
if connection.class == ConnectionAdapters::JdbcAdapter && (connection.is_a?(JdbcSpec::Oracle) || connection.is_a?(JdbcSpec::Mimer))
aq[self.class.primary_key] = "?" if include_primary_key && aq[self.class.primary_key].nil?
if respond_to?(:attributes_with_quotes)
alias :attributes_with_quotes_pre_oracle :attributes_with_quotes
def attributes_with_quotes(include_primary_key = true, *args) #:nodoc:
aq = attributes_with_quotes_pre_oracle(include_primary_key, *args)
if connection.class == ConnectionAdapters::JdbcAdapter && (connection.is_a?(JdbcSpec::Oracle) || connection.is_a?(JdbcSpec::Mimer))
aq[self.class.primary_key] = "?" if include_primary_key && aq[self.class.primary_key].nil?
end
aq
end
aq
end
end

Expand Down
4 changes: 4 additions & 0 deletions lib/jdbc_adapter/jdbc_mysql.rb
Expand Up @@ -71,6 +71,10 @@ def modify_types(tp)
tp
end

def adapter_name #:nodoc:
'mysql'
end

# QUOTING ==================================================

def quote(value, column = nil)
Expand Down
23 changes: 22 additions & 1 deletion lib/jdbc_adapter/jdbc_postgre.rb
Expand Up @@ -95,6 +95,10 @@ def modify_types(tp)
tp
end

def adapter_name #:nodoc:
'PostgreSQL'
end

def postgresql_version
@postgresql_version ||=
begin
Expand Down Expand Up @@ -202,7 +206,7 @@ def pk_and_sequence_for(table) #:nodoc:
# If that fails, try parsing the primary key's default value.
# Support the 7.x and 8.0 nextval('foo'::text) as well as
# the 8.1+ nextval('foo'::regclass).
result = query(<<-end_sql, 'PK and custom sequence')[0]
result = select(<<-end_sql, 'PK and custom sequence')[0]
SELECT attr.attname,
CASE
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN
Expand Down Expand Up @@ -320,6 +324,23 @@ def drop_database(name)
execute "DROP DATABASE \"#{name}\""
end

def create_schema(schema_name, pg_username)
execute("CREATE SCHEMA \"#{schema_name}\" AUTHORIZATION \"#{pg_username}\"")
end

def drop_schema(schema_name)
execute("DROP SCHEMA \"#{schema_name}\"")
end

def all_schemas
select('select nspname from pg_namespace').map {|r| r["nspname"] }
end

def primary_key(table)
pk_and_sequence = pk_and_sequence_for(table)
pk_and_sequence && pk_and_sequence.first
end

def structure_dump
database = @config[:database]
if database.nil?
Expand Down

0 comments on commit f6118bc

Please sign in to comment.