activerecord-postgresql-extensions 0.0.12 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +3 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +7 -2
  5. data/Rakefile +4 -17
  6. data/activerecord-postgresql-extensions.gemspec +13 -57
  7. data/lib/{postgresql_extensions/postgresql_adapter_extensions.rb → active_record/postgresql_extensions/adapter_extensions.rb} +44 -46
  8. data/lib/{postgresql_extensions/postgresql_constraints.rb → active_record/postgresql_extensions/constraints.rb} +121 -10
  9. data/lib/{postgresql_extensions/postgresql_extensions.rb → active_record/postgresql_extensions/extensions.rb} +1 -1
  10. data/lib/{postgresql_extensions → active_record/postgresql_extensions}/foreign_key_associations.rb +9 -1
  11. data/lib/{postgresql_extensions/postgresql_functions.rb → active_record/postgresql_extensions/functions.rb} +9 -3
  12. data/lib/{postgresql_extensions/postgresql_geometry.rb → active_record/postgresql_extensions/geometry.rb} +111 -35
  13. data/lib/{postgresql_extensions/postgresql_indexes.rb → active_record/postgresql_extensions/indexes.rb} +4 -2
  14. data/lib/{postgresql_extensions/postgresql_languages.rb → active_record/postgresql_extensions/languages.rb} +1 -1
  15. data/lib/{postgresql_extensions/postgresql_permissions.rb → active_record/postgresql_extensions/permissions.rb} +3 -3
  16. data/lib/active_record/postgresql_extensions/postgis.rb +53 -0
  17. data/lib/{postgresql_extensions/postgresql_roles.rb → active_record/postgresql_extensions/roles.rb} +1 -1
  18. data/lib/{postgresql_extensions/postgresql_rules.rb → active_record/postgresql_extensions/rules.rb} +3 -3
  19. data/lib/{postgresql_extensions/postgresql_schemas.rb → active_record/postgresql_extensions/schemas.rb} +1 -1
  20. data/lib/{postgresql_extensions/postgresql_sequences.rb → active_record/postgresql_extensions/sequences.rb} +2 -2
  21. data/lib/{postgresql_extensions/postgresql_tables.rb → active_record/postgresql_extensions/tables.rb} +18 -4
  22. data/lib/{postgresql_extensions/postgresql_tablespaces.rb → active_record/postgresql_extensions/tablespaces.rb} +1 -1
  23. data/lib/{postgresql_extensions/postgresql_text_search.rb → active_record/postgresql_extensions/text_search.rb} +3 -3
  24. data/lib/{postgresql_extensions/postgresql_triggers.rb → active_record/postgresql_extensions/triggers.rb} +1 -1
  25. data/lib/{postgresql_extensions/postgresql_types.rb → active_record/postgresql_extensions/types.rb} +1 -1
  26. data/lib/active_record/postgresql_extensions/utils.rb +23 -0
  27. data/lib/active_record/postgresql_extensions/version.rb +7 -0
  28. data/lib/{postgresql_extensions/postgresql_views.rb → active_record/postgresql_extensions/views.rb} +2 -2
  29. data/lib/activerecord-postgresql-extensions.rb +23 -22
  30. data/test/adapter_tests.rb +9 -9
  31. data/test/constraints_tests.rb +155 -0
  32. data/test/database.yml +17 -0
  33. data/test/geometry_tests.rb +224 -52
  34. data/test/index_tests.rb +16 -1
  35. data/test/rules_tests.rb +4 -4
  36. data/test/sequences_tests.rb +0 -22
  37. data/test/tables_tests.rb +28 -31
  38. data/test/test_helper.rb +70 -23
  39. data/test/trigger_tests.rb +5 -5
  40. metadata +112 -25
  41. data/VERSION +0 -1
data/test/test_helper.rb CHANGED
@@ -1,61 +1,108 @@
1
1
 
2
- ACTIVERECORD_GEM_VERSION = ENV['ACTIVERECORD_GEM_VERSION'] || '~> 3.0.3'
2
+ ACTIVERECORD_GEM_VERSION = ENV['ACTIVERECORD_GEM_VERSION'] || '~> 3.2.0'
3
3
 
