From da6b0bb330758c323b55ff7790dd204c0bba622f Mon Sep 17 00:00:00 2001 From: Alexander Stathis Date: Sat, 12 Oct 2024 12:01:07 -0400 Subject: [PATCH] fix bug in active record columns compiler where column type option can be nil --- Gemfile.lock | 2 +- History.md | 4 ++++ lib/boba/version.rb | 2 +- lib/tapioca/dsl/compilers/active_record_columns_persisted.rb | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b4eb524..138d590 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - boba (0.0.6) + boba (0.0.7) sorbet-static-and-runtime (~> 0.5) tapioca (~> 0.16.2) diff --git a/History.md b/History.md index ee4b521..7a88065 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,9 @@ # Boba History +## 0.0.7 + +- Fix bug in `ActiveRecordColumnsPersisted` where `@column_type_option` can be `nil`. + ## 0.0.6 - Fix a bug inheriting from default Tapioca compilers if corresponding Tapioca default compilers don't exist because diff --git a/lib/boba/version.rb b/lib/boba/version.rb index de226c2..b29f56d 100644 --- a/lib/boba/version.rb +++ b/lib/boba/version.rb @@ -2,5 +2,5 @@ # frozen_string_literal: true module Boba - VERSION = "0.0.6" + VERSION = "0.0.7" end diff --git a/lib/tapioca/dsl/compilers/active_record_columns_persisted.rb b/lib/tapioca/dsl/compilers/active_record_columns_persisted.rb index 224582f..e34f699 100644 --- a/lib/tapioca/dsl/compilers/active_record_columns_persisted.rb +++ b/lib/tapioca/dsl/compilers/active_record_columns_persisted.rb @@ -150,7 +150,7 @@ def type_for(attribute_name, column_name = attribute_name) sig { params(column_name: String).returns([String, String]) } def column_type_for(column_name) - return ["T.untyped", "T.untyped"] if @column_type_option.untyped? + return ["T.untyped", "T.untyped"] if column_type_option.untyped? nilable_column = !has_non_null_database_constraint?(column_name) && !has_unconditional_presence_validator?(column_name) @@ -169,7 +169,7 @@ def column_type_for(column_name) getter_type end - if @column_type_option.persisted? && (virtual_attribute?(column_name) || !nilable_column) + if column_type_option.persisted? && (virtual_attribute?(column_name) || !nilable_column) [getter_type, setter_type] else getter_type = as_nilable_type(getter_type) unless column_type_helper.send(