Amberframework Granite Versions Save

ORM Model with Adapters for mysql, pg, sqlite in the Crystal Language.

v0.17.0

4 years ago

This release has some significant breaking changes to the DSL and leverages Annotations instead of the mutable constants and final macros. @Blacksmoke16 spent many months researching the use of Annotations and has overhauled Granite to take advantage of them.

In the process, we have decided to change the DSL to be more database centric. Here is a list of the breaking changes:

  • Adapters are now added to Granite::Connections array instead of Granite::Adapters
  • the adapter macro was renamed to connection
  • the table_name macro was renamed to table
  • the field macro was renamed to column
  • the primary macro was changed into a flag primary: true on the column macro
  • a primary id field is no longer added by default
  • a column can be declared as Nilable using ?

Here is an example of how to register a new connection:

Granite::Connections << Granite::Adapter::Mysql.new(name: "mysql", url: "YOUR_DATABASE_URL")

Here is an example of a model:

require "granite/adapter/mysql"

class Post < Granite::Base
  connection mysql
  table posts # Name of the table to use for the model, defaults to class name snake cased

  column id : Int64, primary: true # Primary key, defaults to AUTO INCREMENT
  column name : String? # Nilable field
  column body : String # Not nil field
end

Other changes:

  • a866c10 Crystal v0.30.0 support (#354) by @bcardiff
  • 9a2d4fe Count group by fixed (#352) by @unequaled86
  • bdb879f Port Granite to use Annotations (#346) by @Blacksmoke16
  • ce37f7a require "uuid" in fields.cr (#350) by @EnricoMonese
  • c4bc435 Update CRUD delete example code (#348) by @EnricoMonese
  • b2754fc replace @@var with their getter (#345) by @Blacksmoke16
  • 6f2e6a3 Adds an exists? class method (#343) by @Blacksmoke16
  • 82cb04e Support custom field types (#342) by @Blacksmoke16
  • bc68440 Disallow union types (#341) by @Blacksmoke16

v0.16.0

4 years ago
  • d9ab302 fixes for crystal 0.29.0 (#338) by @drujensen
  • f4efb63 Find or create by (and find or initialize by) (#336) by @AndyRosenberg
  • d5e4122 document on_to_json/yaml (#335) by @Blacksmoke16
  • 46cafcd docs/relationships.md: add example many to many insert (#332) by @nathanj
  • 70afa14 Some updates for Crystal 0.28.0 (#330) by @Blacksmoke16
  • 2de9e89 Extract Migrator#create and #drop sql into separate methods (#326) by @Jens0512
  • db6b5ed Make primary_type return the class type vs string (#325) by @Blacksmoke16
  • 75e8473 Do not update created_at on update (#324) by @Blacksmoke16
  • 040f1c1 Pass annotations from a belongs_to to the resulting field (#323) by @Blacksmoke16
  • e9f8fe9 Make Granite::Base abstract (#322) by @Blacksmoke16
  • 2a8bb18 Raise NilAssertionError on nil value (#321) by @Blacksmoke16
  • 9b2991c Logger optimization (#315) by @Blacksmoke16

v0.15.2

5 years ago

Support default values (#312) @Blacksmoke16 Add colors to logged queries (#311) @Blacksmoke16 Implement #touch (#314) @Blacksmoke16 Support array IN queries with query builder (#313) @Blacksmoke16

v0.15.1

5 years ago

add timezone support #310 - @icyleaf Association improvements #307 - @Blacksmoke16

v0.15.0

5 years ago

Include clause when using custom select statement - #305 by @hfjallemark Belongs_to refactor - #304 by @Blacksmoke16 Use env vars to specify sqlite version - #303 by @Blacksmoke16 Crystal 0.27.0 - #302 by @Blacksmoke16 Only define updated/created_at properties if they are wanted - #301 by @Blacksmoke16 Fix Assembler#count - #299 by @c910335 Add support for AND and OR clause - #297 by @drujensen Test PG11 on travis - #294 by @Blacksmoke16 Better UUID support - #293 by @Blacksmoke16

v0.14.2

5 years ago

Query Builder support Mysql and Sqlite (#285) @drujensen Support PG Array Types (#286) @Blacksmoke16 Crystal 0.26.1 Support (#288) @Blacksmoke16 Annotation Support (#289) @Blacksmoke16 Extend Query Builder (#290) @drujensen Update Query Documentation (#292) @drujensen

v0.14.1

5 years ago

Add limit and offset to QueryBuilder, mild refactoring (#284) @c910335 Refactored the validator helpers and added exclusion validator (#283) @Thellior add spaces (#281) @drujensen list the documentation instead of the docs directory (#280) @drujensen

v0.14.0

5 years ago

Clear errors before validating models (#279) @yumoose

Breaking Changes

Dj/129 has many (#278) @drujensen

v0.13.1

5 years ago

Dj/lazy load connection (#277) @drujensen Test multiple databases (#270) @Thellior Example for String foreign_key (#265) @winhackua Dj/271 maintain one database connection (#274) @drujensen Has one relationship (#264) @zaidakram Make the "through class" a symbol (#269) @Hansterdam

v0.13.0

5 years ago

Targeting Crystal 0.26 (#268 thanks @robacarp) Fix time parsing on Crystal 26.0 (#267 thanks @msa7) Adapter Registration Support (#257 thanks @Blacksmoke16) add nodoc to granite methods generated by macros (#261 thanks @Blacksmoke16) Adds support for YAML::Serializable (#255 thanks @Blacksmoke16) Fix wording on dep install (#259 thanks @drinkmorewaters) Split docs into smaller files (#256 thanks @Blacksmoke16) Adds support for JSON::Serializable (#253 thanks @Blacksmoke16) - Breaking change fix conflicting use of query (#247 thanks @drujensen) - Breaking change Update database docker (#241 thanks @Thellior) Add ameba, fix style errors (#240 thanks @Thellior) Adding transaction save!, create!, destroy! methods (#232, thanks @Thellior)