4
4
  require 'rubygems'
5
5
  gem 'activerecord', ACTIVERECORD_GEM_VERSION
6
6
 
7
7
  require 'active_record'
8
8
  require 'test/unit'
9
+ require 'logger'
9
10
  require File.join(File.dirname(__FILE__), *%w{ .. lib activerecord-postgresql-extensions })
10
11
 
12
+ ActiveRecord::Base.logger = Logger.new("debug.log") if ENV['ENABLE_LOGGER']
11
13
  ActiveRecord::Base.configurations = {
12
- 'arunit' => {
13
- :adapter => 'postgresql',
14
- :database => 'postgresql_extensions_unit_tests',
15
- :min_messages => 'warning'
16
- }
14
+ 'arunit' => {}
17
15
  }
18
16
 
19
- ActiveRecord::Base.establish_connection 'arunit'
20
- #ActiveRecord::Base.connection.drop_database('postgresql_extensions_unit_tests')
21
- #ActiveRecord::Base.connection.create_database('postgresql_extensions_unit_tests')
17
+ %w{
18
+ database.yml
19
+ local_database.yml
20
+ }.each do |file|
21
+ file = File.join('test', file)
22
+
23
+ next unless File.exists?(file)
24
+
25
+ configuration = YAML.load(File.read(file))
26
+
27
+ if configuration['arunit']
28
+ ActiveRecord::Base.configurations['arunit'].merge!(configuration['arunit'])
29
+ end
22
30
 
31
+ if defined?(JRUBY_VERSION) && configuration['jdbc']
32
+ ActiveRecord::Base.configurations['arunit'].merge!(configuration['jdbc'])
33
+ end
34
+ end
35
+
36
+ ActiveRecord::Base.establish_connection 'arunit'
23
37
  ARBC = ActiveRecord::Base.connection
24
38
 
25
39
  puts "Testing against ActiveRecord #{Gem.loaded_specs['activerecord'].version.to_s}"
26
- if postgresql_version = ARBC.query('SELECT version()').flatten.to_s
40
+ if postgresql_version = ARBC.select_rows('SELECT version()').first.first
27
41
  puts "PostgreSQL info from version(): #{postgresql_version}"
28
42
  end
29
43
 
44
+ if postgis_version = ActiveRecord::PostgreSQLExtensions::PostGIS.VERSION[:lib]
45
+ puts "PostGIS info from postgis_full_version(): #{postgis_version}"
46
+ else
47
+ puts "PostGIS not installed"
48
+ end
49
+
30
50
  class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
31
51
  def statements
32
52
  @statements ||= []
33
53
  end
34
54
 
35
- def execute_with_statement_capture(sql, name = nil)
36
- statements << sql
37
- #execute_without_statement_capture(sql, name)
38
- end
39
- alias_method_chain :execute, :statement_capture
55
+ def execute_with_statement_capture(*args)
56
+ PostgreSQLExtensionsTestHelper.add_statement(args.first)
57
+
58
+ if RUBY_PLATFORM == 'java'
59
+ if args.first =~ /pg_tables/
60
+ return execute_without_statement_capture(*args)
61
+ end
62
+ end
40
63
 
41
- def query_with_statement_capture(sql, name = nil)
42
- statements << sql
43
- #query_without_statement_capture(sql, name)
64
+ args.first
44
65
  end
45
- alias_method_chain :query, :statement_capture
66
+ alias_method_chain :execute, :statement_capture
46
67
 
47
- def clear_statements!
48
- @statements = []
68
+ unless RUBY_PLATFORM == 'java'
69
+ def query_with_statement_capture(*args)
70
+ PostgreSQLExtensionsTestHelper.add_statement(args.first)
71
+ #query_without_statement_capture(*args)
72
+ end
73
+ alias_method_chain :query, :statement_capture
49
74
  end
50
75
  end
51
76
 
52
77
  module PostgreSQLExtensionsTestHelper
