Skip to content

Commit

Permalink
Merge pull request #100 from imdrasil/v0.5.0
Browse files Browse the repository at this point in the history
Release V0.5.0
  • Loading branch information
imdrasil committed Feb 13, 2018
2 parents afd9314 + cf733b7 commit 0847244
Show file tree
Hide file tree
Showing 117 changed files with 4,178 additions and 1,668 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
/bin/
/.shards/
.idea
jennifer.code-workspace
/spec/fixtures/*.db

# Libraries don't need dependency lock
# Dependencies will be locked in application that uses them
/shard.lock
/examples/structure.sql
/examples/test.cr
/examples/test.db
/examples/test.db
7 changes: 0 additions & 7 deletions .travis.install-mysql-5.7.sh

This file was deleted.

22 changes: 22 additions & 0 deletions .travis.setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set -exo pipefail

if [ "$DB" == 'postgres' ] || [ "$PAIR" == '1' ]; then
# Create database for postgres
psql -c 'create database jennifer_test;' -U postgres
fi

if [ "$DB" == 'mysql' ] || [ "$PAIR" == '1' ]; then
# Install newer MySQL
sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com A4A9406876FCBD3C456770C88C718D3B5072E1F5
wget http://dev.mysql.com/get/mysql-apt-config_0.8.1-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.1-1_all.deb
sudo apt-get update -q
sudo apt-get install -q -y -o Dpkg::Options::=--force-confnew mysql-server
sudo mysql_upgrade -u root --force
sudo service mysql restart

# Create database for mysql
crystal ./examples/run.cr -- db:create
fi

crystal ./examples/run.cr -- db:migrate
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ addons:
env:
- DB=mysql DB_USER=root DB_PASSWORD=""
- DB=postgres DB_USER=postgres DB_PASSWORD=""
before_script:
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database jennifer_test;' -U postgres; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then bash .travis.install-mysql-5.7.sh; crystal ./examples/run.cr -- db:create; fi"
- crystal ./examples/run.cr -- db:migrate
- DB=postgres DB_USER=postgres DB_PASSWORD="" PAIR=1
- DB=mysql DB_USER=root DB_PASSWORD="" PAIR=1
- DB=postgres DB_USER=postgres DB_PASSWORD="" LEGACY_INSERT=1
before_script: bash .travis.setup.sh
134 changes: 62 additions & 72 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# 0.5.0 (13-02-2018)

* `ifrit/core` pact is required
* adds `i18n` lib support
* adds `time_zone` lib support

**QueryBuilder**

* now `#destroy` uses `#find_each`
* adds `#patch` and `#patch!` which invokes `#update` on each object
* introduced `CriteriaContainer` to resolve issue with using `Criteria` object as a key for `@order` hash
* all `#as_sql` methods now accept `SQLGenerator` class

**Model**

* added methods `#update` & `#update!` which allows to massassign attributes and store object to the db
* added support of localization lib (i18n)
* added methods `::human_attribute_name`, `::human_error` and `::human` to translate model attribute name, error message and model name
* added own `#valid?` and `#validate!` methods - they performs validation and trigger callbacks each call
* added `#invalid?` - doesn't trigger validation and callbacks
* moved all validation error messages to yaml file
* now `%validates_with` accepts oly one class and allows to pass extra arguments to validator class
* `%validate_presence_of` is renamed to `%validate_presence`
* adds new validation macros: `%validate_absence`, `%validates_numericality`, `%validates_acceptance` and `%validates_confirmation`
* introduced own validator class
* adds `after_update`/`before_update` callbacks
* adds `after_commit`/`after_rollback` callbacks
* reorganizes the way how callback method names are stored
* now `%mapping` automatically guess is it should be sti or common mapping (should be used in places of `%sti_mapping`)
* removed `#attributes_hash`
* any time object is converted to UTC when is stored and to local when is retrieved from db

**View**

* any time object is converted to local when is retrieved from db

**Config**

* adds `::local_time_zone_name` method to set application time zone
* adds `::local_time_zone` - returns local time zone object

**Adapter**

* any time object passed as argument is converted from local time to UTC
* `postgres` adapter now use `INSERT` with `RETURNING`
* now several adapters could be required at the same time
* all schema manipulation methods now in located in the `SchemaProcessor`

# 0.4.3 (2-01-2018)

* All macro methods were rewritten to new 0.24.1 crystal syntax
Expand All @@ -16,7 +64,7 @@
* move `Jennifer::Mode::build` method to `%mapping` macro
* allow retrieving and building sti records using base class
* fix `#reload` method for sti record
* optimize building sti record from hash
* optimize building sti record from hash

**QueryBuilder**

Expand All @@ -27,14 +75,14 @@

* introduce `View::Materialized` superclass for materialized views
* add `COLUMNS_METADATA` constant
* add `::columns_tuple` which retrns `COLUMNS_METADATA`
* add `::columns_tuple` which returns `COLUMNS_METADATA`
* remove `::children_classes`
* make `after_initialize` callback respect inheritance
* add `::adapter`

**Exceptions**

* add `AbstractMethod` exception which represents expectation of overriding current method by parents (is usefull when method can't be real abstract one)
* add `AbstractMethod` exception which represents expectation of overriding current method by parents (is useful when method can't be real abstract one)
* add `UnknownSTIType`

# 0.4.2 (24-11-2017)
Expand All @@ -45,94 +93,61 @@

**Migration**

* rename `TableBuilder::DropInde` to `TableBuilder::DropIndex`

* remove printing out redundand execution information during db drop and create

* rename `TableBuilder::DropIndex` to `TableBuilder::DropIndex`
* remove printing out redundant execution information during db drop and create
* remove `Migration::Base::TABLE_NAME` constant

* allow to pass `QueryBuilder::Query` as source to the `CreateMaterializedView` (postgres only)

**Model**

* move `Base#build` method witout arguments to `Mapping` module under the `%mapping`

* move `Base#build` method without arguments to `Mapping` module under the `%mapping`
* added `validates_presence_of` validation macros

* fixed callback invokation from parent classes

* fixed callback invocation from parent classes
* add `allow_blank` key to `validates_inclusion`, `validates_exclusion`, `validates_format`

* add `ValidationMessages` module which includes methods generating validation error messages

* add `Primary32` and `Primary64` shortcuts for `Int32` and `Int64` primary field declarations for model and view

* allow use nil usions instead of `null: true` named tuple option

**QueryBuilder**

* `#count` method is moved from `Executables` module to the `Aggregations` one

* changed method signature of `#find_in_batches`

* add `#find_each` - works same way as `#find_in_batches` but yields each record instead of array

* add `#ordered?` method to `Ordering` module

* switch `Criteria#hash` to use `object_id` as seed

* add `Query#eql?`

* add `Query#clone` and all related methods

* add `Query#except` - creates clone except given clauses

* make `IModelQuery` class as new superclass of `ModelQuery(T)`; move all methods no depending on `T` to the new class

# 0.4.1 (20-10-2017)

**Config**

* added `port` configuration

* `::reset_config` resets to default configurations

* added validation for adapter and db

* `::from_uri` allows to load onfiguration from uri
* `::from_uri` allows to load configuration from uri

**Adapter**

* added `#query_array` method to request array of arrays of given type

* added `#with_table_lock` which allows to lock table (mysql and postgres have different behaviors)

**Query**

* added `all` and `any` statements

* refactored logical operators - now they don't group themselves with "()"

* added `ExpressionBuilder#g` (`ExpressionBuilder#grouping`) to group some condition

* added `XOR`

* moved all executable methods to `Executables` module

* change behavior of `#distinct` - now it accepts no arguments and just prepend `DISTINCT` to common select query

* added `#find_in_batches` - allows to search over requested collection reqtrieved only determined amount of records per iteration

* added `#find_in_batches` - allows to search over requested collection required only determined amount of records per iteration
* `#find_records_by_sql` - returns array of `Record` by given sql string

* added `:full_outer` join type

* added `#lateral_join` to make `LATERAL JOIN` (for now is supported only by PostgreSQL)

* extracted all join methods to `Joining` module

* extracted all ordering methods to `Ordering` module

* added `#reorder` method allowing to reorder existing query

**ModelQuery**
Expand All @@ -142,19 +157,14 @@
**Model**

* added `::with_table_lock`

* added `::adapter`

* added `::import` to perform one query import

* fixed bug with reloading empty relations

**Mapping**

* added `inverse_of` option to `has_many` and `has_one` relations to sets owner during relation loading



# 0.4.0 (30-09-2017)

**Exception**
Expand All @@ -168,43 +178,27 @@
**QueryBuilder**

* now `#eager_load` behaves as old variant of `#includes` - via joining relations and adding them to the `SELECT` statement (**breaking changes**)

* added `#preload` method which allows to load all listed relations after execution of main request

* new behavior of `#includes` is same as `#preload` (**breaking changes**)

* added `Jennifer::QueryBuilder::QueryObject` which designed to be as a abstract class for query objects for `Model::Base` scopes (**will be renamed in futher releases**)

* all query related objects are clonable

* now `GROUP` clause is placed right after the `WHERE` clause

* aggregation methods is moved to `Jennifer::QueryBuilder::Aggregations` module which is included in the `Query` class

* `Query#select` now accepts `Criteria` object, `Symbol` (which now will be transformed to corresponding `Criteria`), 'String' (which will be transformed to `RawSql`), string and symbol tuples, array of criterias and could raise a block with `ExpressionBuilder` as a current context (`Array(Criteria)` is expeted to be returned)

* `Query#group` got same behavior as `Query#select

* `Query#select` now accepts `Criteria` object, `Symbol` (which now will be transformed to corresponding `Criteria`), 'String' (which will be transformed to `RawSql`), string and symbol tuples, array of criterion and could raise a block with `ExpressionBuilder` as a current context (`Array(Criteria)` is expected to be returned)
* `Query#group` got same behavior as `Query#select`
* `Query#order` realize same idea as with `Query#select` but with hashes

* added `Criteria#alias` method wich allows to alias field in the `SELECT` clause

* `ExpressionBuilder#star` creates "all" attribute; allows optional argument specifing table name

* `RawSql` now has `@use_brakets` atttribute representing if sql statement should be surrounded by brackets

* added `Criteria#alias` method which allows to alias field in the `SELECT` clause
* `ExpressionBuilder#star` creates "all" attribute; allows optional argument specifying table name
* `RawSql` now has `@use_brakets` attribute representing if sql statement should be surrounded by brackets
* `Criteria#sql` method now accepts `use_brackets` argument which is passed to `RawSql`

**Migration**

* mysql got `#varchar` method for column definition

* added invoking of `TableBuilder::CreateMaterializedView` in `#create_materialized_view` method

* now `Jennifer::TableBuilder::CreateMaterializedView` accepts only `String` query

* added `#drop_materialized_view`

* added `CreateIndex`, `DropIndex`, `CreateView`, `DropView` classes and corresponding methods

**Record**
Expand All @@ -214,13 +208,9 @@
**Model**

* added `::context` method which return expression builder for current model

* added `::star` method which returns "all" criteria

* moved scope definition to `Scoping` module

* now scopes accepts `QueryBuilder::QueryObject` class name as a 2nd argument

* now object inserting into db use old variant with inserting and grepping last inserted id (because of bug with pg crystal driver)

**View**
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Passport < Jennifer::Model::Base
contact_id: Int32?
)
validates_with [EnnValidator]
validates_with EnnValidator
belongs_to :contact, Contact
end
Expand All @@ -119,7 +119,7 @@ class Profile < Jennifer::Model::Base
end
class FacebookProfile < Profile
sti_mapping(
mapping(
uid: String
)
Expand Down
Loading

0 comments on commit 0847244

Please sign in to comment.