diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 000000000..73cf55c3b --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,13 @@ +## Core developer + +- Yacine Petitprez (anykeyh@gmail.com) + +## Thanks to + +- 007lva (007.lva@gmail.com) +- Jeremy Woertink (jeremywoertink@gmail.com) +- Matthias Zauner (sagishi@zive.at) +- Russ Smith (russ@bashme.org) +- Troy A. Sornson (troyasornson37@gmail.com) + +For contributing to a better ~world~ ORM. \ No newline at end of file diff --git a/README.md b/README.md index bbf929c45..94c33569e 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,7 @@ You don't want to use Clear if: - [Source Code](https://github.com/anykeyh/clear) - [A simple example is available here](https://github.com/anykeyh/clear/blob/master/sample/wiki/getting_started.cr) - [Changelog](https://github.com/anykeyh/clear/blob/master/CHANGELOG.md) - - +- [Credits](https://github.com/anykeyh/clear/tree/master/CONTRIBUTORS.md) ## Getting started diff --git a/manual/README.md b/manual/README.md index e51f0608d..0b28bd3c0 100644 --- a/manual/README.md +++ b/manual/README.md @@ -22,6 +22,7 @@ If you're in hurry and already at ease with Active Record pattern, a simple stan - [Polymorphism](model/Polymorphism.md) - [Different database connections](model/MultiConnection.md) - [Column data type management](model/TypeConversion.md) +- [SQL Debugging Info](model/DebuggingInfo.md) ## Querying diff --git a/manual/model/DebuggingInfo.md b/manual/model/DebuggingInfo.md new file mode 100644 index 000000000..2cbc65d9a --- /dev/null +++ b/manual/model/DebuggingInfo.md @@ -0,0 +1,36 @@ +#### Inspection + +We've reimplemented `inspect` on models, to offer debugging insights: + +```text + pp post # => #, + @content_column= + "...", + @errors=[], + @id_column=38, + @persisted=true, + @published_column=true, + @read_only=false, + @title_column="Lorem ipsum torquent inceptos"*, + @user_id_column=5> +``` + +In this case, the `*` means a column is changed and the object is dirty and must +be saved on the database. + +#### SQL Logging + +Clear is offering SQL logging tools, with SQL syntax colorizing in your terminal. +For activation, simply setup the logger to `DEBUG` level + +``` +Clear.logger.level = ::Logger::DEBUG +``` + +Also, Clear will log all query made, and when exception will show you the last query +in your terminal. \ No newline at end of file diff --git a/src/clear/extensions/enum/enum.cr b/src/clear/extensions/enum/enum.cr index c413ce231..e540d6573 100644 --- a/src/clear/extensions/enum/enum.cr +++ b/src/clear/extensions/enum/enum.cr @@ -53,7 +53,7 @@ module Clear # ``` macro enum(name, *values) struct {{name.id}} < ::Clear::Enum - AUTHORIZED_VALUES = {} of String => {{name.id}} + private AUTHORIZED_VALUES = {} of String => {{name.id}} {% for i in values %} {{i.camelcase.id}} = {{name.id}}.new("{{i.id}}") @@ -75,6 +75,10 @@ module Clear AUTHORIZED_VALUES.values end + def self.valid?(x) + AUTHORIZED_VALUES[x]? + end + macro finished module ::Clear::Model::Converter::\{{@type}}Converter def self.to_column(x) : ::\{{@type}}?