Skip to content

Release 0.7.0

Compare
Choose a tag to compare
@imdrasil imdrasil released this 08 Jan 19:21
· 334 commits to master since this release
7883a4d

Overview

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 invokes db:seed after db:migrate

QueryBuilder

  • add #and, #or and #xor shortcut methods to ExpressionBuilder
  • Criteria#in now accepts SQLNode as well
  • add Statement module with base abstract functionality needed for query string generating
  • ExpressionBuilder#g and #group now has no argument type restriction
  • Grouping#condition now can be of Statement type
  • Query includes Statement
  • Query#to_sql now is #as_sql, #select_args - #sql_args
  • Condition includes Statement
  • Executables#update accepts block expecting Hash(Symbol, Statement) to be returned
  • Executables#modify is removed in favor of new #update method accepting block
  • now LogicOperator is inherited from SQLNode
  • #delete and exists? of Executables do nothing when #do_nothing? is true
  • add Query#do_nothing?
  • add Query.null which returns Query.new.none
  • Join accepts Grouping for ON condition

Model

  • remove Base.build_params, Base.parameter_converter methods
  • remove ParameterConverter class
  • fix skipping generating default constructor byMapping.mapping when at least one field has default value and all others are nilable
  • stringified_type option is removed from the COLUMNS_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 to Translation::ClassMethods which is automatically extended by target class using included macro
  • #lookup_ancestors and #human_attribute_name methods of Translation are added
  • Errors#base now is type of Translation instead of Base
  • add Base#persisted?
  • now attribute-specific rendering for Resource#inspect is generated by .mapping
  • add polymorphic relation support for has_one, has_many and belongs_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 and Relation::PolymorphicHasOne
  • @new_record, @destroyed, @errors, changeset and relation attributes now is ignored by JSON::Serializable
  • add skip_validation argument to Authentication.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 also Jennifer::DBAny
  • rename Base#update_attributes to Base#set_attributes

Validation

  • all validation macros now accept :if key; the value may be both Symbol 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 of Jennifer::Valdiations::Validator
  • 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 to TableBuilderBuilders module
  • fix syntax in SchemaProcessor#drop_foreign_key
  • all _query arguments in Base methods are renamed to query
  • Base.extract_arguments is removed
  • .delete, .exists and .count of BaseSQLGenerator 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 and Runner::MIGRATION_DATE_FORMAT
  • TableBuilder::CreateTable#reference triggers #foreign_key and accepts polymorphic bool argument presenting whether additional type column should be added; for polymorphic reference foreign key isn't added

Exceptions

  • 'RecordNotFound' from QueryBuilder::Query#first! and QueryBuilder::Query#last! includes detailed parsed query