jennifer v0.10.0 Release Notes

Release Date: 2020-12-11 // 3 months ago
  • ๐Ÿ”„ Changes

    General

    • โž• add crystal 0.35.0 support and drop 0.34.0 support

    QueryBuilder

    • ๐Ÿ‘ allow arbitrary Query instances as nested queries for CTEs
    • ๐Ÿ›  fix failed nil assertion when eager load relations sequence with missing intermediate relation records
    • โž• add IModelQuery#find(id) to retrieve record by primary key
    • โž• add IModelQuery#find!(id) to retrieve record by primary key or raise Jennifer::RecordNotFound exception
    • ModelQuery(T)#to_a and ModelQuery(T)#find_by_sql ensure T has loaded actual table field count before making a request

    Model

    • ๐Ÿ”„ change model constructor hash argument type from Hash(String, Jennifer::DBany) to Hash(String, AttrType) (same for Symbol keys)
    • CommonMapping#attribute uses attribute getter
    • ๐Ÿ‘ป CommonMapping#attribute raises Jennifer::UnknownAttribute exception if model has no requested attribute and raise_exception = true
    • add CommonMapping#attribute_before_typecast which returns given attribute in database format using attribute converter
    • add Mapping#{{attribute}}_will_change! to mark {{attribute}} as changed one
    • #primary uses getter
    • any Mapping.mapping invocation creates AttrType alias to represent union of Jennifer::DBAny and any arbitrary type from fields definition
    • โšก๏ธ change Mapping#update_columns argument type to Hash(String | Symbol, AttrType)
    • โšก๏ธ Mapping#update_columns raises Jennifer::UnknownAttribute if key-value pairs include unknown attribute
    • Mapping#set_attribute to accept AttrType
    • ๐Ÿ‘ป Mapping#set_attribute raises Jennifer::UnknownAttribute exception if model has no requested attribute
    • โšก๏ธ Mapping#update_columns raises Jennifer::UnknownAttribute if key-value pairs include unknown field
    • Mapping#arguments_to_insert and Mapping#arguments_to_save use #attribute_before_typecast to collect attributes to store in a database
    • #add_{{relation}} accepts AttrType as a hash value type
    • ๐Ÿ“‡ rename EnumConverter to PgEnumConverter
    • โž• add EnumConverter(T) to convert string to crystal enum
    • add JSONSerializableConverter(T) to convert JSON field to objects of T that support .from_json and #to_json methods
    • add TimeZoneConverter to convert time attributes from UTC to Jennife::Config.local_time_zone

    Adapter

    • โž• add DBFormater as a proposed default logger formatter
    • ๐Ÿ“‡ change logging - emit Log::Metadata with query, args and time keys (as new crystal-db does)
    • ๐Ÿ›  fix missing reconnect to database on connection lost

    SqlGenerator

    • ๐Ÿ›  fix a potential compilation issue that appears in certain edge cases for postgres adapter (#329)
      Adapter::BaseSQLGenerator now produces valid SQL when using multiple recursive CTEs (.with(..., true)) in a single query

    Migration

    • ๐Ÿ“‡ rename TableBuilder::DB_OPTIONS to TableBuilder::DbOptions

    Exceptions

    • โž• add Jennifer::UnknownAttribute to represent case when unknown attribute is tried to be read/written

Previous changes from v0.9.0

  • ๐Ÿ”„ Changelog

    General

    • โž• add Crystal 0.34.0 support
    • add Jennifer::Presentable with abstract methods declarations (#attribute, #errors, #human_attribute_name, #attribute_metadata, #class_name)

    QueryBuilder

    • Query#initialize now accept Adapter::Base as a second (optional) argument
    • OrderItem is renamed to OrderExpression to avoid possible name collisions

    Model

    • fix an issue with rendering new_record and destroyed system variables by #to_json
    • 0๏ธโƒฃ Resource.table_prefix now returns underscored namespace name (if any) by default
    • Base includes Jennifer::Presentable
    • โž• add Translation#class_name method to return underscored class name
    • โž• add Mapping#attribute_metadata to return attribute metadata by it's name
    • remove Base::primary_field_type
    • Prevent compile time error with models named Model or Record

    View

    • fix an issue with rendering new_record and destroyed system variables by #to_json
    • remove Base::primary_field_type

    Adapter

    • db connection is established on the first request no on adapter initialization
    • ๐Ÿ‘€ Adapter.adapter_class raises BaseException if no valid Config.adapter is specified
    • .command_interface, .create_database, .drop_database, .generate_schema, .load_schema, .db_connection, .connection_string, .database_exists? now are instance methods
    • Base#initialize now excepts Config instance
    • respect host in Jennifer::Postgres::CommandInterface#database_exists?
    • escape connection URI segments
    • ๐ŸŒฒ Config#logger now is Log instead of Logger
    • โž• add read/write adapter segregation
    • ๐Ÿ—„ deprecate .adapter & .adapter_class
    • โœ‚ remove .query, .exec & .scalar

    Config

    • .reset_config invokes #initialize instead of creating new instance

    Migration

    • Base#schema_processor is no more public api
    • Runner.create and Runner.drop now accept option Adapter::Base instance
    • pass to_table in TableBuilder::DropForeignKey#process
    • ๐Ÿ›  fix TableBuilder::CreateTable#reference - now it takes into account given SQL type for the foreign key column
    • add #add_reference, #drop_reference, #add_timestamps to TableBuilder::CHangeTable
    • TableBuilder::CHangeTable#drop_index also accepts single column name
    • โœ‚ remove deprecated TableBuilder::CreateTable#index overrides

    Record

    • ๐Ÿšš #initialize(DB::ResultSet) is removed