Changelog History
Page 1
-
v0.10.0 Changes
December 11, 2020๐ 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 raiseJennifer::RecordNotFound
exception ModelQuery(T)#to_a
andModelQuery(T)#find_by_sql
ensureT
has loaded actual table field count before making a request
Model
- ๐ change model constructor hash argument type from
Hash(String, Jennifer::DBany)
toHash(String, AttrType)
(same forSymbol
keys) CommonMapping#attribute
uses attribute getter- ๐ป
CommonMapping#attribute
raisesJennifer::UnknownAttribute
exception if model has no requested attribute andraise_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 createsAttrType
alias to represent union ofJennifer::DBAny
and any arbitrary type from fields definition - โก๏ธ change
Mapping#update_columns
argument type toHash(String | Symbol, AttrType)
- โก๏ธ
Mapping#update_columns
raisesJennifer::UnknownAttribute
if key-value pairs include unknown attribute Mapping#set_attribute
to acceptAttrType
- ๐ป
Mapping#set_attribute
raisesJennifer::UnknownAttribute
exception if model has no requested attribute - โก๏ธ
Mapping#update_columns
raisesJennifer::UnknownAttribute
if key-value pairs include unknown field Mapping#arguments_to_insert
andMapping#arguments_to_save
use#attribute_before_typecast
to collect attributes to store in a database#add_{{relation}}
acceptsAttrType
as a hash value type- ๐ rename
EnumConverter
toPgEnumConverter
- โ add
EnumConverter(T)
to convert string to crystal enum - add
JSONSerializableConverter(T)
to convert JSON field to objects ofT
that support.from_json
and#to_json
methods - add
TimeZoneConverter
to convert time attributes from UTC toJennife::Config.local_time_zone
Adapter
- โ add
DBFormater
as a proposed default logger formatter - ๐ change logging - emit
Log::Metadata
withquery
,args
andtime
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
toTableBuilder::DbOptions
Exceptions
- โ add
Jennifer::UnknownAttribute
to represent case when unknown attribute is tried to be read/written
-
v0.9.0 Changes
May 24, 2020๐ 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 acceptAdapter::Base
as a second (optional) argumentOrderItem
is renamed toOrderExpression
to avoid possible name collisions
Model
- fix an issue with rendering
new_record
anddestroyed
system variables by#to_json
- 0๏ธโฃ
Resource.table_prefix
now returns underscored namespace name (if any) by default Base
includesJennifer::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
orRecord
View
- fix an issue with rendering
new_record
anddestroyed
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
raisesBaseException
if no validConfig.adapter
is specified .command_interface
,.create_database
,.drop_database
,.generate_schema
,.load_schema
,.db_connection
,.connection_string
,.database_exists?
now are instance methodsBase#initialize
now exceptsConfig
instance- respect host in
Jennifer::Postgres::CommandInterface#database_exists?
- escape connection URI segments
- ๐ฒ
Config#logger
now isLog
instead ofLogger
- โ 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 apiRunner.create
andRunner.drop
now accept optionAdapter::Base
instance- pass
to_table
inTableBuilder::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
toTableBuilder::CHangeTable
TableBuilder::CHangeTable#drop_index
also accepts single column name- โ remove deprecated
TableBuilder::CreateTable#index
overrides
Record
- ๐
#initialize(DB::ResultSet)
is removed
- โ add Crystal
-
v0.8.4 Changes
November 15, 2019๐ Changes
QueryBuilder
- ๐ use adapter's
#read_column
inNestedRelationTree
- โ add
RelationTree#adapter
- ๐ fix
Ordering#order(Hash(String | Symbol, String | Symbol))
Adapter
- ๐ fix issue with treating
tinyint
mysql field asboolean
- remove
ResultParser#result_to_array
- โ add
Mysql#read_column
- add
Base.default_max_bind_vars_count
which returns default maximum count of bind variables that can be used inBase#bulk_insert
(default is 32766) Mysql.default_max_bind_vars_count
andPostgres.default_max_bind_vars_count
returns32766
- ๐
Base#bulk_insert
doesn't do table lock no more - if variables that should be inserted by
Base#bulk_insert
exceedBase.max_bind_vars
all of them are quoted and put into a query - โ remove
BaseSQLGenerator::ARRAY_ESCAPE
- move
BaseSQLGenerator::ARGUMENT_ESCAPE_STRING
toQuoting
- move
BaseSQLGenerator
.quote
,.escape_string
,.filter_out
toQuoting
- โ add correct values quoting for
postgres
adapter - โ add correct values quoting for
mysql
adapter - โช now logger writes
BEGIN
instead ofTRANSACTION START
,COMMIT
instead ofTRANSACTION COMMIT
andROLLBACK
instead ofTRANSACTION ROLLBACK
on corresponding transaction commands - โ add
SchemaProcessor::FkEventActions
enum to validateon_delete
andon_update
action values;String | Symbol
still should be used as an argument type everywhere
Config
- add
max_bind_vars_count
property to present maximum allowed count of bind variables to be used in bulk insert operation - add
MigrationFailureHandler
enum to validatemigration_failure_handler_method
value;Symbol | MigrationFailureHandler
should be used as an argument for it - fix
migration_failure_handler_method
config - make it instance property
- ๐ use adapter's
-
v0.8.3 Changes
October 19, 2019๐ Changes
General
- โ add crystal
0.31.1
compatibility - โ add
[email protected]
support - โ remove
sam
from mandatory dependencies
Model
- ๐ fix bug with primary field presence assertion
View
- ๐ fix bug with primary field presence assertion
Adapter
- โ add
date
SQL data type date_time
field type maps totimestamp
SQL data type (postgres only)
Migration
- โ add
Runner.pending_migration?
to return whether there is pending (not invoked) migration - โ add
Base.with_transaction
method to disable automatic transaction wrapping around migration methods - โ add
Base.with_transaction?
to check whether migration is run under a transaction - โ remove
var_string
field type - โ remove
blob
field type for postgres - ๐ fix wrong explanation message for
TableBuilder::CreateIndex
- โ add new
TableBuilder::CreateTable#index
signatures (old ones are deprecated):#index(fields : Array(Symbol), type : Symbol | ::Nil = nil, name : String | ::Nil = nil, lengths : Hash(Symbol, Int32) = {} of Symbol => Int32, orders : Hash(Symbol, Symbol) = {} of Symbol => Symbol)
#index(field : Symbol, type : Symbol | ::Nil = nil, name : String | ::Nil = nil, length : Int32 | ::Nil = nil, order : Symbol | ::Nil = nil)
- 0๏ธโฃ make default
varchar
length254
(mysql only) - โ add foreign key ON UPDATE and ON DELETE support
Base#add_foreign_key
acceptson_delete
andon_update
keyword arguments to specify corresponding actionsTableBuilder::ChangeTable#add_foreign_key
acceptson_delete
andon_update
keyword arguments to specify corresponding actions- โ
TableBuilder::CreateTable#reference
acceptson_delete
andon_update
options to specify corresponding actions TableBuilder::CreateTable#foreign_key
acceptson_delete
andon_update
keyword arguments to specify corresponding actions
- โ add crystal
-
v0.8.2 Changes
September 11, 2019General
- โฌ๏ธ upgrade
TechMagister/i18n.cr
dependency to0.3.1
- โฌ๏ธ upgrade
-
v0.8.1 Changes
September 04, 2019General
- โ add
crystal-pg
0.18.0 support - โ add ameba check to CI
- ๐ fix bug with not defined
JSON
Model
- โ Add
EnumConverter
converter for PostgreENUM
field convert - (pg only) field presenting
ENUM
field should explicitly specifyconverter: Jennifer::Model::EnumConverter
Adapter
Postgre
adapter now doesn't register decoders for each ENUM type in#prepare
Config
- add
allow_outdated_pending_migration
configuration to specify whether outdated pending migration should be silently processed or error should be raised
Migration
- extend
Jennifer::Migration::TableBuilder::Base::AllowedTypes
alias withInt64
type.
- โ add
-
v0.8.0 Changes
June 11, 2019It 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
-
v0.7.1 Changes
February 09, 2019๐ Changelog
QueryBuilder
#pluck
,#update
,#db_results
,#results
.#each_result_set
and#find_in_batches
ofQuery
respects#none
(returns empty result if it has being called)- โ remove deprecated
QueryObject
constructor accepting array of options and#params
Model
- ๐ fix mapping issue when all
Generic
s are assumed as unions (#208)
Validation
- ๐ allow passing multiple fields to
.validates_uniqueness
to validate combination uniqueness
Adapter
- 0๏ธโฃ
Mysql::SchemaProcessor
now respectsfalse
as column default value - 0๏ธโฃ
Postgres::SchemaProcessor
now respectsfalse
as column default value
Config
- introduce new configuration
pool_size
which setsmax_idle_pool_size = max_pool_size = initial_pool_size
to the given value; getter#pool_size
returns#max_pool_size
- 0๏ธโฃ
postgres
is no more default adapter
Migration
TableBuilder::Base::AllowedTypes
alias includesFloat64
andJSON::Any
-
v0.7.0 Changes
January 08, 2019Overview
๐ This release was hard and pretty long. As a result we've got a set of very important features (like polymorphic relations and complex query update mechanism). Also as a side effect bunch of side-shards were appeared to fill gaps in missing functionality (like form parsing).
๐ Also you can find 3 sample application describing possible way of integrating web frameworks/libraries with Jennifer:
๐ Changelog
General
- โฌ๏ธ bump
sam
to"~> 0.3.0"
- โ add sam command
generate:model
to generate model and related migration - ๐ move all logic regarding file generating to
Jennifer::Generators
space - โ add
db:seed
task as a placeholder seeding task - ๐
db:setup
now invokesdb:seed
afterdb:migrate
QueryBuilder
- โ add
#and
,#or
and#xor
shortcut methods toExpressionBuilder
Criteria#in
now acceptsSQLNode
as well- โ add
Statement
module with base abstract functionality needed for query string generating ExpressionBuilder#g
and#group
now has no argument type restrictionGrouping#condition
now can be ofStatement
typeQuery
includesStatement
Query#to_sql
now is#as_sql
,#select_args
-#sql_args
Condition
includesStatement
- โก๏ธ
Executables#update
accepts block expectingHash(Symbol, Statement)
to be returned - โก๏ธ
Executables#modify
is removed in favor of new#update
method accepting block - now
LogicOperator
is inherited fromSQLNode
#delete
andexists?
ofExecutables
do nothing when#do_nothing?
istrue
- โ add
Query#do_nothing?
- โ add
Query.null
which returnsQuery.new.none
Join
acceptsGrouping
forON
condition
Model
- remove
Base.build_params
,Base.parameter_converter
methods - โ remove
ParameterConverter
class - ๐ fix skipping generating default constructor by
Mapping.mapping
when at least one field has default value and all others are nilable - ๐
stringified_type
option is removed from theCOLUMNS_METADATA
STIMapping#arguments_to_save
&STIMapping#arguments_to_insert
now respect field converter- ๐
Translation
model now is includeable module - ๐ all class methods of
Translation
are moved toTranslation::ClassMethods
which is automatically extended by target class usingincluded
macro #lookup_ancestors
and#human_attribute_name
methods ofTranslation
are added- ๐
Errors#base
now is type ofTranslation
instead ofBase
- โ add
Base#persisted?
- now attribute-specific rendering for
Resource#inspect
is generated by.mapping
- add polymorphic relation support for
has_one
,has_many
andbelongs_to
relations - โ add
:nodoc:
for almost all generated relation methods (except#association
) - โ add missing relation names for criterion in
Relation::Base
methods - โ add
Relation::IPolymorphicBelongsTo
,Relation::PolymorphicHasMany
andRelation::PolymorphicHasOne
@new_record
,@destroyed
,@errors
, changeset and relation attributes now is ignored byJSON::Serializable
- add
skip_validation
argument toAuthentication.with_authentication
macro to specify whether validation should be added - โ add generating predicate method
#{{attribute}}?
for boolean attribute - ๐ allow
Jennifer::Model::Base#attribute=
to accept not only defined type but alsoJennifer::DBAny
- rename
Base#update_attributes
toBase#set_attributes
Validation
- all validation macros now accept
:if
key; the value may be bothSymbol
name of a method to be called or expression - replace validation logic generated during a macro call with new validators usage:
Validations::Absence
,Validations::Acceptance
,Validations::Confirmation
,Validations::Exclusion
,Validations::Format
,Validations::Inclusion
,Validations::Length
,Validations::Numericality
,Validations::Presence
,Validations::Uniqueness
- โ remove
Jennifer::Validator
in favour ofJennifer::Valdiations::Validator
- 0๏ธโฃ all validators by default implement singleton pattern
- ๐ all validation macros are moved to
Jennifer::Validations::Macros
View
- now attribute-specific rendering for
Resource#inspect
is generated by.mapping
- โ add generating predicate method
#{{attribute}}?
for boolean attribute
Adapter
- ๐ fix output stream for postgres schema dump
- โ remove legacy postgres insert
- add
Adapter#foreign_key_exists?
- โ add
Mysql::SchameProcessor
- now
Base#schema_processor
is abstract - โ add
Postgres::SchemaProcessor#rename_table
SchemaProcessor
now is abstract class- ๐ all builder methods are moved from
SchemaProcessor
class toTableBuilderBuilders
module - fix syntax in
SchemaProcessor#drop_foreign_key
- all
_query
arguments inBase
methods are renamed toquery
- ๐
Base.extract_arguments
is removed .delete
,.exists
and.count
ofBaseSQLGenerator
now returns string- ๐
Postgres.bulk_insert
is removed - ๐
Transaction#with_connection
ensure to release connection - ๐ all sqlite3 related code are removed
Config
- fix
migration_failure_handler_method
property from being global - add new property
model_files_path
representing model directory (is used in a scope of model generating) - fix ignoring
skip_dumping_schema_sql
config
SqlGenerator
.select_clause
now doesn't invoke.from_clause
under the hood- ๐
.lock_clause
adds whitespaces around lock statement automatically
Migration
- remove
Runner.generate
andRunner::MIGRATION_DATE_FORMAT
TableBuilder::CreateTable#reference
triggers#foreign_key
and acceptspolymorphic
bool argument presenting whether additional type column should be added; for polymorphic reference foreign key isn't added
Exceptions
- ๐ 'RecordNotFound' from
QueryBuilder::Query#first!
andQueryBuilder::Query#last!
includes detailed parsed query
- โฌ๏ธ bump
-
v0.6.2 Changes
October 23, 2018๐ This is an intermediate release before the breaking
0.7.0
.๐ Changelog
General
- โ add
:nodoc:
to all internal constants and generated methods (implementing standard ORM methods) from the macros
QueryBuilder
Query
isn't extended byIfrit
- โ add
OrderItem
to describe order direction - โ add
Criteria#order
,Criteria#asc
andCriteria#desc
to createOrderItem
- โ add
Condition#eql?
to compare with other condition orSQLNode
(returnsfalse
) - โ add
Criteria#eql?
,Grouping#eql?
,LogicOperator#eql?
- โ add
Query#order
andQuery#reorder
with acceptingOrderItem
- now
Query#order
with block to expect aOrderItem
- โ remove
CriteriaContainer
QueryObject
now is an abstract class- ๐ changed wording for the
ArgumentError
in#max
,#min
,#sum
,#avg
methods ofAggregation
to "Cannot be used with grouping" - ๐ change
Query#from(_from : String | Query)
signature toQuery#from(from : String | Query)
Model
- โก๏ธ
#save
and#update
will returntrue
when is called on an object with no changed fields (all before callbacks are invoked) - next
Base
methods become abstract:.primary_auto_incrementable?
,.build_params
,#destroy
,#arguments_to_save
,#arguments_to_insert
Base#_extract_attributes
andBase#_sti_extract_attributes
become private- all callback invocation methods become protected
- next
Resource
methods become abstract:.primary
,.field_count
,.field_names
,.columns_tuple
,#to_h
,#to_str_h
Resource
isn't extended byIfrit
- ๐ regenerate
.build_params
for STI models Scoping.scope(Symbol,QueryObject)
now checks in runtime whetherT
ofJennifer::QueryBuilder::ModelQuery(T)
responds to method named after the scope
View
Base#_after_initialize_callback
becomes protectedBase#_extract_attributes
becomes private
Adapter
- ๐ fix custom port not used when accessing the Postgres database
Migration
TableBuilder::Base
isn't extended byIfrit
- rename
TableBuilder::ChangeTable#new_table_rename
getter to#new_table_name
- ๐ fix misuse of local variable in
TableBuilder::ChangeTable#rename_table
TableBuilder::ChangeTable#change_column
has next changes:old_name
argument renamed toname
new_name
argument is replaced with option inoptions
arguemnt hash- raise
ArgumentError
if bothtype
andoptions[:sql_type]
arenil
TableBuilder::ChangeTable#change_column
raisesArgumentError
if bothtype
andoptions[:sql_type]
arenil
TableBuilder::CreateTable#field
data_type
argument renamed totype
- 0๏ธโฃ
TableBuilder::CreateTable#timestamps
creates fields withnull: false
by default - ๐
TableBuilder::CreateTable#add_index
is removed in favour of#index
- ๐
.pending_versions
,.assert_outdated_pending_migrations
and.default_adapter
methods ofRunner
become private - ๐
Runner.config
is removed
- โ add