Skip to content

@vladfaust vladfaust released this Mar 17, 2019

New Features

Infrastructure 🏭

  • (CI) cd7943b improve TravisCI build
  • (CI) 84734a8 build API docs on release tags only

Documentation 📚

  • 527caed state that only Array(T) is supported in Model.schema
Assets 2

@vladfaust vladfaust released this Mar 10, 2019 · 5 commits to master since this release

New Features

  • cd8c676 ⚠️ breaking not_null option for fields and references (closes #69)
  • (Query) b0cd32d ⚠️ breaking select * by default (closes #73)
  • (Query) 34d2a0e increased type-safety
  • (Query) 473d741 add select(nil) method (closes #78)
  • (Query) 6358068 add explicit #insert(name, value) method (closes #77)
  • 9799e94 bang getters to unsafely access variables

Deletions 🗑

  • (Query) f0d60b2 ⚠️ breaking #first and #last shortcuts

Bug Fixes 🐛

  • (Model::Changeset) 1fce652 disallow updating foreign references (fixes #72)
  • eeea14d use full paths to Model module in enums

Infrastructure 🏭

Documentation 📚

  • a129775 improve references to objects
  • (README) 3acc9e6 simplify
  • (README) b778d26 add Documentation section

Refactoring 📝

  • (Mapping) 94e7939 move checking enumerables to #initialize
  • (Query) 84d215f remove redundant check

Chores 🔧

Patrons 🕊

Assets 2

@vladfaust vladfaust released this Feb 20, 2019 · 24 commits to master since this release

Bug Fixes 🐛

  • (Model) d19ea13 allow default values in schema
Assets 2

@vladfaust vladfaust released this Feb 17, 2019 · 26 commits to master since this release

Bug Fixes 🐛

  • (Infrastructure) 0b5b0ca move deploy to separate build stage
Assets 2

@vladfaust vladfaust released this Feb 17, 2019 · 28 commits to master since this release

New Features

Assets 2
Pre-release

@vladfaust vladfaust released this Sep 15, 2018 · 41 commits to master since this release

Meet new Core rewritten from scratch! Featuring new schema declaration syntax, type-safe querying, spec splitting and overall code reduction!

Removed functionality:

  • Validations have been removed. Use external shard, e.g. validations.cr. Closes #46
  • Repository #insert, #update, #delete and all query other than #query methods are removed in favour of type safety, thus closing #47 and closing #61 and also closing #33. Use Schema#insert, Schema#update and Schema#delete instead
  • Converters concept has been liquidated, types now rely on #to_db and #from_rs methods via monkey patching, which closes #60

New schema declaration syntax (#58, #52)

Given SQL:

CREATE TABLE users(
  uuid UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name VARCHAR(100) NOT NULL,
  age INT,
  created_at TIMESTAMPTZ  NOT NULL DEFAULT NOW()
);

CREATE TABLE posts(
  id SERIAL PRIMARY KEY,
  author_uuid INT NOT NULL REFERENCES users (uuid),
  content TEXT NOT NULL,
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMPTZ
);

Crystal code:

require "pg"
require "core"

class User
  include Core::Schema

  schema users do
    pkey uuid : UUID # UUIDs are supported out of the box

    type name : String # Has NOT NULL in the column definition
    type age : Union(Int32 | Nil) # Doesn't have NOT NULL in the column definition
    type created_at : Time = DB::Default # Has DEFAULT in the column definition

    type posts : Array(Post), foreign_key: "author_uuid" # That is an implicit reference
  end
end

class Post
  include Core::Schema

  schema posts do
    pkey id : Int32

    type author : User, key: "author_id" # That is an explicit reference
    type content : String

    type created_at : Time = DB::Default
    type updated_at : Union(Time | Nil)
  end
end

Type-safe Query (#48)

Query's #insert, #join, #order_by, #returning, #select, #set and #where methods are now type-safe! It means that they would raise if passed invalid arguments in compilation time, e.g:

User.where(id: 42)
# Class 'User' doesn't have an attribute or reference with name 'id' defined in its schema eligible for 'Core::Query(User)#where' call

User.where(age: "18")
# Invalid type 'String' of argument 'age' for 'Core::Query(User)#where' call. Expected: 'Union(Int32 | Nil)'

user = User.new # Would raise because `name` is not null

user.insert # `Core::Query(User)` instance
# equals to
User.insert(name: "John")

user = repo.query(user.insert)
# or
repo.exec(user.insert)
Assets 2
Sep 19, 2018
fix: travis build
Sep 16, 2018
fix: minor bugfixes
Sep 15, 2018
overhaul
Meet new Core rewritten from scratch! Featuring new schema declaration syntax, type-safe querying, spec splitting and overall code reduction!

Removed functionality:

- Validations have been removed. Use external shards instead if needed. Closes #46
- Repository `#insert`, `#update`, `#delete` and all query other than `#query` methods are removed in favour of type safety, thus closing #47 and closing #61 and also closing #33
- Converters concept has been liquidated, types now rely on `#to_db` and `#from_rs` methods via monkey patching, which closes #60

New schema declaration syntax closes #58 and closes #52. Rewritten Query resolves #48. The overhaul itself closes #55 as well

Hope you guys enjoy it!

@vladfaust vladfaust released this Aug 26, 2018 · 61 commits to master since this release

New Features

  • b1fde0b add Converters::EnumArray
Assets 2
You can’t perform that action at this time.