Jennifer.cr Versions Save

Crystal ORM using ActiveRecord pattern with flexible query DSL

v0.4.1

6 years ago

Config

  • added port configuration

  • ::reset_config resets to default configurations

  • added validation for adapter and db

  • ::from_uri allows to load onfiguration 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

  • #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

  • added #find_by_sql similar to Query#find_records_by_sql

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

v0.4.0

6 years ago

Most important changes are new Query#select, Query#order, Query#group behavior and added View support.

Exception

  • BadQuery now allows to append query body to the main error text

Adapter

  • added #view_exists?(name)

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#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

  • 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

  • added attribute(name : String, type : T.class) method

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

  • added view support for both mysql and postgres - name of abstract class for inheritance Jennifer::View::Base

v0.3.4

6 years ago

Change log:

  • General:
    • now logger also contains information about query execution time
  • Model
    • now #save and #destroy wrap operation into transaction; if current connection already is under transaction - will be performed within it
    • proper column count for each model grepped from DB; this is important because of non strict mapping usage
    • now could be used for mapping materialized view as well (postgres only); is a temporary solution - in future all views will have own proper parent class
    • all further callback execution will be stopped after raising Jennifer::Skip exception
    • if field declared type is different from one in the result set - Jennifer::DataTypeMismatch exception will be raised
    • if there is some undefined column in result set - Jennifer::BaseException with descriptive message will be raised (for strict mapping only)
    • added raising exception for missing defined field in the result set, casting from nil value to Union without it
    • now model without primary key is not allowed
    • adding dependent option to has_many, belongs_to, has_one relations
    • now empty relation will not be reloaded each time it is called for one object
  • Query
    • added #union method which accepts another query object
    • update and delete request now can have joins
    • renamed #to_sql method to #as_sql
    • added #to_sql method for Query which will return generated sql request
    • added #between operator
    • added json path extractor operators (for mysql and postgres)
    • added #none method
    • added #preload
  • Adapter
    • extended officially supported data types (for mysql and postgres)
    • added #refresh_materialized_view method which will refresh materialized view with given name (postgres only)
    • added #material_view_exists which represent existence of materialized view (postgres only)
    • added Jennifer::Record structure; now all responses for Jennifer::QueryBuilder::Query execution results will be dumbed to it; this struct allow to access fields using #[] or even by attribute name
  • Migration
    • added #create_materialized_view - will create materialized view depending on passed query object (postgres only; purly tested)
    • added method for each data type for creating table
    • now running db:migrate without any migration defined will do nothing (instead of raising compile time exception)

v0.3.3

6 years ago
  • moved readme to wiki
  • extend callback worflow
  • extend query dsl
  • add workaround for mysql DateTime
  • start moving sql generating to separate class
  • add locking

v0.3.2

6 years ago
  • added pg array support and 3 array operators for sql generating
  • added script to generate docs

v0.3.1

6 years ago
  • added ENUM support
  • added aggregation functions
  • added dumping database schema to sql file
  • extended sam commands
  • made breaking changes to migration API
  • changed names for PlainQuery and Query(T)
  • bugs fixing

v0.3.0

7 years ago
  • added many-to-many relation
  • fixed transaction and concurrency
  • added callbacks
  • added validations
  • improved relation API
  • added way to fast clean db in test mode
  • extended configs
  • extended query dsl - now it is even more flexible
  • a lot of bug were fixed

v0.2.3

7 years ago

All logic of sql generation were moved to adapters and this allowed to add several adapters (like sweet postgres).

v0.2.1

7 years ago
  • extends query DSL
  • refactor model - move some staff to Relation

v0.2.0

7 years ago

Initial version. Not fully covered with test so couldn't be used for production. But now it is on her first release :tada: :balloon: