clear v0.4 Release Notes
Release Date: 2018-11-12 // over 5 years ago-
๐ Features
#48 Add
lateral join
feature:Model.query.left_join("other_model", lateral: true){ model.id == other_model.model_id }
#35 Add methods
import
over collection, to be able to insert multiple objects with one query:user_array = 10.times.map{ |x| User.new(name: "user#{x}") } Model.import(user_array)
๐ #42 Add support of
ON CONFLICT
both inInsert
andModel#save
u = User.new(id: 1, first_name: "me") u.save! &.on_conflict("(id)").do_update(&.set("first_name = excluded.first_name").where { model_users.id == excluded.id })
- Note: Method
Model#import
explained above can use the same syntax to resolve conflict.
This will helps to use Clear for import, CSV and batch processing.
- Note: Method
๐ #26 Add
to_json
supports to model. Please note that some core lib and shardspg
objects got
๐ extended to allow this support:- By default, undefined fields are not exported. To export all columns even thoses which are not fetched in SQL, use
full: true
. For example:
User.query.first!.to_json # => {"id":1, "first_name":"Louis", "last_name": "XVI"}User.query.select("id, first_name").first!.to_json # => {"id":1, "first_name":"Louis"}User.query.select("id, first_name").first!.to_json(full: true) # => {"id":1, "first_name":"Louis", "last_name": null}
- By default, undefined fields are not exported. To export all columns even thoses which are not fetched in SQL, use
๐ Bug fixes
- Escaping table, columns and schema name to allow Clear to works on any SQL restricted names.
- This is very demanding work as it turns out table and columns naming are used everywhere
in the ORM. Please give me feedback in case of any issues !
- This is very demanding work as it turns out table and columns naming are used everywhere
- ๐ Fix #31, #36, #38, #37
- ๐ Fix issue with polymorphic table
๐ฅ Breaking changes
- Renaming
insert
method onInsertQuery
tovalues
, making API more elegant. Usage of
var
in Expression engine has been changed and is now different from raw:var
provide simple way to construct[schema].table.field
structure,
with escaped table, field and schema keywords.raw
works as usual, printing the raw string fragment to you condition.- Therefore:
where{ var("a.b") == 1 } # Wrong now! => WHERE "a.b" = 1# Must be changed by: where{ var("a", "b") == 1 } # OR where{ raw("a.b") }
TL;DR, if you currently use
var
function, please useraw
instead from now.- ๐ Revamping the converter system, allowing to work seemlessly with complexes types like Union and Generic
- Documentation will follow soon.