78
+ class << self
79
+ def statements
80
+ @statements ||= []
81
+ end
82
+
83
+ def clear_statements!
84
+ @statements = []
85
+ end
86
+
87
+ def add_statement(sql)
88
+ case sql
89
+ when /SHOW search_path;/, /pg_tables/
90
+ # ignore
91
+ else
92
+ ActiveRecord::Base.logger.debug(sql) if ENV['ENABLE_LOGGER']
93
+ self.statements << sql
94
+ end
95
+
96
+ sql
97
+ end
98
+ end
99
+
53
100
  def clear_statements!
54
- ActiveRecord::Base.connection.clear_statements!
101
+ PostgreSQLExtensionsTestHelper.clear_statements!
55
102
  end
56
103
 
57
104
  def statements
58
- ActiveRecord::Base.connection.statements
105
+ PostgreSQLExtensionsTestHelper.statements
59
106
  end
60
107
 
61
108
  def setup
@@ -15,7 +15,7 @@ class TriggerTests < Test::Unit::TestCase
15
15
  %{ALTER TABLE "foos" ENABLE TRIGGER "bar";},
16
16
  %{ALTER TABLE "foos" ENABLE TRIGGER "bar";},
17
17
  %{ALTER TABLE "foos" ENABLE TRIGGER "baz";}
18
- ], ARBC.statements)
18
+ ], statements)
19
19
  end
20
20
 
21
21
  def test_disable_triggers
@@ -28,7 +28,7 @@ class TriggerTests < Test::Unit::TestCase
28
28
  %{ALTER TABLE "foos" DISABLE TRIGGER "bar";},
29
29
  %{ALTER TABLE "foos" DISABLE TRIGGER "bar";},
30
30
  %{ALTER TABLE "foos" DISABLE TRIGGER "baz";}
31
- ], ARBC.statements)
31
+ ], statements)
32
32
  end
33
33
 
34
34
  def test_without_triggers
@@ -62,7 +62,7 @@ class TriggerTests < Test::Unit::TestCase
62
62
  %{ALTER TABLE "foos" DISABLE TRIGGER "baz";},
63
63
  %{ALTER TABLE "foos" ENABLE TRIGGER "bar";},
64
64
  %{ALTER TABLE "foos" ENABLE TRIGGER "baz";}
65
- ], ARBC.statements)
65
+ ], statements)
66
66
  end
67
67
 
68
68
  def test_create_trigger # (name, called, events, table, function, options = {})
@@ -70,7 +70,7 @@ class TriggerTests < Test::Unit::TestCase
70
70
 
71
71
  assert_equal([
72
72
  %{CREATE TRIGGER "foo" BEFORE UPDATE ON "bar" FOR EACH ROW EXECUTE PROCEDURE "do_it"();}
73
- ], ARBC.statements)
73
+ ], statements)
74
74
  end
75
75
 
76
76
  def test_drop_trigger # (name, table, options = {})
@@ -80,6 +80,6 @@ class TriggerTests < Test::Unit::TestCase
80
80
  assert_equal([
81
81
  %{DROP TRIGGER "bar" ON "foo";},
82
82
  %{DROP TRIGGER IF EXISTS "bar" ON "foo" CASCADE;}
83
- ], ARBC.statements)
83
+ ], statements)
84
84
  end
85
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgresql-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,72 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-22 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-08-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '2.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '2.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: pg
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.9'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.9'
14
78
  description: A whole bunch of extensions the ActiveRecord PostgreSQL adapter.
15
79
  email: code@zoocasa.com
16
80
  executables: []
@@ -18,33 +82,38 @@ extensions: []
18
82
  extra_rdoc_files:
19
83
  - README.rdoc
20
84
  files:
85
+ - .gitignore
86
+ - Gemfile
21
87
  - MIT-LICENSE
22
88
  - README.rdoc
23
89
  - Rakefile
24
- - VERSION
25
90
  - activerecord-postgresql-extensions.gemspec
