Skip to content

Commit

Permalink
Primary key support only on 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tan committed Aug 30, 2024
1 parent 78afec1 commit a5c0082
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions spec/tapioca/dsl/compilers/active_record_columns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,28 +240,30 @@ def body?; end
end

it "handles composite primary keys" do
add_ruby_file("schema.rb", <<~RUBY)
ActiveRecord::Migration.suppress_messages do
ActiveRecord::Schema.define do
create_table :posts, primary_key: [:a, :b] do |t|
t.string :a, null: false
t.integer :b, null: false
if rails_version(">= 7.1")
add_ruby_file("schema.rb", <<~RUBY)
ActiveRecord::Migration.suppress_messages do
ActiveRecord::Schema.define do
create_table :posts, primary_key: [:a, :b] do |t|
t.string :a, null: false
t.integer :b, null: false
end
end
end
end
RUBY
RUBY

add_ruby_file("post.rb", <<~RUBY)
class Post < ActiveRecord::Base
end
RUBY
add_ruby_file("post.rb", <<~RUBY)
class Post < ActiveRecord::Base
end
RUBY

expected = indented(<<~RBI, 4)
sig { returns([::String, ::Integer]) }
def id; end
RBI
expected = indented(<<~RBI, 4)
sig { returns([::String, ::Integer]) }
def id; end
RBI

assert_includes(rbi_for(:Post), expected)
assert_includes(rbi_for(:Post), expected)
end
end

it "uses ActiveModel::Type::Value types when inheriting from EncryptedAttributeType" do
Expand Down

0 comments on commit a5c0082

Please sign in to comment.