activerecord-postgis-array 0.3.4
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/.gitignore +21 -0
- data/.rspec +2 -0
- data/.travis.yml +18 -0
- data/CHANGELOG.md +99 -0
- data/CONTRIBUTING.md +35 -0
- data/Gemfile +12 -0
- data/LICENSE +22 -0
- data/README.md +87 -0
- data/Rakefile +33 -0
- data/activerecord-postgis-array.gemspec +30 -0
- data/docs/indexes.md +28 -0
- data/docs/migrations.md +92 -0
- data/docs/querying.md +170 -0
- data/docs/type_casting.md +51 -0
- data/lib/activerecord-postgis-array.rb +3 -0
- data/lib/activerecord-postgis-array/active_record.rb +4 -0
- data/lib/activerecord-postgis-array/active_record/connection_adapters.rb +1 -0
- data/lib/activerecord-postgis-array/active_record/connection_adapters/postgres_adapter.rb +346 -0
- data/lib/activerecord-postgis-array/active_record/relation.rb +2 -0
- data/lib/activerecord-postgis-array/active_record/relation/predicate_builder.rb +71 -0
- data/lib/activerecord-postgis-array/active_record/relation/query_methods.rb +84 -0
- data/lib/activerecord-postgis-array/active_record/sanitization.rb +30 -0
- data/lib/activerecord-postgis-array/active_record/schema_dumper.rb +157 -0
- data/lib/activerecord-postgis-array/arel.rb +3 -0
- data/lib/activerecord-postgis-array/arel/nodes.rb +2 -0
- data/lib/activerecord-postgis-array/arel/nodes/array_nodes.rb +9 -0
- data/lib/activerecord-postgis-array/arel/nodes/contained_within.rb +20 -0
- data/lib/activerecord-postgis-array/arel/predications.rb +25 -0
- data/lib/activerecord-postgis-array/arel/visitors.rb +2 -0
- data/lib/activerecord-postgis-array/arel/visitors/to_sql.rb +15 -0
- data/lib/activerecord-postgis-array/arel/visitors/visitor.rb +38 -0
- data/lib/activerecord-postgis-array/version.rb +3 -0
- data/spec/arel/arel_spec.rb +30 -0
- data/spec/arel/array_spec.rb +77 -0
- data/spec/columns/array_spec.rb +120 -0
- data/spec/dummy/.gitignore +15 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/person.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +6 -0
- data/spec/dummy/config/database.yml.example +14 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +38 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/migrate/20120501163758_create_people.rb +12 -0
- data/spec/dummy/db/schema.rb +25 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/lib/tasks/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/index.html +241 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/factories/people.rb +7 -0
- data/spec/dummy/test/fixtures/.gitkeep +0 -0
- data/spec/dummy/test/functional/.gitkeep +0 -0
- data/spec/dummy/test/integration/.gitkeep +0 -0
- data/spec/dummy/test/performance/browsing_test.rb +12 -0
- data/spec/dummy/test/test_helper.rb +13 -0
- data/spec/dummy/test/unit/.gitkeep +0 -0
- data/spec/dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/migrations/active_record_migration_spec.rb +29 -0
- data/spec/migrations/array_spec.rb +136 -0
- data/spec/migrations/index_spec.rb +67 -0
- data/spec/models/array_spec.rb +285 -0
- data/spec/queries/array_queries_spec.rb +72 -0
- data/spec/queries/sanity_spec.rb +16 -0
- data/spec/schema_dumper/array_spec.rb +17 -0
- data/spec/schema_dumper/extension_spec.rb +14 -0
- data/spec/schema_dumper/index_spec.rb +46 -0
- data/spec/spec_helper.rb +29 -0
- metadata +318 -0
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
bin/
|
19
|
+
.rbenv-version*
|
20
|
+
|
21
|
+
spec/dummy/config/database.yml
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
rvm:
|
2
|
+
- 1.8.7
|
3
|
+
- 1.9.2
|
4
|
+
- 1.9.3
|
5
|
+
- jruby-18mode
|
6
|
+
- jruby-19mode
|
7
|
+
|
8
|
+
before_script:
|
9
|
+
- psql -c 'create database activerecord-postgis-array_test;' -U postgres
|
10
|
+
- cp spec/dummy/config/database.yml.example spec/dummy/config/database.yml
|
11
|
+
- RAILS_ENV=test rake db:migrate
|
12
|
+
|
13
|
+
notifications:
|
14
|
+
email:
|
15
|
+
- git@danmcclain.net
|
16
|
+
campfire:
|
17
|
+
rooms:
|
18
|
+
- secure: "yVESPleawl+fzvnzXw/W7rULyCjMEq3gPc3cEqcqM2SBBtEIDNXto2zoTAoR\nC5yqhijr+UtmVMsI7CxVK3XvfkmCJZN9P4DP0uas8XYx5DsSabCdPN0h3pka\nbaDCMCInU5QF4WswL2iuyLsOJeKDRwxh09adsHi1HpMgf0nTKPA="
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
## 0.3.1
|
2
|
+
|
3
|
+
* Fixes issue with array -> string code - Dan McClain
|
4
|
+
* Adds support for ISN types - Ezekiel Templin
|
5
|
+
* Fix for Squeel compatibility - Alexander Borovsky
|
6
|
+
|
7
|
+
## 0.3.0
|
8
|
+
|
9
|
+
* Adds support to create indexes concurrently - Dan McClain
|
10
|
+
* Changes using syntax, updates specs - Dan McClain
|
11
|
+
* Empty strings are converted to nil by string_to_cidr_address - Dan McClain
|
12
|
+
* Replaced .symbolize with .to_sym in arel nodes. - OMCnet Development Team
|
13
|
+
* Removes array_contains in favor of a column aware contains - Dan McClain
|
14
|
+
* Renames Arel array_overlap to overlap - Dan McClain
|
15
|
+
* Merge pull request #67 from jagregory/array_contains Array contains operator support - Dan McClain
|
16
|
+
* Update querying doc to include array_contains - James Gregory
|
17
|
+
* Array contains operator ( @> ) support - James Gregory
|
18
|
+
* how to use SQL to convert string-delimited arrays in docs - Turadg Aleahmad
|
19
|
+
* Check if connection responds to #support_extensions? before invoking it - Dirk von Grünigen
|
20
|
+
|
21
|
+
## 0.2.2
|
22
|
+
|
23
|
+
* Fixes issue with visit_Array monkey patch - Dan McClain (@danmcclain)
|
24
|
+
|
25
|
+
## 0.2.1
|
26
|
+
|
27
|
+
* Fixes issue with citext change column calls - Dan McClain
|
28
|
+
(@danmcclain)
|
29
|
+
|
30
|
+
## 0.2.0
|
31
|
+
|
32
|
+
* Introduces extensions to `ActiveRecord::Relation.where` to simplify
|
33
|
+
Array and INET/CIDR queries - Dan McClain (@danmcclain)
|
34
|
+
* Fixes `where(:array => [1,2])` to use equailty instead of IN clauses
|
35
|
+
- Dan McClain (@danmcclain)
|
36
|
+
* Adds Arel predicates for more network comparisons - Patrick Muldoon
|
37
|
+
(@doon)
|
38
|
+
* Adds support for citext in migrations/schema.rb - Jonathan Younger
|
39
|
+
(@daikini)
|
40
|
+
* Fixes text character encoding for text columns - Andy Monat (@amonat)
|
41
|
+
* Cleans up alias_method_chains for better interoperability - Raido
|
42
|
+
Paaslepp (@legendetm)
|
43
|
+
* Doc updates - Dan McClain, Caleb Woods (@danmcclain @calebwoods)
|
44
|
+
|
45
|
+
## 0.1.0
|
46
|
+
|
47
|
+
* Performs PostgreSQL version check before attempting to dumpe
|
48
|
+
extensions - Dan McClain (@danmcclain)
|
49
|
+
* Fixes issues with schema dumper when indexes have no index_opclass -
|
50
|
+
Mario Visic (@mariovisic)
|
51
|
+
|
52
|
+
## 0.0.10
|
53
|
+
|
54
|
+
* Fixes parsing of number arrays when they are set from a string array - Alexey Noskov (@alno)
|
55
|
+
* Cleans up spec organization - Dan McClain (@danmcclain)
|
56
|
+
* Adds support for index operator classes (:index_opclass) in
|
57
|
+
migrations and schema dumps - & Dan McClain (@danmcclain)
|
58
|
+
* Fixes Arel Nodes created by activerecord-postgis-array - Dan McClain (@danmcclain)
|
59
|
+
* Add support to schema.rb to export and import extensions - Keenan
|
60
|
+
Brock (@kbrock)
|
61
|
+
* Handles PostgreSQL strings when passed in as defaults by fixing the
|
62
|
+
quote method
|
63
|
+
* Documentation updates. - Dan McClain & Doug Yun (@danmcclain
|
64
|
+
@duggieawesome)
|
65
|
+
* Fixes #update_column calls - Dan McClain (@danmcclain)
|
66
|
+
|
67
|
+
|
68
|
+
## 0.0.9
|
69
|
+
|
70
|
+
* Fixes #<attribute_name>?, Adds (pending) test case for #update_column - Dan McClain (@danmcclain)
|
71
|
+
* Fix handing of pgsql arrays for the literal and argument-binding
|
72
|
+
cases - Michael Graff (@skandragon)
|
73
|
+
* Fixes UTF-8 strings in string arrays are not returned as UTF-8
|
74
|
+
encoded strings - Michael Graff (@skandragon)
|
75
|
+
* Documentation fixes - Michael Graff (@skandragon) and Dan McClain
|
76
|
+
(@danmcclain)
|
77
|
+
* Properly encode strings stored in an array. - Michael Graff
|
78
|
+
(@skandragon)
|
79
|
+
* Fixes integer array support - Keenan Brock (@kbrock)
|
80
|
+
* Adds more robust index types with add_index options :index_type and :where. - Keenan Brock (@kbrock)
|
81
|
+
|
82
|
+
## 0.0.8
|
83
|
+
|
84
|
+
Fixes add and change column
|
85
|
+
|
86
|
+
## 0.0.7
|
87
|
+
|
88
|
+
Adds Arel predicate functions for array overlap operator (`&&`) and
|
89
|
+
INET/CIDR contained within operator (`<<`)
|
90
|
+
|
91
|
+
## 0.0.6
|
92
|
+
|
93
|
+
Lots of array related fixes:
|
94
|
+
* Model creation should no longer fail when not assigning a value to an
|
95
|
+
array column
|
96
|
+
* Array columns follow database defaults
|
97
|
+
|
98
|
+
Migration fix (rn0 and gilltots)
|
99
|
+
Typos in README (bcardarella)
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Contribution Guidelines #
|
2
|
+
|
3
|
+
## Submitting a new issue ##
|
4
|
+
|
5
|
+
If you need to open a new issue you *must* provide the following:
|
6
|
+
|
7
|
+
1. Version of Rails
|
8
|
+
|
9
|
+
Failure to include the aforementioned requirements will result in the
|
10
|
+
issue being closed.
|
11
|
+
|
12
|
+
If you want to ensure that your issue gets fixed *fast* you should
|
13
|
+
attempt to reproduce the issue in an isolated example application that
|
14
|
+
you can share.
|
15
|
+
|
16
|
+
## Making a pull request ##
|
17
|
+
|
18
|
+
If you'd like to submit a pull request please adhere to the following:
|
19
|
+
|
20
|
+
1. Your code *must* be tested. Please TDD your code!
|
21
|
+
2. No single-character variables
|
22
|
+
3. Two-spaces instead of tabs
|
23
|
+
4. Single-quotes instead of double-quotes unless you are using string
|
24
|
+
interpolation or escapes.
|
25
|
+
5. General Rails/Ruby naming conventions for files and classes
|
26
|
+
6. *Do not* use Ruby 1.9 hash syntax
|
27
|
+
7. *Do not* use Ruby 1.9 stubby proc syntax
|
28
|
+
8. Follow Tim Pope's [model for git commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). This will make it
|
29
|
+
much easier to generate change logs and navigate through the logs
|
30
|
+
|
31
|
+
Please note that you must adhere to each of the aforementioned rules.
|
32
|
+
Failure to do so will result in an immediate closing of the pull
|
33
|
+
request. If you update and rebase the pull request to follow the
|
34
|
+
guidelines your pull request will be re-opened and considered for
|
35
|
+
inclusion.
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in activerecord-postgis-array.gemspec
|
4
|
+
gemspec
|
5
|
+
unless ENV['CI']
|
6
|
+
if RUBY_PLATFORM =~ /java/
|
7
|
+
gem 'ruby-debug'
|
8
|
+
elsif RUBY_VERSION == '1.9.3' || RUBY_VERSION == '2.0.0'
|
9
|
+
gem 'debugger'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
gem 'fivemat'
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Dan Seaver
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# ActiveRecordPostgisArrays
|
2
|
+
|
3
|
+
Adds support for missing PostgreSQL data types to ActiveRecord.
|
4
|
+
|
5
|
+
[](http://travis-ci.org/dockyard/activerecord-postgis-array)
|
6
|
+
[](https://codeclimate.com/github/dockyard/activerecord-postgis-array)
|
7
|
+
|
8
|
+
## Looking for help? ##
|
9
|
+
|
10
|
+
If it is a bug [please open an issue on
|
11
|
+
Github](https://github.com/dockyard/party_foul/issues). If you need help using
|
12
|
+
the gem please ask the question on
|
13
|
+
[Stack Overflow](http://stackoverflow.com). Be sure to tag the
|
14
|
+
question with `DockYard` so we can find it.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
gem 'activerecord-postgis-array'
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install activerecord-postgis-array
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
Just `require 'activerecord-postgis-array'` and use ActiveRecord as you normally would! postgres\_ext extends
|
33
|
+
ActiveRecord's data type handling.
|
34
|
+
|
35
|
+
* [Migration/Schema.rb support](docs/migrations.md)
|
36
|
+
* [Type Casting support](docs/type_casting.md)
|
37
|
+
* [Querying PostgreSQL datatypes](docs/querying.md)
|
38
|
+
* [Indexes](docs/indexes.md)
|
39
|
+
|
40
|
+
## Usage Notes
|
41
|
+
Avoid the use of in place operators (ie `Array#<<`). These changes are
|
42
|
+
*not* tracked by Rails ([this issue](https://github.com/rails/rails/issues/6954))
|
43
|
+
explains why). In place modifications also modify the default object.
|
44
|
+
|
45
|
+
Assuming we have the following model:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
create_table :items do |t|
|
49
|
+
t.string :names, :array => true, :default => []
|
50
|
+
end
|
51
|
+
|
52
|
+
class Item < ActiveRecord::Base
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
The following will modify the default value of the names attribute.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
a = Item.new
|
60
|
+
a.names << 'foo'
|
61
|
+
|
62
|
+
b = Item.new
|
63
|
+
puts b.names
|
64
|
+
# => ['foo']
|
65
|
+
```
|
66
|
+
|
67
|
+
The supported way of modifying `a.names`:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
a = Item.new
|
71
|
+
a.names += ['foo']
|
72
|
+
|
73
|
+
b = Item.new
|
74
|
+
puts b.names
|
75
|
+
# => []
|
76
|
+
```
|
77
|
+
|
78
|
+
As a result, in place operators are discouraged and will not be
|
79
|
+
supported in postgres\_ext at this time.
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
## Authors
|
85
|
+
|
86
|
+
Dan McClain [twitter](http://twitter.com/_danmcclain) [github](http://github.com/danmcclain)
|
87
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'activerecord-postgis-array'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
30
|
+
t.pattern = 'spec/**/*_spec.rb'
|
31
|
+
end
|
32
|
+
|
33
|
+
task :default => :spec
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/activerecord-postgis-array/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Hannah Howard"]
|
6
|
+
gem.email = ["hannah@techgirlwonder.com"]
|
7
|
+
gem.description = %q{Adds missing native PostgreSQL array types to ActiveRecord}
|
8
|
+
gem.summary = %q{Extends ActiveRecord to handle native PostgreSQL array types and is compatible with postgis}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "activerecord-postgis-array"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = ActiveRecordPostgisArray::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'activerecord', '~> 3.2.0'
|
19
|
+
gem.add_dependency 'pg_array_parser', '~> 0.0.8'
|
20
|
+
gem.add_dependency 'activerecord-postgis-adapter'
|
21
|
+
|
22
|
+
gem.add_development_dependency 'rails', '~> 3.2.0'
|
23
|
+
gem.add_development_dependency 'rspec-rails', '~> 2.12.0'
|
24
|
+
gem.add_development_dependency 'bourne', '~> 1.3.0'
|
25
|
+
if RUBY_PLATFORM =~ /java/
|
26
|
+
gem.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
|
27
|
+
else
|
28
|
+
gem.add_development_dependency 'pg', '~> 0.13.2'
|
29
|
+
end
|
30
|
+
end
|
data/docs/indexes.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Indexes
|
2
|
+
|
3
|
+
## Index types
|
4
|
+
|
5
|
+
Postgres\_ext allows you to specify index type and index operator
|
6
|
+
class at index creation.
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
add_index :table_name, :column, :using => :gin
|
10
|
+
add_index :table_name, :column, :using => :gin, :index_opclass => :gin_trgm_ops
|
11
|
+
```
|
12
|
+
|
13
|
+
## Where clauses
|
14
|
+
|
15
|
+
Postgres\_ext allows you to specify a where clause at index creation.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
add_index :table_name, :column, :where => 'column < 50'
|
19
|
+
```
|
20
|
+
|
21
|
+
## Concurrent Indexes
|
22
|
+
|
23
|
+
Postgres\_ext allows you to create indexes concurrently using the
|
24
|
+
`:algorithm` option
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
add_index :table_name, :column, :algorithm => :concurrently
|
28
|
+
```
|
data/docs/migrations.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Migration/Schema.rb support
|
2
|
+
|
3
|
+
## INET
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
create_table :testing do |t|
|
7
|
+
t.inet :inet_column
|
8
|
+
# or
|
9
|
+
t.inet :inet_column_1, :inet_column_2
|
10
|
+
# or
|
11
|
+
t.column :inet_column, :inet
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
## CIDR
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
create_table :testing do |t|
|
19
|
+
t.cidr :cidr_column
|
20
|
+
# or
|
21
|
+
t.cidr :cidr_column_1, :cidr_column_2
|
22
|
+
# or
|
23
|
+
t.column :cidr_column, :cidr
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
## MACADDR
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
create_table :testing do |t|
|
31
|
+
t.macaddr :macaddr_column
|
32
|
+
# or
|
33
|
+
t.macaddr :macaddr_column_1, :macaddr_column_2
|
34
|
+
# or
|
35
|
+
t.column :macaddr_column, :macaddr
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
## UUID
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
create_table :testing do |t|
|
43
|
+
t.uuid :uuid_column
|
44
|
+
# or
|
45
|
+
t.uuid :uuid_column_1, :uuid_column_2
|
46
|
+
# or
|
47
|
+
t.column :uuid_column, :uuid
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
## CITEXT
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
create_table :testing do |t|
|
55
|
+
t.citext :citext_column
|
56
|
+
# or
|
57
|
+
t.citext :citext_column_1, :citext_column_2
|
58
|
+
# or
|
59
|
+
t.column :citext_column, :citext
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
## Arrays
|
64
|
+
Arrays are created from any ActiveRecord supported datatype (including
|
65
|
+
ones added by postgres\_ext), and respect length constraints
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
create_table :testing do |t|
|
69
|
+
t.integer :int_array, :array => true
|
70
|
+
# integer[]
|
71
|
+
t.integer :int_array, :array => true, :limit => 2
|
72
|
+
# smallint[]
|
73
|
+
t.string :macaddr_column_1, :array => true, :limit => 30
|
74
|
+
# char varying(30)[]
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
### Converting to Arrays
|
79
|
+
|
80
|
+
If you have an existing column with a string-delimited array (e.g. 'val1 val2 val3') convert that data using SQL in your migration.
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
class AddLinkedArticleIdsToLinkSet < ActiveRecord::Migration
|
84
|
+
def change
|
85
|
+
add_column :link_sets, :linked_article_ids, :integer, :array => true, :default => []
|
86
|
+
execute <<-eos
|
87
|
+
UPDATE link_sets
|
88
|
+
SET linked_article_ids = cast (string_to_array(linked_articles_string, ' ') as integer[])
|
89
|
+
eos
|
90
|
+
end
|
91
|
+
end
|
92
|
+
````
|