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 respectsafter_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 withpostgres
adapter - โ add
Query#insert
andQuery#upsert
- โ add
ExpressionBuilder#values
andValues
to reference toVALUES
statement in upsert .find_by_sql
and.to_a
ofModelQuery(T)
useT.new
instead ofT.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 beUNION 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
andconcat_ws
sql functions round
function now accepts second optional argument specifying precisionFunction
's#operands_to_sql
and#operand_sql
now are public- ๐
Function.define
macro acceptscomment
key to specify function class documentation comment - 0๏ธโฃ
Function.define
macroarity
argument by default is0
(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 toBool
(thanks @skloibi) - โ add
Executables#explain
Model
- ๐
Base.new
now callsafter_initialize
hooks and supports STI - ๐
Base.build
now is alias forBase.new
- ๐ properties passed to
Mapping.mapping
now is parsed before main mapping macro is executed #append_{{relation_name}}
methods ofRelationDefinition
now use.new
to build a related object- ๐
Resource::Supportable
alias is removed Resource.search_by_sql
is removed in favour ofResource.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 toResource
Mapping
module now can be included by another module with mapping definitionSTIMapping
now doesn't convert result set to hash and use same logic asMapping
- โ 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 ofExperimentalMapping
; new mapping heavily reuseModel::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
- nowMigration::Base
creates commands by its own - speed-up tables column count fetch at application start-up
- ๐ Fix result type of
#exists?
query method toBool
forBase
andPostgres
adapters (thanks @skloibi) - โ add
Base#explain
abstract method and implementations forMysql
andPostgres
Config
- โ add
verbose_migrations
to hide or show migration details duringdb:migrate
command invocation
SqlGenerator
- add
.insert_on_duplicate
and.values_expression
toBaseSQLGenerator
as abstract methods and implementations toPostgres
andMysql
- 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 forTableBuilder::CreateTable#index
andTableBuilder::ChangeTable#add_index
)#drop_index(table : String | Symbol, fields : Array(Symbol) = [] of Symbol, name : String? = nil)
(same forTableBuilder::ChangeTable#drop_index
)#drop_foreign_key(to_table : String | Symbol, column = nil, name = nil)
(same forTableBuilder::ChangeTable#drop_foreign_key
)
- โ add
TableBuilder::CreateTable#column
as alias toTableBuilder::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 ofKeyError
- extended model mapping