drysql 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/base.rb CHANGED
@@ -92,11 +92,15 @@ module ActiveRecord
92
92
  @associations ? @associations : {}
93
93
  end
94
94
 
95
+ alias :base_table_exists? :table_exists?
95
96
  def table_exists?(class_name=nil)
96
- if connection.respond_to?(:tables)
97
- connection.tables.include? construct_table_name_from_class_name(class_name)
97
+ if class_name.nil? then base_table_exists?
98
98
  else
99
- false
99
+ if connection.respond_to?(:tables)
100
+ connection.tables.include? construct_table_name_from_class_name(class_name)
101
+ else
102
+ false
103
+ end
100
104
  end
101
105
  end
102
106
 
@@ -98,10 +98,15 @@ module ActiveRecord
98
98
 
99
99
  def constraints(table_name, name = nil)#:nodoc:
100
100
  constraints = []
101
- sql = "select t2.*, t1.COLUMN_NAME, t3.UNIQUE_CONSTRAINT_CATALOG, t3.UNIQUE_CONSTRAINT_SCHEMA, t3.UNIQUE_CONSTRAINT_NAME, t4.table_catalog as REFERENCED_TABLE_CATALOG, t4.table_schema as REFERENCED_TABLE_SCHEMA, t4.table_name as REFERENCED_TABLE_NAME, t4.column_name as REFERENCED_COLUMN_NAME from ar.information_schema.constraint_column_usage as t1 inner join
102
- ar.information_schema.table_constraints as t2 on (t2.constraint_name=t1.constraint_name AND t2.table_catalog=t1.table_catalog AND t2.table_schema=t1.table_schema AND t2.table_name=t1.table_name) left outer join
103
- ar.information_schema.referential_constraints as t3 on (t3.constraint_name=t2.constraint_name AND t3.constraint_catalog=t2.constraint_catalog AND t3.constraint_schema=t2.constraint_schema) left outer join
104
- ar.information_schema.constraint_column_usage as t4 on (t4.constraint_name=t3.unique_constraint_name AND t4.constraint_catalog=t3.unique_constraint_catalog AND t4.constraint_schema=t3.unique_constraint_schema)
101
+ sql = "select t2.*, t1.COLUMN_NAME, t3.UNIQUE_CONSTRAINT_CATALOG, t3.UNIQUE_CONSTRAINT_SCHEMA, t3.UNIQUE_CONSTRAINT_NAME,
102
+ t4.table_catalog as REFERENCED_TABLE_CATALOG, t4.table_schema as REFERENCED_TABLE_SCHEMA, t4.table_name as REFERENCED_TABLE_NAME,
103
+ t4.column_name as REFERENCED_COLUMN_NAME from information_schema.constraint_column_usage as t1 inner join
104
+ information_schema.table_constraints as t2 on (t2.constraint_name=t1.constraint_name AND t2.table_catalog=t1.table_catalog
105
+ AND t2.table_schema=t1.table_schema AND t2.table_name=t1.table_name) left outer join
106
+ information_schema.referential_constraints as t3 on (t3.constraint_name=t2.constraint_name AND
107
+ t3.constraint_catalog=t2.constraint_catalog AND t3.constraint_schema=t2.constraint_schema) left outer join
108
+ information_schema.constraint_column_usage as t4 on (t4.constraint_name=t3.unique_constraint_name AND
109
+ t4.constraint_catalog=t3.unique_constraint_catalog AND t4.constraint_schema=t3.unique_constraint_schema)
105
110
  where t4.table_name='#{table_name}' or t2.table_name='#{table_name}'"
106
111
  results = select_all(sql, name)
107
112
  constraint_name_hash = {}
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: drysql
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.5
7
- date: 2006-12-05 00:00:00 -05:00
6
+ version: 0.1.6
7
+ date: 2006-12-13 00:00:00 -05:00
8
8
  summary: Dynamic, Reflective, Invisible Object-Relational Mapping for Ruby
9
9
  require_paths:
10
10
  - lib