Releases: amberframework/granite
Handle string conversion and errors
e2784bf Handle string conversion & conversion errors (#357) by @Blacksmoke16
Crystal 0.30.0 and DSL breaking changes
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 ofGranite::Adapters
- the
adapter
macro was renamed toconnection
- the
table_name
macro was renamed totable
- the
field
macro was renamed tocolumn
- the
primary
macro was changed into a flagprimary: true
on thecolumn
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
Crystal 0.29.0 Support
- 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
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
v.0.15.0
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
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
v0.14.0
v0.13.1
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