Skip to content

Instantly share code, notes, and snippets.

@drwl
Created June 12, 2023 19:55
Show Gist options
  • Save drwl/471881fe899c44494c2377bce8db0305 to your computer and use it in GitHub Desktop.
Save drwl/471881fe899c44494c2377bce8db0305 to your computer and use it in GitHub Desktop.
prettifying defaults
# The column object we get from AR has a default value that's String
# [4] pry(#<AnnotateRb::ModelAnnotator::ColumnAnnotation::AttributesBuilder>)> rcol = @column.instance_variable_get("@column")
# => #<ActiveRecord::ConnectionAdapters::PostgreSQL::Column:0x000000010e19ea60
# @collation=nil,
# @comment=nil,
# @default="0",
# @default_function=nil,
# @generated="",
# @name="duration_minutes",
# @null=true,
# @serial=nil,
# @sql_type_metadata=
# #<ActiveRecord::ConnectionAdapters::SqlTypeMetadata:0x000000010e19f140
# @limit=4,
# @precision=nil,
# @scale=nil,
# @sql_type="integer",
# @type=:integer>>
# Internally, it also is a String
# [4] pry(#<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter>)> field
# => ["duration_minutes", "integer", "0", false, 23, -1, nil, nil, ""]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment