Skip to content

Commit

Permalink
Fix read_attribute, see #396 (#397)
Browse files Browse the repository at this point in the history
* Fix read_attribute, see #396

* Fix typo

Co-authored-by: George Dietrich <george@dietrich.app>
  • Loading branch information
msa7 and Blacksmoke16 authored May 5, 2020
1 parent 536a9b4 commit 1daaa35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions spec/granite/columns/read_attribute_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "../../spec_helper"

describe "read_attribute" do
# Only PG supports array types
{% if env("CURRENT_ADAPTER") == "pg" %}
it "able to read arrays" do
ArrayModel.new.read_attribute("i32_array").should be_nil
end
{% end %}
end
2 changes: 1 addition & 1 deletion src/granite/columns.cr
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ module Granite::Columns
self
end

def read_attribute(attribute_name : Symbol | String) : DB::Any
def read_attribute(attribute_name : Symbol | String) : Type
{% begin %}
case attribute_name.to_s
{% for column in @type.instance_vars.select { |ivar| ivar.annotation(Granite::Column) } %}
Expand Down

0 comments on commit 1daaa35

Please sign in to comment.