-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug #506 - .uniq breaks with pg and json columns
fix bug #506 - .uniq breaks with pg and json columns updated specs for 'select distinct' and pg issues * new model/table with a json column for postgresql specific testing * add tests for explicit distinct in a select and for all queries to test if tagged_with adds a distinct clause on the query. http://github.com/mbleigh/acts-as-taggable-on/issues/357 * add tests for taggable_model_with_json * exclude test should sort the array result and expected array. PostgreSQL won't always return the two expected results in the expected order so the test failed intermittently. use group vs distinct when options[:any] is true update CHANGELOG check pg version and only use json if >=9.2 move change to master section move table with json to spec/internal/db/schema.rb
- Loading branch information
Showing
7 changed files
with
162 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
ActiveRecord::Schema.define :version => 0 do | ||
create_table :tags, :force => true do |t| | ||
t.string :name | ||
t.integer :taggings_count, :default => 0 | ||
end | ||
add_index "tags", ["name"], name: "index_tags_on_name", unique: true | ||
|
||
create_table :taggings, :force => true do |t| | ||
t.references :tag | ||
|
||
# You should make sure that the column created is | ||
# long enough to store the required class names. | ||
t.references :taggable, :polymorphic => true | ||
t.references :tagger, :polymorphic => true | ||
|
||
# Limit is created to prevent MySQL error on index | ||
# length for MyISAM table type: http://bit.ly/vgW2Ql | ||
t.string :context, :limit => 128 | ||
|
||
t.datetime :created_at | ||
end | ||
add_index "taggings", | ||
["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], | ||
unique: true, name: "taggings_idx" | ||
|
||
# above copied from | ||
# generators/acts_as_taggable_on/migration/migration_generator | ||
|
||
create_table :taggable_models, :force => true do |t| | ||
t.column :name, :string | ||
t.column :type, :string | ||
end | ||
|
||
create_table :non_standard_id_taggable_models, :primary_key => "an_id", :force => true do |t| | ||
t.column :name, :string | ||
t.column :type, :string | ||
end | ||
|
||
create_table :untaggable_models, :force => true do |t| | ||
t.column :taggable_model_id, :integer | ||
t.column :name, :string | ||
end | ||
|
||
create_table :cached_models, :force => true do |t| | ||
t.column :name, :string | ||
t.column :type, :string | ||
t.column :cached_tag_list, :string | ||
end | ||
|
||
create_table :other_cached_models, :force => true do |t| | ||
t.column :name, :string | ||
t.column :type, :string | ||
t.column :cached_language_list, :string | ||
t.column :cached_status_list, :string | ||
t.column :cached_glass_list, :string | ||
end | ||
|
||
create_table :users, :force => true do |t| | ||
t.column :name, :string | ||
end | ||
|
||
create_table :other_taggable_models, :force => true do |t| | ||
t.column :name, :string | ||
t.column :type, :string | ||
end | ||
|
||
create_table :ordered_taggable_models, :force => true do |t| | ||
t.column :name, :string | ||
t.column :type, :string | ||
end | ||
|
||
create_table :taggable_model_with_jsons, :force => true do |t| | ||
t.column :name, :string | ||
t.column :type, :string | ||
if self.connection.adapter_name == 'PostgreSQL' && self.connection.execute("SHOW SERVER_VERSION").first["server_version"].to_f >= 9.2 | ||
type = :json | ||
else | ||
type = :string | ||
end | ||
t.column :opts, type | ||
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