Releases: imdrasil/jennifer.cr
Releases · imdrasil/jennifer.cr
Release 0.13.0
Release notes
General
- address "positional parameter of the overridden method, which has a different name and may affect named argument passing" crystal
1.5.0
warning (for full list see MR) - upgrade supported mysql driver version to
0.14.0
- upgrade supported pg driver version to
0.26.0
- add
jsonb
type support for model and migration generators - replace
phoffer/inflector.cr
inflector library withluckyframework/wordsmith
QueryBuilder
Query.count
returnsInt64
instead ofInt32
Query.offset
acceptsInt32
orInt64
as input instead of onlyInt32
#group
,#select
raise anArgumentError
if block returns anything except array#having
,#reorder
,#order
raisesExpressionBuilder
as a block argument#where
accepts hash with string keys as well- added
#find_or_create_by
,#find_or_create_by!
,#find_or_initialize_by
to create/instantiate a record if nothing was found in the DB - added
#find_by
and#find_by!
as a shortcut for.where().first
and.where().first!
Model
- change default
id
attribute type fromInt32
toInt64
- generate a setter method for a
Int64
attribute that calls#to_i64
onInt32
value - in mapping automatically assign
null: true
ifnull
property is missing and field is primary - enhance type coercion on initializing instance from hash
- change return type of
.ids
toArray(Int64)
Model.count
returnsInt64
instead ofInt32
- add support for
JSON::PullParser
attribute class - model class responds to:
#here
,#select
,#from
,#union
,#distinct
,#order
,#group
,#with
,#merge
,#limit
,#offset
,#lock
,#reorder
,#count
,#max
,#min
,#sum
,#avg
,#group_count
,#group_max
,#group_min
,#group_sum
,#group_avg
,#with_relation
,#includes
,#preload
,#eager_load
,#last
,#last!
,#first
,#first!
,#find_by
,#find_by!
,#pluck
,#exists?
,#increment
,#decrement
,#ids
,#find_records_by_sql
,#find_in_batches
,#find_each
,#join
,#right_join
,#left_join
,#lateral_join
- adds
.create
and.create!
that accepts block - fix a bug when password digest wasn't generated when password was set by passing it to a constructor
- add missing STI initialization to constructors accepting a hash or named tuple
- use
Adapter::Base.coerce_database_value
in constructors accepting a hash or named tuple to coerce values for columns that don't have specified converter - Fix the issue of
Jennifer::Model::OptimisticLocking#reset_lock_version
decreasing lock version column when it's not changed
Validation
- add
jennifer.errors.messages.required
message in locale yaml file Jennifer::Model::Errors#add
acceptsString | Symbol | Proc(Translation, String, String)
formessage
argumentvalidates_inclusion
,validates_exclusion
,validates_format
,validates_length
,validates_uniqueness
,validates_presence
,validates_absence
,validates_numericality
,validates_acceptance
&validates_confirmation
validation macros acceptsmessage
option that allows to specify validation message
Relation
belongs_to
relation macro acceptsrequired
option to validate existence of relation on save
View
- model class responds to:
#here
,#select
,#from
,#union
,#distinct
,#order
,#group
,#with
,#merge
,#limit
,#offset
,#lock
,#reorder
,#count
,#max
,#min
,#sum
,#avg
,#group_count
,#group_max
,#group_min
,#group_sum
,#group_avg
,#with_relation
,#includes
,#preload
,#eager_load
,#last
,#last!
,#first
,#first!
,#find_by
,#find_by!
,#pluck
,#exists?
,#increment
,#decrement
,#ids
,#find_records_by_sql
,#find_in_batches
,#find_each
,#join
,#right_join
,#left_join
,#lateral_join
Adapter
- remove
id
column from theversions
table schema - change default
id
column type fromint
tobigint
- add
Base.coerce_database_value
method to provide interface to perform coercing from default database type used to read column to hash to a desired model attribute type
SqlGenerator
- fix invalid SQL generating for
FROM
clause when string value is given for#from
Record
- now calling a
#foo_bar
method on a record that is missing raisesArgumentError
instead ofKeyError
Release 0.12.0
In memory of my father - even with very low understanding in programming, he was always interested in the current state of Jennifer and whether it was useful to people
Changelog
General
- add crystal 1.2.0 support
QueryBuilder
#pluck
accepts splatted named tuple of desired attribute-type pairs and returns array of such tuples as a records#upsert
passes expression builder as a block argument
Model
- add Optimistic locking support via macro
with_optimistic_lock(column_name = lock_version)
updated_at
andcreated_at
fields aren't override on save if have been set manually- add
upsert
class method to insert multiple models while ignoring conflicts on specified unique fields
Adapter
- fix database connection query arguments building
- each adapter includes
RequestMethods
instead of including it by base adapter class - add a new
upsert
overload that allows passing a collection ofJennifer::Model::Base
- fix
insert_on_duplicates
sql generation for postgres adapter if no unique fields given
SqlGenerator
- any
INSERT
,UPDATE
,SELECT
andDELETE
requests uses quoted tables/columns if they are created byQueryBuilder::ExpressionBuilder
(raw SQL is placed as-is) .select_clause
uses specified query attributes to select and fall back to custom fields only if there is no custom attribute to select
Migration
TableBuilder::ChangeTable
now performsDropForeignKey
,DropIndex
&DropReference
before any column manipulation- fix
TableBuilder::ChangeEnum
to use specified adapter to query effected tables
Release 0.11.1
Changelog
General
- switch to the
crimson-knight/i18n.cr
~> 0.4.1
Migration
- fix
TableBuilder::ChangeTable#drop_reference
dropping column before reference - add
TableBuilder::DropReference
Release 0.11.0
I'm happy to announce that the release supporting crystal >= 1.0.0
is published. Summarizing changelog below I'd like to emphasize next points:
- now models/views/record have
#to_json
method to simplify serialization - Jennifer supports latest mysql/postgresl/sqlite driver versions
- now string-based values can be used much easily with new coercing logic
- time zone related logic become more flexible and configurable
- now each pull request merge and release automatically rebuilds documentation so you always can check fresh version here
- currently i18n shard has a bit unstable support so may cause some issues (feel free to open issue if you face one)
Changelog
General
- add crystal
>= 1.0.0
support - fix inconsistent method signatures in multiple places
- add
#to_json
to the following structs:PG::Numeric
,PG::Geo::Point
,PG::Geo::Line
,PG::Geo::Circle
,PG::Geo::LineSegment
,PG::Geo::Box
,PG::Geo::Path
,PG::Geo::Polygon
,Char
,Time::Span
,Slice
,UUID
- add
crystal-mysql: 0.13.0
support - add
crystal-pg: 0.23.2
support
QueryBuilder
- add custom
#to_json
to serialize retrieved collection - add
#where
acceptingHash(Symbol, _)
- add
Criteria#equal
andCriteria#not_equal
as original implementation ofCriteria#==
andCriteria#!=
- add
ExpressionBuilder
#and
,#or
and#xor
methods that accepts array of conditions
Model
Authentication#password
returns given unecrypted value- add
Coercer
module with static methods to localize all coercing logic for different types - add
.coercer
method to return object responding to all coercing methods described inCoercer
mapping
generates.coerce_{{attribute}(value : String)
methods for every field to coerce string value toattribute
's typemapping
generates for every non-string attribute with a setter additional#{{attribute}}=(value : String)
setter- allow all build methods (
.new
,.create
and.update
) to receiveHash(String, String)
and coerce values to expected types - add
.column_name
to return all field names - fix
.field_names
from returning child's properties for parent class - add custom
#to_json
- change converter interface to
.from_db(DB::ResultSet, NamedTuple)
,.from_db(DB::ResultSet, NamedTuple)
and.from_hash(Hash, String | Symbol, NamedTuple)
- change all existing converters to support new required interface
- add
BigDecimalConverter(T)
converter - add
Coercer.coerce(String, (BigDecimal?).class)
- add
time_zone_aware
option forTimeZoneConverter
to specify whether field should respect time zone converting logic - add support of date only and time only string formats for
TimeZoneConverter
- add
time_format
,date_time_format
anddate_format
to customize time, date time and date formats respectively - fix a bug where updated_at is not set in the generated sql query from model.save
NumericToFloat64Converter
,BigDecimalConverter
,TimeZoneConverter
#from_hash
accepts string as field valueBigDecimalConverter#from_hash
accepts integer and float values as field value- fix
Errors#inspect
bug using oldUInt64#to_s
signature - introduce
Timestamp
module that now includeswith_timestamps
macro - reworked how
updated_at
andcreated_at
fields are set before save - now they are set explicitly without utilizing callbacks - add
Resource.where
acceptingHash(Symbol, _)
Validation
- change
Validator#validate
abstract interface to#validate(record, **opts)
- update all built-in validators to reflect new
Validator
interface - make
Validator.with_blank_validation
macro to accept arguments to reference record, field name, value and blank value acceptance
Relation
- remove abstract
#condition_clause
&#condition_clause(a)
declarations fromIRelation
View
- add custom
#to_json
Adapter
- remove abstract
#update
declaration fromBase
BaseSQLGenerator#parse_query
convertsTime
arguments to UTC only ifConfig.time_zone_aware_attributes
set totrue
Mysql#read_column
callssuper
if column isn't a tiny intResultParser#read_column
convert time toConfig.local_time_zone
ifConfig.time_zone_aware_attributes
set totrue
or just change time zone to it otherwise
Config
.reset_config
creates new instance instead of executing#initialize
on existing object- add
Config.time_zone_aware_attributes
to specify whether time zone converting logic should be globally disabled
Migration
- add
precision
andscale
options support fordecimal
data type
Record
- add custom
#to_json
- add custom
#inspect
Release 0.10.0
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 getterCommonMapping#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 attributeMapping#set_attribute
to acceptAttrType
Mapping#set_attribute
raisesJennifer::UnknownAttribute
exception if model has no requested attributeMapping#update_columns
raisesJennifer::UnknownAttribute
if key-value pairs include unknown fieldMapping#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
Release 0.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 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
Resource.table_prefix
now returns underscored namespace name (if any) by defaultBase
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
Release 0.8.4
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
Release 0.8.3
Changes
General
- add crystal
0.31.1
compatibility - add
crystal-db@0.7.0
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)
- 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 actionsTableBuilder::CreateTable#reference
acceptson_delete
andon_update
options to specify corresponding actionsTableBuilder::CreateTable#foreign_key
acceptson_delete
andon_update
keyword arguments to specify corresponding actions
Release 0.8.2
Tiny release to update dependencies
Release 0.8.1
Merge pull request #264 from imdrasil/release/0.8.1 Bump 0.8.1