91
+ - lib/active_record/postgresql_extensions/adapter_extensions.rb
92
+ - lib/active_record/postgresql_extensions/constraints.rb
93
+ - lib/active_record/postgresql_extensions/extensions.rb
94
+ - lib/active_record/postgresql_extensions/foreign_key_associations.rb
95
+ - lib/active_record/postgresql_extensions/functions.rb
96
+ - lib/active_record/postgresql_extensions/geometry.rb
97
+ - lib/active_record/postgresql_extensions/indexes.rb
98
+ - lib/active_record/postgresql_extensions/languages.rb
99
+ - lib/active_record/postgresql_extensions/permissions.rb
100
+ - lib/active_record/postgresql_extensions/postgis.rb
101
+ - lib/active_record/postgresql_extensions/roles.rb
102
+ - lib/active_record/postgresql_extensions/rules.rb
103
+ - lib/active_record/postgresql_extensions/schemas.rb
104
+ - lib/active_record/postgresql_extensions/sequences.rb
105
+ - lib/active_record/postgresql_extensions/tables.rb
106
+ - lib/active_record/postgresql_extensions/tablespaces.rb
107
+ - lib/active_record/postgresql_extensions/text_search.rb
108
+ - lib/active_record/postgresql_extensions/triggers.rb
109
+ - lib/active_record/postgresql_extensions/types.rb
110
+ - lib/active_record/postgresql_extensions/utils.rb
111
+ - lib/active_record/postgresql_extensions/version.rb
112
+ - lib/active_record/postgresql_extensions/views.rb
26
113
  - lib/activerecord-postgresql-extensions.rb
27
- - lib/postgresql_extensions/foreign_key_associations.rb
28
- - lib/postgresql_extensions/postgresql_adapter_extensions.rb
29
- - lib/postgresql_extensions/postgresql_constraints.rb
30
- - lib/postgresql_extensions/postgresql_extensions.rb
31
- - lib/postgresql_extensions/postgresql_functions.rb
32
- - lib/postgresql_extensions/postgresql_geometry.rb
33
- - lib/postgresql_extensions/postgresql_indexes.rb
34
- - lib/postgresql_extensions/postgresql_languages.rb
35
- - lib/postgresql_extensions/postgresql_permissions.rb
36
- - lib/postgresql_extensions/postgresql_roles.rb
37
- - lib/postgresql_extensions/postgresql_rules.rb
38
- - lib/postgresql_extensions/postgresql_schemas.rb
39
- - lib/postgresql_extensions/postgresql_sequences.rb
40
- - lib/postgresql_extensions/postgresql_tables.rb
41
- - lib/postgresql_extensions/postgresql_tablespaces.rb
42
- - lib/postgresql_extensions/postgresql_text_search.rb
43
- - lib/postgresql_extensions/postgresql_triggers.rb
44
- - lib/postgresql_extensions/postgresql_types.rb
45
- - lib/postgresql_extensions/postgresql_views.rb
46
114
  - test/adapter_tests.rb
47
115
  - test/constraints_tests.rb
116
+ - test/database.yml
48
117
  - test/extensions_tests.rb
49
118
  - test/functions_tests.rb
50
119
  - test/geometry_tests.rb
@@ -80,8 +149,26 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
149
  version: '0'
81
150
  requirements: []
82
151
  rubyforge_project:
83
- rubygems_version: 1.8.15
152
+ rubygems_version: 1.8.24
84
153
  signing_key:
85
154
  specification_version: 3
86
155
  summary: A whole bunch of extensions the ActiveRecord PostgreSQL adapter.
87
- test_files: []
156
+ test_files:
157
+ - test/adapter_tests.rb
158
+ - test/constraints_tests.rb
159
+ - test/database.yml
160
+ - test/extensions_tests.rb
161
+ - test/functions_tests.rb
162
+ - test/geometry_tests.rb
163
+ - test/index_tests.rb
164
+ - test/languages_tests.rb
165
+ - test/permissions_tests.rb
166
+ - test/roles_tests.rb
167
+ - test/rules_tests.rb
168
+ - test/schemas_tests.rb
169
+ - test/sequences_tests.rb
170
+ - test/tables_tests.rb
171
+ - test/tablespace_tests.rb
172
+ - test/test_helper.rb
173
+ - test/text_search_tests.rb
174
+ - test/trigger_tests.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.12