Skip to content

v0.4

Compare
Choose a tag to compare
@anykeyh anykeyh released this 12 Nov 11:27
· 367 commits to master since this release
db9da98

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 in Insert and Model#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.
  • #26 Add to_json supports to model. Please note that some core lib and shards pg 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}

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 !
  • Fix #31, #36, #38, #37
  • Fix issue with polymorphic table

Breaking changes

  • Renaming insert method on InsertQuery to values, 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 use raw instead from now.
  • Revamping the converter system, allowing to work seemlessly with complexes types like Union and Generic
    • Documentation will follow soon.