Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for citext[] arrays. #972

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions db/migrations/20230912145332_add_array_citext_to_buckets.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class AddArrayCitextToBuckets::V20230912145332 < Avram::Migrator::Migration::V1
def migrate
alter table_for(Bucket) do
add tags : Array(String), default: [] of String, case_sensitive: false
end
end

def rollback
alter table_for(Bucket) do
remove :tags
end
end
end
8 changes: 8 additions & 0 deletions spec/avram/queryable_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,14 @@ describe Avram::Queryable do
query.select_count.should eq(1)
query.first.id.should eq(bucket2.id)
end

it "queries with citext strings" do
BucketFactory.create &.tags(["ONE", "two", "tHrEe"])

BucketQuery.new.tags.includes("one").select_count.should eq(1)
BucketQuery.new.tags.includes("tWo").select_count.should eq(1)
BucketQuery.new.tags.includes("THRee").select_count.should eq(1)
end
end
end

Expand Down
3 changes: 3 additions & 0 deletions spec/support/models/bucket.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ class Bucket < BaseModel
column names : Array(String) = [] of String
column floaty_numbers : Array(Float64) = [] of Float64
column oody_things : Array(UUID) = [] of UUID

# These are citext strings
column tags : Array(String) = [] of String
end
end