jennifer v0.8.0 Release Notes

Release Date: 2019-06-11 // almost 5 years ago
  • It has been a long time since previous release but expectation is worth it. 0.8.0 release brings a lot of new features such as:

    • extended model mapping
      • new properties to configure sql column name and autoincrementability of primary key
      • opportunity to define mapping in modules and abstract super classes
    • Model.new now respects after_initialize callbacks
    • unify mapping for model and view
    • extended querying functionality
      • make SQL API more natural
      • support of upsert operation
      • add CTE

    ๐ŸŽ Also a lot of bugs were fixed and performance enhancements were made.

    ๐Ÿ“š API documentation is hugely increased so now almost all places are covered.

    ๐Ÿ”„ Changelog

    General

    • 0๏ธโƒฃ by default db:migrate task outputs information about executed migrations
    • db:create command doesn't fail if database already exists

    QueryBuilder

    • โœ‚ remove redundant Criteria#similar which is loaded with postgres adapter
    • โž• add Query#insert and Query#upsert
    • โž• add ExpressionBuilder#values and Values to reference to VALUES statement in upsert
    • .find_by_sql and .to_a of ModelQuery(T) use T.new instead of T.build
    • โž• add CommonTableExpression to present SQL CTE
    • ๐Ÿ“‡ rename EagerLoading#with to #with_relation
    • #last! and #last assigns old limit value back after request instead of additional #reverse_order call
    • speed up Query allocation by making all query part containers nilable
    • โž• add 2nd argument to Query#union setting union to be UNION ALL
    • now Query#with presents API for registering common table expression
    • โž• add Query#merge
    • ๐Ÿ— Query#where yields expression builder
    • Query's #join, #right_join, #left_join and #lateral_join yield expression builders of a main query and joined context
    • โž• add next SQL functions: count, sum, avg, min, max, coalesce and concat_ws sql functions
    • round function now accepts second optional argument specifying precision
    • Function's #operands_to_sql and #operand_sql now are public
    • ๐Ÿ“š Function.define macro accepts comment key to specify function class documentation comment
    • 0๏ธโƒฃ Function.define macro arity argument by default is 0 (instead of -1)
    • โž• add ExpressionBuilder#cast
    • ๐Ÿ– handle an empty array passed to Criteria#in
    • ๐Ÿ›  fix missing LIMIT in query generated by #first!
    • ๐Ÿ›  fix result type of Executables#exists? query method to Bool (thanks @skloibi)
    • โž• add Executables#explain

    Model

    • ๐Ÿ‘ Base.new now calls after_initialize hooks and supports STI
    • ๐Ÿ— Base.build now is alias for Base.new
    • ๐Ÿ“œ properties passed to Mapping.mapping now is parsed before main mapping macro is executed
    • #append_{{relation_name}} methods of RelationDefinition now use .new to build a related object
    • ๐Ÿšš Resource::Supportable alias is removed
    • Resource.search_by_sql is removed in favour of Resource.all.find_by_sql
    • ๐Ÿ›  fix bug with ignoring of field converter by a STI child
    • ๐Ÿ›  fix default constructor for STI child - now it is generated if parent model has only type field without default value
    • ๐Ÿ‘ allow mapping option column that defines a custom column name that is mapped to this field (thank @skloibi)
    • ๐Ÿšš Base#table_name is moved to Resource
    • Mapping module now can be included by another module with mapping definition
    • STIMapping now doesn't convert result set to hash and use same logic as Mapping
    • โž• add :auto mapping option to specify whether primary key is autoincrementable

    Validation

    • ๐Ÿ”„ change Validations::Uniqueness to consider field mappings when validating properties (thank @skloibi)
    • ๐Ÿ‘ allow passing multiple fields to .validates_uniqueness to validate combination uniqueness (thank @skloibi)

    View

    • introduce Mapping instead of ExperimentalMapping; new mapping heavily reuse Model::Mapping
    • ๐Ÿ‘ allow specification of property aliases via column option (cf. Model) (thank @skloibi)
    • mapping shares same functionality as Model's

    Adapter

    • โœ‚ remove Base::ArgType alias
    • โž• add Base#upsert
    • Postgres::Adapter#data_type_exists? is renamed to #enum_exists?
    • ๐Ÿ›  fix bug for dropping foreign key for postgres adapter
    • โœ‚ remove TableBuilderBuilders - now Migration::Base creates commands by its own
    • speed-up tables column count fetch at application start-up
    • ๐Ÿ›  Fix result type of #exists? query method to Bool for Base and Postgres adapters (thanks @skloibi)
    • โž• add Base#explain abstract method and implementations for Mysql and Postgres

    Config

    • โž• add verbose_migrations to hide or show migration details during db:migrate command invocation

    SqlGenerator

    • add .insert_on_duplicate and .values_expression to BaseSQLGenerator as abstract methods and implementations to Postgres and Mysql
    • now BaseSQLGenerator.from_clause accepts 2 arguments (instead of 2..3) accepting table name as 2nd argument
    • โž• add BaseSQLGenerator.with_clause which generates CTE
    • โž• add BaseSQLGenerator.explain

    Migration

    • โž• add Base#tinyint (not all adapter support it)
    • ๐Ÿ”„ change next Base instance method signature:
      • #foreign_key_exists?(from_table, to_table = nil, column = nil, name : String? = nil)
      • #add_index(table_name : String | Symbol, field : Symbol, type : Symbol? = nil, name : String? = nil, length : Int32? = nil, order : Symbol? = nil) (same for TableBuilder::CreateTable#index and TableBuilder::ChangeTable#add_index)
      • #drop_index(table : String | Symbol, fields : Array(Symbol) = [] of Symbol, name : String? = nil) (same for TableBuilder::ChangeTable#drop_index)
      • #drop_foreign_key(to_table : String | Symbol, column = nil, name = nil) (same for TableBuilder::ChangeTable#drop_foreign_key)
    • โž• add TableBuilder::CreateTable#column as alias to TableBuilder::CreateTable#field
    • ๐Ÿ†• new signature of TableBuilder::CreateTable#reference - #reference(name, type : Symbol = :integer, options : Hash(Symbol, AAllowedTypes) = DB_OPTIONS.new)

    Record

    • ๐Ÿ‘€ for missing fields BaseException exception is raised instead of KeyError