-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from kbrock/more_postgres_features
More postgres features
- Loading branch information
Showing
9 changed files
with
176 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'spec_helper' | ||
|
||
describe 'index migrations' do | ||
let!(:connection) { ActiveRecord::Base.connection } | ||
it 'creates special index' do | ||
lambda do | ||
connection.create_table :index_types do |t| | ||
t.integer :col1, :array => true | ||
t.integer :col2 | ||
end | ||
connection.add_index(:index_types, :col1, :index_type => :gin) | ||
connection.add_index(:index_types, :col2, :where => '(col2 > 50)') | ||
end.should_not raise_exception | ||
|
||
indexes = connection.indexes(:index_types) | ||
index_1 = indexes.detect { |c| c.columns.map(&:to_s) == ['col1']} | ||
index_2 = indexes.detect { |c| c.columns.map(&:to_s) == ['col2']} | ||
|
||
index_1.index_type.to_s.should eq 'gin' | ||
index_2.where.should match /col2 > 50/ | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe 'index schema dumper' do | ||
let!(:connection) { ActiveRecord::Base.connection } | ||
it 'correctly generates index statements' do | ||
connection.create_table :index_types do |t| | ||
t.integer :col1, :array => true | ||
t.integer :col2 | ||
end | ||
connection.add_index(:index_types, :col1, :index_type => :gin) | ||
connection.add_index(:index_types, :col2, :where => '(col2 > 50)') | ||
|
||
stream = StringIO.new | ||
ActiveRecord::SchemaDumper.dump(connection, stream) | ||
output = stream.string | ||
|
||
output.should match /:index_type => :gin/ | ||
output.should_not match /:index_type => :btree/ | ||
output.should match /:where => "\(col2 > 50\)"/ | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters