+
+ 404 Not Found +
+ ++ This page is unavailable in this version of the API docs. +
+ ++ You can use the sidebar to search for your page, or try a different + Crystal version. +
+ +diff --git a/404.html b/404.html new file mode 100644 index 000000000..253e98230 --- /dev/null +++ b/404.html @@ -0,0 +1,1532 @@ + + +
+ + + + + + + + + + + + + ++ This page is unavailable in this version of the API docs. +
+ ++ You can use the sidebar to search for your page, or try a different + Crystal version. +
+ +A BigDecimal
can represent arbitrarily large precision decimals.
It is internally represented by a pair of BigInt
and UInt64
: value and scale.
+Value contains the actual value, and scale tells the decimal point place.
+E.g. when value is 1234
and scale 2
, the result is 12.34
.
NOTE To use BigDecimal
, you must explicitly import it with require "big"
The general idea and some of the arithmetic algorithms were adapted from +the MIT/APACHE-licensed bigdecimal-rs.
+ + + + + +A Char
represents a Unicode code point.
+It occupies 32 bits.
It is created by enclosing an UTF-8 character in single quotes.
+'a'
+'z'
+'0'
+'_'
+'あ'
+You can use a backslash to denote some characters:
+'\'' # single quote
+'\\' # backslash
+'\e' # escape
+'\f' # form feed
+'\n' # newline
+'\r' # carriage return
+'\t' # tab
+'\v' # vertical tab
+You can use a backslash followed by an u and four hexadecimal characters to denote a unicode codepoint written:
+'\u0041' # == 'A'
+Or you can use curly braces and specify up to four hexadecimal numbers:
+'\u{41}' # == 'A'
+See Char
literals in the language reference.
Represents a case insensitive text, used by Postgres +Wrap a string and basically change the equality check to make it case insensitive.s
+ + + + + + + + + + + + + + +::Log.for("clear")
+ {{ (`shards version /home/runner/work/clear/clear/src/clear`).chomp.stringify }}
+ Register a seed block.
Check for the CLI.
Register a type to allow use in Clear column system.
Register a seed block.
+this block will be called by Clear.apply_seeds
+or conveniently by the CLI
+using $cli_cmd migrate seeds
Check for the CLI. If the CLI is not triggered, yield the block passed as parameter
+Clear offers full support of postgres enum strings.
+Let's say you need to define an enum for genders:
+# Define the enum
+Clear.enum MyApp::Gender, "male", "female" # , ...
+In migration, we tell Postgres about the enum:
+create_enum :gender, MyApp::Gender # < Create the new type `gender` in the database
+
+create_table :users do |t|
+ # ...
+ t.gender "gender" # < first `gender` is the type of column, while second is the name of the column
+end
+Finally in your model, simply add the enum as column:
+class User
+ include Clear::Model
+ # ...
+
+ column gender : MyApp::Gender
+end
+Now, you can assign the enum:
+u = User.new
+u.gender = MyApp::Gender::Male
+You can dynamically check and build the enumeration values:
+MyApp::Gender.authorized_values # < return ["male", "female"]
+MyApp::Gender.all # < return [MyApp::Gender::Male, MyApp::Gender::Female]
+
+MyApp::Gender.from_string("male") # < return MyApp::Gender::Male
+MyApp::Gender.from_string("unknown") # < throw Clear::IllegalEnumValueError
+
+MyApp::Gender.valid?("female") # < Return true
+MyApp::Gender.valid?("unknown") # < Return false
+However, you cannot write:
+u = User.new
+u.gender = "male"
+But instead:
+u = User.new
+u.gender = MyApp::Gender::Male
+ Register a type to allow use in Clear column system. +Type must include JSON::Serializable. +More info about how to use JSON::Serializable it can be found here
+Clear.json_serializable_converter(MyJsonType)
+
+# ...
+
+class YourModel
+ include Clear::Model
+ # ...
+ column my_column : MyJsonType # jsonb (recommended), json or string column in postgresql.
+end
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__version__" => {kind: "bool", type: "Bool", default: "false", description: {"--version", "Displays the version of the current application."}, short: "nil", long: "version", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{"name" => {type: "String", description: {"name", ""}, default: "nil", is_required: false}} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}, "directory" => {kind: "nil", type: "String", default: "\".\"", description: {"--directory, -d (default: \".\")", "Set target directory"}, short: "d", long: "directory", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{"name" => {type: "String", description: {"name", ""}, default: "nil", is_required: false}} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}, "directory" => {kind: "nil", type: "String", default: "\".\"", description: {"--directory, -d (default: \".\")", "Set target directory"}, short: "d", long: "directory", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{"name" => {type: "String", description: {"name", ""}, default: "nil", is_required: false}} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "directory" => {kind: "nil", type: "String", default: "\".\"", description: {"--directory, -d (default: \".\")", "Set target directory"}, short: "d", long: "directory", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{"migration_number" => {type: "Int64", description: {"migration_number (required)", ""}, default: "nil", is_required: true}} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{"num" => {type: "Int64", description: {"num", ""}, default: "nil", is_required: false}} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{"to" => {type: "Int64", description: {"to (required)", ""}, default: "nil", is_required: true}} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "direction" => {kind: "nil", type: "String", default: "\"both\"", description: {"--direction, -d (default: \"both\")", ""}, short: "d", long: "direction", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{"migration_number" => {type: "Int64", description: {"migration_number (required)", ""}, default: "nil", is_required: true}} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ {"description" => ""}
+ Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
You can access names arguments by name.
+You can also access the remaning arguments using .arguments[index]
.
Returns the commands Flags
object.
You can access names flags by name.
+The run command.
+Invokes a sub command by name, passing self
as the parent.
{} of String => NamedTuple(type: String, description: Tuple(String, String | ::Nil), default: String, is_required: Bool)
+ Extend the flags struct to include the flag
+ + + + + + + + + + + + + + +{} of String => String
+ {"verbose" => {kind: "bool", type: "Bool", default: "false", description: {"--verbose, -v", "Display verbose informations during execution"}, short: "v", long: "verbose", is_required: true}, "no_color" => {kind: "bool", type: "Bool", default: "false", description: {"--no-color", "Cancel color output"}, short: "nil", long: "no-color", is_required: true}, "__help__" => {kind: "bool", type: "Bool", default: "false", description: {"--help", "Displays help for the current command."}, short: "nil", long: "help", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)
+ Clear::Enum wrap the enums used in PostgreSQL.
+See Clear.enum
macro helper.
Returns true
if this struct is equal to other.
Returns a nicely readable and concise string representation of this object, typically intended for users.
Clear::Expression::Literal
Returns true
if this struct is equal to other.
Both structs' instance vars are compared to each other. Thus, two +structs are considered equal if each of their instance variables are +equal. Subclasses should override this method to provide specific +equality semantics.
+struct Point
+ def initialize(@x : Int32, @y : Int32)
+ end
+end
+
+p1 = Point.new 1, 2
+p2 = Point.new 1, 2
+p3 = Point.new 3, 4
+
+p1 == p2 # => true
+p1 == p3 # => false
+ Returns a nicely readable and concise string representation of this object, +typically intended for users.
+This method should usually not be overridden. It delegates to
+#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.
This module list most of the runtime errors happening in Clear. +It's an attempt to make Clear user friendly by enabling advanced resolution +of problems when they raise.
+ + + + + + + +The goal of this module is to offer the most natural way to write down your +query in crystal.
+If you're familiar with Sequel on Ruby, then here you have !
+Instead of writing:
+model_collection.where("created_at BETWEEN ? AND ?", 1.day.ago, DateTime.local)
+You can write:
+model_collection.where { created_at.between(1.day.ago, DateTime.local) }
+or even:
+model_collection.where { created_at.in?(1.day.ago..DateTime.local) }
+(Note for the later, it will generate created_at > 1.day.ago AND created_at < DateTime.local
)
Due to the use of missing_method
macro, some case can be confusing.
id = 1
+model_collection.where { id > 100 } # Will raise an error, because the expression is resolved by Crystal !
+# Should be:
+id = 1
+model_collection.where { var("id") > 100 } # Will works
+And/Or can be used using the bitwises operators &
and |
.
+Due to the impossibility to reuse ||
and &&
, beware the operator precendance
+rules are changed.
# v-- This below will not works, as we cannot redefine the `or` operator
+model_collection.where { first_name == "yacine" || last_name == "petitprez" }
+# v-- This will works, but beware of the parenthesis between each terms, as `|` is prioritary on `==`
+model.collection.where { (firt_name == "yacine") | (last_name == "petitprez") }
+# ^-- ... WHERE first_name = 'yacine' OR last_name == ''
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "%Y-%m-%d"
+ "%Y-%m-%d %H:%M:%S.%L %:z"
+ A fast way to call self.safe_literal
See .safe_literal(x : _)
This method will raise error on compilation if discovered in the code.
In case the name of the variable is a reserved word (e.g.
In case the name of the variable is a reserved word (e.g.
See self.raw
Can pass an array to this version
Transform multiple objects into a string which is SQL-Injection safe.
Safe literal of a time return a string representation of time in the format understood by postgresql.
Sanitize an object and return a String
representation of itself which is proofed against SQL injections.
Return unsafe string injected to the query.
Return a node of the expression engine This node can then be combined with others node in case of chain request creation where {...}.where {...}
through the chaining engine
NOT
operator
Because many postgresql operators are not transcriptable in Crystal lang, this helpers helps to write the expressions:
In case the name of the variable is a reserved word (e.g.
In case the name of the variable is a reserved word (e.g.
Use var to create expression of variable.
A fast way to call self.safe_literal
+See .safe_literal(x : _)
This method will raise error on compilation if discovered in the code. +This allow to avoid issues like this one at compile type:
+id = 1
+# ... and later
+User.query.where { id == 2 }
+In this case, the local var id will be evaluated in the expression engine. +leading to buggy code.
+Having this method prevent the code to compile.
+To be able to pass a literal or values other than node, please use #raw
+method.
In case the name of the variable is a reserved word (e.g. #not
, #var
, #raw
)
+or in case of a complex piece of computation impossible to express with the expression engine
+(e.g. usage of functions) you can use then raw to pass the String.
BE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.
+having { raw("COUNT(*)") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5
+where { raw("func(?, ?) = ?", a, b, c) } # SELECT ... FROM ... WHERE function(a, b) = c
+ In case the name of the variable is a reserved word (e.g. #not
, #var
, #raw
)
+or in case of a complex piece of computation impossible to express with the expression engine
+(e.g. usage of functions) you can use then raw to pass the String.
BE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.
+having { raw("COUNT(*)") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5
+where { raw("func(:a, :b) = :c", a: a, b: b, c: c) } # SELECT ... FROM ... WHERE function(a, b) = c
+ See self.raw
+Can pass an array to this version
Transform multiple objects into a string which is SQL-Injection safe.
+Safe literal of a time return a string representation of time in the format understood by postgresql.
+If the optional parameter date
is passed, the time is truncated and only the date is passed:
Clear::Expression[Time.local] # < "2017-04-03 23:04:43.234 +08:00"
+Clear::Expression[Time.local, date: true] # < "2017-04-03"
+ Sanitize an object and return a String
representation of itself which is proofed against SQL injections.
Return unsafe string injected to the query.
+can be used for example in insert
query building
Return a node of the expression engine
+This node can then be combined with others node
+in case of chain request creation where {...}.where {...}
+through the chaining engine
NOT
operator
Return an logically reversed version of the contained Node
Clear::Expression.where { not(a == b) }.resolve # >> "WHERE NOT( a = b )
+ Because many postgresql operators are not transcriptable in Crystal lang, +this helpers helps to write the expressions:
+where { op(jsonb_field, "something", "?") } # << Return "jsonb_field ? 'something'"
+ In case the name of the variable is a reserved word (e.g. #not
, #var
, #raw
)
+or in case of a complex piece of computation impossible to express with the expression engine
+(e.g. usage of functions) you can use then raw to pass the String.
BE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.
+having { raw("COUNT(*)") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5
+where { raw("func(?, ?) = ?", a, b, c) } # SELECT ... FROM ... WHERE function(a, b) = c
+ In case the name of the variable is a reserved word (e.g. #not
, #var
, #raw
)
+or in case of a complex piece of computation impossible to express with the expression engine
+(e.g. usage of functions) you can use then raw to pass the String.
BE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.
+having { raw("COUNT(*)") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5
+where { raw("func(:a, :b) = :c", a: a, b: b, c: c) } # SELECT ... FROM ... WHERE function(a, b) = c
+ Use var to create expression of variable. Variables are columns with or without the namespace and tablename:
+It escapes each part of the expression with double-quote as requested by PostgreSQL.
+This is useful to escape SQL keywords or .
and "
character in the name of a column.
var("template1", "users", "name") # "template1"."users"."name"
+var("template1", "users.table2", "name") # "template1"."users.table2"."name"
+var("order") # "order"
+ Bool | Clear::Expression::Literal | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil
+
+
+
+
+
+
+
+
+
+
+
+
+ Allow any type to be used into the expression engine
+by including the module Clear::Expression::Literal
+and defining the method #to_sql
.
Mother class of all the rendering nodes
+ + + + + +Clear::Expression::JSONB::Node
A node managing the rendering of (var BETWEEN a AND b)
+expressions.
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
Clear::Expression::Node | Float32 | Float64 | Int32 | Int64 | String | Time
+
+
+
+
+
+
+
+
+
+
+
+
+ A node managing the rendering of
+combination operations like <val1> <op> <val2>
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing the rendering of functions in Postgres.
+ + + + + + + + + + + + + + +Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing the rendering of array in Postgres.
+val IN (...)
.FALSE
instead.Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing the rendering a range in Postgres.
+Example:
+value.in?(1..5)
+will render:
+value >= 1 AND value < 5
+Inclusion and exclusion of the last number of the range is featured
+ + + + + + + + + + + + + + +Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing the rendering of value IN ( <SUBQUERY> )
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
Define a array contains? (?) operation between a jsonb column and a json hash
+ + + + + + + + + + + + + + +Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
Define a value match? (@>) operation between a jsonb column and a json hash
+ + + + + +Clear::SQL::JSONB
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
Clear::SQL::JSONB
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
Management of rendering of literal values.
+ + + + + + + + + + + + + + +Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing the unary -
operator.
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
This node is used to generate expression like ( a AND b AND ... AND k )
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing the unary NOT
operator.
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing the rendering of (var NOT BETWEEN a AND b)
+expressions.
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
Clear::Expression::Node | Float32 | Float64 | Int32 | Int64 | String | Time
+
+
+
+
+
+
+
+
+
+
+
+
+ Render NULL !
+ + + + + + + + + + + + + + +Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A node managing PG structure array[args...]
+Named PGArray instead of Array to avoid issue with naming
Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
This node manage the rendering of a raw SQL fragment.
+ + + + + + + + + + + + + + +Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
A variable AST node. +It's what's created under the hood when you use a non-existent variable:
+where { users.id != nil }
+
+will produce this tree:
+
+# => double_operator('<>')
+# # => variable('id', parent: 'users')
+# # => null
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Clear::Expression::Node
Clear::Expression::Node
Clear::Expression::JSONB::Node
Wrap an unsafe string. Useful to cancel-out the +safe_literal function used internally. +Obviously, this can lead to SQL injection, so beware!
+ + + + + +Returns a nicely readable and concise string representation of this object, typically intended for users.
Clear::Expression::Literal
Returns a nicely readable and concise string representation of this object, +typically intended for users.
+This method should usually not be overridden. It delegates to
+#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.
It can be converted automatically from/to a interval
column.
class MyModel
+ include Clear::Model
+
+ column interval : Clear::TimeInDay
+end
+
+interval = Clear::Interval.new(60.days)
+record = MyModel.create!(interval: interval)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ For PG::Interval
For PG::Interval
Migrations in Clear are very similar to active record's migrations. +Migrations are two-way modification of the database.
+It helps to keep a consistent database state during development lifecycle +of your application.
+To create a migration, two ways:
+You can create a new file which will be present in src/db/migrate
using:
clear-cli migration:g migration_name
Thus will create a migration in src/db/migration/[:uid]_migration_name.cr
+(with uid number) and a class MigrationName
You can use clear-cli migration help
to get advanced options.
You can create a class following this naming convention:
+Anything + Number.
+The number is then used to order the migration between each others and must be unique.
Following the rule than inclusion is often better than inheritance, just
+include the module Clear::Migration
to your class.
Only one method must be overrided: change
. In comparison to ActiveRecord, there's no
+up and down methods, instead you can put specific up/down code like this:
def change(dir)
+ dir.down { irreversible! }
+end
+def change(dir)
+ add_column :users, :full_name, :string
+
+ dir.up do
+ execute("UPDATE users SET full_name = (SELECT first_name || ' ' || last_name) from users")
+ end
+end
+
+
+
+
+
+ ::Log.for("clear.migration")
+ Clear::Migration::Helper
Clear::Migration::Helper
Clear::Migration::FullTextSearchableHelpers
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
0
+ 1
+ Run the block given in parameter if the direction is a rollback
Return true whether the migration is a rollback
Run the block given in parameter if the direction is a upstream
Return true whether the migration is a upstream
Run the block given in parameter if the direction is a rollback
+Return true whether the migration is a rollback
+Run the block given in parameter if the direction is a upstream
+Return true whether the migration is a upstream
+Clear::Migration::Operation
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Add a tsvector
field to a table.
Add a tsvector
field to a table.
+Create column, index and trigger.
Clear::Migration::Operation
Clear::ErrorMessages
'B'
+ 'D'
+ 'C'
+ 'A'
+ {"string" => "text", "int32" => "int", "int64" => "bigint", "long" => "bigint", "bigdecimal" => "numeric", "datetime" => "timestamp without time zone"}
+ Replace some common type to their equivalent in postgresql if the type is not found in the correspondance table, then return itself
Add a column to a specific table
This will apply the migration in a given direction (up or down)
Add a column to a specific table
Helper used in migration to create a new table.
Clear::Migration::FullTextSearchableHelpers
Replace some common type to their equivalent in postgresql +if the type is not found in the correspondance table, then return +itself
+Add a column to a specific table
+This will apply the migration in a given direction (up or down)
+Helper used in migration to create a new table.
+Usage:
+create_table(:users) do |t|
+ t.column :first_name, :string
+ t.column :last_name, :string
+ t.column :email, :string, unique: true
+ t.timestamps
+end
+By default, a column id
of type integer
will be created as primary key of the table.
+This can be prevented using primary: false
create_table(:users, id: false) do |t|
+ t.column :user_id, :integer, primary: true # Use custom name for the primary key
+ t.column :first_name, :string
+ t.column :last_name, :string
+ t.column :email, :string, unique: true
+ t.timestamps
+end
+ This error is throw when you try to revert a migration which is irreversible.
+ + + + + + + + + + + + + + +The migration manager is a singleton, it load all the migrations,
+check which one are #up
and #down
, and can trigger one or multiple
+downgrade / upgrade of the database.
The migration system needs the creation of a table named __clear_metadatas
+in your database. This table will be created automatically on the first
+initialization of the Migration Manager.
"1"
+ Used to migrate between metadata version, in case we need it in the future.
+To access to the manager
Apply all the migrations not yet applied.
Return true
if the migration has been commited (already applied into the database) or false
otherwise
Force down a migration; throw error if the mgiration is already down
Create if needed the metadata table to save the migrations.
Fetch the migration instance with the selected number
Fetch all the migrations already activated on the database.
Print out the status ( up | down ) of all migrations found by the manager.
Force reloading the migration system Recheck all the current up migrations and the metadata table.
Force up a migration; throw error if the migration is already up
Clear::ErrorMessages
To access to the manager
+Clear::Migration::Manager.instance
+ Apply all the migrations not yet applied.
+Return true
if the migration has been commited (already applied into the database)
+or false
otherwise
Force down a migration; throw error if the mgiration is already down
+Create if needed the metadata table +to save the migrations.
+Fetch the migration instance with the selected number
+Fetch all the migrations already activated on the database.
+Print out the status ( up | down ) of all migrations found by the manager.
+Force reloading the migration system +Recheck all the current up migrations +and the metadata table. +This is useful if you access to the migration process +through another program, or during specs
+Force up a migration; throw error if the migration is already up
+Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Clear::Migration::Operation
Clear::ErrorMessages
Reopen Table to add the helpers
+ + + + + +DEPRECATED Method missing is used to generate add_column using the method name as column type (ActiveRecord's style)
Add/alter a column for this table.
Add or replace an index for this table.
Add the timestamps to the field.
Clear::Migration::FullTextSearchableTableHelpers
Clear::Migration::Operation
Clear::ErrorMessages
DEPRECATED +Method missing is used to generate add_column using the method name as +column type (ActiveRecord's style)
+Add/alter a column for this table.
+Add or replace an index for this table.
+Alias for add_index
Add the timestamps to the field.
+Model definition is made by adding the Clear::Model
mixin in your class.
class MyModel
+ include Clear::Model
+
+ column my_column : String
+end
+We just created a new model, linked to your database, mapping the column my_column
of type String (text
in postgres).
Now, you can play with your model:
+row = MyModel.new # create an empty row
+row.my_column = "This is a content"
+row.save! # insert the new row in the database !
+By convention, the table name will follow an underscore, plural version of your model: my_models
.
+A model into a module will prepend the module name before, so Logistic::MyModel
will check for logistic_my_models
in your database.
+You can force a specific table name using:
class MyModel
+ include Clear::Model
+ self.table = "another_table_name"
+end
+Unlike many ORM around, Clear carry about non-nullable pattern in crystal. Meaning column my_column : String
assume than a call to row.my_column
will return a String.
But it exists cases where the column is not yet initialized:
+For example, this code will compile:
+row = MyModel.new # create an empty row
+puts row.my_column
+However, it will throw a runtime exception You cannot access to the field 'my_column' because it never has been initialized
Same way, trying to save the object will raise an error:
+row.save # Will return false
+pp row.errors # Will tell you than `my_column` presence is mandatory.
+Thanks to expressiveness of the Crystal language, we can handle presence validation by simply using the Nilable
type in crystal:
class MyModel
+ include Clear::Model
+
+ column my_column : String? # Now, the column can be NULL or text in postgres.
+end
+This time, the code above will works; in case of no value, my_column will be nil
by default.
Whenever you want to fetch data from your database, you must create a new collection query:
+MyModel.query #Will setup a vanilla 'SELECT * FROM my_models'
Queries are fetchable using each
:
MyModel.query.each do |model|
+ # Do something with your model here.
+end
+A collection query offers a lot of functionalities. You can read the API for more informations.
+By default, Clear map theses columns types:
+String
=> text
Numbers
(any from 8 to 64 bits, float, double, big number, big float) => int, large int etc... (depends of your choice)
Bool
=> text or bool
Time
=> timestamp without timezone or text
JSON::Any
=> json and jsonb
Nilable
=> NULL
(treated as special !)NOTE: The crystal-pg
gems map also some structures like GIS coordinates, but their implementation is not tested in Clear. Use them at your own risk. Tell me if it's working 😉
If you need to map special structure, see Mapping Your Data guides for more informations.
+Primary key is essential for relational mapping. Currently Clear support only one column primary key.
+A model without primary key can work in sort of degraded mode, throwing error in case of using some methods on them:
+collection#first
will be throwing error if no order_by
has been setupTo setup a primary key, you can add the modifier primary: true
to the column:
class MyModel
+ include Clear::Model
+
+ column id : Int32, primary: true, presence: false
+ column my_column : String?
+end
+Note the flag presence: false
added to the column. This tells Clear than presence checking on save is not mandatory. Usually this happens if you setup a default value in postgres. In the case of our primary key id
, we use a serial auto-increment default value.
+Therefore, saving the model without primary key will works. The id will be fetched after insertion:
m = MyModel
+m.save!
+m.id # Now the id value is setup.
+Clear provides various built-in helpers to facilitate your life:
+class MyModel
+ include Clear::Model
+ timestamps # Will map the two columns 'created_at' and 'updated_at', and map some hooks to update their values.
+end
+Theses fields are automatically updated whenever you call save
methods, and works as Rails ActiveRecord.
class MyModel
+ include Clear::Model
+ primary_key "my_primary_key"
+end
+Basically rewrite column id : UInt64, primary: true, presence: false
Argument is optional (default = id)
+ + + + + +A scope allow you to filter in a very human way a set of data.
Alias method for primary key.
Clear::Model::FullTextSearchable
Clear::Model::FullTextSearchable
Clear::Model::HasFactory
Clear::Model::HasRelations
Clear::Model::HasValidation
Clear::Validation::Helper
Clear::Model::HasSaving
Clear::Model::HasSerialPkey
Clear::Model::HasTimestamps
Clear::Model::HasColumns
Clear::Model::HasColumns
Clear::Model::HasHooks
Clear::Model::HasHooks
Clear::ErrorMessages
A scope allow you to filter in a very human way a set of data.
+Usage:
+scope("admin") { where({role: "admin"}) }
+for example, instead of writing:
+User.query.where { (role == "admin") & (active == true) }
+You can write:
+User.admin.active
+Scope can be used for other purpose than just filter (e.g. ordering), +but I would not recommend it.
+Alias method for primary key.
+If Model#id
IS the primary key, then calling Model#__pkey__
is exactly the same as Model#id
.
This method exists to tremendously simplify the meta-programming code. +If no primary key has been setup to this model, raise an exception.
+CollectionBase(T)
is the base class for collection of model.
+Collection of model are a SQL SELECT
query mapping & building system. They are Enumerable and are
+`Clear::SQL::SelectBuilder` behavior; therefore, they can be used array-like and are working with low-level SQL
+Building.
The CollectionBase(T)
is extended by each model. For example, generating the model MyModel
will generate the
+class MyModel::Collection
which inherits from CollectionBase(MyModel)
Collection are instantiated using Model.query
method.
Add an item to the current collection.
Get a range of models
Basically a fancy way to write OFFSET x LIMIT 1
Basically a fancy way to write OFFSET x LIMIT 1
Alias for Collection#<<
Check whether the query return any row.
Build a new collection; if the collection comes from a has_many relation (e.g.
Build a new collection; if the collection comes from a has_many relation (e.g.
Build a new collection; if the collection comes from a has_many relation (e.g.
Build a new collection; if the collection comes from a has_many relation (e.g.
Use SQL COUNT
over your query, and return this number as a Int64
Build a new object and setup the fields like setup in the condition tuple.
Build a new object and setup the fields like setup in the condition tuple.
Build a new object and setup the fields like setup in the condition tuple.
Build a new object and setup the fields like setup in the condition tuple.
Build a new object and setup the fields like setup in the condition tuple.
Build a new object and setup the fields like setup in the condition tuple.
Build a new object and setup the fields like setup in the condition tuple.
Build a new object and setup the fields like setup in the condition tuple.
Delete all the rows which would have been returned by this collection.
Duplicate the query
Build the SQL, send the query then iterate through each models gathered by the request.
Build the SQL, send the query then iterate through each models gathered by the request.
Inverse of #any?
, return true if the request return no rows.
A convenient way to write where { condition }.first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first
A convenient way to write where { condition }.first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!
Try to fetch a row.
Try to fetch a row.
Try to fetch a row.
Try to fetch a row.
Try to fetch a row.
Get the first row from the collection query.
Get the first row from the collection query.
Return the model class for this collection
Get the last row from the collection query.
Get the last row from the collection query.
Build the SQL, send the query then build and array by applying the block transformation over it.
Create an array from the query.
Unlink the model currently referenced through a relation has_many through
Clear::SQL::SelectBuilder
Clear::SQL::SelectBuilder
Clear::SQL::Query::WithPagination
Clear::SQL::Query::Change
Clear::SQL::Query::Connection
Clear::SQL::Query::Pluck
Clear::SQL::Query::Fetch
Clear::SQL::Query::Execute
Clear::SQL::Query::Lock
Clear::SQL::Query::Window
Clear::SQL::Query::CTE
Clear::SQL::Query::Aggregate
Clear::SQL::Query::OffsetLimit
Clear::SQL::Query::GroupBy
Clear::SQL::Query::OrderBy
Clear::SQL::Query::Having
Clear::SQL::Query::Where
Clear::SQL::Query::Join
Clear::SQL::Query::From
Clear::SQL::Query::Select
Add an item to the current collection.
+If the current collection is not originated from a has_many
or has_many through:
relation, calling <<
over
+the collection will raise a Clear::SQL::OperationNotPermittedError
Returns self
and therefore can be chained
Get a range of models
+Basically a fancy way to write OFFSET x LIMIT 1
Basically a fancy way to write OFFSET x LIMIT 1
Check whether the query return any row.
+Build a new collection; if the collection comes from a has_many relation
+(e.g. my_model.associations.build
), the foreign column which store
+the primary key of my_model
will be setup by default, preventing you
+to forget it.
+You can pass extra parameters using a named tuple:
+my_model.associations.build({a_column: "value"})
Build a new collection; if the collection comes from a has_many relation
+(e.g. my_model.associations.build
), the foreign column which store
+the primary key of my_model
will be setup by default, preventing you
+to forget it.
+You can pass extra parameters using a named tuple:
+my_model.associations.build({a_column: "value"})
Build a new collection; if the collection comes from a has_many relation
+(e.g. my_model.associations.build
), the foreign column which store
+the primary key of my_model
will be setup by default, preventing you
+to forget it.
+You can pass extra parameters using a named tuple:
+my_model.associations.build({a_column: "value"})
Build a new collection; if the collection comes from a has_many relation
+(e.g. my_model.associations.build
), the foreign column which store
+the primary key of my_model
will be setup by default, preventing you
+to forget it.
+You can pass extra parameters using a named tuple:
+my_model.associations.build({a_column: "value"})
Use SQL COUNT
over your query, and return this number as a Int64
Build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Build a new object and setup
+the fields like setup in the condition tuple.
+Just after building, save the object.
+But instead of returning self if validation failed,
+raise Clear::Model::InvalidError
exception
Build a new object and setup
+the fields like setup in the condition tuple.
+Just after building, save the object.
+But instead of returning self if validation failed,
+raise Clear::Model::InvalidError
exception
Build a new object and setup
+the fields like setup in the condition tuple.
+Just after building, save the object.
+But instead of returning self if validation failed,
+raise Clear::Model::InvalidError
exception
Build a new object and setup
+the fields like setup in the condition tuple.
+Just after building, save the object.
+But instead of returning self if validation failed,
+raise Clear::Model::InvalidError
exception
Delete all the rows which would have been returned by this collection.
+Is equivalent to collection.to_delete.execute
Duplicate the query
+Build the SQL, send the query then iterate through each models +gathered by the request.
+Build the SQL, send the query then iterate through each models +gathered by the request. +Use a postgres cursor to avoid memory bloating. +Useful to fetch millions of rows at once.
+Inverse of #any?
, return true if the request return no rows.
A convenient way to write where { condition }.first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first
A convenient way to write where { condition }.first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!
Try to fetch a row. If not found, build a new object and setup +the fields like setup in the condition tuple.
+Try to fetch a row. If not found, build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Try to fetch a row. If not found, build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Try to fetch a row. If not found, build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Try to fetch a row. If not found, build a new object and setup +the fields like setup in the condition tuple. +Just after building, save the object.
+Get the first row from the collection query.
+if not found, return nil
Get the first row from the collection query. +if not found, throw an error
+Return the model class for this collection
+Get the last row from the collection query.
+if not found, return nil
Get the last row from the collection query. +if not found, throw an error
+Build the SQL, send the query then build and array by applying the +block transformation over it.
+Create an array from the query.
+Unlink the model currently referenced through a relation has_many through
If the current colleciton doesn't come from a has_many through
relation,
+this method will throw Clear::SQL::OperationNotPermittedError
Returns true
if unlinking is successful (e.g. one or more rows have been updated), or false
otherwise
A column of a Model +Provide some methods like:
+get_def
to get with default valueUnknownClass.new
+ Completely clear the column, remove both #value
and #old_value
and turning the column in a non-defined state.
Reset #changed?
flag to false
.
Check whether the column is defined or not.
Reset #changed?
flag to true
.
Inspect this column.
Return true
if the value is an union of a Type with Nilable, false
otherwise.
Reset the current field.
If the column is dirty (e.g the value has been changed), return to the previous state.
Return the database converted value using the converter
Returns the current value of this column or default
if the value is undefined.
Returns the current value of this column.
Set the value of the column to the value x
.
Clear::ErrorMessages
Completely clear the column, remove both #value
and #old_value
and turning the column in a non-defined state.
Check whether the column is defined or not.
+Reset #changed?
flag to true
. See Column(T)#clear_change_flag
for the counter part.
Inspect this column. +If a column is not loaded (e.g. not defined once), it will show "#undef". +If a column is dirty (e.g. change hasn't be saved), it will show a "*" after the value.
+Return true
if the value is an union of a Type with Nilable, false
otherwise.
Reset the current field.
+Restore the #old_value
state to current value.
+Reset the flag changed
to false.
If the column is dirty (e.g the value has been changed), return to the previous state.
+Returns the current value of this column or default
if the value is undefined.
Returns the current value of this column. +If the value has never been initialized, throw an exception
+Set the value of the column to the value x
. If x
is not equal to the old value, then the column #changed?
+flag is set to true
.
{"Array(Bool)" => Clear::Model::Converter::ArrayConverterBool, "Array(Bool | Nil)" => Clear::Model::Converter::ArrayConverterBool, "Array(String)" => Clear::Model::Converter::ArrayConverterString, "Array(String | Nil)" => Clear::Model::Converter::ArrayConverterString, "Array(Float32)" => Clear::Model::Converter::ArrayConverterFloat32, "Array(Float32 | Nil)" => Clear::Model::Converter::ArrayConverterFloat32, "Array(Float64)" => Clear::Model::Converter::ArrayConverterFloat64, "Array(Float64 | Nil)" => Clear::Model::Converter::ArrayConverterFloat64, "Array(Int32)" => Clear::Model::Converter::ArrayConverterInt32, "Array(Int32 | Nil)" => Clear::Model::Converter::ArrayConverterInt32, "Array(Int64)" => Clear::Model::Converter::ArrayConverterInt64, "Array(Int64 | Nil)" => Clear::Model::Converter::ArrayConverterInt64, "Bool" => Clear::Model::Converter::BoolConverter, "JSON::Any" => Clear::Model::Converter::JSON::AnyConverter, "Int8" => ::Clear::Model::Converter::Int8Converter, "Int16" => ::Clear::Model::Converter::Int16Converter, "Int32" => ::Clear::Model::Converter::Int32Converter, "Int64" => ::Clear::Model::Converter::Int64Converter, "UInt8" => ::Clear::Model::Converter::UInt8Converter, "UInt16" => ::Clear::Model::Converter::UInt16Converter, "UInt32" => ::Clear::Model::Converter::UInt32Converter, "UInt64" => ::Clear::Model::Converter::UInt64Converter, "Float32" => ::Clear::Model::Converter::Float32Converter, "Float64" => ::Clear::Model::Converter::Float64Converter, "BigInt" => ::Clear::Model::Converter::BigIntConverter, "BigFloat" => ::Clear::Model::Converter::BigFloatConverter, "BigDecimal" => ::Clear::Model::Converter::BigDecimalConverter, "String" => Clear::Model::Converter::StringConverter, "Time" => Clear::Model::Converter::TimeConverter, "Crypto::Bcrypt::Password" => Clear::Model::Converter::BcryptPasswordConverter, "Clear::TSVector" => Clear::TSVector::Converter, "Clear::Interval" => Clear::Interval::Converter, "Clear::TimeInDay" => Clear::TimeInDay::Converter, "UUID" => Clear::Model::Converter::UUIDConverter} of String => Base.class
+ Convert from and to BigDecimal
+ + + + + + + + + + + + + + +Convert from and to BigFloat
+ + + + + + + + + + + + + + +Convert from and to BigInt
+ + + + + + + + + + + + + + +Convert the column to a boolean
+If value is not boolean (e.g. string or number), rules of falsey
+value is used:
falsey's values are:
+false
, nil
, 0
, "0"
, ""
(empty string), "false"
, "f"
Anything else is considered true
Convert from and to Float32
+ + + + + + + + + + + + + + +Convert from and to Float64
+ + + + + + + + + + + + + + +Convert from and to Int16
+ + + + + + + + + + + + + + +Convert from and to Int32
+ + + + + + + + + + + + + + +Convert from and to Int64
+ + + + + + + + + + + + + + +Convert from and to Int8
+ + + + + + + + + + + + + + +Convert from and to UInt16
+ + + + + + + + + + + + + + +Convert from and to UInt32
+ + + + + + + + + + + + + + +Convert from and to UInt64
+ + + + + + + + + + + + + + +Convert from and to UInt8
+ + + + + + + + + + + + + + +Convert from UUID column to Crystal's UUID
+ + + + + + + + + + + + + + +Global storage for model lifecycle event management
+This class acts as a storage and can trigger events +This class a singleton.
+ + + + + + + + + + + + + + +{} of EventKey => Array(HookFunction)
+ {} of String => String
+ Map the inheritance between models.
Add an event for a specific class, to a specific direction (after or before), a specific event Symbol (validate, save, commit...)
Trigger events callback for a specific model.
Map the inheritance between models. Events which belongs to parent model are triggered when child model lifecycle +actions occurs
+Add an event for a specific class, to a specific direction (after or before), a specific event Symbol (validate, save, commit...)
+Trigger events callback for a specific model.
+Direction can be :before
and :after
+In case of :before
direction, the events are called in reverse order:
before:
+- Last defined event
+- First defined event
+action
+after:
+- First defined events
+- Last defined events
+ {String, Symbol, Symbol}
+
+
+
+
+
+
+
+
+
+
+
+
+ Clear::Model -> Nil
+
+
+
+
+
+
+
+
+
+
+
+
+ {"Clear::Reflection::Column" => ::Clear::Model::Factory::SimpleFactory(Clear::Reflection::Column).new, "Clear::Reflection::Table" => ::Clear::Model::Factory::SimpleFactory(Clear::Reflection::Table).new} of String => Clear::Model::Factory::Base
+ Clear::Model::Factory::Base
Clear::Model::Factory::Base
Full text search plugin offers full integration with tsvector
capabilities of
+Postgresql.
It allows you to query models through the text content of one or multiple fields.
+Let's assume we have a blog and want to implement full text search over title and content:
+create_table "posts" do |t|
+ t.column :title, :string, null: false
+ t.column :content, :string, null: false
+
+ t.full_text_searchable on: [{"title", 'A'}, {"content", 'C'}]
+end
+This migration will create a 3rd column named full_text_vector
of type tsvector
,
+a gin index, a trigger and a function to update automatically this column.
Over the on
keyword, '{"title", 'A'}'
means it allows search of the content of "title", with level of priority (weight) "A", which tells postgres than title content is more meaningful than the article content itself.
Now, let's build some models:
+
+ model Post
+ include Clear::Model
+ #...
+
+ full_text_searchable
+ end
+
+ Post.create!({title: "About poney", content: "Poney are cool"})
+ Post.create!({title: "About dog and cat", content: "Cat and dog are cool. But not as much as poney"})
+ Post.create!({title: "You won't believe: She raises her poney like as star!", content: "She's cool because poney are cool"})
+Search is now easily done
+Post.query.search("poney") # Return all the articles !
+Obviously, search call can be chained:
+user = User.find! { email == "some_email@example.com" }
+Post.query.from_user(user).search("orm")
+catalog
Select the catalog to use to build the tsquery. By default, pg_catalog.english
is used.
# in your migration:
+t.full_text_searchable on: [{"title", 'A'}, {"content", 'C'}], catalog: "pg_catalog.french"
+
+# in your model
+full_text_searchable catalog: "pg_catalog.french"
+Note: For now, Clear doesn't offers dynamic selection of catalog (for let's say multi-lang service). +If your app need this feature, do not hesitate to open an issue.
+trigger_name
, function_name
In migration, you can change the name generated for the trigger and the function, using theses two keys.
+dest_field
The field created in the database, which will contains your ts vector. Default is full_text_vector
.
# in your migration
+t.full_text_searchable on: [{"title", 'A'}, {"content", 'C'}], dest_field: "tsv"
+
+# in your model
+full_text_searchable "tsv"
+
+
+
+
+
+
+
+
+
+
+
+ Parse client side text and generate string ready to be ingested by PG's to_tsquery
.
Set this model as searchable using tsvector
Parse client side text and generate string ready to be ingested by PG's to_tsquery
.
Author note: pg to_tsquery
is awesome but can easily fail to parse.
+search
method use then a wrapper text_to_search used to ensure than
+request is understood and produce ALWAYS legal string for to_tsquery
+This is a good helper then to use with the input of your end-users !
However, this helper can be improved, as it doesn't use all the features +of tsvector (parentesis, OR operator etc...)
+Set this model as searchable using tsvector
+This module declare all the methods and macro related to columns in Clear::Model
Bind a column to the model.
Access to direct SQL attributes given by the request used to build the model.
Access to direct SQL attributes given by the request and used to build the model or Nil if not found.
Reset one or multiple columns; Reseting set the current value of the column to the given value, while the changed?
flag remains false.
See #set(**t : **T)
See #set(**t : **T)
Set one or multiple columns to a specific value This two are equivalents:
Returns the model columns as Hash.
Returns the current hash of the modified values:
Bind a column to the model.
+Simple example:
+class MyModel
+ include Clear::Model
+
+ column some_id : Int32, primary: true
+ column nullable_column : String?
+end
+options:
+primary : Bool
: Let Clear ORM know which column is the primary key.
+Currently compound primary key are not compatible with Clear ORM.
converter : Class | Module
: Use this class to convert the data from the
+SQL. This class must possess the class methods
+to_column(::Clear::SQL::Any) : T
and to_db(T) : ::Clear::SQL::Any
+with T
the type of the column.
column_name : String
: If the name of the column in the model doesn't fit the name of the
+column in the SQL, you can use the parameter column_name
to tell Clear about
+which db column is linked to current field.
presence : Bool (default = true)
: Use this option to let know Clear that
+your column is not nullable but with default value generated by the database
+on insert (e.g. serial)
+During validation before saving, the presence will not be checked on this field
+and Clear will try to insert without the field value.
mass_assign : Bool (default = true)
: Use this option to turn on/ off mass assignment
+when instantiating or updating a new model from json through .from_json
methods from
+the Clear::Model::JSONDeserialize
module.
Access to direct SQL attributes given by the request used to build the model. +Access is read only and updating the model columns will not apply change to theses columns.
+model = Model.query.select("MIN(id) as min_id").first(fetch_columns: true)
+id = model["min_id"].to_i32
+ Access to direct SQL attributes given by the request and used to build the model +or Nil if not found.
+Access is read only and updating the model columns will not apply change to theses columns.
+You must set fetch_column: true
in your model to access the attributes.
Reset one or multiple columns; Reseting set the current value of the column
+to the given value, while the changed?
flag remains false.
+If you call save on a persisted model, the reset columns won't be
+commited in the UPDATE query.
See #set(**t : **T)
See #set(**t : **T)
Set one or multiple columns to a specific value +This two are equivalents:
+model.set(a: 1)
+model.a = 1
+ Returns the model columns as Hash.
+Calling #to_h
will returns only the defined columns, while settings the optional parameter full
to true
+will return all the column and fill the undefined columns by nil
values.
+Example:
# Assuming our model has a primary key, a first name and last name and two timestamp columns:
+model = Model.query.select("first_name, last_name").first!
+model.to_h # => { "first_name" => "Johnny", "last_name" => "Walker" }
+model.to_h(full: true) # => {"id" => nil, "first_name" => "Johnny", "last_name" => "Walker", "created_at" => nil, "updated_at" => nil}
+ Returns the current hash of the modified values:
+model = Model.query.first!
+model.update_h # => {}
+model.first_name = "hello"
+model.update_h # => { "first_name" => "hello" }
+model.save!
+model.update_h # => {}
+ Define a polymorphic factory, if the model is tagged as polymorphic
Define a polymorphic factory, if the model is tagged as polymorphic
+Triggers the events hooked after event_name
Triggers the events hooked before event_name
This performs theses operations:
Triggers the events hooked after event_name
Triggers the events hooked before event_name
This performs theses operations:
+ +model.with_triggers("email_sent") do |m|
+ model.send_email
+end
+Returns self
class Model
+ include Clear::Model
+
+ has_many posts : Post, foreign_key: Model.underscore_name + "_id", no_cache : false
+
+ has_one passport : Passport
+ has_many posts
+end
+
+
+
+
+
+
+
+
+
+
+
+
Has Many and Has One are the relations where the model share its primary key into a foreign table.
The method has_one
declare a relation 1 to [0,1] where the current model primary key is stored in the foreign table.
class Model
+ include Clear::Model
+
+ belongs_to user : User, foreign_key: "the_user_id"
+end
+ Has Many and Has One are the relations where the model share its primary key into a foreign table. In our example above, we can assume than a User has many Post as author.
+Basically, for each belongs_to
declaration, you must have a has_many
or has_one
declaration on the other model.
While has_many
relation returns a list of models, has_one
returns only one model when called.
Example:
+class User
+ include Clear::Model
+
+ has_many posts : Post, foreign_key: "author_id"
+end
+ The method has_one
declare a relation 1 to [0,1]
+where the current model primary key is stored in the foreign table.
+primary_key
method (default: self#__pkey__
) and foreign_key
method
+(default: table_name in singular, plus "_id" appended)
+can be redefined
Example:
+model Passport
+ column id : Int32, primary : true
+ has_one user : User It assumes the table `users` have a column `passport_id`
+end
+
+model Passport
+ column id : Int32, primary : true
+ has_one owner : User # It assumes the table `users` have a column `passport_id`
+end
+ Delete the model by building and executing a DELETE
query.
Save the model.
Performs #save
call, but instead of returning false
if validation failed, raise Clear::Model::InvalidError
exception
Pass the on_conflict
optional parameter via block.
Set the fields passed as argument and call #save
on the object
Set the fields passed as argument and call #save!
on the object
Delete the model by building and executing a DELETE
query.
+A deleted model is not persisted anymore, and can be saved again.
+Clear will do INSERT
instead of UPDATE
then
+Return true
if the model has been successfully deleted, and false
otherwise.
Save the model. If the model is already persisted, will call UPDATE
query.
+If the model is not persisted, will call INSERT
Optionally, you can pass a Proc
to refine the INSERT
with on conflict
+resolution functions.
Return false
if the model cannot be saved (validation issue)
+Return true
if the model has been correctly saved.
Example:
+u = User.new
+if u.save
+ puts "User correctly saved !"
+else
+ puts "There was a problem during save: "
+ # do something with `u.errors`
+end
+on_conflict
optional parameterExample:
+u = User.new id: 123, email: "email@example.com"
+u.save(-> (qry) { qry.on_conflict.do_update { |u| u.set(email: "email@example.com") } #update
+# IMPORTANT NOTICE: user may not be saved, but will be still detected as persisted !
+You may want to use a block for on_conflict
optional parameter:
u = User.new id: 123, email: "email@example.com"
+u.save do |qry|
+ qry.on_conflict.do_update { |u| u.set(email: "email@example.com")
+end
+ Performs #save
call, but instead of returning false
if validation failed,
+raise Clear::Model::InvalidError
exception
Pass the on_conflict
optional parameter via block.
Set the fields passed as argument and call #save
on the object
Set the fields passed as argument and call #save!
on the object
{"bigserial" => "column(__name__ : Int64, primary: true, presence: false)", "serial" => "column(__name__ : Int32, primary: true, presence: false)", "text" => "column(__name__ : String, primary: true, presence: true)", "int" => "column(__name__ : Int32, primary: true, presence: true)", "bigint" => "column(__name__ : Int64, primary: true, presence: true)", "uuid" => "column(__name__ : UUID, primary: true, presence: true)\nbefore(:validate) do |m|\n if !m.persisted? && (m.as(self)).__name___column.value(nil).nil?\n (m.as(self)).__name__ = UUID.random\n end\nend\n"} of Nil => Nil
+ Add a hook for the primary_key
In the hook, name will be replaced by the column name required by calling primary_key
Macro used to define serializable primary keys.
Add a hook for the primary_key
+In the hook, name will be replaced by the column name required by calling primary_key
Clear::Model::HasSerialPkey.add_pkey_type("awesomepkeysystem") do
+ column __name__ : AwesomePkey, primary: true, presence: false
+
+ before_validate do
+ # ...
+ end
+end
+ Macro used to define serializable primary keys.
+Currently support bigserial
, serial
and uuid
.
For bigserial
and serial
, let to PostgreSQL the handling of sequence numbers.
+For uuid
, will generate a new UUID
number on creation.
Generate the columns updated_at
and created_at
The two column values are automatically set during insertion or update of the model.
Generate the columns updated_at
and created_at
+The two column values are automatically set during insertion
+or update of the model.
Add validation error related to a specific column
Add validation error not related to a specific column
Clear the errors log (if any) of the model and return itself
Return true
if saving has been declined because of validation issues.
List of errors raised during validation, in case the model hasn't been saved properly.
Print the errors in string.
Check whether the model is valid.
Return true
if the model
This method is called whenever #valid?
or save
is called.
Clear::Validation::Helper
Add validation error related to a specific column
+Add validation error not related to a specific column
+Clear the errors log (if any) of the model and return itself
+Return true
if saving has been declined because of validation issues.
+The error list can be found by calling Clear::Model#errors
List of errors raised during validation, in case the model hasn't been saved properly.
+Print the errors in string. Useful for debugging or simple error handling.
+Check whether the model is valid. If not, raise InvalidModelError
.
+Return the model itself
This method is called whenever #valid?
or save
is called.
+By default, #validate
is empty and must be overriden by your own validation code.
This module declare all the methods and macro related to deserializing json in Clear::Model
The Clear::Model::QueryCache +is a fire-and-forget cache used when caching associations and preventing N+1 queries anti-pattern.
+This is not a global cache: One cache instance exists per collection, and the cache +disappear at the same time the Collection is unreferenced.
+Each cache can references multiples relations at the same time. +This cache use an underlying hash to access to the references keys.
+ + + + + + + + + + + + + + +Tell this cache than we active the cache over a specific relation name.
Check whether the cache is active on a certain association.
Empty the cache and flag all relations has unactive
Try to hit the cache.
Set the cached array for a specific key {relation_name,relation_value}
Perform some operations with the cache then eventually clear the cache.
Tell this cache than we active the cache over a specific relation name.
+Returns self
Check whether the cache is active on a certain association.
+Returns true
if relation_name
is flagged as encached, or false
otherwise.
Empty the cache and flag all relations has unactive
+Try to hit the cache. If an array is found, it will be returned. +Otherwise, empty array is returned.
+This methods do not check if a relation flagged as is actively cached or not. Therefore, hitting a non-cached +relation will return always an empty-array.
+Set the cached array for a specific key {relation_name,relation_value}
Perform some operations with the cache then eventually clear the cache.
+Reflection of the columns using information_schema in postgreSQL.
+TODO Usage of view instead of model
+ + + + + +{"table_catalog" => {type: String, primary: false, converter: "String", db_column_name: "table_catalog", crystal_variable_name: table_catalog, presence: true, mass_assign: true}, "table_schema" => {type: String, primary: false, converter: "String", db_column_name: "table_schema", crystal_variable_name: table_schema, presence: true, mass_assign: true}, "table_name" => {type: String, primary: false, converter: "String", db_column_name: "table_name", crystal_variable_name: table_name, presence: false, mass_assign: true}, "column_name" => {type: String, primary: true, converter: "String", db_column_name: "column_name", crystal_variable_name: column_name, presence: true, mass_assign: true}} of Nil => Nil
+ {} of Nil => Nil
+ Build a new empty model and fill the columns using the NamedTuple in argument.
Build a new empty model and fill the columns using the NamedTuple in argument.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build a new empty model and fill the columns using the NamedTuple in argument.
Build a new empty model and fill the columns using the NamedTuple in argument.
Build a new empty model and fill the columns using the NamedTuple in argument.
Define on which connection the model is living.
Define on which connection the model is living.
Create a new model from json and save it.
Create a new model from json and save it.
Returns a model using primary key equality Returns nil
if not found.
Returns a model using primary key equality.
Create a new empty model and fill the columns from json.
returns the fully qualified and escaped name for this table.
Import a bulk of models in one SQL insert query.
Return a new empty query SELECT * FROM [my_model_table]
.
Define the current schema used in PostgreSQL.
Define the current schema used in PostgreSQL.
Return the table name setup for this model.
Return the table name setup for this model.
Attributes, used when fetch_columns is true
Return true
if the model is dirty (e.g.
Reset the #changed?
flag on all columns
Returns the value of #column_name
column or throw an exception if the column is not defined.
Setter for #column_name
column.
Returns the column object used to manage #column_name
field
Set the columns from hash
Set the model fields from hash
reset flavors
Set the columns from hash
Set the model fields from hash
Set one or multiple columns to a specific value This two are equivalents:
Set the fields from json passed as argument Trusted flag set to true will allow mass assignment without protection, FALSE by default
The method table is a belongs_to
relation to Clear::Reflection::Table
Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Setter for #table_name
column.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Setter for #table_schema
column.
Returns the column object used to manage #table_schema
field
Return a hash version of the columns of this model.
Set the fields from json passed as argument and call save
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
For each column, ensure than when needed the column has present information into it.
Clear::Model
Clear::Model
Clear::Model::FullTextSearchable
Clear::Model::FullTextSearchable
Clear::Model::HasFactory
Clear::Model::HasRelations
Clear::Model::HasValidation
Clear::Validation::Helper
Clear::Model::HasSaving
Clear::Model::HasSerialPkey
Clear::Model::HasTimestamps
Clear::Model::HasColumns
Clear::Model::HasColumns
Clear::Model::HasHooks
Clear::Model::HasHooks
Clear::ErrorMessages
Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Define on which connection the model is living. Useful in case of models living in different databases.
+Is set to "default" by default.
+See Clear::SQL#init(URI, *opts)
for more information about multi-connections.
Example:
+Clear::SQL.init("postgres://postgres@localhost/database_1")
+Clear::SQL.init("secondary", "postgres://postgres@localhost/database_2")
+
+class ModelA
+ include Clear::Model
+
+ # Performs all the queries on `database_1`
+ # self.connection = "default"
+ column id : Int32, primary: true, presence: false
+ column title : String
+end
+
+class ModelB
+ include Clear::Model
+
+ # Performs all the queries on `database_2`
+ self.connection = "secondary"
+
+ column id : Int32, primary: true, presence: false
+end
+ Define on which connection the model is living. Useful in case of models living in different databases.
+Is set to "default" by default.
+See Clear::SQL#init(URI, *opts)
for more information about multi-connections.
Example:
+Clear::SQL.init("postgres://postgres@localhost/database_1")
+Clear::SQL.init("secondary", "postgres://postgres@localhost/database_2")
+
+class ModelA
+ include Clear::Model
+
+ # Performs all the queries on `database_1`
+ # self.connection = "default"
+ column id : Int32, primary: true, presence: false
+ column title : String
+end
+
+class ModelB
+ include Clear::Model
+
+ # Performs all the queries on `database_2`
+ self.connection = "secondary"
+
+ column id : Int32, primary: true, presence: false
+end
+ Create a new model from json and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
Create a new model from json and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process. +Trusted flag set to true will allow mass assignment without protection, FALSE by default
+Returns a model using primary key equality
+Returns nil
if not found.
Returns a model using primary key equality. +Raises error if the model is not found.
+Create a new empty model and fill the columns from json. Returns the new model
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
+returns the fully qualified and escaped name for this table. +add schema if schema is different from 'public' (default schema)
+ex: "schema"."table"
+Import a bulk of models in one SQL insert query. +Each model must be non-persisted.
+on_conflict
callback can be optionnaly turned on
+to manage constraints of the database.
Note: Old models are not modified. This method return a copy of the +models as saved in the database.
+users = [User.new(id: 1), User.new(id: 2), User.new(id: 3)]
+users = User.import(users)
+ Return a new empty query SELECT * FROM [my_model_table]
. Can be refined after that.
Define the current schema used in PostgreSQL. The value is nil
by default, which lead to non-specified
+schema during the querying, and usage of "public" by PostgreSQL.
This property can be redefined on initialization. Example:
+class MyModel
+ include Clear::Model
+
+ self.schema = "my_schema"
+end
+MyModel.query.to_sql # SELECT * FROM "my_schema"."my_models"
+ Define the current schema used in PostgreSQL. The value is nil
by default, which lead to non-specified
+schema during the querying, and usage of "public" by PostgreSQL.
This property can be redefined on initialization. Example:
+class MyModel
+ include Clear::Model
+
+ self.schema = "my_schema"
+end
+MyModel.query.to_sql # SELECT * FROM "my_schema"."my_models"
+ Return the table name setup for this model. +By convention, the class name is by default equals to the pluralized underscored string form of the model name. +Example:
+MyModel => "my_models"
+Person => "people"
+Project::Info => "project_infos"
+The property can be updated at initialization to a custom table name:
+class MyModel
+ include Clear::Model
+
+ self.table = "another_table_name"
+end
+MyModel.query.to_sql # SELECT * FROM "another_table_name"
+ Return the table name setup for this model. +By convention, the class name is by default equals to the pluralized underscored string form of the model name. +Example:
+MyModel => "my_models"
+Person => "people"
+Project::Info => "project_infos"
+The property can be updated at initialization to a custom table name:
+class MyModel
+ include Clear::Model
+
+ self.table = "another_table_name"
+end
+MyModel.query.to_sql # SELECT * FROM "another_table_name"
+ Attributes, used when fetch_columns is true
+Return true
if the model is dirty (e.g. one or more fields
+have been changed.). Return false
otherwise.
Reset the #changed?
flag on all columns
The model behave like its not dirty anymore +and call to save would apply no changes.
+Returns self
Returns the value of #column_name
column or throw an exception if the column is not defined.
Returns the column object used to manage #column_name
field
Set one or multiple columns to a specific value +This two are equivalents:
+model.set(a: 1)
+model.a = 1
+ Set the fields from json passed as argument +Trusted flag set to true will allow mass assignment without protection, FALSE by default
+The method table is a belongs_to
relation to Clear::Reflection::Table
Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Returns the column object used to manage #table_schema
field
Return a hash version of the columns of this model.
+Set the fields from json passed as argument and call save
on the object
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
+For each column, ensure than when needed the column has present +information into it.
+This method is called on validation.
+:doc: +Clear::Model::Collection
+This is the object managing a SELECT
request.
+A new collection is created by calling Clear::Model.query
Collection are mutable and refining the SQL will mutate the collection.
+You may want to copy the collection by calling dup
See Clear::Model::CollectionBase
Clear::Model::CollectionBase(Clear::Reflection::Column)
Clear::SQL::SelectBuilder
Clear::SQL::SelectBuilder
Clear::SQL::Query::WithPagination
Clear::SQL::Query::Change
Clear::SQL::Query::Connection
Clear::SQL::Query::Pluck
Clear::SQL::Query::Fetch
Clear::SQL::Query::Execute
Clear::SQL::Query::Lock
Clear::SQL::Query::Window
Clear::SQL::Query::CTE
Clear::SQL::Query::Aggregate
Clear::SQL::Query::OffsetLimit
Clear::SQL::Query::GroupBy
Clear::SQL::Query::OrderBy
Clear::SQL::Query::Having
Clear::SQL::Query::Where
Clear::SQL::Query::Join
Clear::SQL::Query::From
Clear::SQL::Query::Select
Reflection of the tables using information_schema in postgreSQL.
+TODO Usage of view instead of model
+ + + + + +{"table_catalog" => {type: String, primary: false, converter: "String", db_column_name: "table_catalog", crystal_variable_name: table_catalog, presence: true, mass_assign: true}, "table_schema" => {type: String, primary: false, converter: "String", db_column_name: "table_schema", crystal_variable_name: table_schema, presence: true, mass_assign: true}, "table_name" => {type: String, primary: true, converter: "String", db_column_name: "table_name", crystal_variable_name: table_name, presence: true, mass_assign: true}, "table_type" => {type: String, primary: false, converter: "String", db_column_name: "table_type", crystal_variable_name: table_type, presence: true, mass_assign: true}} of Nil => Nil
+ {} of Nil => Nil
+ Build a new empty model and fill the columns using the NamedTuple in argument.
Build a new empty model and fill the columns using the NamedTuple in argument.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build and new model and save it.
Build a new empty model and fill the columns using the NamedTuple in argument.
Build a new empty model and fill the columns using the NamedTuple in argument.
Build a new empty model and fill the columns using the NamedTuple in argument.
Define on which connection the model is living.
Define on which connection the model is living.
Create a new model from json and save it.
Create a new model from json and save it.
Returns a model using primary key equality Returns nil
if not found.
Returns a model using primary key equality.
Create a new empty model and fill the columns from json.
returns the fully qualified and escaped name for this table.
Import a bulk of models in one SQL insert query.
Return a new empty query SELECT * FROM [my_model_table]
.
Define the current schema used in PostgreSQL.
Define the current schema used in PostgreSQL.
Return the table name setup for this model.
Return the table name setup for this model.
Attributes, used when fetch_columns is true
Return true
if the model is dirty (e.g.
Reset the #changed?
flag on all columns
The method columns is a has_many
relation to Clear::Reflection::Column
List all the indexes related to the current table.
Force to clean-up the caches for the relations connected to this model.
Set the columns from hash
Set the model fields from hash
reset flavors
Set the columns from hash
Set the model fields from hash
Set one or multiple columns to a specific value This two are equivalents:
Set the fields from json passed as argument Trusted flag set to true will allow mass assignment without protection, FALSE by default
Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Setter for #table_name
column.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Setter for #table_schema
column.
Returns the column object used to manage #table_schema
field
Returns the value of #table_type
column or throw an exception if the column is not defined.
Setter for #table_type
column.
Returns the column object used to manage #table_type
field
Return a hash version of the columns of this model.
Set the fields from json passed as argument and call save
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
For each column, ensure than when needed the column has present information into it.
Clear::Model
Clear::Model
Clear::Model::FullTextSearchable
Clear::Model::FullTextSearchable
Clear::Model::HasFactory
Clear::Model::HasRelations
Clear::Model::HasValidation
Clear::Validation::Helper
Clear::Model::HasSaving
Clear::Model::HasSerialPkey
Clear::Model::HasTimestamps
Clear::Model::HasColumns
Clear::Model::HasColumns
Clear::Model::HasHooks
Clear::Model::HasHooks
Clear::ErrorMessages
Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build and new model and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process.
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Build a new empty model and fill the columns using the NamedTuple in argument.
+Returns the new model
+Define on which connection the model is living. Useful in case of models living in different databases.
+Is set to "default" by default.
+See Clear::SQL#init(URI, *opts)
for more information about multi-connections.
Example:
+Clear::SQL.init("postgres://postgres@localhost/database_1")
+Clear::SQL.init("secondary", "postgres://postgres@localhost/database_2")
+
+class ModelA
+ include Clear::Model
+
+ # Performs all the queries on `database_1`
+ # self.connection = "default"
+ column id : Int32, primary: true, presence: false
+ column title : String
+end
+
+class ModelB
+ include Clear::Model
+
+ # Performs all the queries on `database_2`
+ self.connection = "secondary"
+
+ column id : Int32, primary: true, presence: false
+end
+ Define on which connection the model is living. Useful in case of models living in different databases.
+Is set to "default" by default.
+See Clear::SQL#init(URI, *opts)
for more information about multi-connections.
Example:
+Clear::SQL.init("postgres://postgres@localhost/database_1")
+Clear::SQL.init("secondary", "postgres://postgres@localhost/database_2")
+
+class ModelA
+ include Clear::Model
+
+ # Performs all the queries on `database_1`
+ # self.connection = "default"
+ column id : Int32, primary: true, presence: false
+ column title : String
+end
+
+class ModelB
+ include Clear::Model
+
+ # Performs all the queries on `database_2`
+ self.connection = "secondary"
+
+ column id : Int32, primary: true, presence: false
+end
+ Create a new model from json and save it. Returns the model.
+The model may not be saved due to validation failure;
+check the returned model errors?
and persisted?
flags.
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
Create a new model from json and save it. Returns the model.
+Returns the newly inserted model +Raises an exception if validation failed during the saving process. +Trusted flag set to true will allow mass assignment without protection, FALSE by default
+Returns a model using primary key equality
+Returns nil
if not found.
Returns a model using primary key equality. +Raises error if the model is not found.
+Create a new empty model and fill the columns from json. Returns the new model
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
+returns the fully qualified and escaped name for this table. +add schema if schema is different from 'public' (default schema)
+ex: "schema"."table"
+Import a bulk of models in one SQL insert query. +Each model must be non-persisted.
+on_conflict
callback can be optionnaly turned on
+to manage constraints of the database.
Note: Old models are not modified. This method return a copy of the +models as saved in the database.
+users = [User.new(id: 1), User.new(id: 2), User.new(id: 3)]
+users = User.import(users)
+ Return a new empty query SELECT * FROM [my_model_table]
. Can be refined after that.
Define the current schema used in PostgreSQL. The value is nil
by default, which lead to non-specified
+schema during the querying, and usage of "public" by PostgreSQL.
This property can be redefined on initialization. Example:
+class MyModel
+ include Clear::Model
+
+ self.schema = "my_schema"
+end
+MyModel.query.to_sql # SELECT * FROM "my_schema"."my_models"
+ Define the current schema used in PostgreSQL. The value is nil
by default, which lead to non-specified
+schema during the querying, and usage of "public" by PostgreSQL.
This property can be redefined on initialization. Example:
+class MyModel
+ include Clear::Model
+
+ self.schema = "my_schema"
+end
+MyModel.query.to_sql # SELECT * FROM "my_schema"."my_models"
+ Return the table name setup for this model. +By convention, the class name is by default equals to the pluralized underscored string form of the model name. +Example:
+MyModel => "my_models"
+Person => "people"
+Project::Info => "project_infos"
+The property can be updated at initialization to a custom table name:
+class MyModel
+ include Clear::Model
+
+ self.table = "another_table_name"
+end
+MyModel.query.to_sql # SELECT * FROM "another_table_name"
+ Return the table name setup for this model. +By convention, the class name is by default equals to the pluralized underscored string form of the model name. +Example:
+MyModel => "my_models"
+Person => "people"
+Project::Info => "project_infos"
+The property can be updated at initialization to a custom table name:
+class MyModel
+ include Clear::Model
+
+ self.table = "another_table_name"
+end
+MyModel.query.to_sql # SELECT * FROM "another_table_name"
+ Attributes, used when fetch_columns is true
+Return true
if the model is dirty (e.g. one or more fields
+have been changed.). Return false
otherwise.
Reset the #changed?
flag on all columns
The model behave like its not dirty anymore +and call to save would apply no changes.
+Returns self
The method columns is a has_many
relation to Clear::Reflection::Column
List all the indexes related to the current table. +return an hash where the key is the name of the column +and the value is an array containing all the indexes related to this specific +field.
+Force to clean-up the caches for the relations +connected to this model.
+Set one or multiple columns to a specific value +This two are equivalents:
+model.set(a: 1)
+model.a = 1
+ Set the fields from json passed as argument +Trusted flag set to true will allow mass assignment without protection, FALSE by default
+Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Returns the column object used to manage #table_schema
field
Returns the value of #table_type
column or throw an exception if the column is not defined.
Returns the column object used to manage #table_type
field
Return a hash version of the columns of this model.
+Set the fields from json passed as argument and call save
on the object
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object
+Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
+For each column, ensure than when needed the column has present +information into it.
+This method is called on validation.
+Addition of the method for eager loading and N+1 avoidance.
+ + + + + + + + + + + + + + +Eager load the has many relation columns.
Clear::Model::CollectionBase(Clear::Reflection::Table)
Clear::SQL::SelectBuilder
Clear::SQL::SelectBuilder
Clear::SQL::Query::WithPagination
Clear::SQL::Query::Change
Clear::SQL::Query::Connection
Clear::SQL::Query::Pluck
Clear::SQL::Query::Fetch
Clear::SQL::Query::Execute
Clear::SQL::Query::Lock
Clear::SQL::Query::Window
Clear::SQL::Query::CTE
Clear::SQL::Query::Aggregate
Clear::SQL::Query::OffsetLimit
Clear::SQL::Query::GroupBy
Clear::SQL::Query::OrderBy
Clear::SQL::Query::Having
Clear::SQL::Query::Where
Clear::SQL::Query::Join
Clear::SQL::Query::From
Clear::SQL::Query::Select
Eager load the has many relation columns. +Use it to avoid N+1 queries.
+Clear is made like an onion:
++------------------------------------+
+| THE ORM STACK +
++------------------------------------+
+| Model | DB Views | Migrations | < High Level Tools
++---------------+--------------------+
+| Columns | Validation | Converters | < Mapping system
++---------------+--------------------+
+| Clear::SQL | Clear::Expression | < Low Level SQL Builder
++------------------------------------+
+| Crystal DB | Crystal PG | < Low Level connection
++------------------------------------+
+On the bottom stack, Clear offer SQL query building. +Theses features are then used by top level parts of the engine.
+The SQL module provide a simple API to generate #delete
, #insert
, #select
+and #update
methods.
Each requests can be duplicated then modified and executed.
+Note: Each request object is mutable. Therefore, to update and store a request,
+you must use manually the dup
method.
Lock completetly a table.
Truncate a table or a model
Start a DELETE table query
Escape the expression, double quoting it.
Execute a SQL statement on a specific connection.
Execute a SQL statement.
Alias of #insert_into
, for hurry developers
Create a new INSERT query
Prepare a new INSERT INTO table query :ditto:
Start an INSERT INTO table query
This provide a fast way to create SQL fragment while escaping items, both with ?
and :key
system:
See self.raw
Can pass an array to this version
Raise a rollback, in case of transaction
Sanitize string and convert some literals (e.g.
Start a SELECT FROM table query
Start a UPDATE table query
Create a transaction, but this one is stackable using savepoints.
Clear::SQL::Transaction
Clear::SQL::Logger
Clear::SQL::Logger
Lock completetly a table.
+Clear::SQL.lock("my_table") do
+end
+Optional parameter mode
allow you to decide over the lock level
+Modes are:
Truncate a table or a model
+User.query.count # => 200
+Clear::SQL.truncate(User) # equivalent to Clear::SQL.truncate(User.table, connection_name: User.connection)
+User.query.count # => 0
+SEE https://www.postgresql.org/docs/current/sql-truncate.html +for more information.
+restart_sequence
set to true will append RESTART IDENTITY
to the querycascade
set to true will append CASCADE
to the querytruncate_inherited
set to false will append ONLY
to the queryconnection_name
will be: Model.connection
or default
unless optionally defined.Escape the expression, double quoting it.
+It allows use of reserved keywords as table or column name
+NOTE Escape is used for escaping postgresql keyword. For example +if you have a column named order (which is a reserved word), you want +to escape it by double-quoting it.
+For escaping STRING value, please use Clear::SQL.sanitize
+Execute a SQL statement on a specific connection.
+Usage: +Clear::SQL.execute("seconddatabase", "SELECT 1 FROM users")
+Execute a SQL statement.
+Usage: +Clear::SQL.execute("SELECT 1 FROM users")
+Alias of #insert_into
, for hurry developers
Start an INSERT INTO table query
+Clear::SQL.insert_into("table", {id: 1, name: "hello"}, {id: 2, name: "World"})
+ This provide a fast way to create SQL fragment while escaping items, both with ?
and :key
system:
query = Mode.query.select(Clear::SQL.raw("CASE WHEN x=:x THEN 1 ELSE 0 END as check", x: "blabla"))
+query = Mode.query.select(Clear::SQL.raw("CASE WHEN x=? THEN 1 ELSE 0 END as check", "blabla"))
+ See self.raw
+Can pass an array to this version
Raise a rollback, in case of transaction
+Sanitize string and convert some literals (e.g. Time
)
Start a SELECT FROM table query
+Create a transaction, but this one is stackable +using savepoints.
+Example:
+Clear::SQL.with_savepoint do
+ # do something
+ Clear::SQL.with_savepoint do
+ rollback # < Rollback only the last `with_savepoint` block
+ end
+end
+ Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil
+
+
+
+
+
+
+
+
+
+
+
+
+ Like rollback, but used into savepoint, it will revert completely the transaction
+ + + + + + + + + + + + + + +Clear::SQL::Fragment
Clear::SQL::Fragment
Retrieve a connection from the connection pool, or wait for it.
Retrieve a connection from the connection pool, or wait for it. +If the current Fiber already has a connection, the connection is returned; +this strategy provides easy usage of multiple statement connection (like BEGIN/ROLLBACK features).
+Return the list of where clause; each where clause are transformed into Clear::Expression::Node
Clear::SQL::Query::Change
Clear::SQL::Query::Execute
Clear::SQL::Query::Where
Clear::SQL::Query::Connection
Return the list of where clause; each where clause are transformed into +Clear::Expression::Node
+Clear::SQL::Fragment
Clear::SQL::Fragment
An insert query
+cf. postgres documentation
+[ WITH [ RECURSIVE ] with_query [, ...] ]
+INSERT INTO table_name [ AS alias ] [ ( column_name [, ...] ) ]
+ { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }
+ [ ON CONFLICT [ conflict_target ] conflict_action ]
+ [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
+
+
+
+
+
+ Used with values
Number of rows of this insertion request
Fast insert system
Insert into ...
Clear::SQL::Query::OnConflict
Clear::SQL::Query::Connection
Clear::SQL::Query::Change
Clear::SQL::Query::CTE
Used with values
+Number of rows of this insertion request
+Fast insert system
+insert({field: "value"}).into(:table)
+Insert into ... (...) SELECT
+Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil
+
+
+
+
+
+
+
+
+
+
+
+
+ jsonb ?&
operator Do all of these array strings exist as top-level keys?
jsonb ?|
operator Do any of these array strings exist as top-level keys?
Test equality using the @>
operator
Does the string exist as a top-level key within the JSON value?
Transform a key to a hash
Return text selector for the field/key :
jsonb ?&
operator
+Do all of these array strings exist as top-level keys?
jsonb ?|
operator
+Do any of these array strings exist as top-level keys?
Test equality using the @>
operator
jsonb_eq("data.sub.key", "value")
+=> data @> '{"sub": {"key": "value"}}'
Does the string exist as a top-level key within the JSON value?
+Return text selector for the field/key :
+jsonb_text("data", "sub.key").like("user%")
+# => "data->'sub'->>'key' LIKE 'user%'"
+ Hash(String, Clear::SQL::JSONB::JSONBKey)
+
+
+
+
+
+
+
+
+
+
+
+
+ Bool | Clear::Expression::Literal | Float32 | Float64 | Hash(String, Clear::SQL::JSONB::JSONBKey) | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil
+
+
+
+
+
+
+
+
+
+
+
+
+ {left: "LEFT JOIN", inner: "INNER JOIN", right: "RIGHT JOIN", full_outer: "FULL OUTER JOIN", cross: "CROSS JOIN"}
+ Clear::SQL::Fragment
Clear::SQL::Fragment
Call an custom aggregation function, like MEDIAN or other:
SQL aggregation function "AVG":
Use SQL COUNT
over your query, and return this number as a Int64
SQL aggregation function "MAX":
SQL aggregation function "MIN":
SUM through a field and return a Float64 Note: This function is not safe injection-wise, so beware !.
Call an custom aggregation function, like MEDIAN or other:
+query.agg("MEDIAN(age)", Int64)
+Note than COUNT, MIN, MAX, SUM and AVG are already conveniently mapped.
+This return only one row, and should not be used with group_by
(prefer pluck or fetch)
SQL aggregation function "AVG":
+query.avg("field", Int64)
+ Use SQL COUNT
over your query, and return this number as a Int64
as count return always a scalar, the usage of COUNT(*) OVER GROUP BY
can be done by
+using pluck
or select
SQL aggregation function "MAX":
+query.max("field", Int64)
+ SQL aggregation function "MIN":
+query.min("field", Int64)
+ SUM through a field and return a Float64 +Note: This function is not safe injection-wise, so beware !.
+Allow usage of Common Table Expressions (CTE) in the query building
+ + + + + + + + + + + +List the current CTE of the query.
Add a CTE to the query.
Add a CTE to the query.
List the current CTE of the query. The key is the name of the CTE, +while the value is the fragment (string or Sub-select)
+Add a CTE to the query.
+Clear::SQL.select.with_cte("full_year",
+ "SELECT DATE(date)"
+ "FROM generate_series(NOW() - INTERVAL '1 year', NOW(), '1 day'::interval) date")
+ .select("*").from("full_year")
+# WITH full_year AS ( SELECT DATE(date) ... ) SELECT * FROM full_year;
+ Add a CTE to the query. Use NamedTuple convention:
+Clear::SQL.select.with_cte(cte: "xxx")
+# WITH cte AS xxx SELECT...
+ This method is called everytime the request has been changed By default, this do nothing and return self
.
This method is called everytime the request has been changed
+By default, this do nothing and return self
. However, it can be
+reimplemented to change some behavior when the query is changed
(eg. it is by Clear::Model::Collection
, to discard cache over collection)
Connection used by the query.
Change the connection used by the query on execution
Connection used by the query.
+Change it using #use_connection
method
Change the connection used by the query on execution
+Execute an SQL statement which does not return anything.
Execute an SQL statement which does not return anything.
+If an optional connection_name
parameter is given, this will
+override the connection used by the query.
%(default secondary).each do |cnx|
+ Clear::SQL.select("pg_shards('xxx')").execute(cnx)
+end
+ Fetch the result set row per row fetch_all
optional parameter is helpful in transactional environment, so it stores the result and close the resultset before starting to call yield over the data preventing creation of a new connection if you need to call SQL into the yielded block.
Alias for #first
because first is redefined in Collection::Base object to return a model instead.
Fetch the data using CURSOR.
Return the first line of the query as Hash(String, ::Clear::SQL::Any), or nil if not found
Helpers to fetch a SELECT with only one row and one column return.
Return an array with all the rows fetched.
Fetch the result set row per row
+fetch_all
optional parameter is helpful in transactional environment, so it stores
+the result and close the resultset before starting to call yield over the data
+preventing creation of a new connection if you need to call SQL into the
+yielded block.
# This is wrong: The connection is still busy retrieving the users:
+Clear::SQL.select.from("users").fetch do |u|
+ Clear::SQL.select.from("posts").where { u["id"] == posts.id }
+end
+
+# Instead, use `fetch_all`
+# Clear will store the value of the result set in memory
+# before calling the block, and the connection is now ready to handle
+# another query.
+Clear::SQL.select.from("users").fetch(fetch_all: true) do |u|
+ Clear::SQL.select.from("posts").where { u["id"] == posts.id }
+end
+ Alias for #first
because first is redefined in Collection::Base
+object to return a model instead.
Fetch the data using CURSOR. +This will prevent Clear to load all the data from the database into memory. +This is useful if you need to retrieve and update a large dataset.
+Return the first line of the query as Hash(String, ::Clear::SQL::Any), or nil +if not found
+Helpers to fetch a SELECT with only one row and one column return.
+Return an array with all the rows fetched.
+Clear the FROM clause and return self
FROM fragment of the SQL query
Clear the FROM clause and return self
FROM fragment of the SQL query
+Clear::SQL.select.from("airplanes").to_sql # < SELECT * FROM airplanes
+ Clear all the having clauses and return self
Build SQL #having
condition using a Clear::Expression::Node
Build SQL #having
condition using the Expression engine.
Build SQL #having
condition using a NamedTuple.
Build SQL #having
condition using a template string and interpolating ?
characters with parameters given in a tuple or array.
Build SQL #having
interpolating :keyword
with the NamedTuple passed in argument.
Build SQL #or_having
condition using a Clear::Expression::Node
Build SQL #having
condition using the Expression engine.
Clear all the having clauses and return self
Build SQL #having
condition using a Clear::Expression::Node
query.having(Clear::Expression::Node::InArray.new("id", ['1', '2', '3', '4']))
+# Note: in this example, InArray node use unsafe strings
+If useful for moving a having clause from a request to another one:
+query1.having { a == b } # having a = b
+query2.having(query1.havings[0]) # HAVING a = b
+ Build SQL #having
condition using the Expression engine.
query.having { id == 1 }
+ Build SQL #having
condition using a NamedTuple.
+this will use:
=
operator if compared with a literalquery.having({keyword: "hello"}) # having keyword = 'hello'
+IN
operator if compared with an array:query.having({x: [1, 2]}) # having x in (1, 2)
+>=
and <=
| <
if compared with a range:query.having({x: (1..4)}) # having x >= 1 AND x <= 4
+query.having({x: (1...4)}) # having x >= 1 AND x < 4
+query.having({x: another_select}) # having x IN (SELECT ... )
+ Build SQL #having
condition using a template string and
+interpolating ?
characters with parameters given in a tuple or array.
having("x = ? OR y = ?", 1, "l'eau") # having x = 1 OR y = 'l''eau'
+Raise error if there's not enough parameters to cover all the ?
placeholders
Build SQL #having
interpolating :keyword
with the NamedTuple passed in argument.
having("id = :id OR date >= :start", id: 1, start: 1.day.ago)
+# having id = 1 AND date >= '201x-xx-xx ...'
+ Build SQL #or_having
condition using a Clear::Expression::Node
query.or_having(Clear::Expression::Node::InArray.new("id", ['1', '2', '3', '4']))
+# Note: in this example, InArray node use unsafe strings
+If useful for moving a having clause from a request to another one:
+query1.or_having { a == b } # having a = b
+query2.or_having(query1.havings[0]) # having a = b
+ Build SQL #having
condition using the Expression engine.
query.or_having { id == 1 }
+ Add a "FULL_OUTER" JOIN directive to the query
Add a "FULL_OUTER" JOIN directive to the query
Add a "INNER" JOIN directive to the query
Add a "INNER" JOIN directive to the query
Add a "LEFT" JOIN directive to the query
Add a "LEFT" JOIN directive to the query
Add a "RIGHT" JOIN directive to the query
Add a "RIGHT" JOIN directive to the query
Fragment used when ON CONFLICT WHERE ...
+ + + + + +Returns a nicely readable and concise string representation of this object, typically intended for users.
Return the list of where clause; each where clause are transformed into Clear::Expression::Node
Clear::SQL::Query::Where
Returns a nicely readable and concise string representation of this object, +typically intended for users.
+This method should usually not be overridden. It delegates to
+#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.
Return the list of where clause; each where clause are transformed into +Clear::Expression::Node
+Encode for:
+ORDER BY expression [ASC | DESC | USING operator] [NULLS FIRST | NULLS LAST];
Current implementation:
+[x] Multiple Order by clauses +[x] ASC/DESC +[x] NULLS FIRST / NULLS LAST +[ ] NOT IMPLEMENTED: USING OPERATOR
+ + + + + + + + + + + +Remove all order by clauses
Add multiple ORDER BY clause using a tuple:
Add one ORDER BY clause
Add one ORDER BY clause
Add multiple ORDER BY clause using a tuple:
Flip over all order bys by switching the ASC direction to DESC and the NULLS FIRST to NULLS LAST
Remove all order by clauses
+Add multiple ORDER BY clause using a tuple:
+query = Clear::SQL.select.from("users").order_by(id: :desc, name: {:asc, :nulls_last})
+query.to_sql # > SELECT * FROM users ORDER BY "id" DESC, "name" ASC NULLS LAST
+ Add one ORDER BY clause
+query = Clear::SQL.select.from("users").order_by(:id, :desc, nulls_last)
+query.to_sql # > SELECT * FROM users ORDER BY "id" DESC NULLS LAST
+ Add one ORDER BY clause
+query = Clear::SQL.select.from("users").order_by(:id, :desc, nulls_last)
+query.to_sql # > SELECT * FROM users ORDER BY "id" DESC NULLS LAST
+ Add multiple ORDER BY clause using a tuple:
+query = Clear::SQL.select.from("users").order_by(id: :desc, name: {:asc, :nulls_last})
+query.to_sql # > SELECT * FROM users ORDER BY "id" DESC, "name" ASC NULLS LAST
+ Flip over all order bys by switching the ASC direction to DESC and the NULLS FIRST to NULLS LAST
+query = Clear::SQL.select.from("users").order_by(id: :desc, name: :asc, company: {:asc, :nulls_last})
+query.reverse_order_by
+query.to_sql # SELECT * FROM users ORDER BY "id" ASC, "name" DESC, "company" DESC NULLS FIRST
+return self
Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected arguments:
Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected arguments:
Select specifics columns and returns on array of tuple of type of the named tuple passed as parameter:
Select a specific column of your SQL query, execute the query and return an array containing this field.
Select a specific column of your SQL query, execute the query and return an array containing this field.
Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected +arguments:
+User.query.pluck("first_name", "last_name").each do |(first_name, last_name)|
+ # ...
+end
+ Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected +arguments:
+User.query.pluck("first_name", "last_name").each do |(first_name, last_name)|
+ # ...
+end
+ Select specifics columns and returns on array of tuple of type of the named tuple passed as parameter:
+User.query.pluck(id: Int64, "UPPER(last_name)": String).each do #...
+ Select a specific column of your SQL query, execute the query +and return an array containing this field.
+User.query.pluck_col("id") # [1,2,3,4...]
+Note: It returns an array of Clear::SQL::Any
. Therefore, you may want to use #pluck_col(str, Type)
to return
+an array of Type
:
User.query.pluck_col("id", Int64)
+The field argument is a SQL fragment; it's not escaped (beware SQL injection) and allow call to functions +and aggregate methods:
+# ...
+User.query.pluck_col("CASE WHEN id % 2 = 0 THEN id ELSE NULL END AS id").each do
+# ...
+ Select a specific column of your SQL query, execute the query +and return an array containing this field.
+User.query.pluck_col("id") # [1,2,3,4...]
+Note: It returns an array of Clear::SQL::Any
. Therefore, you may want to use #pluck_col(str, Type)
to return
+an array of Type
:
User.query.pluck_col("id", Int64)
+The field argument is a SQL fragment; it's not escaped (beware SQL injection) and allow call to functions +and aggregate methods:
+# ...
+User.query.pluck_col("CASE WHEN id % 2 = 0 THEN id ELSE NULL END AS id").each do
+# ...
+ Remove distinct
In some case you want you query to return table.*
instead of *
if no select parameters has been set.
Add DISTINCT to the SELECT part of the query
def select(name : Symbolic, var = nil) @columns << Column.new(name, var) self end
Add field(s) to selection from tuple
In some case you want you query to return table.*
instead of *
+if no select parameters has been set. This occurs in the case of joins
+between models.
Add DISTINCT to the SELECT part of the query
+on
is blank (empty string, default), will call a simple SELECT DISTINCT ...
on
is nil, will remove the distinct (see #clear_distinct
)on
is a non empty string, will call SELECT DISTINCT ON (on) ...
def select(name : Symbolic, var = nil) +@columns << Column.new(name, var) +self +end
+Add field(s) to selection from tuple
+select({user_id: "uid", updated_at: "updated_at"})
+# => Output "SELECT user_id as uid, updated_at as updated_at"
+ Feature WHERE clause building.
+each call to where method stack where clause.
+Theses clauses are then combined together using the AND
operator.
+Therefore, query.where("a").where("b")
will return a AND b
Clear all the where clauses and return self
Build SQL #or_where
condition using a Clear::Expression::Node
Build SQL #where
condition using the Expression engine.
Build SQL #where
condition using a Clear::Expression::Node
Build SQL #where
condition using the Expression engine.
Build SQL #where
condition using a NamedTuple.
Build custom SQL #where
beware of SQL injections!
Build SQL #where
condition using a template string and interpolating ?
characters with parameters given in a tuple or array.
Build SQL #where
interpolating :keyword
with the NamedTuple passed in argument.
Clear all the where clauses and return self
Build SQL #or_where
condition using a Clear::Expression::Node
query.or_where(Clear::Expression::Node::InArray.new("id", ['1', '2', '3', '4']))
+# Note: in this example, InArray node use unsafe strings
+If useful for moving a where clause from a request to another one:
+query1.or_where { a == b } # WHERE a = b
+query2.or_where(query1.wheres[0]) # WHERE a = b
+ Build SQL #where
condition using the Expression engine.
query.or_where { id == 1 }
+ Build SQL #where
condition using a Clear::Expression::Node
query.where(Clear::Expression::Node::InArray.new("id", ['1', '2', '3', '4']))
+# Note: in this example, InArray node use unsafe strings
+If useful for moving a where clause from a request to another one:
+query1.where { a == b } # WHERE a = b
+query2.where(query1.wheres[0]) # WHERE a = b
+ Build SQL #where
condition using the Expression engine.
query.where { id == 1 }
+ Build SQL #where
condition using a NamedTuple.
+this will use:
=
operator if compared with a literalquery.where({keyword: "hello"}) # WHERE keyword = 'hello'
+IN
operator if compared with an array:query.where({x: [1, 2]}) # WHERE x in (1,2)
+>=
and <=
| <
if compared with a range:query.where({x: (1..4)}) # WHERE x >= 1 AND x <= 4
+query.where({x: (1...4)}) # WHERE x >= 1 AND x < 4
+query.where({x: another_select}) # WHERE x IN (SELECT ... )
+ Build custom SQL #where
+beware of SQL injections!
where("ADD_SOME_DANGEROUS_SQL_HERE") # WHERE ADD_SOME_DANGEROUS_SQL_HERE
+ Build SQL #where
condition using a template string and
+interpolating ?
characters with parameters given in a tuple or array.
where("x = ? OR y = ?", 1, "l'eau") # WHERE x = 1 OR y = 'l''eau'
+Raise error if there's not enough parameters to cover all the ?
placeholders
Build SQL #where
interpolating :keyword
with the NamedTuple passed in argument.
where("id = :id OR date >= :start", id: 1, start: 1.day.ago)
+# WHERE id = 1 AND date >= '201x-xx-xx ...'
+ eq.
eq. WINDOW window_name AS ( window_definition )
+{String, String}
+
+
+
+
+
+
+
+
+
+
+
+
+ 50
+ 1
+ Return the current page
Return current_page + 1
or nil
if there is no next page
Helper method that is true when someone tries to fetch a page with a larger number than the last page.
Enter pagination mode.
Return the number of items maximum per page.
Return current_page - 1
or nil
if there is no previous page
Return the total number of pages.
Return current_page + 1
or nil
if there is no next page
Helper method that is true when someone tries to fetch a page with a +larger number than the last page. Can be used in combination with flashes +and redirecting.
+Enter pagination mode.
+This is helpful to manage paginated table.
+Pagination will handle the page progression automatically and update
+offset
and limit
parameters by his own.
page = query.paginate(2, 50)
+ Return the number of items maximum per page.
+Return current_page - 1
or nil
if there is no previous page
Return the total number of pages.
+Rollback the transaction or the last savepoint.
+ + + + + + + + + + + + + + +A hook to apply some operation just before the query is executed.
Duplicate the query
Construct a delete query from this select query.
Return the list of where clause; each where clause are transformed into Clear::Expression::Node
Clear::SQL::Query::WithPagination
Clear::SQL::Query::Change
Clear::SQL::Query::Connection
Clear::SQL::Query::Pluck
Clear::SQL::Query::Fetch
Clear::SQL::Query::Execute
Clear::SQL::Query::Lock
Clear::SQL::Query::Window
Clear::SQL::Query::CTE
Clear::SQL::Query::Aggregate
Clear::SQL::Query::OffsetLimit
Clear::SQL::Query::GroupBy
Clear::SQL::Query::OrderBy
Clear::SQL::Query::Having
Clear::SQL::Query::Where
Clear::SQL::Query::Join
Clear::SQL::Query::From
Clear::SQL::Query::Select
A hook to apply some operation just before the query is executed.
+call = 0
+req = Clear::SQL.select("1").before_query { call += 1 }
+10.times { req.execute }
+pp call # 10
+ Construct a delete query from this select query.
+It uses only the from
and the where
clause fo the current select request.
+Can be useful in some case, but
+use at your own risk !
Return the list of where clause; each where clause are transformed into +Clear::Expression::Node
+A Select Query builder
+Postgres documentation:
+[ WITH [ RECURSIVE ] with_query [, ...] ]
+SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
+ [ * | expression [ [ AS ] output_name ] [, ...] ]
+ [ FROM from_item [, ...] ]
+ [ WHERE condition ]
+ [ GROUP BY grouping_element [, ...] ]
+ [ HAVING condition [, ...] ]
+ [ WINDOW window_name AS ( window_definition ) [, ...] ]
+ [ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]
+ [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] ]
+ [ LIMIT { count | ALL } ]
+ [ OFFSET start [ ROW | ROWS ] ]
+ [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]
+ [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ]
+
+
+
+
+
+ Must yield this collection's elements to the block.
Clear::SQL::SelectBuilder
Clear::SQL::SelectBuilder
Clear::SQL::Query::WithPagination
Clear::SQL::Query::Change
Clear::SQL::Query::Connection
Clear::SQL::Query::Pluck
Clear::SQL::Query::Fetch
Clear::SQL::Query::Execute
Clear::SQL::Query::Lock
Clear::SQL::Query::Window
Clear::SQL::Query::CTE
Clear::SQL::Query::Aggregate
Clear::SQL::Query::OffsetLimit
Clear::SQL::Query::GroupBy
Clear::SQL::Query::OrderBy
Clear::SQL::Query::Having
Clear::SQL::Query::Where
Clear::SQL::Query::Join
Clear::SQL::Query::From
Clear::SQL::Query::Select
Must yield this collection's elements to the block.
+Clear::SQL::SelectBuilder | String | Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+ String | Symbol
+
+
+
+
+
+
+
+
+
+
+
+
+ Register a callback function which will be fired once when SQL COMMIT
operation is called
Check whether the current pair of fiber/connection is in transaction block or not.
Rollback a transaction or return to the previous savepoint in case of a with_savepoint block.
Rollback the transaction.
Enter new transaction block for the current connection/fiber pair.
Create a transaction, but this one is stackable using savepoints.
Register a callback function which will be fired once when SQL COMMIT
+operation is called
This can be used for example to send email, or perform others tasks +when you want to be sure the data is secured in the database.
+transaction do
+ @user = User.find(1)
+ @user.subscribe!
+ Clear::SQL.after_commit { Email.deliver(ConfirmationMail.new(@user)) }
+end
+In case the transaction fail and eventually rollback, the code won't be called.
+Check whether the current pair of fiber/connection is in transaction +block or not.
+Rollback a transaction or return to the previous savepoint in case of a
+with_savepoint block.
+The params to
offer
Rollback the transaction. In case the call is made inside a savepoint block +rollback everything.
+Enter new transaction block for the current connection/fiber pair.
+Example:
+Clear::SQL.transaction do
+ # do something
+ Clear::SQL.transaction do # Technically, this block do nothing, since we already are in transaction
+ rollback # < Rollback the up-most `transaction` block.
+ end
+end
+see #with_savepoint to use a stackable version using savepoints.
+Create a transaction, but this one is stackable +using savepoints.
+Example:
+Clear::SQL.with_savepoint do
+ # do something
+ Clear::SQL.with_savepoint do
+ rollback # < Rollback only the last `with_savepoint` block
+ end
+end
+ Represents the differents levels of transactions +as described in https://www.postgresql.org/docs/9.5/transaction-iso.html
+ReadUncommited is voluntarly ommited as it fallback to ReadCommited in PostgreSQL
+ + + + + + + + + + + + + + +0
+ 1
+ 2
+ TODO Documentation
+ + + + + +Return the list of where clause; each where clause are transformed into Clear::Expression::Node
Clear::SQL::Query::Execute
Clear::SQL::Query::Where
Clear::SQL::Query::Change
Clear::SQL::Query::Connection
Clear::SQL::Query::CTE
Return the list of where clause; each where clause are transformed into +Clear::Expression::Node
+Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil
+
+
+
+
+
+
+
+
+
+
+
+
+ Hash(String, Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil) | String
+
+
+
+
+
+
+
+
+
+
+
+
+ ['A', 'B', 'C', 'D']
+ Clear::TimeInDay
represents the "time" object of PostgreSQL
It can be converted automatically from/to a time
column.
+It offers helpers which makes it usable also as a stand alone.
time = Clear::TimeInDay.parse("12:33")
+puts time.hour # 12
+puts time.minutes # 0
+
+Time.local.at(time) # Today at 12:33:00
+time.to_s # 12:33:00
+time.to_s(false) # don't show seconds => 12:33
+
+time = time + 2.minutes # 12:35
+As with Interval, you might wanna use it as a column (use underlying time
type in PostgreSQL):
class MyModel
+ include Clear::Model
+
+ column time_in_day : Clear::TimeInDay
+end
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Parse a string, of format HH:MM or HH:MM:SS
Returns an unambiguous and information-rich string representation of this object, typically intended for developers.
Returns a nicely readable and concise string representation of this object, typically intended for users.
Return a string
Parse a string, of format HH:MM or HH:MM:SS
+Returns an unambiguous and information-rich string representation of this +object, typically intended for developers.
+This method should usually not be overridden. It delegates to
+#inspect(IO)
which can be overridden for custom implementations.
Also see #to_s
.
Returns a nicely readable and concise string representation of this object, +typically intended for users.
+This method should usually not be overridden. It delegates to
+#to_s(IO)
which can be overridden for custom implementations.
Also see #inspect
.
Return a string
+A set of method(s) useful for building Clear ORM.
+ + + + + + + +Return a new hash which is union of two hash (some kind of deep merge)
Equivalent to ruby's lambda with one parameter.
Return a new hash which is union of two hash (some kind of deep merge)
+Equivalent to ruby's lambda with one parameter. +This method is useful combined with the macro system of Crystal.
+Usage example:
Usage example:
+ensure_than email, "must be an email" do |v|
+ EmailRegexp.valid?(v)
+end
+ Create and maintain your database views directly in the code.
+You could use the migration system to create and drop your views. However this +is proven to be difficult, even more if you want to update a view which depends on +another subviews.
+When you migrate using the migration system, all the views registered +are going to be destroyed and recreated again. +Order of creation depends of the requirement for each views
+Clear::View.register :room_per_days do |view|
+ view.require(:rooms, :year_days)
+
+ view.query <<-SQL
+ SELECT room_id, day
+ FROM year_days
+ CROSS JOIN rooms
+ SQL
+end
+
+Clear::View.register :rooms do |view|
+ view.query <<-SQL
+ SELECT room.id as room_id
+ FROM generate_series(1, 4) AS room(id)
+ SQL
+end
+
+Clear::View.register :year_days do |view|
+ view.query <<-SQL
+ SELECT date.day::date as day
+ FROM generate_series(
+ date_trunc('day', NOW()),
+ date_trunc('day', NOW() + INTERVAL '364 days'),
+ INTERVAL '1 day'
+ ) AS date(day)
+ SQL
+end
+In the example above, room_per_days will be first dropped before a migration +start and last created after the migration finished, to prevent issue where some +views are linked to others
+ + + + + + + + + + + + + + +install the view into postgresql using CREATE VIEW
install the view into postgresql using CREATE VIEW
Call the DSL to register a new view
database connection where is installed the view
whether the view is materialized or not.
name of the view
query body related to the view.
list of dependencies from the other view related to this view
schema to store the view (default public)
install the view into postgresql using CREATE VIEW
+Call the DSL to register a new view
+Clear::View.register(:name) do |view|
+ # describe the view here.
+end
+ database connection where is installed the view
+whether the view is materialized or not. I would recommend to use +migration execute create/drop whenever the view is a materialized view
+name of the view
+query body related to the view. Must be a SELECT clause
+list of dependencies from the other view related to this view
+schema to store the view (default public)
+A Slice
is a Pointer
with an associated size.
While a pointer is unsafe because no bound checks are performed when reading from and writing to it,
+reading from and writing to a slice involve bound checks.
+In this way, a slice is a safe alternative to Pointer
.
A Slice can be created as read-only: trying to write to it
+will raise. For example the slice of bytes returned by
+String#to_slice
is read-only.
Time
represents a date-time instant in
+incremental time
+observed in a specific time zone.
The calendaric calculations are based on the rules of the proleptic Gregorian +calendar as specified in ISO 8601. +Leap seconds are ignored.
+Internally, the time is stored as an Int64
representing seconds from epoch
+(0001-01-01 00:00:00.0 UTC
) and an Int32
representing
+nanosecond-of-second with value range 0..999_999_999
.
The supported date range is 0001-01-01 00:00:00.0
to
+9999-12-31 23:59:59.999_999_999
in any local time zone.
There are several methods to retrieve a Time
instance representing the
+current time:
Time.utc # returns the current time in UTC
+Time.local Time::Location.load("Europe/Berlin") # returns the current time in time zone Europe/Berlin
+Time.local # returns the current time in current time zone
+It is generally recommended to keep instances in UTC and only apply a +local time zone when formatting for user display, unless the domain logic +requires having a specific time zone (for example for calendaric operations).
+Time
instances representing a specific instant can be created by
+.utc
or .new
with the date-time specified as individual arguments:
time = Time.utc(2016, 2, 15, 10, 20, 30)
+time.to_s # => "2016-02-15 10:20:30 UTC"
+time = Time.local(2016, 2, 15, 10, 20, 30, location: Time::Location.load("Europe/Berlin"))
+time.to_s # => "2016-02-15 10:20:30 +01:00"
+# The time-of-day can be omitted and defaults to midnight (start of day):
+time = Time.utc(2016, 2, 15)
+time.to_s # => "2016-02-15 00:00:00 UTC"
+Each Time
instance allows querying calendar data:
time = Time.utc(2016, 2, 15, 10, 20, 30)
+time.year # => 2016
+time.month # => 2
+time.day # => 15
+time.hour # => 10
+time.minute # => 20
+time.second # => 30
+time.millisecond # => 0
+time.nanosecond # => 0
+time.day_of_week # => Time::DayOfWeek::Monday
+time.day_of_year # => 46
+time.monday? # => true
+time.time_of_day # => 10:20:30
+For querying if a time is at a specific day of week, Time
offers named
+predicate methods, delegating to #day_of_week
:
time.monday? # => true
+# ...
+time.sunday? # => false
+Each time is attached to a specific time zone, represented by a Location
+(see #location
).
+#zone
returns the time zone observed in this location at the current time
+(i.e. the instant represented by this Time
).
+#offset
returns the offset of the current zone in seconds.
time = Time.local(2018, 3, 8, 22, 5, 13, location: Time::Location.load("Europe/Berlin"))
+time # => 2018-03-08 22:05:13 +01:00 Europe/Berlin
+time.location # => #<Time::Location Europe/Berlin>
+time.zone # => #<Time::Location::Zone CET +01:00 (3600s) STD>
+time.offset # => 3600
+Using .utc
, the location is Time::Location::UTC
:
time = Time.utc(2018, 3, 8, 22, 5, 13)
+time # => 2018-03-08 22:05:13.0 UTC
+time.location # => #<Time::Location UTC>
+time.zone # => #<Time::Location::Zone UTC +00:00 (0s) STD>
+time.offset # => 0
+A Time
instance can be transformed to a different time zone while retaining
+the same instant using #in
:
time_de = Time.local(2018, 3, 8, 22, 5, 13, location: Time::Location.load("Europe/Berlin"))
+time_ar = time_de.in Time::Location.load("America/Buenos_Aires")
+time_de # => 2018-03-08 22:05:13 +01:00 Europe/Berlin
+time_ar # => 2018-03-08 18:05:13 -03:00 America/Buenos_Aires
+Both Time
instances show a different local date-time, but they represent
+the same date-time in the instant time-line, therefore they are considered
+equal:
time_de.to_utc # => 2018-03-08 21:05:13 UTC
+time_ar.to_utc # => 2018-03-08 21:05:13 UTC
+time_de == time_ar # => true
+There are also two special methods for converting to UTC and local time zone:
+time.to_utc # equals time.in(Location::UTC)
+time.to_local # equals time.in(Location.local)
+#to_local_in
allows changing the time zone while keeping
+the same local date-time (wall clock) which results in a different instant
+on the time line.
To make date-time instances exchangeable between different computer systems +or readable to humans, they are usually converted to and from a string +representation.
+The method #to_s
formats the date-time according to a specified pattern.
time = Time.utc(2015, 10, 12, 10, 30, 0)
+time.to_s("%Y-%m-%d %H:%M:%S %:z") # => "2015-10-12 10:30:00 +00:00"
+Similarly, Time.parse
and Time.parse!
are used to construct a Time
instance from date-time
+information in a string, according to a specified pattern:
Time.parse("2015-10-12 10:30:00 +00:00", "%Y-%m-%d %H:%M:%S %z", Time::Location::UTC)
+Time.parse!("2015-10-12 10:30:00 +00:00", "%Y-%m-%d %H:%M:%S %z")
+See Time::Format
for all directives.
Time.utc(2015, 10, 10) - 5.days # => 2015-10-05 00:00:00 +00:00
+
+span = Time.utc(2015, 10, 10) - Time.utc(2015, 9, 10)
+span.days # => 30
+span.total_hours # => 720
+span.total_minutes # => 43200
+The typical time representation provided by the operating system is based on +a "wall clock" which is subject to changes for clock synchronization. +This can result in discontinuous jumps in the time-line making it not +suitable for accurately measuring elapsed time.
+Instances of Time
are focused on telling time – using a "wall clock".
+When Time.local
is called multiple times, the difference between the
+returned instances is not guaranteed to equal to the time elapsed between
+making the calls; even the order of the returned Time
instances might
+not reflect invocation order.
t1 = Time.utc
+# operation that takes 1 minute
+t2 = Time.utc
+t2 - t1 # => ?
+The resulting Time::Span
could be anything, even negative, if the
+computer's wall clock has changed between both calls.
As an alternative, the operating system also provides a monotonic clock. +Its time-line has no specified starting point but is strictly linearly +increasing.
+This monotonic clock should always be used for measuring elapsed time.
+A reading from this clock can be taken using .monotonic
:
t1 = Time.monotonic
+# operation that takes 1 minute
+t2 = Time.monotonic
+t2 - t1 # => 1.minute (approximately)
+The execution time of a block can be measured using .measure
:
elapsed_time = Time.measure do
+ # operation that takes 20 milliseconds
+end
+elapsed_time # => 20.milliseconds (approximately)
+
+
+
+
+
+ Represents a UUID (Universally Unique IDentifier).
+NOTE To use UUID
, you must explicitly import it with require "uuid"
Clear is an ORM built specifically for PostgreSQL in Crystal.
+It's probably the most advanced ORM for PG on Crystal in term of features offered. +It features Active Record pattern models, and low-level SQL builder.
+You can deal out of the box with jsonb, tsvectors, cursors, CTE, bcrypt password,
+array, uuid primary key, foreign constraints... and other things !
+It also has a powerful DSL to construct where
and having
clauses.
The philosophy beneath is to please me (and you !) with emphasis made on business +code readability and minimal setup.
+The project is quite active and well maintened, too !
+In few seconds, you want to use Clear if:
+You don't want to use Clear if:
+ # Like ...
+ Product.query.where { ( type == "Book" ) & ( metadata.jsonb("author.full_name") == "Philip K. Dick" ) }
+ # ^--- will use @> operator, to relay on your gin index. For real.
+
+ Product.query.where { ( products.type == "Book" ) & ( products.metadata.jsonb("author.full_name") != "Philip K. Dick" ) }
+ # ^--- this time will use -> notation, because no optimizations possible :/
+
+ # Or...
+ User.query.where { created_at.in? 5.days.ago .. 1.day.ago }
+
+ # Or even...
+ ORM.query.where { ( description =~ /(^| )awesome($| )/i ) }.first!.name # Clear! :-)
+In shards.yml
dependencies:
+ clear:
+ github: crystal-garage/clear
+ branch: develop
+Then:
+ require "clear"
+Clear offers some mixins, just include them in your classes to clear them:
+
+class User
+ include Clear::Model
+
+ column id : Int64, primary: true
+
+ column email : String
+
+ column first_name : String?
+ column last_name : String?
+
+ column encrypted_password : Crypto::Bcrypt::Password
+
+ def password=(x)
+ self.encrypted_password = Crypto::Bcrypt::Password.create(password)
+ end
+end
+
+Number
, String
, Time
, Boolean
and Jsonb
structures are already mapped.Array
of primitives too.
+For other type of data, just create your own converter !class Clear::Model::Converter::MyClassConversion
+ def self.to_column(x) : MyClass?
+ case x
+ when String
+ MyClass.from_string(x)
+ when Slice(UInt8)
+ MyClass.from_slice(x)
+ else
+ raise "Cannot convert from #{x.class} to MyClass"
+ end
+ end
+
+ def self.to_db(x : UUID?)
+ x.to_s
+ end
+end
+
+Clear::Model::Converter.add_converter("MyClass", Clear::Model::Converter::MyClassConversion)
+Most of the ORM for Crystal are mapping column type as Type | Nil
union.
+It makes sens so we allow selection of some columns only of a model.
+However, this have a caveats: columns are still accessible, and will return nil,
+even if the real value of the column is not null !
Moreover, most of the developers will enforce nullity only on their programming +language level via validation, but not on the database, leading to inconsistency.
+Therefore, we choose to throw exception whenever a column is accessed before +it has been initialized and to enforce presence through the union system of +Crystal.
+Clear offers this through the use of column wrapper.
+Wrapper can be of the type of the column as in postgres, or in UNKNOWN
state.
+This approach offers more flexibility:
User.query.select("last_name").each do |usr|
+ puts usr.first_name #Will raise an exception, as first_name hasn't been fetched.
+end
+
+u = User.new
+u.first_name_column.defined? #Return false
+u.first_name_column.value("") # Call the value or empty string if not defined :-)
+u.first_name = "bonjour"
+u.first_name_column.defined? #Return true now !
+Wrapper give also some pretty useful features:
+u = User.new
+u.email = "me@myaddress.com"
+u.email_column.changed? # TRUE
+u.email_column.revert
+u.email_column.defined? # No more
+Clear offers has_many
, has_one
, belongs_to
and has_many through
associations:
class Security::Action
+ belongs_to role : Role
+end
+
+class Security::Role
+ has_many user : User
+end
+
+class User
+ include Clear::Model
+
+ has_one user_info : UserInfo
+ has_many posts : Post
+
+ belongs_to role : Security::Role
+
+ # Use of the standard keys (users_id <=> security_role_id)
+ has_many actions : Security::Action, through: Security::Role
+end
+Clear offers a collection system for your models. The collection system
+takes origin to the lower API Clear::SQL
, used to build requests.
To fetch one model:
+# 1. Get the first user
+User.query.first #Get the first user, ordered by primary key
+
+# Get a specific user
+User.find!(1) #Get the first user, or throw exception if not found.
+
+# Usage of query provides a `find_by` kind of method:
+u : User? = User.query.find { email =~ /yacine/i }
+To prepare a collection, juste use Model#query
.
+Collections include SQL::Select
object, so all the low level API
+(where
, join
, group_by
, lock
...) can be used in this context.
# Get multiple users
+User.query.where { (id >= 100) & (id <= 200) }.each do |user|
+ # Do something with user !
+end
+
+#In case you know there's millions of row, use a cursor to avoid memory issues !
+User.query.where { (id >= 1) & (id <= 20_000_000) }.each_cursor(batch: 100) do |user|
+ # Do something with user; only 100 users will be stored in memory
+ # This method is using pg cursor, so it's 100% transaction-safe
+end
+Call aggregate functions from the query is possible. For complex aggregation,
+I would recommend to use the SQL::View
API (note: Not yet developed),
+and keep the model query for fetching models only
# count
+user_on_gmail = User.query.where { email.ilike "@gmail.com%" }.count #Note: count return is Int64
+# min/max
+max_id = User.query.where { email.ilike "@gmail.com%" }.max("id", Int32)
+# your own aggregate
+weighted_avg = User.query.agg("SUM(performance_weight * performance_score) / SUM(performance_weight)", Float64)
+Associations are basically getter which create predefined SQL. +To access to an association, just call it !
+User.query.each do |user|
+ puts "User #{user.id} posts:"
+ user.posts.each do |post| #Works, but will trigger a request for each user.
+ puts "• #{post.id}"
+ end
+end
+For every association, you can tell Clear to encache the results to avoid
+N+1 queries, using with_XXX
on the collection:
# Will call two requests only.
+User.query.with_posts.each do |user|
+ puts "User #{user.id} posts:"
+ user.posts.each do |post|
+ puts "• #{post.id}"
+ end
+end
+Note than Clear doesn't perform a join method, and the SQL produced will use
+the operator IN
on the association.
In the case above:
+ SELECT * FROM users;
+ SELECT * FROM posts WHERE user_id IN ( SELECT id FROM users )
+I have plan in a late future to offer different query strategies for the cache (e.g. joins, unions...)
+When you use the caching system of the association, using filters on association will +invalidate the cache, and N+1 query will happens.
+For example:
+User.query.with_posts.each do |user|
+ puts "User #{user.id} published posts:"
+ # Here: The cache system will not work. The cache on association
+ # is invalidated by the filter `where`.
+ user.posts.where({published: true}).each do |post|
+ puts "• #{post.id}"
+ end
+end
+The way to fix it is to filter on the association itself:
+User.query.with_posts(&.where({published: true})).each do |user|
+ puts "User #{user.id} published posts:"
+ # The posts collection of user is already encached with the published filter
+ user.posts.each do |post|
+ puts "• #{post.id}"
+ end
+end
+Note than, of course in this example user.posts
are not ALL the posts but only the
+published
posts
Thanks to this system, we can stack it to encache long distance relations:
+# Will cache users<=>posts & posts<=>category
+# Total: 3 requests !
+User.query.with_posts(&.with_category).each do |user|
+ #...
+end
+In case you want columns computed by postgres, or stored in another table, you can use fetch_column
.
+By default, for performance reasons, fetch_columns
option is set to false.
users = User.query.select(email: "users.email",
+ remark: "infos.remark").join("infos"){ infos.user_id == users.id }.to_a(fetch_columns: true)
+
+# Now the column "remark" will be fetched into each user object.
+# Access can be made using `[]` operator on the model.
+
+users.each do |u|
+ puts "email: `#{u.email}`, remark: `#{u["remark"]?}`"
+end
+inspect
over model offers debugging insights:
p # => #<Post:0x10c5f6720
+ @attributes={},
+ @cache=
+ #<Clear::Model::QueryCache:0x10c6e8100
+ @cache={},
+ @cache_activation=Set{}>,
+ @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 diverge from the database.
One thing very important for a good ORM is to offer vision of the SQL +called under the hood. +Clear is offering SQL logging tools, with SQL syntax colorizing in your terminal.
+For activation, simply setup the logger to DEBUG
level !
Log.builder.bind "clear.*", :debug, Log::IOBackend.new(STDOUT)
+Object can be persisted, saved, updated:
+u = User.new
+u.email = "test@example.com"
+u.save! #Save or throw if unsavable (validation failed).
+Columns can be checked & reverted:
+u = User.new
+u.email = "test@example.com"
+u.email_column.changed? # < Return "true"
+u.email_column.revert # Return to #undef.
+Presence validator is done using the type of the column:
+class User
+ include Clear::Model
+
+ column first_name : String # Must be present
+ column last_name : String? # Can be null
+end
+NOT NULL DEFAULT ...
CASEThere's a case when a column CAN be null inside Crystal, if not persisted, +but CANNOT be null inside Postgres.
+It's for example the case of the id
column, which take value after saving !
In this case, you can write:
+class User
+ column id : Int64, primary: true, presence: false #id will be set using pg serial !
+end
+Thus, in all case this will fail:
+u = User.new
+u.id # raise error
+When you save your model, Clear will call first the presence validators, then
+call your custom made validators. All you have to do is to reimplement
+the validate
method:
class MyModel
+#...
+ def validate
+ # Your code goes here
+ end
+end
+Validation fails if model#errors
is not empty:
class MyModel
+ #...
+ def validate
+ if first_name_column.defined? && first_name != "ABCD" #< See below why `defined?` must be called.
+ add_error("first_name", "must be ABCD!")
+ end
+ end
+ end
+Please use unique
feature of postgres. Unique validator at crystal level is a
+non-go and lead to terrible race concurrency issues if your deploy on multiple nodes/pods.
+It's an anti-pattern and must be avoided at any cost.
In the case you try validation on a column which has not been initialized, +Clear will complain, telling you you cannot access to the column. +Let's see an example here:
+class MyModel
+ #...
+ def validate
+ add_error("first_name", "should not be empty") if first_name == ""
+ end
+end
+
+MyModel.new.save! #< Raise unexpected exception, not validation failure :(
+This validator will raise an exception, because first_name has never been initialized. +To avoid this, we have many way:
+# 1. Check presence:
+
+def validate
+ if first_name_column.defined? #Ensure we have a value here.
+ add_error("first_name", "should not be empty") if first_name == ""
+ end
+end
+
+# 2. Use column object + default value
+def validate
+ add_error("first_name", "should not be empty") if first_name_column.value("") == ""
+end
+
+# 3. Use the helper macro `on_presence`
+def validate
+ on_presence(first_name) do
+ add_error("first_name", "should not be empty") if first_name == ""
+ end
+end
+
+#4. Use the helper macro `ensure_than`
+def validate
+ ensure_than(first_name, "should not be empty", &.!=(""))
+end
+
+#5. Use the `ensure_than` helper (but with block notation) !
+def validate
+ ensure_than(first_name, "should not be empty") do |column|
+ column != ""
+ end
+end
+
+I recommend the 4th method in most of the cases you will faces. +Simple to write and easy to read !
+Clear offers of course a migration system.
+Migration should have an order
column set.
+This number can be wrote at the end of the class itself:
class Migration1
+ include Clear::Migration
+
+ def change(dir)
+ #...
+ end
+end
+Another way is to write down all your migrations one file per migration, and
+naming the file using the [number]_migration_description.cr
pattern.
+In this case, the migration class name doesn't need to have a number at the end of the class name.
# in src/db/migrations/1234_create_table.cr
+class CreateTable
+ include Clear::Migration
+
+ def change(dir)
+ #...
+ end
+end
+Migration must implement the method change(dir : Migration::Direction)
Direction is the current direction of the migration (up or down).
+It provides few methods: up?
, down?
, up(&block)
, down(&block)
You can create a table:
+ def change(dir)
+ create_table(:test) do |t|
+ t.column :first_name, :string, index: true
+ t.column :last_name, :string, unique: true
+
+ t.index "lower(first_name || ' ' || last_name)", using: :btree
+
+ t.timestamps
+ end
+ end
+I strongly encourage to use the foreign key constraints of postgres for your references:
+ t.references to: "users", on_delete: "cascade", null: false
+There's no plan to offer on Crystal level the on_delete
feature, like
+dependent
in ActiveRecord. That's a standard PG feature, just set it
+up in migration
Models add a layer of computation. Below is a sample with a very simple model +(two integer column), with fetching of 100k rows over 1M rows database, using --release flag:
+| Method | | Total time | Speed | +| -------------------------: | ----: | -------------------- | -----------: | +| Simple load 100k | 12.04 | ( 83.03ms) (± 3.87%) | 2.28× slower | +| With cursor | 8.26 | ( 121.0ms) (± 1.25%) | 3.32× slower | +| With attributes | 10.30 | ( 97.12ms) (± 4.07%) | 2.67× slower | +| With attributes and cursor | 7.55 | (132.52ms) (± 2.39%) | 3.64× slower | +| SQL only | 27.46 | ( 36.42ms) (± 5.05%) | fastest |
+Simple load 100k
is using an array to fetch the 100k rows.With cursor
is querying 1000 rows at a timeWith attribute
setup a hash to deal with unknown attributes in the model (e.g. aggregates)With attribute and cursor
is doing cursored fetch with hash attributes createdSQL only
build and execute SQL using SQL::BuilderAs you can see, it takes around 100ms to fetch 100k rows for this simple model (SQL included). +If for more complex model, it would take a bit more of time, I think the performances +are quite reasonable, and tenfold or plus faster than Rails's ActiveRecord.
+This shard is provided under the MIT license.
+All contributions are welcome ! As a specialized ORM for PostgreSQL, +be sure a great contribution on a very specific PG feature will be incorporated +to this shard. +I hope one day we will cover all the features of PG here !
+In order to run the test suite, you will need to have the PostgresSQL service locally available via a socket for access with psql. psql will attempt to use the 'postgres' user to create the test database. If you are working with a newly installed database that may not have the postgres user, this can be created with createuser -s postgres
.
Used internally to deserialise json
","abstract":false,"location":{"filename":"src/clear/model/json_deserialize.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/json_deserialize.cr#L19"},"def":{"name":"columns_to_instance_vars","visibility":"Public","body":" \n# :nodoc:\n\n struct Assigner\n include JSON::Serializable\n\n \n{% for name, settings in COLUMNS %}\n @[JSON::Field(presence: true)]\n getter {{ name.id }} : {{ settings[:type] }} {% if settings[:type].resolve.nilable? %}{% else %} | Nil {% end %}\n @[JSON::Field(ignore: true)]\n getter? {{ name.id }}_present : Bool\n {% end %}\n\n\n \n# Create a new empty model and fill the columns with object's instance variables\n\n \n# Trusted flag set to true will allow mass assignment without protection\n\n def create(trusted : Bool)\n assign_columns(\n{{ @type }}\n.new, trusted)\n \nend\n\n \n# Update the inputted model and assign the columns with object's instance variables\n\n \n# Trusted flag set to true will allow mass assignment without protection\n\n def update(model, trusted : Bool)\n assign_columns(model, trusted)\n \nend\n\n macro finished\n \n# Assign properties to the model inputted with object's instance variables\n\n \n# Trusted flag set to true will allow mass assignment without protection\n\n protected def assign_columns(model, trusted : Bool)\n \n{% for name, settings in COLUMNS %}\n if ({{ settings[:mass_assign] }} || trusted) && self.{{ name.id }}_present?\n %value = self.{{ name.id }}\n {% if settings[:type].resolve.nilable? %}\n model.{{ name.id }} = %value\n {% else %}\n model.{{ name.id }} = %value unless %value.nil?\n {% end %}\n end\n {% end %}\n\n\n model\n \nend\n \nend\n \nend\n\n \n# Create a new empty model and fill the columns from json. Returns the new model\n\n \n#\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def self.from_json(string_or_io : String | IO, trusted : Bool = false)\n Assigner.from_json(string_or_io).create(trusted)\n \nend\n\n \n# Create a new model from json and save it. Returns the model.\n\n \n#\n\n \n# The model may not be saved due to validation failure;\n\n \n# check the returned model `errors?` and `persisted?` flags.\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def self.create_from_json(string_or_io : String | IO, trusted : Bool = false)\n mdl = self.from_json(string_or_io, trusted)\n mdl.save\n mdl\n \nend\n\n \n# Create a new model from json and save it. Returns the model.\n\n \n#\n\n \n# Returns the newly inserted model\n\n \n# Raises an exception if validation failed during the saving process.\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def self.create_from_json!(string_or_io : String | IO, trusted : Bool = false)\n self.from_json(string_or_io, trusted).save!\n \nend\n\n \n# Set the fields from json passed as argument\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def set_from_json(string_or_io : String | IO, trusted : Bool = false)\n Assigner.from_json(string_or_io).update(self, trusted)\n \nend\n\n \n# Set the fields from json passed as argument and call `save` on the object\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def update_from_json(string_or_io : String | IO, trusted : Bool = false)\n mdl = set_from_json(string_or_io, trusted)\n mdl.save\n mdl\n \nend\n\n \n# Set the fields from json passed as argument and call `save!` on the object\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def update_from_json!(string_or_io : String | IO, trusted : Bool = false)\n set_from_json(string_or_io, trusted).save!\n \nend\n\n"}}],"types":[{"html_id":"clear/BigDecimal","path":"BigDecimal.html","kind":"struct","full_name":"BigDecimal","name":"BigDecimal","abstract":false,"superclass":{"html_id":"clear/Number","kind":"struct","full_name":"Number","name":"Number"},"ancestors":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Number","kind":"struct","full_name":"Number","name":"Number"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Steppable","kind":"module","full_name":"Steppable","name":"Steppable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/core_ext.cr","line_number":121,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/core_ext.cr#L121"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"}],"doc":"A `BigDecimal` can represent arbitrarily large precision decimals.\n\nIt is internally represented by a pair of `BigInt` and `UInt64`: value and scale.\nValue contains the actual value, and scale tells the decimal point place.\nE.g. when value is `1234` and scale `2`, the result is `12.34`.\n\nNOTE: To use `BigDecimal`, you must explicitly import it with `require \"big\"`\n\nThe general idea and some of the arithmetic algorithms were adapted from\nthe MIT/APACHE-licensed [bigdecimal-rs](https://github.com/akubera/bigdecimal-rs).","summary":"A BigDecimal
can represent arbitrarily large precision decimals.
A Char
represents a Unicode code point.
Represents a case insensitive text, used by Postgres Wrap a string and basically change the equality check to make it case insensitive.s
","constructors":[{"html_id":"new(string:String)-class-method","name":"new","abstract":false,"args":[{"name":"string","external_name":"string","restriction":"::String"}],"args_string":"(string : String)","args_html":"(string : String)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L8"},"def":{"name":"new","args":[{"name":"string","external_name":"string","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(string)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"!=(x:String|Citext)-instance-method","name":"!=","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"args_string":"(x : String | Citext)","args_html":"(x : String | Citext)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L15"},"def":{"name":"!=","args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"visibility":"Public","body":"!(self == x)"}},{"html_id":"==(x:String|Citext)-instance-method","name":"==","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"args_string":"(x : String | Citext)","args_html":"(x : String | Citext)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L11"},"def":{"name":"==","args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"visibility":"Public","body":"(compare(x.to_s, true)) == 0"}},{"html_id":"string:String-instance-method","name":"string","abstract":false,"location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L4"},"def":{"name":"string","return_type":"String","visibility":"Public","body":"@string"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L6"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" @string.\n{{ call }}\n\n \n"}}]},{"html_id":"clear/Clear","path":"Clear.html","kind":"module","full_name":"Clear","name":"Clear","abstract":false,"locations":[{"filename":"src/clear/cli.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L9"},{"filename":"src/clear/extensions/enum/enum.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L1"},{"filename":"src/clear/log.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/log.cr#L3"},{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L24"},{"filename":"src/clear/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/seed.cr#L1"},{"filename":"src/clear/sql/lock.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/lock.cr#L1"},{"filename":"src/clear/sql/sql.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L19"},{"filename":"src/clear/sql/truncate.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/truncate.cr#L1"},{"filename":"src/clear/version.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/version.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(\"clear\")"},{"id":"VERSION","name":"VERSION","value":"{{ (`shards version /home/runner/work/clear/clear/src/clear`).chomp.stringify }}"}],"class_methods":[{"html_id":"apply_seeds-class-method","name":"apply_seeds","abstract":false,"location":{"filename":"src/clear/seed.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/seed.cr#L12"},"def":{"name":"apply_seeds","visibility":"Public","body":"Clear::SQL.transaction do\n @@seed_list.each(&.call)\nend"}},{"html_id":"seed(&block)-class-method","name":"seed","doc":"Register a seed block.\nthis block will be called by `Clear.apply_seeds`\nor conveniently by the CLI\nusing `$cli_cmd migrate seeds`","summary":"Register a seed block.
","abstract":false,"location":{"filename":"src/clear/seed.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/seed.cr#L8"},"def":{"name":"seed","yields":0,"block_arity":0,"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":"@@seed_list << block"}},{"html_id":"with_cli(&)-class-method","name":"with_cli","doc":"Check for the CLI. If the CLI is not triggered, yield the block passed as parameter","summary":"Check for the CLI.
","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L32"},"def":{"name":"with_cli","yields":0,"block_arity":0,"visibility":"Public","body":"if ARGV.size > 0 && (ARGV[0] == \"clear\")\n ARGV.shift\n Clear::CLI.run\nelse\n yield\nend"}}],"macros":[{"html_id":"enum(name,*values,&block)-macro","name":"enum","doc":"## Enum\n\nClear offers full support of postgres enum strings.\n\n### Example\n\nLet's say you need to define an enum for genders:\n\n```\n# Define the enum\nClear.enum MyApp::Gender, \"male\", \"female\" # , ...\n```\n\nIn migration, we tell Postgres about the enum:\n\n```\ncreate_enum :gender, MyApp::Gender # < Create the new type `gender` in the database\n\ncreate_table :users do |t|\n # ...\n t.gender \"gender\" # < first `gender` is the type of column, while second is the name of the column\nend\n```\n\nFinally in your model, simply add the enum as column:\n\n```\nclass User\n include Clear::Model\n # ...\n\n column gender : MyApp::Gender\nend\n```\n\nNow, you can assign the enum:\n\n```\nu = User.new\nu.gender = MyApp::Gender::Male\n```\n\nYou can dynamically check and build the enumeration values:\n\n```\nMyApp::Gender.authorized_values # < return [\"male\", \"female\"]\nMyApp::Gender.all # < return [MyApp::Gender::Male, MyApp::Gender::Female]\n\nMyApp::Gender.from_string(\"male\") # < return MyApp::Gender::Male\nMyApp::Gender.from_string(\"unknown\") # < throw Clear::IllegalEnumValueError\n\nMyApp::Gender.valid?(\"female\") # < Return true\nMyApp::Gender.valid?(\"unknown\") # < Return false\n```\n\nHowever, you cannot write:\n\n```\nu = User.new\nu.gender = \"male\"\n```\n\nBut instead:\n\n```\nu = User.new\nu.gender = MyApp::Gender::Male\n```","summary":"Register a type to allow use in Clear column system.
","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""}],"args_string":"(type)","args_html":"(type)","location":{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L40"},"def":{"name":"json_serializable_converter","args":[{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":" \n{% type = type.resolve %}\n\n module ::Clear::Model::Converter::\n{{ type }}\nConverter\n def self.to_column(x) : ::\n{{ type }}\n?\n case x\n when ::\n{{ type }}\n\n x\n when String\n ::\n{{ type }}\n.new(::JSON::PullParser.new(x))\n when ::JSON::PullParser\n ::\n{{ type }}\n.new(x)\n when ::JSON::Any\n ::\n{{ type }}\n.new(::JSON::PullParser.new(x.to_json))\n \nelse\n raise \"Cannot convert to \n{{ type }}\n from #{x.class}\"\n \nend\n \nend\n\n def self.to_db(x : ::\n{{ type }}\n?)\n x ? x.to_json : nil\n \nend\n \nend\n\n ::Clear::Model::Converter.add_converter(\n{{ \"#{type}\" }}\n, ::Clear::Model::Converter::\n{{ type }}\nConverter)\n \n"}}],"types":[{"html_id":"clear/Clear/CLI","path":"Clear/CLI.html","kind":"module","full_name":"Clear::CLI","name":"CLI","abstract":false,"locations":[{"filename":"src/clear/cli.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L10"},{"filename":"src/clear/cli/command.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/command.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"class_methods":[{"html_id":"run-class-method","name":"run","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L11"},"def":{"name":"run","visibility":"Public","body":"Clear::CLI::Base.run"}}],"types":[{"html_id":"clear/Clear/CLI/Base","path":"Clear/CLI/Base.html","kind":"class","full_name":"Clear::CLI::Base","name":"Base","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L16"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L25"},"def":{"name":"run_impl","visibility":"Public","body":"STDOUT.puts(help)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"__version__-instance-method","name":"__version__","abstract":false,"def":{"name":"__version__","visibility":"Public","body":"@__version__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__version__.nil?\n raise(Admiral::Error.new(\"Flag required: --version\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Command","path":"Clear/CLI/Command.html","kind":"module","full_name":"Clear::CLI::Command","name":"Command","abstract":false,"locations":[{"filename":"src/clear/cli/command.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/command.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/CLI/Base","kind":"class","full_name":"Clear::CLI::Base","name":"Base"},{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},{"html_id":"clear/Clear/CLI/Generator/Migration","kind":"class","full_name":"Clear::CLI::Generator::Migration","name":"Migration"},{"html_id":"clear/Clear/CLI/Generator/Model","kind":"class","full_name":"Clear::CLI::Generator::Model","name":"Model"},{"html_id":"clear/Clear/CLI/Generator/NewKemal","kind":"class","full_name":"Clear::CLI::Generator::NewKemal","name":"NewKemal"},{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},{"html_id":"clear/Clear/CLI/Migration/Down","kind":"class","full_name":"Clear::CLI::Migration::Down","name":"Down"},{"html_id":"clear/Clear/CLI/Migration/Migrate","kind":"class","full_name":"Clear::CLI::Migration::Migrate","name":"Migrate"},{"html_id":"clear/Clear/CLI/Migration/Rollback","kind":"class","full_name":"Clear::CLI::Migration::Rollback","name":"Rollback"},{"html_id":"clear/Clear/CLI/Migration/Seed","kind":"class","full_name":"Clear::CLI::Migration::Seed","name":"Seed"},{"html_id":"clear/Clear/CLI/Migration/Set","kind":"class","full_name":"Clear::CLI::Migration::Set","name":"Set"},{"html_id":"clear/Clear/CLI/Migration/Status","kind":"class","full_name":"Clear::CLI::Migration::Status","name":"Status"},{"html_id":"clear/Clear/CLI/Migration/Up","kind":"class","full_name":"Clear::CLI::Migration::Up","name":"Up"},{"html_id":"clear/Clear/CLI/Seed","kind":"class","full_name":"Clear::CLI::Seed","name":"Seed"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"}},{"html_id":"clear/Clear/CLI/Generator","path":"Clear/CLI/Generator.html","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},{"filename":"src/clear/cli/generators/migration.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L3"},{"filename":"src/clear/cli/generators/model.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L3"},{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"[](name)-class-method","name":"[]","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/clear/cli/generator.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L21"},"def":{"name":"[]","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"@@generators[name]"}},{"html_id":"[]?(name)-class-method","name":"[]?","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/clear/cli/generator.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L17"},"def":{"name":"[]?","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"@@generators[name]?"}},{"html_id":"add(name,desc,&block:Array(String)->Nil)-class-method","name":"add","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"desc","external_name":"desc","restriction":""}],"args_string":"(name, desc, &block : Array(String) -> Nil)","args_html":"(name, desc, &block : Array(String) -> Nil)","location":{"filename":"src/clear/cli/generator.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L13"},"def":{"name":"add","args":[{"name":"name","external_name":"name","restriction":""},{"name":"desc","external_name":"desc","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Array(String) -> Nil)"},"visibility":"Public","body":"@@generators[name] = Record.new(name, desc, block)"}},{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"generators-class-method","name":"generators","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L11"},"def":{"name":"generators","visibility":"Public","body":"@@generators"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L5"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L25"},"def":{"name":"run_impl","visibility":"Public","body":"puts(help)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]},{"html_id":"clear/Clear/CLI/Generator/Migration","path":"Clear/CLI/Generator/Migration.html","kind":"class","full_name":"Clear::CLI::Generator::Migration","name":"Migration","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L19"},"def":{"name":"run_impl","visibility":"Public","body":"g = Generate::Generator.new\ng.target_directory = flags.directory\nname = arguments.name\nif name\n name_underscore = name.underscore\n class_name = name.camelcase\n migration_uid = Time.local.to_unix.to_s.rjust(10, '0')\n g[\"migration_uid\"] = migration_uid\n g[\"class_name\"] = class_name\n migration_file = \"#{migration_uid}_#{name_underscore}.cr\"\n if Dir[File.join(g.target_directory, \"src/db/migrations/*_#{name_underscore}.cr\")].empty?\n else\n puts(\"A migration file `xxxx_#{name_underscore}.cr` already exists\")\n exit(1)\n end\n g.in_directory(\"src/db/migrations\") do\n g.file(migration_file, Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/../../../../templates/migration.cr.ecr\", g))\n end\nelse\n puts(\"Please provide a name for the migration\")\n exit(1)\nend\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"directory-instance-method","name":"directory","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L11"},"def":{"name":"directory","visibility":"Public","body":"@directory.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nif @directory.nil?\n raise(Admiral::Error.new(\"Flag required: --directory\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Generator/Model","path":"Clear/CLI/Generator/Model.html","kind":"class","full_name":"Clear::CLI::Generator::Model","name":"Model","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L19"},"def":{"name":"run_impl","visibility":"Public","body":"g = Generate::Generator.new\ng.target_directory = flags.directory\nname = arguments.name\nif name\n name_underscore = name.underscore\n model_table = name_underscore.pluralize\n class_name = name.camelcase\n fields = @argv.join(\"|\")\n migration_uid = Time.local.to_unix.to_s.rjust(10, '0')\n g[\"model_class\"] = class_name\n g[\"migration_uid\"] = migration_uid\n g[\"model_table\"] = model_table\n g[\"model_fields\"] = fields\n model_file = \"#{name_underscore}.cr\"\n migration_file = \"#{migration_uid}_create_#{name_underscore.pluralize}.cr\"\n if Dir[File.join(g.target_directory, \"src/db/migrations/*_create_#{name_underscore.pluralize}.cr\")].empty?\n else\n puts(\"A migration file `xxxx__create_#{name_underscore.pluralize}.cr` already exists\")\n exit(1)\n end\n g.in_directory(\"src/models\") do\n g.file(model_file, Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/../../../../templates/model/model.cr.ecr\", g))\n end\n g.in_directory(\"src/db/migrations\") do\n g.file(migration_file, Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/../../../../templates/model/migration.cr.ecr\", g))\n end\nelse\n puts(\"Please provide a name for the model\")\n exit(1)\nend\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"directory-instance-method","name":"directory","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L11"},"def":{"name":"directory","visibility":"Public","body":"@directory.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nif @directory.nil?\n raise(Admiral::Error.new(\"Flag required: --directory\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Generator/NewKemal","path":"Clear/CLI/Generator/NewKemal.html","kind":"class","full_name":"Clear::CLI::Generator::NewKemal","name":"NewKemal","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L17"},"def":{"name":"run_impl","visibility":"Public","body":"g = Generate::Generator.new\ng.target_directory = flags.directory\ng[\"app_name\"] = arguments.name || (File.basename(g.target_directory))\ng[\"app_name_underscore\"] = g[\"app_name\"].underscore\ng[\"app_name_camelcase\"] = g[\"app_name\"].camelcase\ng[\"git_username\"] = (`git config user.email`).chomp || \"email@example.com\"\ng[\"git_email\"] = (`git config user.name`).chomp || \"Your Name\"\ng.in_directory(\"bin\") do\n g.file(\"appctl\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/bin/appctl.ecr\", g))\n g.file(\"clear_cli.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/bin/clear_cli.cr.ecr\", g))\n g.file(\"server.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/bin/server.cr.ecr\", g))\nend\ng.in_directory(\"config\") do\n g.file(\"database.yml\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/config/database.yml.ecr\", g))\nend\ng.in_directory(\"src\") do\n g.in_directory(\"controllers\") do\n g.file(\"application_controller.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/controllers/application_controller.ecr\", g))\n g.file(\"welcome_controller.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/controllers/welcome_controller.ecr\", g))\n end\n g.in_directory(\"db\") do\n g.file(\"init.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/db/init.ecr\", g))\n end\n g.in_directory(\"models\") do\n g.file(\"init.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/models/application_model.ecr\", g))\n end\n g.in_directory(\"views\") do\n g.in_directory(\"components\") do\n g.file(\"footer.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/views/components/footer.ecr\", g))\n end\n g.in_directory(\"layouts\") do\n g.file(\"application.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/views/layouts/application.ecr\", g))\n end\n g.in_directory(\"welcome\") do\n g.file(\"index.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/views/welcome/index.ecr\", g))\n end\n end\n g.file(\"app.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/app.ecr\", g))\nend\ng.file(\".gitignore\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/_gitignore.ecr\", g))\ng.file(\"shard.yml\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/shard.yml.ecr\", g))\nsystem(\"chmod +x #{g.target_directory}/bin/appctl\")\nsystem(\"cd #{g.target_directory} && shards\")\nputs(\"Clear + Kemal template is now generated. `cd #{g.target_directory} && clear-cli server` to play ! :-)\")\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"directory-instance-method","name":"directory","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L9"},"def":{"name":"directory","visibility":"Public","body":"@directory.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @directory.nil?\n raise(Admiral::Error.new(\"Flag required: --directory\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Generator/Record","path":"Clear/CLI/Generator/Record.html","kind":"struct","full_name":"Clear::CLI::Generator::Record","name":"Record","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"constructors":[{"html_id":"new(name:String,desc:String,callback:Array(String)->Nil)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"desc","external_name":"desc","restriction":"String"},{"name":"callback","external_name":"callback","restriction":"(Array(String) -> Nil)"}],"args_string":"(name : String, desc : String, callback : Array(String) -> Nil)","args_html":"(name : String, desc : String, callback : Array(String) -> Nil)","location":{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"desc","external_name":"desc","restriction":"String"},{"name":"callback","external_name":"callback","restriction":"(Array(String) -> Nil)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, desc, callback)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"callback:Array(String)->Nil-instance-method","name":"callback","abstract":false,"def":{"name":"callback","return_type":"(Array(String) -> Nil)","visibility":"Public","body":"@callback"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@name.clone, @desc.clone, @callback.clone)"}},{"html_id":"copy_with(name_name=@name,desc_desc=@desc,callback_callback=@callback)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_desc","default_value":"@desc","external_name":"desc","restriction":""},{"name":"_callback","default_value":"@callback","external_name":"callback","restriction":""}],"args_string":"(name _name = @name, desc _desc = @desc, callback _callback = @callback)","args_html":"(name _name = @name, desc _desc = @desc, callback _callback = @callback)","location":{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"},"def":{"name":"copy_with","args":[{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_desc","default_value":"@desc","external_name":"desc","restriction":""},{"name":"_callback","default_value":"@callback","external_name":"callback","restriction":""}],"visibility":"Public","body":"self.class.new(_name, _desc, _callback)"}},{"html_id":"desc:String-instance-method","name":"desc","abstract":false,"def":{"name":"desc","return_type":"String","visibility":"Public","body":"@desc"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}}]}]},{"html_id":"clear/Clear/CLI/Migration","path":"Clear/CLI/Migration.html","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L2"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L108"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.apply_all"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L38"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L43"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.down(arguments.migration_number)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L37"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Flags","path":"Clear/CLI/Migration/Flags.html","kind":"struct","full_name":"Clear::CLI::Migration::Flags","name":"Flags","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DESCRIPTIONS","name":"DESCRIPTIONS","value":"{} of String => String"},{"id":"SPECS","name":"SPECS","value":"{\"verbose\" => {kind: \"bool\", type: \"Bool\", default: \"false\", description: {\"--verbose, -v\", \"Display verbose informations during execution\"}, short: \"v\", long: \"verbose\", is_required: true}, \"no_color\" => {kind: \"bool\", type: \"Bool\", default: \"false\", description: {\"--no-color\", \"Cancel color output\"}, short: \"nil\", long: \"no-color\", is_required: true}, \"__help__\" => {kind: \"bool\", type: \"Bool\", default: \"false\", description: {\"--help\", \"Displays help for the current command.\"}, short: \"nil\", long: \"help\", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"doc":"Extend the flags struct to include the flag","summary":"Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]},{"html_id":"clear/Clear/CLI/Migration/Migrate","path":"Clear/CLI/Migration/Migrate.html","kind":"class","full_name":"Clear::CLI::Migration::Migrate","name":"Migrate","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L72"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":74,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L74"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.apply_all"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Rollback","path":"Clear/CLI/Migration/Rollback.html","kind":"class","full_name":"Clear::CLI::Migration::Rollback","name":"Rollback","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":80,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L80"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":85,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L85"},"def":{"name":"run_impl","visibility":"Public","body":"array = Clear::Migration::Manager.instance.migrations_up.to_a.sort\nnum = (arguments.num.try(&.to_i) || 1) + 1\nif num > array.size\n num = array.size - 1\nend\nClear::Migration::Manager.instance.apply_to(array[-num], direction: :down)\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Seed","path":"Clear/CLI/Migration/Seed.html","kind":"class","full_name":"Clear::CLI::Migration::Seed","name":"Seed","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L17"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L21"},"def":{"name":"run_impl","visibility":"Public","body":"Clear.apply_seeds"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Set","path":"Clear/CLI/Migration/Set.html","kind":"class","full_name":"Clear::CLI::Migration::Set","name":"Set","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L49"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L54"},"def":{"name":"run_impl","visibility":"Public","body":"dir_symbol = case flags.direction\nwhen \"up\"\n :up\nwhen \"down\"\n :down\nwhen \"both\"\n :both\nelse\n puts(\"Bad argument --direction : #{flags.direction}. Must be up|down|both\")\n exit(1)\nend\nClear::Migration::Manager.instance.apply_to(arguments.to, direction: dir_symbol)\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"direction-instance-method","name":"direction","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L51"},"def":{"name":"direction","visibility":"Public","body":"@direction.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @direction.nil?\n raise(Admiral::Error.new(\"Flag required: --direction\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Status","path":"Clear/CLI/Migration/Status.html","kind":"class","full_name":"Clear::CLI::Migration::Status","name":"Status","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L11"},"def":{"name":"run_impl","visibility":"Public","body":"puts(Clear::Migration::Manager.instance.print_status)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Up","path":"Clear/CLI/Migration/Up.html","kind":"class","full_name":"Clear::CLI::Migration::Up","name":"Up","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L27"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L32"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.up(arguments.migration_number)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]}]},{"html_id":"clear/Clear/CLI/Seed","path":"Clear/CLI/Seed.html","kind":"class","full_name":"Clear::CLI::Seed","name":"Seed","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/seed.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L2"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/seed.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L6"},"def":{"name":"run_impl","visibility":"Public","body":"Clear.apply_seeds"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]}]},{"html_id":"clear/Clear/Enum","path":"Clear/Enum.html","kind":"struct","full_name":"Clear::Enum","name":"Enum","abstract":true,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/enum/enum.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"Clear::Enum wrap the enums used in PostgreSQL.\nSee `Clear.enum` macro helper.","summary":"Clear::Enum wrap the enums used in PostgreSQL.
","constructors":[{"html_id":"new(value:JSON::PullParser|String)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::JSON::PullParser | ::String"}],"args_string":"(value : JSON::PullParser | String)","args_html":"(value : JSON::PullParser | String)","location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L12"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::JSON::PullParser | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(x)-instance-method","name":"==","doc":"Returns `true` if this struct is equal to *other*.\n\nBoth structs' instance vars are compared to each other. Thus, two\nstructs are considered equal if each of their instance variables are\nequal. Subclasses should override this method to provide specific\nequality semantics.\n\n```\nstruct Point\n def initialize(@x : Int32, @y : Int32)\n end\nend\n\np1 = Point.new 1, 2\np2 = Point.new 1, 2\np3 = Point.new 3, 4\n\np1 == p2 # => true\np1 == p3 # => false\n```","summary":"Returns true
if this struct is equal to other.
Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L15"},"def":{"name":"to_s","return_type":"String","visibility":"Public","body":"@value.to_s"}},{"html_id":"to_sql:String-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L19"},"def":{"name":"to_sql","return_type":"String","visibility":"Public","body":"@value.to_sql"}}],"types":[{"html_id":"clear/Clear/Enum/Converter","path":"Clear/Enum/Converter.html","kind":"module","full_name":"Clear::Enum::Converter(T)","name":"Converter","abstract":false,"locations":[{"filename":"src/clear/extensions/enum/enum.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L31"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Enum","kind":"struct","full_name":"Clear::Enum","name":"Enum"},"class_methods":[{"html_id":"to_column(x):T|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : T | Nil","args_html":"(x) : T | Nil","location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L32"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"T | ::Nil","visibility":"Public","body":"case x\nwhen String\n T.authorized_values[x]\nwhen Nil\n nil\nelse\n raise(converter_error(x.class.name, \"Enum: #{T.class.name}\"))\nend"}}]}]},{"html_id":"clear/Clear/ErrorMessages","path":"Clear/ErrorMessages.html","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages","abstract":false,"locations":[{"filename":"src/clear/error_messages.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"including_types":[{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},{"html_id":"clear/Clear/Migration/Manager","kind":"class","full_name":"Clear::Migration::Manager","name":"Manager"},{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},{"html_id":"clear/Clear/Model/Column","kind":"class","full_name":"Clear::Model::Column(T, C)","name":"Column"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"This module list most of the runtime errors happening in Clear.\nIt's an attempt to make Clear user friendly by enabling advanced resolution\nof problems when they raise.","summary":"This module list most of the runtime errors happening in Clear.
","instance_methods":[{"html_id":"build_error_message(message:String,ways_to_resolve:Tuple|Array=Tuple.new,manual_pages:Tuple|Array=Tuple.new)-instance-method","name":"build_error_message","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"},{"name":"ways_to_resolve","default_value":"Tuple.new","external_name":"ways_to_resolve","restriction":"Tuple | Array"},{"name":"manual_pages","default_value":"Tuple.new","external_name":"manual_pages","restriction":"Tuple | Array"}],"args_string":"(message : String, ways_to_resolve : Tuple | Array = Tuple.new, manual_pages : Tuple | Array = Tuple.new)","args_html":"(message : String, ways_to_resolve : Tuple | Array = Tuple.new, manual_pages : Tuple | Array = Tuple.new)","location":{"filename":"src/clear/error_messages.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L65"},"def":{"name":"build_error_message","args":[{"name":"message","external_name":"message","restriction":"String"},{"name":"ways_to_resolve","default_value":"Tuple.new","external_name":"ways_to_resolve","restriction":"Tuple | Array"},{"name":"manual_pages","default_value":"Tuple.new","external_name":"manual_pages","restriction":"Tuple | Array"}],"visibility":"Public","body":"{% if flag?(:release) %}\n message\n {% else %}\n format_width({\n build_message(message),\n build_tips(ways_to_resolve),\n build_manual(manual_pages),\n (\n \"You may also have encountered a bug. \\n\" +\n \"Feel free to submit an issue: \\n#{build_url(\"https://github.com/anykeyh/clear/issues/new\")}\"\n ),\n \"\\n\\nStack trace:\\n\",\n }.join)\n {% end %}"}},{"html_id":"converter_error(from,to)-instance-method","name":"converter_error","abstract":false,"args":[{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"args_string":"(from, to)","args_html":"(from, to)","location":{"filename":"src/clear/error_messages.cr","line_number":209,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L209"},"def":{"name":"converter_error","args":[{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"visibility":"Public","body":"build_error_message(\"Clear cannot convert from `#{from}` to #{to}.\", {\"Ensure your database column type matches the column declaration in Clear\"}, {\"model/Definition.md\"})"}},{"html_id":"format_width(x,w=80)-instance-method","name":"format_width","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""},{"name":"w","default_value":"80","external_name":"w","restriction":""}],"args_string":"(x, w = 80)","args_html":"(x, w = 80)","location":{"filename":"src/clear/error_messages.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L11"},"def":{"name":"format_width","args":[{"name":"x","external_name":"x","restriction":""},{"name":"w","default_value":"80","external_name":"w","restriction":""}],"visibility":"Public","body":"counter = 0\no = [] of String\n(x.split(/([ \\n\\t])/)).each do |word|\n case word\n when \"\\n\"\n o << word\n counter = 0\n else\n counter = counter + word.size\n if counter > w\n o << \"\\n\"\n if word == \" \"\n counter = 0\n else\n o << word\n counter = word.size\n end\n else\n o << word\n end\n end\nend\no.join\n"}},{"html_id":"illegal_setter_access_to_undefined_column(name)-instance-method","name":"illegal_setter_access_to_undefined_column","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/clear/error_messages.cr","line_number":177,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L177"},"def":{"name":"illegal_setter_access_to_undefined_column","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"build_error_message(\"You're trying to access to the column `#{name}` but it is not initialized.\", {\"Ensure that the column `#{name}` exists in your table\", \"If the model comes from a collection query, there was maybe a filtering on your `select` clause, \" + \"and you forgot to declare the column `#{name}`\", \"In the case of unpersisted models, please initialize by calling `#{name}=` first\", \"For validator, try `ensure_than` method, or use `#{name}_column.defined?` to avoid your validation code.\", \"Are you calling `#{name}_column.revert` somewhere before?\", \"If your model comes from JSON, please ensure the JSON source defines the column. Usage of `strict` mode will \" + \"trigger exception on JSON loading.\"}, {\"model/Definition.md\", \"model/Lifecycle.md\"})"}},{"html_id":"lack_of_primary_key(model_name)-instance-method","name":"lack_of_primary_key","abstract":false,"args":[{"name":"model_name","external_name":"model_name","restriction":""}],"args_string":"(model_name)","args_html":"(model_name)","location":{"filename":"src/clear/error_messages.cr","line_number":218,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L218"},"def":{"name":"lack_of_primary_key","args":[{"name":"model_name","external_name":"model_name","restriction":""}],"visibility":"Public","body":"build_error_message(\"Model `#{model_name}` lacks of primary key field\", {\"Define a column as primary key\", \"Only one column can be primary key (no compound keys are allowed in Clear for now)\", \"You can use the helpers for primary key (see manual page)\"}, {\"model/PrimaryKeyTweaking.md\"})"}},{"html_id":"migration_already_down(number)-instance-method","name":"migration_already_down","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/error_messages.cr","line_number":94,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L94"},"def":{"name":"migration_already_down","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"build_error_message(\"Migration already down: #{number}\", {\"You're trying to force a migration which is not set in your database yet. \" + \"You should up the migration first, then down it again.\"}, {\"migration/Migration.md\"})"}},{"html_id":"migration_already_up(number)-instance-method","name":"migration_already_up","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/error_messages.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L82"},"def":{"name":"migration_already_up","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"build_error_message(\"Migration already up: #{number}\", {\"You're trying to force a migration which is already existing in your database. \" + \"You should down the migration first, then up it again.\"}, {\"migration/Migration.md\"})"}},{"html_id":"migration_irreversible(name=nil,operation=nil)-instance-method","name":"migration_irreversible","abstract":false,"args":[{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"operation","default_value":"nil","external_name":"operation","restriction":""}],"args_string":"(name = nil, operation = nil)","args_html":"(name = nil, operation = nil)","location":{"filename":"src/clear/error_messages.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L144"},"def":{"name":"migration_irreversible","args":[{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"operation","default_value":"nil","external_name":"operation","restriction":""}],"visibility":"Public","body":"op_string = operation ? \"This is caused by the operation #{operation} which is irreversible.\" : nil\nmig_string = name ? \"The migration `#{name}` is irreversible. You're trying to down a migration which is not downable, \" + \"because the operations are one way only.\" : \"A migration is irreversible. You're trying to down a migration which is not downable, \" + \"because the operations are one way only.\"\nbuild_error_message(mig_string, [op_string, \"Build a way to revert the migration\", \"Do not revert the migration\", \"Maybe you need to manually flush the migration using Postgres. `__clear_metadatas` table store loaded \" + \"migrations. Good luck !\"].compact, {\"migration/Migration.md\"})\n"}},{"html_id":"migration_not_found(number)-instance-method","name":"migration_not_found","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/error_messages.cr","line_number":106,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L106"},"def":{"name":"migration_not_found","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"build_error_message(\"The migration number `#{number}` is not found.\", {\"Ensure your migration files are required\", \"Number of the migrations can be found in the filename, \" + \"in the classname or in the `uid` method of the migration.\"}, {\"migration/Migration.md\"})"}},{"html_id":"migration_not_unique(numbers)-instance-method","name":"migration_not_unique","abstract":false,"args":[{"name":"numbers","external_name":"numbers","restriction":""}],"args_string":"(numbers)","args_html":"(numbers)","location":{"filename":"src/clear/error_messages.cr","line_number":164,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L164"},"def":{"name":"migration_not_unique","args":[{"name":"numbers","external_name":"numbers","restriction":""}],"visibility":"Public","body":"build_error_message(\"The migration manage found collision on migration number. Migrations number are: #{numbers.join(\", \")}\", {\"It happens when migration share the same `uid`. Try to change the UID of one of your migrations\", \"By default, Clear has a `-1` migration used internally. Do not use this migration number.\", \"Migration numbers can be found in filename, classname or return of `uid` method\"}, {\"migration/Migration.md\"})"}},{"html_id":"no_migration_yet(version)-instance-method","name":"no_migration_yet","abstract":false,"args":[{"name":"version","external_name":"version","restriction":""}],"args_string":"(version)","args_html":"(version)","location":{"filename":"src/clear/error_messages.cr","line_number":119,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L119"},"def":{"name":"no_migration_yet","args":[{"name":"version","external_name":"version","restriction":""}],"visibility":"Public","body":"build_error_message(\"No migrations are registered yet, so we cannot go to version=#{version}\", {\"Ensure your migration files are required\", \"Ensure you have some migration files. Captain obvious to the rescue! ;-)\"}, {\"migration/Migration.md\"})"}},{"html_id":"null_column_mapping_error(name,type)-instance-method","name":"null_column_mapping_error","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""}],"args_string":"(name, type)","args_html":"(name, type)","location":{"filename":"src/clear/error_messages.cr","line_number":196,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L196"},"def":{"name":"null_column_mapping_error","args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":"build_error_message(\"Your field `#{name}` is declared as `#{type}` but `NULL` value has been found in the database.\", {\"In your model, declare your column `column #{name} : #{type}?` (note the `?` which allow nil value)\", \"In your database, adding `DEFAULT` value and/or `NOT NULL` constraint should disallow NULL fields \" + \"from your data.\"}, {\"model/Definition.md#presence-validation\"})"}},{"html_id":"order_by_error_invalid_order(current_order)-instance-method","name":"order_by_error_invalid_order","abstract":false,"args":[{"name":"current_order","external_name":"current_order","restriction":""}],"args_string":"(current_order)","args_html":"(current_order)","location":{"filename":"src/clear/error_messages.cr","line_number":259,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L259"},"def":{"name":"order_by_error_invalid_order","args":[{"name":"current_order","external_name":"current_order","restriction":""}],"visibility":"Public","body":"build_error_message(\"Order by allow only ASC and DESC directions. But #{current_order} was given.\", {\"Ensure to use :asc, :desc symbol (or string) when constructing your query.\", \"If the code is dynamic, force the casting to one of the two value above, to avoid SQL injection.\"}, {\"querying/RequestBuilding.md\"})"}},{"html_id":"polymorphic_nil(through)-instance-method","name":"polymorphic_nil","abstract":false,"args":[{"name":"through","external_name":"through","restriction":""}],"args_string":"(through)","args_html":"(through)","location":{"filename":"src/clear/error_messages.cr","line_number":229,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L229"},"def":{"name":"polymorphic_nil","args":[{"name":"through","external_name":"through","restriction":""}],"visibility":"Public","body":"build_error_message(\"Impossible to instantiate polymorphic object, because the type given by the data is nil.\", {\"The column `#{through}` contains NULL value, but is set as storage for \" + \"the type of the polymorphic object.\", \"Try to set DEFAULT value for your column `#{through}`\", \"In case of new implementation of polymorphic system, we recommend you to update the column to the previous \" + \"Class value. Value must be equal to the fully qualified model class name in Crystal (e.g. `MyApp::MyModel`)\"}, {\"model/Polymorphism.md\"})"}},{"html_id":"polymorphic_unknown_class(class_name)-instance-method","name":"polymorphic_unknown_class","abstract":false,"args":[{"name":"class_name","external_name":"class_name","restriction":""}],"args_string":"(class_name)","args_html":"(class_name)","location":{"filename":"src/clear/error_messages.cr","line_number":242,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L242"},"def":{"name":"polymorphic_unknown_class","args":[{"name":"class_name","external_name":"class_name","restriction":""}],"visibility":"Public","body":"build_error_message(\"Impossible to instantiate a new `#{class_name}` using polymorphism.\", {((\"Ensure the type is properly setup in your `polymorphic` helper. \" + \"Any model which can exists in your database needs to manually be setup as in the example below:\\n\") + \"`polymorphic Dog, Cat, through: \\\"type\\\"`\\n\") + \"In this case, if you have a `Cow` object in your database, then add it in the list of allowed polymorphic objects.\", (\"Ensure the name match a fully qualified, with full path, Clear model:\\n\" + \"`polymorphic ::Animal::Dog, ::Animal::Cat, through: \\\"type\\\"`\\n\") + \"The column should then contains `Animal::Dog` and not `Dog`\"}, {\"model/Polymorphism.md\"})"}},{"html_id":"query_building_error(message)-instance-method","name":"query_building_error","abstract":false,"args":[{"name":"message","external_name":"message","restriction":""}],"args_string":"(message)","args_html":"(message)","location":{"filename":"src/clear/error_messages.cr","line_number":271,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L271"},"def":{"name":"query_building_error","args":[{"name":"message","external_name":"message","restriction":""}],"visibility":"Public","body":"Clear::SQL::QueryBuildingError.new(build_error_message({\"You're trying to construct an invalid SQL request:\\n\", message}.join, manual_pages: {\"querying/RequestBuilding.md\"}))"}},{"html_id":"uid_not_found(class_name)-instance-method","name":"uid_not_found","abstract":false,"args":[{"name":"class_name","external_name":"class_name","restriction":""}],"args_string":"(class_name)","args_html":"(class_name)","location":{"filename":"src/clear/error_messages.cr","line_number":131,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L131"},"def":{"name":"uid_not_found","args":[{"name":"class_name","external_name":"class_name","restriction":""}],"visibility":"Public","body":"build_error_message(\"I don't know how to order the migration `#{class_name}`\", {\"Rename your migration class to have the migration UID at the end of the class name\", \"Rename the file where your migration stand to have the migration UID in front of the filename\", \"Override the method `uid`. Be sure the number is immutable (e.g. return constant)\"}, {\"migration/Migration.md\"})"}},{"html_id":"uninitialized_db_connection(connection)-instance-method","name":"uninitialized_db_connection","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":""}],"args_string":"(connection)","args_html":"(connection)","location":{"filename":"src/clear/error_messages.cr","line_number":278,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L278"},"def":{"name":"uninitialized_db_connection","args":[{"name":"connection","external_name":"connection","restriction":""}],"visibility":"Public","body":"build_error_message(\"You're trying to access the connection #{connection} which is not initialized\", {\"Use `Clear::SQL.init(#{connection}: \\\"postgres://XXX...\\\" )` on startup of your application\", \"The name of the connection (#{connection}) can't be found. It may have been mistyped.\"}, {\"Setup.md\", \"model/MultiConnection.md\"})"}}]},{"html_id":"clear/Clear/Expression","path":"Clear/Expression.html","kind":"class","full_name":"Clear::Expression","name":"Expression","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/expression.cr","line_number":55,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L55"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DATABASE_DATE_FORMAT","name":"DATABASE_DATE_FORMAT","value":"\"%Y-%m-%d\""},{"id":"DATABASE_DATE_TIME_FORMAT","name":"DATABASE_DATE_TIME_FORMAT","value":"\"%Y-%m-%d %H:%M:%S.%L %:z\""}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"## Clear's Expression engine\n\nThe goal of this module is to offer the most natural way to write down your\nquery in crystal.\n\nIf you're familiar with Sequel on Ruby, then here you have !\n\nInstead of writing:\n\n```\nmodel_collection.where(\"created_at BETWEEN ? AND ?\", 1.day.ago, DateTime.local)\n```\n\nYou can write:\n```\nmodel_collection.where { created_at.between(1.day.ago, DateTime.local) }\n```\n\nor even:\n\n```\nmodel_collection.where { created_at.in?(1.day.ago..DateTime.local) }\n```\n\n(Note for the later, it will generate `created_at > 1.day.ago AND created_at < DateTime.local`)\n\n## Limitations\n\nDue to the use of `missing_method` macro, some case can be confusing.\n\n### Existing local variable / instance method\n\n```\nid = 1\nmodel_collection.where { id > 100 } # Will raise an error, because the expression is resolved by Crystal !\n# Should be:\nid = 1\nmodel_collection.where { var(\"id\") > 100 } # Will works\n```\n\n### Usage of AND / OR\n\nAnd/Or can be used using the bitwises operators `&` and `|`.\nDue to the impossibility to reuse `||` and `&&`, beware the operator precendance\nrules are changed.\n\n```\n# v-- This below will not works, as we cannot redefine the `or` operator\nmodel_collection.where { first_name == \"yacine\" || last_name == \"petitprez\" }\n# v-- This will works, but beware of the parenthesis between each terms, as `|` is prioritary on `==`\nmodel.collection.where { (firt_name == \"yacine\") | (last_name == \"petitprez\") }\n# ^-- ... WHERE first_name = 'yacine' OR last_name == ''\n```\n","summary":"A fast way to call self.safe_literal
See .safe_literal(x : _)
This method will raise error on compilation if discovered in the code.
","abstract":false,"args":[{"name":"any","external_name":"any","restriction":""}],"args_string":"(any)","args_html":"(any)","location":{"filename":"src/clear/expression/expression.cr","line_number":188,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L188"},"def":{"name":"ensure_node!","args":[{"name":"any","external_name":"any","restriction":""}],"visibility":"Public","body":"{% raise(((((\"The expression engine discovered a runtime-evaluable condition.\\n\" + \"It happens when a test is done with values on both sides.\\n\") + \"Maybe a local variable is breaking the expression engine like here:\\n\") + \"id = 1\\n\") + \"Users.where { id == nil }\\n\\n\") + \"In this case, please use `raw(\\\"id IS NULL\\\")` to allow the expression.\") %}"}},{"html_id":"raw(x:String,*args)-class-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(?, ?) = ?\", a, b, c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"args_string":"(x : String, *args)","args_html":"(x : String, *args)","location":{"filename":"src/clear/expression/expression.cr","line_number":252,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L252"},"def":{"name":"raw","args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"splat_index":1,"visibility":"Public","body":"raw_enum(x, args)"}},{"html_id":"raw(__template:String,**tuple)-class-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(:a, :b) = :c\", a: a, b: b, c: c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"__template","external_name":"__template","restriction":"String"}],"args_string":"(__template : String, **tuple)","args_html":"(__template : String, **tuple)","location":{"filename":"src/clear/expression/expression.cr","line_number":296,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L296"},"def":{"name":"raw","args":[{"name":"__template","external_name":"__template","restriction":"String"}],"double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"__template.gsub(/(^|[^:])\\:([a-zA-Z0-9_]+)/) do |_, match|\n begin\n sym = match[2]\n match[1] + Clear::Expression[tuple[sym]]\n rescue e : KeyError\n raise(Clear::ErrorMessages.query_building_error(e.message))\n end\nend"}},{"html_id":"raw_enum(x:String,args)-class-method","name":"raw_enum","doc":"See `self.raw`\nCan pass an array to this version","summary":"See self.raw
Can pass an array to this version
Transform multiple objects into a string which is SQL-Injection safe.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Enumerable(AvailableLiteral)"}],"args_string":"(x : Enumerable(AvailableLiteral)) : Enumerable(String)","args_html":"(x : Enumerable(AvailableLiteral)) : Enumerable(String)","location":{"filename":"src/clear/expression/expression.cr","line_number":127,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L127"},"def":{"name":"safe_literal","args":[{"name":"x","external_name":"x","restriction":"Enumerable(AvailableLiteral)"}],"return_type":"Enumerable(String)","visibility":"Public","body":"x.map do |item|\n safe_literal(item)\nend"}},{"html_id":"safe_literal(x:Time,date:Bool=false):String-class-method","name":"safe_literal","doc":"Safe literal of a time return a string representation of time in the format understood by postgresql.\n\nIf the optional parameter `date` is passed, the time is truncated and only the date is passed:\n\n## Example\n\n```\nClear::Expression[Time.local] # < \"2017-04-03 23:04:43.234 +08:00\"\nClear::Expression[Time.local, date: true] # < \"2017-04-03\"\n```","summary":"Safe literal of a time return a string representation of time in the format understood by postgresql.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Time"},{"name":"date","default_value":"false","external_name":"date","restriction":"Bool"}],"args_string":"(x : Time, date : Bool = false) : String","args_html":"(x : Time, date : Bool = false) : String","location":{"filename":"src/clear/expression/expression.cr","line_number":147,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L147"},"def":{"name":"safe_literal","args":[{"name":"x","external_name":"x","restriction":"Time"},{"name":"date","default_value":"false","external_name":"date","restriction":"Bool"}],"return_type":"String","visibility":"Public","body":"{\"'\", x.to_utc.to_s(date ? DATABASE_DATE_FORMAT : DATABASE_DATE_TIME_FORMAT), \"'\"}.join"}},{"html_id":"safe_literal(x:_):String-class-method","name":"safe_literal","doc":"Sanitize an object and return a `String` representation of itself which is proofed against SQL injections.","summary":"Sanitize an object and return a String
representation of itself which is proofed against SQL injections.
Return unsafe string injected to the query.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/expression/expression.cr","line_number":133,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L133"},"def":{"name":"unsafe","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"Clear::Expression::UnsafeSql.new(x)"}},{"html_id":"where(&):Node-class-method","name":"where","doc":"Return a node of the expression engine\nThis node can then be combined with others node\nin case of chain request creation `where {...}.where {...}`\nthrough the chaining engine","summary":"Return a node of the expression engine This node can then be combined with others node in case of chain request creation where {...}.where {...}
through the chaining engine
NOT
operator
Because many postgresql operators are not transcriptable in Crystal lang, this helpers helps to write the expressions:
","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"Node | AvailableLiteral"},{"name":"b","external_name":"b","restriction":"Node | AvailableLiteral"},{"name":"op","external_name":"op","restriction":"String"}],"args_string":"(a : Node | AvailableLiteral, b : Node | AvailableLiteral, op : String)","args_html":"(a : Node | AvailableLiteral, b : Node | AvailableLiteral, op : String)","location":{"filename":"src/clear/expression/expression.cr","line_number":337,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L337"},"def":{"name":"op","args":[{"name":"a","external_name":"a","restriction":"Node | AvailableLiteral"},{"name":"b","external_name":"b","restriction":"Node | AvailableLiteral"},{"name":"op","external_name":"op","restriction":"String"}],"visibility":"Public","body":"if a.is_a?(AvailableLiteral)\n a = Node::Literal.new(a)\nend\nif b.is_a?(AvailableLiteral)\n b = Node::Literal.new(b)\nend\nNode::DoubleOperator.new(a, b, op)\n"}},{"html_id":"raw(x:String,*args)-instance-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(?, ?) = ?\", a, b, c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"args_string":"(x : String, *args)","args_html":"(x : String, *args)","location":{"filename":"src/clear/expression/expression.cr","line_number":237,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L237"},"def":{"name":"raw","args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"splat_index":1,"visibility":"Public","body":"Node::Raw.new(self.class.raw(x, *args))"}},{"html_id":"raw(__template:String,**tuple)-instance-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(:a, :b) = :c\", a: a, b: b, c: c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"__template","external_name":"__template","restriction":"String"}],"args_string":"(__template : String, **tuple)","args_html":"(__template : String, **tuple)","location":{"filename":"src/clear/expression/expression.cr","line_number":281,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L281"},"def":{"name":"raw","args":[{"name":"__template","external_name":"__template","restriction":"String"}],"double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"Node::Raw.new(self.class.raw(__template, **tuple))"}},{"html_id":"var(*parts)-instance-method","name":"var","doc":"Use var to create expression of variable. Variables are columns with or without the namespace and tablename:\n\nIt escapes each part of the expression with double-quote as requested by PostgreSQL.\nThis is useful to escape SQL keywords or `.` and `\"` character in the name of a column.\n\n```\nvar(\"template1\", \"users\", \"name\") # \"template1\".\"users\".\"name\"\nvar(\"template1\", \"users.table2\", \"name\") # \"template1\".\"users.table2\".\"name\"\nvar(\"order\") # \"order\"\n```","summary":"Use var to create expression of variable.
","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/clear/expression/expression.cr","line_number":317,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L317"},"def":{"name":"var","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"_var(parts)"}}],"types":[{"html_id":"clear/Clear/Expression/AvailableLiteral","path":"Clear/Expression/AvailableLiteral.html","kind":"alias","full_name":"Clear::Expression::AvailableLiteral","name":"AvailableLiteral","abstract":false,"locations":[{"filename":"src/clear/expression/expression.cr","line_number":91,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L91"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Bool | Clear::Expression::Literal | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)","aliased_html":"Bool | Clear::Expression::Literal | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil","const":false,"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"}},{"html_id":"clear/Clear/Expression/JSONB","path":"Clear/Expression/JSONB.html","kind":"module","full_name":"Clear::Expression::JSONB","name":"JSONB","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/node.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"},"types":[{"html_id":"clear/Clear/Expression/JSONB/Node","path":"Clear/Expression/JSONB/Node.html","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/node.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"}],"namespace":{"html_id":"clear/Clear/Expression/JSONB","kind":"module","full_name":"Clear::Expression::JSONB","name":"JSONB"},"instance_methods":[{"html_id":"jsonb(key:String)-instance-method","name":"jsonb","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L21"},"def":{"name":"jsonb","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"Clear::Expression::Node::JSONB::Field.new(self, key)"}},{"html_id":"jsonb_all_keys_exists?(keys:Array(T))forallT-instance-method","name":"jsonb_all_keys_exists?","abstract":false,"args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"args_string":"(keys : Array(T)) forall T","args_html":"(keys : Array(T)) forall T","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L17"},"def":{"name":"jsonb_all_keys_exists?","args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"visibility":"Public","body":"_jsonb_keys_exists(keys, \"?&\")"}},{"html_id":"jsonb_any_key_exists?(keys:Array(T))forallT-instance-method","name":"jsonb_any_key_exists?","abstract":false,"args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"args_string":"(keys : Array(T)) forall T","args_html":"(keys : Array(T)) forall T","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L13"},"def":{"name":"jsonb_any_key_exists?","args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"visibility":"Public","body":"_jsonb_keys_exists(keys, \"?|\")"}},{"html_id":"jsonb_key_exists?(key:String)-instance-method","name":"jsonb_key_exists?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L2"},"def":{"name":"jsonb_key_exists?","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"Clear::Expression::Node::DoubleOperator.new(self, Clear::Expression::Node::Literal.new(key), \"?\")"}}]}]},{"html_id":"clear/Clear/Expression/Literal","path":"Clear/Expression/Literal.html","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal","abstract":false,"locations":[{"filename":"src/clear/expression/expression.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L62"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Enum","kind":"struct","full_name":"Clear::Enum","name":"Enum"},{"html_id":"clear/Clear/Expression/UnsafeSql","kind":"class","full_name":"Clear::Expression::UnsafeSql","name":"UnsafeSql"}],"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"},"doc":"Allow any type to be used into the expression engine\n by including the module Clear::Expression::Literal\n and defining the method `to_sql`.","summary":"Allow any type to be used into the expression engine by including the module Clear::Expression::Literal and defining the method #to_sql
.
Mother class of all the rendering nodes
","instance_methods":[{"html_id":"!=(any:Node):Node-instance-method","name":"!=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L49"},"def":{"name":"!=","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"<>\")"}},{"html_id":"!=(some_nil:Nil):Node-instance-method","name":"!=","abstract":false,"args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"args_string":"(some_nil : Nil) : Node","args_html":"(some_nil : Nil) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L49"},"def":{"name":"!=","args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Null.new, \"IS NOT\")"}},{"html_id":"!=(any:T):NodeforallT-instance-method","name":"!=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L49"},"def":{"name":"!=","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"<>\")"}},{"html_id":"!~(any:Node):Node-instance-method","name":"!~","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L29"},"def":{"name":"!~","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"!~\")"}},{"html_id":"!~(regexp:Regex):Node-instance-method","name":"!~","abstract":false,"args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"args_string":"(regexp : Regex) : Node","args_html":"(regexp : Regex) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L41"},"def":{"name":"!~","args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"return_type":"Node","visibility":"Public","body":"if regexp.options.ignore_case?\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"!~*\")\nelse\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"!~\")\nend"}},{"html_id":"&(any:Node):Node-instance-method","name":"&","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L53"},"def":{"name":"&","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"AND\")"}},{"html_id":"&(any:T):NodeforallT-instance-method","name":"&","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L53"},"def":{"name":"&","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"AND\")"}},{"html_id":"*(any:Node):Node-instance-method","name":"*","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"*","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"*\")"}},{"html_id":"*(any:T):NodeforallT-instance-method","name":"*","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"*","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"*\")"}},{"html_id":"+(any:Node):Node-instance-method","name":"+","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"+","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"+\")"}},{"html_id":"+(any:T):NodeforallT-instance-method","name":"+","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"+","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"+\")"}},{"html_id":"-(any:Node):Node-instance-method","name":"-","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"-","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"-\")"}},{"html_id":"-(any:T):NodeforallT-instance-method","name":"-","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"-","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"-\")"}},{"html_id":"--instance-method","name":"-","abstract":false,"location":{"filename":"src/clear/expression/nodes/node.cr","line_number":78,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L78"},"def":{"name":"-","visibility":"Public","body":"Node::Minus.new(self)"}},{"html_id":"/(any:Node):Node-instance-method","name":"/","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"/","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"/\")"}},{"html_id":"/(any:T):NodeforallT-instance-method","name":"/","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"/","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"/\")"}},{"html_id":"<(any:Node):Node-instance-method","name":"<","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"<","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"<\")"}},{"html_id":"<(any:T):NodeforallT-instance-method","name":"<","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"<","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"<\")"}},{"html_id":"<=(any:Node):Node-instance-method","name":"<=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"<=","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"<=\")"}},{"html_id":"<=(any:T):NodeforallT-instance-method","name":"<=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"<=","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"<=\")"}},{"html_id":"==(any:Node):Node-instance-method","name":"==","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L50"},"def":{"name":"==","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"=\")"}},{"html_id":"==(some_nil:Nil):Node-instance-method","name":"==","abstract":false,"args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"args_string":"(some_nil : Nil) : Node","args_html":"(some_nil : Nil) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L50"},"def":{"name":"==","args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Null.new, \"IS\")"}},{"html_id":"==(any:T):NodeforallT-instance-method","name":"==","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L50"},"def":{"name":"==","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"=\")"}},{"html_id":"=~(any:Node):Node-instance-method","name":"=~","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L25"},"def":{"name":"=~","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"~\")"}},{"html_id":"=~(regexp:Regex):Node-instance-method","name":"=~","abstract":false,"args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"args_string":"(regexp : Regex) : Node","args_html":"(regexp : Regex) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L33"},"def":{"name":"=~","args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"return_type":"Node","visibility":"Public","body":"if regexp.options.ignore_case?\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"~*\")\nelse\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"~\")\nend"}},{"html_id":">(any:Node):Node-instance-method","name":">","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":">","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \">\")"}},{"html_id":">(any:T):NodeforallT-instance-method","name":">","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":">","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \">\")"}},{"html_id":">=(any:Node):Node-instance-method","name":">=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":">=","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \">=\")"}},{"html_id":">=(any:T):NodeforallT-instance-method","name":">=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":">=","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \">=\")"}},{"html_id":"|(any:Node):Node-instance-method","name":"|","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L54"},"def":{"name":"|","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"OR\")"}},{"html_id":"|(any:T):NodeforallT-instance-method","name":"|","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L54"},"def":{"name":"|","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"OR\")"}},{"html_id":"~-instance-method","name":"~","abstract":false,"location":{"filename":"src/clear/expression/nodes/node.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L82"},"def":{"name":"~","visibility":"Public","body":"Node::Not.new(self)"}},{"html_id":"between(a,b)-instance-method","name":"between","abstract":false,"args":[{"name":"a","external_name":"a","restriction":""},{"name":"b","external_name":"b","restriction":""}],"args_string":"(a, b)","args_html":"(a, b)","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":74,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L74"},"def":{"name":"between","args":[{"name":"a","external_name":"a","restriction":""},{"name":"b","external_name":"b","restriction":""}],"visibility":"Public","body":"Node::Between.new(self, a, b)"}},{"html_id":"ilike(any:Node):Node-instance-method","name":"ilike","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L52"},"def":{"name":"ilike","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"ILIKE\")"}},{"html_id":"ilike(any:T):NodeforallT-instance-method","name":"ilike","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L52"},"def":{"name":"ilike","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"ILIKE\")"}},{"html_id":"in?(range:Range(B,E))forallB,E-instance-method","name":"in?","abstract":false,"args":[{"name":"range","external_name":"range","restriction":"Range(B, E)"}],"args_string":"(range : Range(B, E)) forall B, E","args_html":"(range : Range(B, E)) forall B, E","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L56"},"def":{"name":"in?","args":[{"name":"range","external_name":"range","restriction":"Range(B, E)"}],"visibility":"Public","body":"Node::InRange.new(self, Clear::Expression[range.begin]..Clear::Expression[range.end], range.exclusive?)"}},{"html_id":"in?(arr:Array(T))forallT-instance-method","name":"in?","abstract":false,"args":[{"name":"arr","external_name":"arr","restriction":"Array(T)"}],"args_string":"(arr : Array(T)) forall T","args_html":"(arr : Array(T)) forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L62"},"def":{"name":"in?","args":[{"name":"arr","external_name":"arr","restriction":"Array(T)"}],"visibility":"Public","body":"Node::InArray.new(self, arr.map do |x|\n Clear::Expression[x]\nend)"}},{"html_id":"in?(tuple:Tuple(*T))forallT-instance-method","name":"in?","abstract":false,"args":[{"name":"tuple","external_name":"tuple","restriction":"Tuple(*T)"}],"args_string":"(tuple : Tuple(*T)) forall T","args_html":"(tuple : Tuple(*T)) forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":66,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L66"},"def":{"name":"in?","args":[{"name":"tuple","external_name":"tuple","restriction":"Tuple(*T)"}],"visibility":"Public","body":"in?(tuple.to_a)"}},{"html_id":"in?(request:Clear::SQL::SelectBuilder)-instance-method","name":"in?","abstract":false,"args":[{"name":"request","external_name":"request","restriction":"::Clear::SQL::SelectBuilder"}],"args_string":"(request : Clear::SQL::SelectBuilder)","args_html":"(request : Clear::SQL::SelectBuilder)","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L70"},"def":{"name":"in?","args":[{"name":"request","external_name":"request","restriction":"::Clear::SQL::SelectBuilder"}],"visibility":"Public","body":"Node::InSelect.new(self, request)"}},{"html_id":"like(any:Node):Node-instance-method","name":"like","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L51"},"def":{"name":"like","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"LIKE\")"}},{"html_id":"like(any:T):NodeforallT-instance-method","name":"like","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L51"},"def":{"name":"like","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"LIKE\")"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":true,"location":{"filename":"src/clear/expression/nodes/node.cr","line_number":86,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L86"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":""}}],"macros":[{"html_id":"define_operator(op_name,sql_name,null=false)-macro","name":"define_operator","abstract":false,"args":[{"name":"op_name","external_name":"op_name","restriction":""},{"name":"sql_name","external_name":"sql_name","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""}],"args_string":"(op_name, sql_name, null = false)","args_html":"(op_name, sql_name, null = false)","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L5"},"def":{"name":"define_operator","args":[{"name":"op_name","external_name":"op_name","restriction":""},{"name":"sql_name","external_name":"sql_name","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""}],"visibility":"Public","body":" def \n{{ op_name.id }}\n(any : Node) : Node\n Node::DoubleOperator.new(self, any, \"\n{{ sql_name.id }}\n\")\n \nend\n\n \n{% if null %}\n def {{ op_name.id }}(some_nil : Nil) : Node\n Node::DoubleOperator.new(self, Null.new, {{ null }} )\n end\n {% end %}\n\n\n def \n{{ op_name.id }}\n(any : T) : Node forall T\n Node::DoubleOperator.new(self, Literal.new(any), \"\n{{ sql_name.id }}\n\")\n \nend\n \n"}}],"types":[{"html_id":"clear/Clear/Expression/Node/Between","path":"Clear/Expression/Node/Between.html","kind":"class","full_name":"Clear::Expression::Node::Between","name":"Between","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/between.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/between.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the rendering of `(var BETWEEN a AND b)`\nexpressions.","summary":"A node managing the rendering of (var BETWEEN a AND b)
expressions.
A node managing the rendering of combination operations like <val1> <op> <val2>
A node managing the rendering of functions in Postgres.
","constructors":[{"html_id":"new(name:String,args:Array(String))-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"args","external_name":"args","restriction":"Array(String)"}],"args_string":"(name : String, args : Array(String))","args_html":"(name : String, args : Array(String))","location":{"filename":"src/clear/expression/nodes/function.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/function.cr#L5"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"args","external_name":"args","restriction":"Array(String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, args)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/function.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/function.cr#L7"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"{@name, \"(\", @args.join(\", \"), \")\"}.join"}}]},{"html_id":"clear/Clear/Expression/Node/InArray","path":"Clear/Expression/Node/InArray.html","kind":"class","full_name":"Clear::Expression::Node::InArray","name":"InArray","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/in_array.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_array.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the rendering of array in Postgres.\n- It renders `val IN (...)`.\n- If the array passed as argument is empty, it renders `FALSE` instead.","summary":"A node managing the rendering of array in Postgres.
","constructors":[{"html_id":"new(target:Node,array:Array(String))-class-method","name":"new","abstract":false,"args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"array","external_name":"array","restriction":"Array(String)"}],"args_string":"(target : Node, array : Array(String))","args_html":"(target : Node, array : Array(String))","location":{"filename":"src/clear/expression/nodes/in_array.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_array.cr#L7"},"def":{"name":"new","args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"array","external_name":"array","restriction":"Array(String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(target, array)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/in_array.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_array.cr#L9"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"if @array.size == 0\n \"FALSE\"\nelse\n {@target.resolve, \" IN (\", @array.join(\", \"), \")\"}.join\nend"}}]},{"html_id":"clear/Clear/Expression/Node/InRange","path":"Clear/Expression/Node/InRange.html","kind":"class","full_name":"Clear::Expression::Node::InRange","name":"InRange","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/in_range.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_range.cr#L19"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the rendering a range in Postgres.\n\nExample:\n\n```\nvalue.in?(1..5)\n```\n\nwill render:\n\n```\nvalue >= 1 AND value < 5\n```\n\nInclusion and exclusion of the last number of the range is featured\n","summary":"A node managing the rendering a range in Postgres.
","constructors":[{"html_id":"new(target:Node,range:Range(String,String),exclusive:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"range","external_name":"range","restriction":"Range(String, String)"},{"name":"exclusive","default_value":"false","external_name":"exclusive","restriction":"::Bool"}],"args_string":"(target : Node, range : Range(String, String), exclusive : Bool = false)","args_html":"(target : Node, range : Range(String, String), exclusive : Bool = false)","location":{"filename":"src/clear/expression/nodes/in_range.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_range.cr#L20"},"def":{"name":"new","args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"range","external_name":"range","restriction":"Range(String, String)"},{"name":"exclusive","default_value":"false","external_name":"exclusive","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(target, range, exclusive)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/in_range.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_range.cr#L22"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"rt = @target.resolve\nfinal_op = @exclusive ? \" < \" : \" <= \"\n{\"(\", rt, \" >= \", @range.begin, \" AND \", rt, final_op, @range.end, \")\"}.join\n"}}]},{"html_id":"clear/Clear/Expression/Node/InSelect","path":"Clear/Expression/Node/InSelect.html","kind":"class","full_name":"Clear::Expression::Node::InSelect","name":"InSelect","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/in_select.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_select.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":" A node managing the rendering of `value IN (A node managing the rendering of value IN ( <SUBQUERY> )
Define a array contains? (?) operation between a jsonb column and a json hash
","constructors":[{"html_id":"new(jsonb_field:String,value:String)-class-method","name":"new","abstract":false,"args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::String"}],"args_string":"(jsonb_field : String, value : String)","args_html":"(jsonb_field : String, value : String)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L62"},"def":{"name":"new","args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(jsonb_field, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"jsonb_field:String-instance-method","name":"jsonb_field","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":59,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L59"},"def":{"name":"jsonb_field","return_type":"String","visibility":"Public","body":"@jsonb_field"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L65"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"{@jsonb_field, @value}.join(\" ? \")"}},{"html_id":"value:String-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":60,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L60"},"def":{"name":"value","return_type":"String","visibility":"Public","body":"@value"}}]},{"html_id":"clear/Clear/Expression/Node/JSONB/Equality","path":"Clear/Expression/Node/JSONB/Equality.html","kind":"class","full_name":"Clear::Expression::Node::JSONB::Equality","name":"Equality","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"},{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L43"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}],"namespace":{"html_id":"clear/Clear/Expression/Node/JSONB","kind":"module","full_name":"Clear::Expression::Node::JSONB","name":"JSONB"},"doc":"Define a __value match? (@>)__ operation between a jsonb column and a json hash","summary":"Define a value match? (@>) operation between a jsonb column and a json hash
","constructors":[{"html_id":"new(jsonb_field:String,value:Hash(String,Clear::SQL::JSONB::JSONBKey))-class-method","name":"new","abstract":false,"args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::Hash(::String, ::Clear::SQL::JSONB::JSONBKey)"}],"args_string":"(jsonb_field : String, value : Hash(String, Clear::SQL::JSONB::JSONBKey))","args_html":"(jsonb_field : String, value : Hash(String, Clear::SQL::JSONB::JSONBKey))","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L49"},"def":{"name":"new","args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::Hash(::String, ::Clear::SQL::JSONB::JSONBKey)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(jsonb_field, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"jsonb_field:String-instance-method","name":"jsonb_field","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":46,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L46"},"def":{"name":"jsonb_field","return_type":"String","visibility":"Public","body":"@jsonb_field"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L52"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"{@jsonb_field, Clear::Expression[@value.to_json]}.join(\" @> \")"}},{"html_id":"value:JSONBHash-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L47"},"def":{"name":"value","return_type":"JSONBHash","visibility":"Public","body":"@value"}}]},{"html_id":"clear/Clear/Expression/Node/JSONB/Field","path":"Clear/Expression/Node/JSONB/Field.html","kind":"class","full_name":"Clear::Expression::Node::JSONB::Field","name":"Field","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"},{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}],"namespace":{"html_id":"clear/Clear/Expression/Node/JSONB","kind":"module","full_name":"Clear::Expression::Node::JSONB","name":"JSONB"},"constructors":[{"html_id":"new(field:Clear::Expression::Node,key:String,cast:Nil|String=nil)-class-method","name":"new","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"::Clear::Expression::Node"},{"name":"key","external_name":"key","restriction":"::String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":"::Nil | ::String"}],"args_string":"(field : Clear::Expression::Node, key : String, cast : Nil | String = nil)","args_html":"(field : Clear::Expression::Node, key : String, cast : Nil | String = nil)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L10"},"def":{"name":"new","args":[{"name":"field","external_name":"field","restriction":"::Clear::Expression::Node"},{"name":"key","external_name":"key","restriction":"::String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":"::Nil | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(field, key, cast)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(value:Clear::Expression::Node)-instance-method","name":"==","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Clear::Expression::Node"}],"args_string":"(value : Clear::Expression::Node)","args_html":"(value : Clear::Expression::Node)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L21"},"def":{"name":"==","args":[{"name":"value","external_name":"value","restriction":"Clear::Expression::Node"}],"visibility":"Public","body":"super(value)"}},{"html_id":"==(value:_)-instance-method","name":"==","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"_"}],"args_string":"(value : _)","args_html":"(value : _)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L25"},"def":{"name":"==","args":[{"name":"value","external_name":"value","restriction":"_"}],"visibility":"Public","body":"if @cast\n super(value)\nelse\n Clear::Expression::Node::JSONB::Equality.new(field.resolve, jsonb_k2h(key, value))\nend"}},{"html_id":"cast(cast:Nil|String)-instance-method","name":"cast","abstract":false,"args":[{"name":"cast","external_name":"cast","restriction":"::Nil | ::String"}],"args_string":"(cast : Nil | String)","args_html":"(cast : Nil | String)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L17"},"def":{"name":"cast","args":[{"name":"cast","external_name":"cast","restriction":"::Nil | ::String"}],"visibility":"Public","body":"@cast = cast\nself\n"}},{"html_id":"cast:String|Nil-instance-method","name":"cast","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L8"},"def":{"name":"cast","return_type":"String | ::Nil","visibility":"Public","body":"@cast"}},{"html_id":"contains?(expression:Clear::Expression::Node)-instance-method","name":"contains?","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Clear::Expression::Node"}],"args_string":"(expression : Clear::Expression::Node)","args_html":"(expression : Clear::Expression::Node)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L33"},"def":{"name":"contains?","args":[{"name":"expression","external_name":"expression","restriction":"Clear::Expression::Node"}],"visibility":"Public","body":"Clear::Expression::Node::JSONB::ArrayContains.new(resolve, expression.resolve)"}},{"html_id":"contains?(expression)-instance-method","name":"contains?","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":""}],"args_string":"(expression)","args_html":"(expression)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L37"},"def":{"name":"contains?","args":[{"name":"expression","external_name":"expression","restriction":""}],"visibility":"Public","body":"Clear::Expression::Node::JSONB::ArrayContains.new(resolve, Clear::Expression[expression])"}},{"html_id":"field:Node-instance-method","name":"field","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L6"},"def":{"name":"field","return_type":"Node","visibility":"Public","body":"@field"}},{"html_id":"key:String-instance-method","name":"key","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L7"},"def":{"name":"key","return_type":"String","visibility":"Public","body":"@key"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L13"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"jsonb_resolve(@field.resolve, jsonb_k2a(key), @cast)"}}]}]},{"html_id":"clear/Clear/Expression/Node/Literal","path":"Clear/Expression/Node/Literal.html","kind":"class","full_name":"Clear::Expression::Node::Literal","name":"Literal","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/literal.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"Management of rendering of literal values.","summary":"Management of rendering of literal values.
","constructors":[{"html_id":"new(value)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value)","args_html":"(value)","location":{"filename":"src/clear/expression/nodes/literal.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L7"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/literal.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L17"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"Clear::Expression[@value]"}},{"html_id":"value:AvailableLiteral-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/expression/nodes/literal.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L5"},"def":{"name":"value","return_type":"AvailableLiteral","visibility":"Public","body":"@value"}}]},{"html_id":"clear/Clear/Expression/Node/Minus","path":"Clear/Expression/Node/Minus.html","kind":"class","full_name":"Clear::Expression::Node::Minus","name":"Minus","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/minus.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/minus.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the unary `-` operator.","summary":"A node managing the unary -
operator.
This node is used to generate expression like `( a AND b AND ...
","constructors":[{"html_id":"new(expression:Array(Node),link:String)-class-method","name":"new","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"},{"name":"link","external_name":"link","restriction":"::String"}],"args_string":"(expression : Array(Node), link : String)","args_html":"(expression : Array(Node), link : String)","location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L8"},"def":{"name":"new","args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"},{"name":"link","external_name":"link","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(expression, link)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"expression:Array(Node)-instance-method","name":"expression","abstract":false,"location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L5"},"def":{"name":"expression","return_type":"Array(Node)","visibility":"Public","body":"@expression"}},{"html_id":"expression=(expression:Array(Node))-instance-method","name":"expression=","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"}],"args_string":"(expression : Array(Node))","args_html":"(expression : Array(Node))","location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L5"},"def":{"name":"expression=","args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"}],"visibility":"Public","body":"@expression = expression"}},{"html_id":"link:String-instance-method","name":"link","abstract":false,"location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L6"},"def":{"name":"link","return_type":"String","visibility":"Public","body":"@link"}},{"html_id":"link=(link:String)-instance-method","name":"link=","abstract":false,"args":[{"name":"link","external_name":"link","restriction":"String"}],"args_string":"(link : String)","args_html":"(link : String)","location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L6"},"def":{"name":"link=","args":[{"name":"link","external_name":"link","restriction":"String"}],"visibility":"Public","body":"@link = link"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L12"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"if !@expression.empty?\n {\"(\", @expression.join(\" #{@link} \", &.resolve), \")\"}.join\nelse\n \"\"\nend"}}]},{"html_id":"clear/Clear/Expression/Node/Not","path":"Clear/Expression/Node/Not.html","kind":"class","full_name":"Clear::Expression::Node::Not","name":"Not","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/not.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/not.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the unary `NOT` operator.","summary":"A node managing the unary NOT
operator.
A node managing the rendering of (var NOT BETWEEN a AND b)
expressions.
Render NULL !
","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/expression/nodes/null.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/null.cr#L5"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/null.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/null.cr#L8"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"\"NULL\""}}]},{"html_id":"clear/Clear/Expression/Node/PGArray","path":"Clear/Expression/Node/PGArray.html","kind":"class","full_name":"Clear::Expression::Node::PGArray(T)","name":"PGArray","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/pg_array.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/pg_array.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing PG structure `array[args...]`\nNamed PGArray instead of Array to avoid issue with naming","summary":"A node managing PG structure array[args...]
Named PGArray instead of Array to avoid issue with naming
This node manage the rendering of a raw SQL fragment.
","constructors":[{"html_id":"new(raw:String)-class-method","name":"new","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String)","args_html":"(raw : String)","location":{"filename":"src/clear/expression/nodes/raw.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/raw.cr#L5"},"def":{"name":"new","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(raw)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/raw.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/raw.cr#L7"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"@raw"}}]},{"html_id":"clear/Clear/Expression/Node/Variable","path":"Clear/Expression/Node/Variable.html","kind":"class","full_name":"Clear::Expression::Node::Variable","name":"Variable","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/variable.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L16"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A variable AST node.\nIt's what's created under the hood when you use a non-existent variable:\n\n```\nwhere { users.id != nil }\n\nwill produce this tree:\n\n# => double_operator('<>')\n# # => variable('id', parent: 'users')\n# # => null\n\n```","summary":"A variable AST node.
","constructors":[{"html_id":"new(name:String,parent:Variable|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"parent","default_value":"nil","external_name":"parent","restriction":"Variable | ::Nil"}],"args_string":"(name : String, parent : Variable | Nil = nil)","args_html":"(name : String, parent : Variable | Nil = nil)","location":{"filename":"src/clear/expression/nodes/variable.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L17"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"parent","default_value":"nil","external_name":"parent","restriction":"Variable | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, parent)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/variable.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L28"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"parent = @parent\nif parent\n {parent.resolve, \".\", Clear::SQL.escape(@name)}.join\nelse\n Clear::SQL.escape(@name)\nend\n"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/clear/expression/nodes/variable.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L19"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" \n{% if call.args.size > 0 %}\n args = Clear::Expression[{{ call.args }}].join(\", \")\n return Node::Variable.new(\"{{ call.name.id }}(#{args})\", self)\n {% else %}\n return Node::Variable.new({{ call.name.id.stringify }}, self)\n {% end %}\n\n \n"}}]}]},{"html_id":"clear/Clear/Expression/UnsafeSql","path":"Clear/Expression/UnsafeSql.html","kind":"class","full_name":"Clear::Expression::UnsafeSql","name":"UnsafeSql","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/expression.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L70"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"}],"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"},"doc":"Wrap an unsafe string. Useful to cancel-out the\nsafe_literal function used internally.\nObviously, this can lead to SQL injection, so beware!","summary":"Wrap an unsafe string.
","constructors":[{"html_id":"new(value:String)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::String"}],"args_string":"(value : String)","args_html":"(value : String)","location":{"filename":"src/clear/expression/expression.cr","line_number":75,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L75"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"to_json(json=nil):String-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","default_value":"nil","external_name":"json","restriction":""}],"args_string":"(json = nil) : String","args_html":"(json = nil) : String","location":{"filename":"src/clear/expression/expression.cr","line_number":86,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L86"},"def":{"name":"to_json","args":[{"name":"json","default_value":"nil","external_name":"json","restriction":""}],"visibility":"Public","body":"@value"}},{"html_id":"to_s:String-instance-method","name":"to_s","doc":"Returns a nicely readable and concise string representation of this object,\ntypically intended for users.\n\nThis method should usually **not** be overridden. It delegates to\n`#to_s(IO)` which can be overridden for custom implementations.\n\nAlso see `#inspect`.","summary":"Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"location":{"filename":"src/clear/expression/expression.cr","line_number":78,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L78"},"def":{"name":"to_s","visibility":"Public","body":"@value"}},{"html_id":"to_sql:String-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/expression/expression.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L82"},"def":{"name":"to_sql","visibility":"Public","body":"@value"}}]}]},{"html_id":"clear/Clear/IllegalEnumValueError","path":"Clear/IllegalEnumValueError.html","kind":"class","full_name":"Clear::IllegalEnumValueError","name":"IllegalEnumValueError","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/enum/enum.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"}},{"html_id":"clear/Clear/Interval","path":"Clear/Interval.html","kind":"struct","full_name":"Clear::Interval","name":"Interval","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/interval/interval.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/interval/interval.cr#L17"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"It can be converted automatically from/to a `interval` column.\n\n## Usage example\n\n```\nclass MyModel\n include Clear::Model\n\n column interval : Clear::TimeInDay\nend\n\ninterval = Clear::Interval.new(60.days)\nrecord = MyModel.create!(interval: interval)\n```","summary":"It can be converted automatically from/to a interval
column.
For PG::Interval
Run the block given in parameter if the direction is a rollback
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L38"},"def":{"name":"down","yields":0,"block_arity":0,"visibility":"Public","body":"if down?\n yield\nend"}},{"html_id":"down?-instance-method","name":"down?","doc":"Return true whether the migration is a rollback","summary":"Return true whether the migration is a rollback
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L43"},"def":{"name":"down?","visibility":"Public","body":"self == Down"}},{"html_id":"up(&)-instance-method","name":"up","doc":"Run the block given in parameter if the direction is a upstream","summary":"Run the block given in parameter if the direction is a upstream
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L28"},"def":{"name":"up","yields":0,"block_arity":0,"visibility":"Public","body":"if self == Up\n yield\nend"}},{"html_id":"up?-instance-method","name":"up?","doc":"Return true whether the migration is a upstream","summary":"Return true whether the migration is a upstream
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L33"},"def":{"name":"up?","visibility":"Public","body":"self == Up"}}]},{"html_id":"clear/Clear/Migration/DropEnum","path":"Clear/Migration/DropEnum.html","kind":"class","full_name":"Clear::Migration::DropEnum","name":"DropEnum","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/enum/migration.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L18"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(name:String,values:Nil|Array(String))-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"values","external_name":"values","restriction":"::Nil | ::Array(::String)"}],"args_string":"(name : String, values : Nil | Array(String))","args_html":"(name : String, values : Nil | Array(String))","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L22"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"values","external_name":"values","restriction":"::Nil | ::Array(::String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, values)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L29"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"if values = @values\n [\"CREATE TYPE #{@name} AS ENUM (#{Clear::Expression[values].join(\", \")})\"]\nelse\n irreversible!\nend"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L25"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"DROP TYPE #{@name}\"]"}}]},{"html_id":"clear/Clear/Migration/DropTable","path":"Clear/Migration/DropTable.html","kind":"class","full_name":"Clear::Migration::DropTable","name":"DropTable","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":209,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L209"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(table:String,schema:String)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"}],"args_string":"(table : String, schema : String)","args_html":"(table : String, schema : String)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":213,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L213"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, schema)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":224,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L224"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[\"CREATE TABLE #{@table}\"]"}},{"html_id":"full_name-instance-method","name":"full_name","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":216,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L216"},"def":{"name":"full_name","visibility":"Public","body":"{Clear::SQL.escape(@schema), Clear::SQL.escape(@name)}.join(\".\")"}},{"html_id":"schema:String-instance-method","name":"schema","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":211,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L211"},"def":{"name":"schema","return_type":"String","visibility":"Public","body":"@schema"}},{"html_id":"table:String-instance-method","name":"table","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":210,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L210"},"def":{"name":"table","return_type":"String","visibility":"Public","body":"@table"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":220,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L220"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"DROP TABLE #{@table}\"]"}}]},{"html_id":"clear/Clear/Migration/Execute","path":"Clear/Migration/Execute.html","kind":"class","full_name":"Clear::Migration::Execute","name":"Execute","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/execute.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(sql:String,irreversible:Bool|Nil=false)-class-method","name":"new","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":"String"},{"name":"irreversible","default_value":"false","external_name":"irreversible","restriction":"Bool | ::Nil"}],"args_string":"(sql : String, irreversible : Bool | Nil = false)","args_html":"(sql : String, irreversible : Bool | Nil = false)","location":{"filename":"src/clear/migration/operation/execute.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L5"},"def":{"name":"new","args":[{"name":"sql","external_name":"sql","restriction":"String"},{"name":"irreversible","default_value":"false","external_name":"irreversible","restriction":"Bool | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(sql, irreversible)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/execute.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L12"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"if @irreversible\n irreversible!\nend\n[@sql].compact\n"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/execute.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L8"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[@sql].compact"}}]},{"html_id":"clear/Clear/Migration/FullTextSearchableHelpers","path":"Clear/Migration/FullTextSearchableHelpers.html","kind":"module","full_name":"Clear::Migration::FullTextSearchableHelpers","name":"FullTextSearchableHelpers","abstract":false,"locations":[{"filename":"src/clear/extensions/full_text_searchable/migration.cr","line_number":83,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/migration.cr#L83"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Migration/Helper","kind":"module","full_name":"Clear::Migration::Helper","name":"Helper"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"instance_methods":[{"html_id":"add_full_text_searchable(table,on:Array(Tuple(String,Char)),column_name=\"full_text_vector\",catalog=\"pg_catalog.english\",trigger_name=nil,function_name=nil)-instance-method","name":"add_full_text_searchable","doc":"Add a `tsvector` field to a table.\nCreate column, index and trigger.","summary":"Add a tsvector
field to a table.
Replace some common type to their equivalent in postgresql if the type is not found in the correspondance table, then return itself
","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"}],"args_string":"(type : String)","args_html":"(type : String)","location":{"filename":"src/clear/migration/migration.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L82"},"def":{"name":"datatype","args":[{"name":"type","external_name":"type","restriction":"String"}],"visibility":"Public","body":"ts = type\nTYPE_MAPPING[type]? || ts\n"}}],"instance_methods":[{"html_id":"add_column(table,column,datatype,nullable=false,constraint=nil,default=nil,with_values=false)-instance-method","name":"add_column","doc":"Add a column to a specific table","summary":"Add a column to a specific table
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"datatype","external_name":"datatype","restriction":""},{"name":"nullable","default_value":"false","external_name":"nullable","restriction":""},{"name":"constraint","default_value":"nil","external_name":"constraint","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"with_values","default_value":"false","external_name":"with_values","restriction":""}],"args_string":"(table, column, datatype, nullable = false, constraint = nil, default = nil, with_values = false)","args_html":"(table, column, datatype, nullable = false, constraint = nil, default = nil, with_values = false)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":97,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L97"},"def":{"name":"add_column","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"datatype","external_name":"datatype","restriction":""},{"name":"nullable","default_value":"false","external_name":"nullable","restriction":""},{"name":"constraint","default_value":"nil","external_name":"constraint","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"with_values","default_value":"false","external_name":"with_values","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::AddColumn.new(table, column, datatype, nullable, constraint, default, with_values))"}},{"html_id":"add_operation(op:Operation)-instance-method","name":"add_operation","abstract":false,"args":[{"name":"op","external_name":"op","restriction":"Operation"}],"args_string":"(op : Operation)","args_html":"(op : Operation)","location":{"filename":"src/clear/migration/migration.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L95"},"def":{"name":"add_operation","args":[{"name":"op","external_name":"op","restriction":"Operation"}],"visibility":"Public","body":"op.migration = self\n@operations << op\n"}},{"html_id":"apply(dir:Direction=Clear::Migration::Direction::Up)-instance-method","name":"apply","doc":"This will apply the migration in a given direction (up or down)","summary":"This will apply the migration in a given direction (up or down)
","abstract":false,"args":[{"name":"dir","default_value":"Clear::Migration::Direction::Up","external_name":"dir","restriction":"Direction"}],"args_string":"(dir : Direction = Clear::Migration::Direction::Up)","args_html":"(dir : Direction = Clear::Migration::Direction::Up)","location":{"filename":"src/clear/migration/migration.cr","line_number":103,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L103"},"def":{"name":"apply","args":[{"name":"dir","default_value":"Clear::Migration::Direction::Up","external_name":"dir","restriction":"Direction"}],"visibility":"Public","body":"Clear::Migration::Manager.instance.ensure_ready\nClear::SQL.transaction do\n Log.info do\n \"[#{dir}] #{self.class.name}\"\n end\n @operations.clear\n change(dir)\n dir.up do\n @operations.each do |op|\n op.up.each do |x|\n Clear::SQL.execute(x.as(String))\n end\n end\n (SQL.insert(\"__clear_metadatas\", {metatype: \"migration\", value: uid.to_s})).execute\n end\n dir.down do\n @operations.reverse_each do |op|\n op.down.each do |x|\n Clear::SQL.execute(x.as(String))\n end\n end\n ((SQL.delete(\"__clear_metadatas\")).where({metatype: \"migration\", value: uid.to_s})).execute\n end\n self\nend\n"}},{"html_id":"change(dir)-instance-method","name":"change","abstract":true,"args":[{"name":"dir","external_name":"dir","restriction":""}],"args_string":"(dir)","args_html":"(dir)","location":{"filename":"src/clear/migration/migration.cr","line_number":100,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L100"},"def":{"name":"change","args":[{"name":"dir","external_name":"dir","restriction":""}],"visibility":"Public","body":""}},{"html_id":"change_column_type(table,column,from,to)-instance-method","name":"change_column_type","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"args_string":"(table, column, from, to)","args_html":"(table, column, from, to)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":110,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L110"},"def":{"name":"change_column_type","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::ChangeColumnType.new(table, column, from, to))"}},{"html_id":"create_enum(name,arr:Enumerable(T))forallT-instance-method","name":"create_enum","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","external_name":"arr","restriction":"Enumerable(T)"}],"args_string":"(name, arr : Enumerable(T)) forall T","args_html":"(name, arr : Enumerable(T)) forall T","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L39"},"def":{"name":"create_enum","args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","external_name":"arr","restriction":"Enumerable(T)"}],"visibility":"Public","body":"add_operation(CreateEnum.new(name.to_s, arr.map(&.to_s)))"}},{"html_id":"create_enum(name,e)-instance-method","name":"create_enum","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"e","external_name":"e","restriction":""}],"args_string":"(name, e)","args_html":"(name, e)","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L47"},"def":{"name":"create_enum","args":[{"name":"name","external_name":"name","restriction":""},{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"add_operation(CreateEnum.new(name.to_s, e.authorized_values))"}},{"html_id":"create_index(table,columns:Array(String),name=nil,using=nil,unique=false)-instance-method","name":"create_index","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"columns","external_name":"columns","restriction":"Array(String)"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(table, columns : Array(String), name = nil, using = nil, unique = false)","args_html":"(table, columns : Array(String), name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/indexes.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/indexes.cr#L56"},"def":{"name":"create_index","args":[{"name":"table","external_name":"table","restriction":""},{"name":"columns","external_name":"columns","restriction":"Array(String)"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::CreateIndex.new(table, fields: columns, name: name, using: using, unique: unique))"}},{"html_id":"create_index(table,column,name=nil,using=nil,unique=false)-instance-method","name":"create_index","doc":"Add a column to a specific table","summary":"Add a column to a specific table
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(table, column, name = nil, using = nil, unique = false)","args_html":"(table, column, name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/indexes.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/indexes.cr#L50"},"def":{"name":"create_index","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::CreateIndex.new(table, fields: [column], name: name, using: using, unique: unique))"}},{"html_id":"create_table(name,id:Symbol|Bool=true,schema=\"public\",&)-instance-method","name":"create_table","doc":"\nHelper used in migration to create a new table.\n\nUsage:\n\n```\ncreate_table(:users) do |t|\n t.column :first_name, :string\n t.column :last_name, :string\n t.column :email, :string, unique: true\n t.timestamps\nend\n```\n\nBy default, a column `id` of type `integer` will be created as primary key of the table.\nThis can be prevented using `primary: false`\n\n```\ncreate_table(:users, id: false) do |t|\n t.column :user_id, :integer, primary: true # Use custom name for the primary key\n t.column :first_name, :string\n t.column :last_name, :string\n t.column :email, :string, unique: true\n t.timestamps\nend\n```\n","summary":"Helper used in migration to create a new table.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"id","default_value":"true","external_name":"id","restriction":"Symbol | Bool"},{"name":"schema","default_value":"\"public\"","external_name":"schema","restriction":""}],"args_string":"(name, id : Symbol | Bool = true, schema = \"public\", &)","args_html":"(name, id : Symbol | Bool = true, schema = "public", &)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":257,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L257"},"def":{"name":"create_table","args":[{"name":"name","external_name":"name","restriction":""},{"name":"id","default_value":"true","external_name":"id","restriction":"Symbol | Bool"},{"name":"schema","default_value":"\"public\"","external_name":"schema","restriction":""}],"yields":1,"block_arity":1,"visibility":"Public","body":"table = Table.new(name.to_s, schema.to_s, is_create: true)\nadd_operation(table)\ncase id\nwhen true, :bigserial\n table.column(\"id\", \"bigserial\", primary: true, null: false)\nwhen :serial\n table.column(\"id\", \"serial\", primary: true, null: false)\nwhen :uuid\n table.column(\"id\", \"uuid\", primary: true, null: false)\nwhen false\nelse\n raise(\"Unknown key type while try to create new table: `#{id}`. Candidates are :bigserial, :serial and :uuid\" + \"Please proceed with `id: false` and add the column manually\")\nend\nyield(table)\n"}},{"html_id":"drop_column(table,column,type)-instance-method","name":"drop_column","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""}],"args_string":"(table, column, type)","args_html":"(table, column, type)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":102,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L102"},"def":{"name":"drop_column","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::RemoveColumn.new(table, column, type))"}},{"html_id":"drop_enum(name,arr:Enumerable(T)|Nil=nil)forallT-instance-method","name":"drop_enum","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","default_value":"nil","external_name":"arr","restriction":"Enumerable(T) | ::Nil"}],"args_string":"(name, arr : Enumerable(T) | Nil = nil) forall T","args_html":"(name, arr : Enumerable(T) | Nil = nil) forall T","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L43"},"def":{"name":"drop_enum","args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","default_value":"nil","external_name":"arr","restriction":"Enumerable(T) | ::Nil"}],"visibility":"Public","body":"add_operation(DropEnum.new(name.to_s, arr.try(&.map(&.to_s))))"}},{"html_id":"execute(sql:String)-instance-method","name":"execute","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":"String"}],"args_string":"(sql : String)","args_html":"(sql : String)","location":{"filename":"src/clear/migration/migration.cr","line_number":91,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L91"},"def":{"name":"execute","args":[{"name":"sql","external_name":"sql","restriction":"String"}],"visibility":"Public","body":"@operations << (Clear::Migration::Execute.new(sql))"}},{"html_id":"irreversible!-instance-method","name":"irreversible!","abstract":false,"location":{"filename":"src/clear/migration/migration.cr","line_number":87,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L87"},"def":{"name":"irreversible!","visibility":"Public","body":"raise(IrreversibleMigration.new(migration_irreversible(self.class.name)))"}},{"html_id":"rename_column(table,from,to)-instance-method","name":"rename_column","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"args_string":"(table, from, to)","args_html":"(table, from, to)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":106,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L106"},"def":{"name":"rename_column","args":[{"name":"table","external_name":"table","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::RenameColumn.new(table, from, to))"}}]},{"html_id":"clear/Clear/Migration/IrreversibleMigration","path":"Clear/Migration/IrreversibleMigration.html","kind":"class","full_name":"Clear::Migration::IrreversibleMigration","name":"IrreversibleMigration","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/migration.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L65"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"doc":"This error is throw when you try to revert a migration which is irreversible.","summary":"This error is throw when you try to revert a migration which is irreversible.
"},{"html_id":"clear/Clear/Migration/Manager","path":"Clear/Migration/Manager.html","kind":"class","full_name":"Clear::Migration::Manager","name":"Manager","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/manager.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"METADATA_VERSION","name":"METADATA_VERSION","value":"\"1\"","doc":"Used to migrate between metadata version, in case we need it in the future.","summary":"Used to migrate between metadata version, in case we need it in the future.
"}],"included_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"doc":"The migration manager is a singleton, it load all the migrations,\ncheck which one are `up` and `down`, and can trigger one or multiple\ndowngrade / upgrade of the database.\n\nThe migration system needs the creation of a table named `__clear_metadatas`\nin your database. This table will be created automatically on the first\ninitialization of the Migration Manager.\n","summary":"The migration manager is a singleton, it load all the migrations, check which one are #up
and #down
, and can trigger one or multiple downgrade / upgrade of the database.
To access to the manager
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L22"},"def":{"name":"instance","visibility":"Public","body":"@@instance || (@@instance = Manager.new)"}}],"instance_methods":[{"html_id":"apply_all-instance-method","name":"apply_all","doc":"Apply all the migrations not yet applied.","summary":"Apply all the migrations not yet applied.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":141,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L141"},"def":{"name":"apply_all","visibility":"Public","body":"ensure_ready\nClear::View.apply(:drop)\nlist_of_migrations = @migrations.sort do |a, b|\n a.uid <=> b.uid\nend\nlist_of_migrations.reject! do |x|\n @migrations_up.includes?(x.uid)\nend\nlist_of_migrations.each do |migration|\n migration.apply\n @migrations_up.add(migration.uid)\nend\nClear::View.apply(:create)\n"}},{"html_id":"apply_to(version,direction=:both)-instance-method","name":"apply_to","abstract":false,"args":[{"name":"version","external_name":"version","restriction":""},{"name":"direction","default_value":":both","external_name":"direction","restriction":""}],"args_string":"(version, direction = :both)","args_html":"(version, direction = :both)","location":{"filename":"src/clear/migration/manager.cr","line_number":73,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L73"},"def":{"name":"apply_to","args":[{"name":"version","external_name":"version","restriction":""},{"name":"direction","default_value":":both","external_name":"direction","restriction":""}],"visibility":"Public","body":"ensure_ready\nlist_of_migrations = @migrations.sort do |a, b|\n a.uid <=> b.uid\nend\nversion = compute_version(version, list_of_migrations)\noperations = [] of ::Tuple(Int64, Migration::Direction)\nuid_to_apply = list_of_migrations.map(&.uid).reject(&.>(version)) - @migrations_up.to_a\nuid_to_apply.each do |uid|\n operations << {uid, Migration::Direction::Up}\nend\nuid_to_apply = list_of_migrations.map(&.uid).select(&.>(version)) & @migrations_up.to_a\nuid_to_apply.each do |uid|\n operations << {uid, Migration::Direction::Down}\nend\noperations.sort! do |a, b|\n if a[1].up?\n if b[1].down?\n 1\n else\n a[0] <=> b[0]\n end\n else\n if b[1].down?\n b[0] <=> a[0]\n else\n 0\n end\n end\nend\nif operations.empty?\n Log.info do\n \"Nothing to do.\"\n end\n return\nend\nLog.info do\n \"Migrations will be applied (in this order):\"\nend\noperations.each do |__temp_94|\n uid, d = __temp_94\n Log.info do\n \"#{d.up? ? \"[ UP ]\" : \"[DOWN]\"} #{uid} - #{(find(uid)).class.name}\"\n end\nend\noperations.each do |__temp_95|\n uid, d = __temp_95\n if (direction == (:both)) || (direction == (:up))\n d.up do\n up(uid)\n end\n end\n if (direction == (:both)) || (direction == (:down))\n d.down do\n down(uid)\n end\n end\nend\n"}},{"html_id":"commited?(m:Clear::Migration)-instance-method","name":"commited?","doc":"Return `true` if the migration has been commited (already applied into the database)\nor `false` otherwise","summary":"Return true
if the migration has been commited (already applied into the database) or false
otherwise
Force down a migration; throw error if the mgiration is already down
","abstract":false,"args":[{"name":"number","external_name":"number","restriction":"Int64"}],"args_string":"(number : Int64) : Nil","args_html":"(number : Int64) : Nil","location":{"filename":"src/clear/migration/manager.cr","line_number":232,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L232"},"def":{"name":"down","args":[{"name":"number","external_name":"number","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"m = find(number)\nif migrations_up.includes?(number)\nelse\n raise(migration_already_down(number))\nend\nm.apply(Clear::Migration::Direction::Down)\n@migrations_up.delete(m.uid)\n"}},{"html_id":"ensure_ready-instance-method","name":"ensure_ready","doc":"Create if needed the metadata table\nto save the migrations.","summary":"Create if needed the metadata table to save the migrations.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":165,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L165"},"def":{"name":"ensure_ready","visibility":"Public","body":"if @loaded\nelse\n Clear::SQL.execute(\" CREATE TABLE IF NOT EXISTS __clear_metadatas ( metatype text NOT NULL, value text NOT NULL );\")\n Clear::SQL.execute(\" CREATE UNIQUE INDEX IF NOT EXISTS __clear_metadatas_idx ON __clear_metadatas (metatype, value);\")\n load_existing_migrations\n ensure_unicity!\n @loaded = true\nend"}},{"html_id":"find(number)-instance-method","name":"find","doc":"Fetch the migration instance with the selected number","summary":"Fetch the migration instance with the selected number
","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/migration/manager.cr","line_number":216,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L216"},"def":{"name":"find","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"number = Int64.new(number)\n@migrations.find() do |__arg6|\n __arg6.uid == number\nend || (raise(migration_not_found(number)))\n"}},{"html_id":"load_existing_migrations-instance-method","name":"load_existing_migrations","doc":"Fetch all the migrations already activated on the database.","summary":"Fetch all the migrations already activated on the database.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":203,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L203"},"def":{"name":"load_existing_migrations","visibility":"Public","body":"@migrations_up.clear\n((Clear::SQL.select(\"*\")).from(\"__clear_metadatas\")).where(metatype: \"migration\").map do |m|\n @migrations_up.add(Int64.new(m[\"value\"].as(String)))\nend\n"}},{"html_id":"max_version-instance-method","name":"max_version","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L54"},"def":{"name":"max_version","visibility":"Public","body":"if @migrations.size > 0\n @migrations.max_of(&.uid)\nelse\n nil\nend"}},{"html_id":"migrations_up-instance-method","name":"migrations_up","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L33"},"def":{"name":"migrations_up","visibility":"Public","body":"ensure_ready\n@migrations_up\n"}},{"html_id":"print_status:String-instance-method","name":"print_status","doc":"Print out the status ( up | down ) of all migrations found by the manager.","summary":"Print out the status ( up | down ) of all migrations found by the manager.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":242,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L242"},"def":{"name":"print_status","return_type":"String","visibility":"Public","body":"ensure_ready\n@migrations.sort do |a, b|\n (a.as(Clear::Migration)).uid <=> (b.as(Clear::Migration)).uid\nend.join(\"\\n\") do |m|\n active = @migrations_up.includes?(m.uid)\n \"[#{active ? \"✓\".colorize.green : \"✗\".colorize.red}] #{m.uid} - #{m.class.name}\"\nend\n"}},{"html_id":"refresh-instance-method","name":"refresh","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":211,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L211"},"def":{"name":"refresh","visibility":"Public","body":"load_existing_migrations"}},{"html_id":"reinit!-instance-method","name":"reinit!","doc":"Force reloading the migration system\nRecheck all the current up migrations\nand the metadata table.\nThis is useful if you access to the migration process\nthrough another program, or during specs","summary":"Force reloading the migration system Recheck all the current up migrations and the metadata table.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":187,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L187"},"def":{"name":"reinit!","visibility":"Public","body":"@loaded = false\nensure_ready\nself\n"}},{"html_id":"up(number:Int64):Nil-instance-method","name":"up","doc":"Force up a migration; throw error if the migration is already up","summary":"Force up a migration; throw error if the migration is already up
","abstract":false,"args":[{"name":"number","external_name":"number","restriction":"Int64"}],"args_string":"(number : Int64) : Nil","args_html":"(number : Int64) : Nil","location":{"filename":"src/clear/migration/manager.cr","line_number":222,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L222"},"def":{"name":"up","args":[{"name":"number","external_name":"number","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"m = find(number)\nif migrations_up.includes?(number)\n raise(migration_already_up(number))\nend\nm.apply\n@migrations_up.add(m.uid)\n"}}]},{"html_id":"clear/Clear/Migration/Operation","path":"Clear/Migration/Operation.html","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation","abstract":true,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/operation.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"subclasses":[{"html_id":"clear/Clear/Migration/AddColumn","kind":"class","full_name":"Clear::Migration::AddColumn","name":"AddColumn"},{"html_id":"clear/Clear/Migration/AddTable","kind":"class","full_name":"Clear::Migration::AddTable","name":"AddTable"},{"html_id":"clear/Clear/Migration/ChangeColumnType","kind":"class","full_name":"Clear::Migration::ChangeColumnType","name":"ChangeColumnType"},{"html_id":"clear/Clear/Migration/CreateEnum","kind":"class","full_name":"Clear::Migration::CreateEnum","name":"CreateEnum"},{"html_id":"clear/Clear/Migration/CreateIndex","kind":"class","full_name":"Clear::Migration::CreateIndex","name":"CreateIndex"},{"html_id":"clear/Clear/Migration/DropEnum","kind":"class","full_name":"Clear::Migration::DropEnum","name":"DropEnum"},{"html_id":"clear/Clear/Migration/DropTable","kind":"class","full_name":"Clear::Migration::DropTable","name":"DropTable"},{"html_id":"clear/Clear/Migration/Execute","kind":"class","full_name":"Clear::Migration::Execute","name":"Execute"},{"html_id":"clear/Clear/Migration/FullTextSearchableOperation","kind":"class","full_name":"Clear::Migration::FullTextSearchableOperation","name":"FullTextSearchableOperation"},{"html_id":"clear/Clear/Migration/RemoveColumn","kind":"class","full_name":"Clear::Migration::RemoveColumn","name":"RemoveColumn"},{"html_id":"clear/Clear/Migration/RenameColumn","kind":"class","full_name":"Clear::Migration::RenameColumn","name":"RenameColumn"},{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":true,"location":{"filename":"src/clear/migration/operation/operation.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L8"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"irreversible!(operation_name:String|Nil=nil)-instance-method","name":"irreversible!","abstract":false,"args":[{"name":"operation_name","default_value":"nil","external_name":"operation_name","restriction":"String | ::Nil"}],"args_string":"(operation_name : String | Nil = nil)","args_html":"(operation_name : String | Nil = nil)","location":{"filename":"src/clear/migration/operation/operation.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L10"},"def":{"name":"irreversible!","args":[{"name":"operation_name","default_value":"nil","external_name":"operation_name","restriction":"String | ::Nil"}],"visibility":"Public","body":"operation_name || (operation_name = self.class.name)\nmigration_name = migration ? migration.class.name : nil\nraise(IrreversibleMigration.new(migration_irreversible(migration_name, operation_name)))\n"}},{"html_id":"migration:Clear::Migration|Nil-instance-method","name":"migration","abstract":false,"location":{"filename":"src/clear/migration/operation/operation.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L5"},"def":{"name":"migration","return_type":"Clear::Migration | ::Nil","visibility":"Public","body":"@migration"}},{"html_id":"migration=(migration:Clear::Migration|Nil)-instance-method","name":"migration=","abstract":false,"args":[{"name":"migration","external_name":"migration","restriction":"Clear::Migration | ::Nil"}],"args_string":"(migration : Clear::Migration | Nil)","args_html":"(migration : Clear::Migration | Nil)","location":{"filename":"src/clear/migration/operation/operation.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L5"},"def":{"name":"migration=","args":[{"name":"migration","external_name":"migration","restriction":"Clear::Migration | ::Nil"}],"visibility":"Public","body":"@migration = migration"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":true,"location":{"filename":"src/clear/migration/operation/operation.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L7"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":""}}]},{"html_id":"clear/Clear/Migration/RemoveColumn","path":"Clear/Migration/RemoveColumn.html","kind":"class","full_name":"Clear::Migration::RemoveColumn","name":"RemoveColumn","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/columns.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L39"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(table:String,column:String,datatype)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"column","external_name":"column","restriction":"::String"},{"name":"datatype","external_name":"datatype","restriction":""}],"args_string":"(table : String, column : String, datatype)","args_html":"(table : String, column : String, datatype)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L44"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"column","external_name":"column","restriction":"::String"},{"name":"datatype","external_name":"datatype","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, column, datatype)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L52"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} ADD #{@column} #{@datatype}\"]"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L48"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} DROP #{@column}\"]"}}]},{"html_id":"clear/Clear/Migration/RenameColumn","path":"Clear/Migration/RenameColumn.html","kind":"class","full_name":"Clear::Migration::RenameColumn","name":"RenameColumn","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/columns.cr","line_number":57,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L57"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(table:String,old_column_name:String,new_column_name:String)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"old_column_name","external_name":"old_column_name","restriction":"::String"},{"name":"new_column_name","external_name":"new_column_name","restriction":"::String"}],"args_string":"(table : String, old_column_name : String, new_column_name : String)","args_html":"(table : String, old_column_name : String, new_column_name : String)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L62"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"old_column_name","external_name":"old_column_name","restriction":"::String"},{"name":"new_column_name","external_name":"new_column_name","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, old_column_name, new_column_name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":69,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L69"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} RENAME COLUMN #{@new_column_name} TO #{@old_column_name};\"]"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L65"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} RENAME COLUMN #{@old_column_name} TO #{@new_column_name};\"]"}}]},{"html_id":"clear/Clear/Migration/Table","path":"Clear/Migration/Table.html","kind":"class","full_name":"Clear::Migration::Table","name":"Table","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/FullTextSearchableTableHelpers","kind":"module","full_name":"Clear::Migration::FullTextSearchableTableHelpers","name":"FullTextSearchableTableHelpers"},{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/full_text_searchable.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/full_text_searchable.cr#L8"},{"filename":"src/clear/migration/operation/table.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Migration/FullTextSearchableTableHelpers","kind":"module","full_name":"Clear::Migration::FullTextSearchableTableHelpers","name":"FullTextSearchableTableHelpers"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"doc":"Reopen Table to add the helpers","summary":"Reopen Table to add the helpers
","constructors":[{"html_id":"new(name:String,schema:String,is_create:Bool)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"},{"name":"is_create","external_name":"is_create","restriction":"::Bool"}],"args_string":"(name : String, schema : String, is_create : Bool)","args_html":"(name : String, schema : String, is_create : Bool)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L23"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"},{"name":"is_create","external_name":"is_create","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, schema, is_create)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"add_column(column,type,default=nil,null=true,primary=false,index=false,unique=false,array=false)-instance-method","name":"add_column","doc":"Add/alter a column for this table.","summary":"Add/alter a column for this table.
","abstract":false,"args":[{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"args_string":"(column, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","args_html":"(column, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L52"},"def":{"name":"add_column","args":[{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"visibility":"Public","body":"self.column_operations << ColumnOperation.new(column: column.to_s, type: type.to_s, default: default, null: null, primary: primary, array: array)\nif unique\n add_index(fields: [column.to_s], unique: true)\nelse\n if index\n if index.is_a?(Bool)\n add_index(fields: [column.to_s], unique: false)\n else\n add_index(fields: [column.to_s], unique: false, using: index)\n end\n end\nend\n"}},{"html_id":"add_fkey(fields:Array(String),table:String,foreign_fields:Array(String),on_delete:String,primary:Bool)-instance-method","name":"add_fkey","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"args_string":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","args_html":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":45,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L45"},"def":{"name":"add_fkey","args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"visibility":"Public","body":"self.fkey_operations << FkeyOperation.new(fields: fields, table: table, foreign_fields: foreign_fields, on_delete: on_delete, primary: primary)"}},{"html_id":"column(name,type,default=nil,null=true,primary=false,index=false,unique=false,array=false)-instance-method","name":"column","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"args_string":"(name, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","args_html":"(name, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":167,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L167"},"def":{"name":"column","args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"visibility":"Public","body":"type = case type.to_s\nwhen \"string\"\n \"text\"\nwhen \"int32\", \"integer\"\n \"integer\"\nwhen \"int64\", \"long\"\n \"bigint\"\nwhen \"bigdecimal\", \"numeric\"\n \"numeric\"\nwhen \"datetime\"\n \"timestamp without time zone\"\nelse\n type.to_s\nend\nadd_column(name.to_s, type: type, default: default, null: null, primary: primary, index: index, unique: unique, array: array)\n"}},{"html_id":"column_operations:Array(ColumnOperation)-instance-method","name":"column_operations","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L19"},"def":{"name":"column_operations","return_type":"Array(ColumnOperation)","visibility":"Public","body":"@column_operations"}},{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":113,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L113"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[(if is_create?\n [\"DROP TABLE\", full_name].join(\" \")\nend)].compact"}},{"html_id":"fkey_operations:Array(FkeyOperation)-instance-method","name":"fkey_operations","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L21"},"def":{"name":"fkey_operations","return_type":"Array(FkeyOperation)","visibility":"Public","body":"@fkey_operations"}},{"html_id":"full_name-instance-method","name":"full_name","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":68,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L68"},"def":{"name":"full_name","visibility":"Public","body":"{Clear::SQL.escape(@schema), Clear::SQL.escape(@name)}.join(\".\")"}},{"html_id":"index(field:String|Symbol,name=nil,using=nil,unique=false)-instance-method","name":"index","doc":"Add or replace an index for this table.\nAlias for `add_index`","summary":"Add or replace an index for this table.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"String | Symbol"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(field : String | Symbol, name = nil, using = nil, unique = false)","args_html":"(field : String | Symbol, name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":74,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L74"},"def":{"name":"index","args":[{"name":"field","external_name":"field","restriction":"String | Symbol"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_index(fields: [field.to_s], name: name, using: using, unique: unique)"}},{"html_id":"index(fields:Array,name=nil,using=nil,unique=false)-instance-method","name":"index","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(fields : Array, name = nil, using = nil, unique = false)","args_html":"(fields : Array, name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":78,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L78"},"def":{"name":"index","args":[{"name":"fields","external_name":"fields","restriction":"Array"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_index(fields: fields.map(&.to_s), name: name, using: using, unique: unique)"}},{"html_id":"index_operations:Array(IndexOperation)-instance-method","name":"index_operations","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L20"},"def":{"name":"index_operations","return_type":"Array(IndexOperation)","visibility":"Public","body":"@index_operations"}},{"html_id":"is_create?:Bool-instance-method","name":"is_create?","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L17"},"def":{"name":"is_create?","return_type":"Bool","visibility":"Public","body":"@is_create"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L14"},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"references(to,name:String|Nil=nil,on_delete=\"restrict\",type=\"bigint\",null=false,foreign_key=\"id\",primary=false)-instance-method","name":"references","abstract":false,"args":[{"name":"to","external_name":"to","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":"String | ::Nil"},{"name":"on_delete","default_value":"\"restrict\"","external_name":"on_delete","restriction":""},{"name":"type","default_value":"\"bigint\"","external_name":"type","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""},{"name":"foreign_key","default_value":"\"id\"","external_name":"foreign_key","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""}],"args_string":"(to, name : String | Nil = nil, on_delete = \"restrict\", type = \"bigint\", null = false, foreign_key = \"id\", primary = false)","args_html":"(to, name : String | Nil = nil, on_delete = "restrict", type = "bigint", null = false, foreign_key = "id", primary = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L35"},"def":{"name":"references","args":[{"name":"to","external_name":"to","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":"String | ::Nil"},{"name":"on_delete","default_value":"\"restrict\"","external_name":"on_delete","restriction":""},{"name":"type","default_value":"\"bigint\"","external_name":"type","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""},{"name":"foreign_key","default_value":"\"id\"","external_name":"foreign_key","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""}],"visibility":"Public","body":"name || (name = to.singularize.underscore + \"_id\")\nadd_column(name, type, null: null, index: true)\nadd_fkey(fields: [name.to_s], table: to.to_s, foreign_fields: [foreign_key.to_s], on_delete: on_delete.to_s, primary: primary)\n"}},{"html_id":"schema:String-instance-method","name":"schema","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L15"},"def":{"name":"schema","return_type":"String","visibility":"Public","body":"@schema"}},{"html_id":"timestamps(null=false)-instance-method","name":"timestamps","doc":"Add the timestamps to the field.","summary":"Add the timestamps to the field.
","abstract":false,"args":[{"name":"null","default_value":"false","external_name":"null","restriction":""}],"args_string":"(null = false)","args_html":"(null = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L28"},"def":{"name":"timestamps","args":[{"name":"null","default_value":"false","external_name":"null","restriction":""}],"visibility":"Public","body":"add_column(:created_at, \"timestamp without time zone\", null: null, default: \"NOW()\")\nadd_column(:updated_at, \"timestamp without time zone\", null: null, default: \"NOW()\")\nadd_index([\"created_at\"])\nadd_index([\"updated_at\"])\n"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":97,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L97"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"columns_and_fkeys = print_columns + print_fkeys\nif columns_and_fkeys.empty?\nelse\n content = \"(#{columns_and_fkeys.join(\", \")})\"\nend\narr = if is_create?\n [[\"CREATE TABLE\", full_name, content].compact.join(\" \")]\nelse\n [] of String\nend\narr + print_indexes\n"}}],"macros":[{"html_id":"method_missing(caller)-macro","name":"method_missing","doc":"DEPRECATED\nMethod missing is used to generate add_column using the method name as\ncolumn type (ActiveRecord's style)","summary":"DEPRECATED Method missing is used to generate add_column using the method name as column type (ActiveRecord's style)
","abstract":false,"args":[{"name":"caller","external_name":"caller","restriction":""}],"args_string":"(caller)","args_html":"(caller)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":162,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L162"},"def":{"name":"method_missing","args":[{"name":"caller","external_name":"caller","restriction":""}],"visibility":"Public","body":" \n{% raise(\"Migration: usage of Table##{caller.name} is deprecated.\\n\" + \"Tip: use instead `self.column(NAME, \\\"#{caller.name}\\\", ...)`\") %}\n\n \n"}}],"types":[{"html_id":"clear/Clear/Migration/Table/ColumnOperation","path":"Clear/Migration/Table/ColumnOperation.html","kind":"struct","full_name":"Clear::Migration::Table::ColumnOperation","name":"ColumnOperation","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"},"constructors":[{"html_id":"new(column:String,type:String,null:Bool=false,default:SQL::Any=nil,primary:Bool=false,array:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"column","external_name":"column","restriction":"String"},{"name":"type","external_name":"type","restriction":"String"},{"name":"null","default_value":"false","external_name":"null","restriction":"Bool"},{"name":"default","default_value":"nil","external_name":"default","restriction":"SQL::Any"},{"name":"primary","default_value":"false","external_name":"primary","restriction":"Bool"},{"name":"array","default_value":"false","external_name":"array","restriction":"Bool"}],"args_string":"(column : String, type : String, null : Bool = false, default : SQL::Any = nil, primary : Bool = false, array : Bool = false)","args_html":"(column : String, type : String, null : Bool = false, default : SQL::Any = nil, primary : Bool = false, array : Bool = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"},"def":{"name":"new","args":[{"name":"column","external_name":"column","restriction":"String"},{"name":"type","external_name":"type","restriction":"String"},{"name":"null","default_value":"false","external_name":"null","restriction":"Bool"},{"name":"default","default_value":"nil","external_name":"default","restriction":"SQL::Any"},{"name":"primary","default_value":"false","external_name":"primary","restriction":"Bool"},{"name":"array","default_value":"false","external_name":"array","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(column, type, null, default, primary, array)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"array:Bool-instance-method","name":"array","abstract":false,"def":{"name":"array","return_type":"Bool","visibility":"Public","body":"@array"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@column.clone, @type.clone, @null.clone, @default.clone, @primary.clone, @array.clone)"}},{"html_id":"column:String-instance-method","name":"column","abstract":false,"def":{"name":"column","return_type":"String","visibility":"Public","body":"@column"}},{"html_id":"copy_with(column_column=@column,type_type=@type,null_null=@null,default_default=@default,primary_primary=@primary,array_array=@array)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_column","default_value":"@column","external_name":"column","restriction":""},{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_null","default_value":"@null","external_name":"null","restriction":""},{"name":"_default","default_value":"@default","external_name":"default","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""},{"name":"_array","default_value":"@array","external_name":"array","restriction":""}],"args_string":"(column _column = @column, type _type = @type, null _null = @null, default _default = @default, primary _primary = @primary, array _array = @array)","args_html":"(column _column = @column, type _type = @type, null _null = @null, default _default = @default, primary _primary = @primary, array _array = @array)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"},"def":{"name":"copy_with","args":[{"name":"_column","default_value":"@column","external_name":"column","restriction":""},{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_null","default_value":"@null","external_name":"null","restriction":""},{"name":"_default","default_value":"@default","external_name":"default","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""},{"name":"_array","default_value":"@array","external_name":"array","restriction":""}],"visibility":"Public","body":"self.class.new(_column, _type, _null, _default, _primary, _array)"}},{"html_id":"default:SQL::Any-instance-method","name":"default","abstract":false,"def":{"name":"default","return_type":"SQL::Any","visibility":"Public","body":"@default"}},{"html_id":"null:Bool-instance-method","name":"null","abstract":false,"def":{"name":"null","return_type":"Bool","visibility":"Public","body":"@null"}},{"html_id":"primary:Bool-instance-method","name":"primary","abstract":false,"def":{"name":"primary","return_type":"Bool","visibility":"Public","body":"@primary"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"clear/Clear/Migration/Table/FkeyOperation","path":"Clear/Migration/Table/FkeyOperation.html","kind":"struct","full_name":"Clear::Migration::Table::FkeyOperation","name":"FkeyOperation","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"},"constructors":[{"html_id":"new(fields:Array(String),table:String,foreign_fields:Array(String),on_delete:String,primary:Bool)-class-method","name":"new","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"args_string":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","args_html":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"},"def":{"name":"new","args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(fields, table, foreign_fields, on_delete, primary)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@fields.clone, @table.clone, @foreign_fields.clone, @on_delete.clone, @primary.clone)"}},{"html_id":"copy_with(fields_fields=@fields,table_table=@table,foreign_fields_foreign_fields=@foreign_fields,on_delete_on_delete=@on_delete,primary_primary=@primary)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_table","default_value":"@table","external_name":"table","restriction":""},{"name":"_foreign_fields","default_value":"@foreign_fields","external_name":"foreign_fields","restriction":""},{"name":"_on_delete","default_value":"@on_delete","external_name":"on_delete","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""}],"args_string":"(fields _fields = @fields, table _table = @table, foreign_fields _foreign_fields = @foreign_fields, on_delete _on_delete = @on_delete, primary _primary = @primary)","args_html":"(fields _fields = @fields, table _table = @table, foreign_fields _foreign_fields = @foreign_fields, on_delete _on_delete = @on_delete, primary _primary = @primary)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"},"def":{"name":"copy_with","args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_table","default_value":"@table","external_name":"table","restriction":""},{"name":"_foreign_fields","default_value":"@foreign_fields","external_name":"foreign_fields","restriction":""},{"name":"_on_delete","default_value":"@on_delete","external_name":"on_delete","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""}],"visibility":"Public","body":"self.class.new(_fields, _table, _foreign_fields, _on_delete, _primary)"}},{"html_id":"fields:Array(String)-instance-method","name":"fields","abstract":false,"def":{"name":"fields","return_type":"Array(String)","visibility":"Public","body":"@fields"}},{"html_id":"foreign_fields:Array(String)-instance-method","name":"foreign_fields","abstract":false,"def":{"name":"foreign_fields","return_type":"Array(String)","visibility":"Public","body":"@foreign_fields"}},{"html_id":"on_delete:String-instance-method","name":"on_delete","abstract":false,"def":{"name":"on_delete","return_type":"String","visibility":"Public","body":"@on_delete"}},{"html_id":"primary:Bool-instance-method","name":"primary","abstract":false,"def":{"name":"primary","return_type":"Bool","visibility":"Public","body":"@primary"}},{"html_id":"table:String-instance-method","name":"table","abstract":false,"def":{"name":"table","return_type":"String","visibility":"Public","body":"@table"}}]},{"html_id":"clear/Clear/Migration/Table/IndexOperation","path":"Clear/Migration/Table/IndexOperation.html","kind":"struct","full_name":"Clear::Migration::Table::IndexOperation","name":"IndexOperation","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"},"constructors":[{"html_id":"new(fields:Array(String),name:String,using:String|Nil=nil,unique:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"name","external_name":"name","restriction":"String"},{"name":"using","default_value":"nil","external_name":"using","restriction":"String | ::Nil"},{"name":"unique","default_value":"false","external_name":"unique","restriction":"Bool"}],"args_string":"(fields : Array(String), name : String, using : String | Nil = nil, unique : Bool = false)","args_html":"(fields : Array(String), name : String, using : String | Nil = nil, unique : Bool = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"},"def":{"name":"new","args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"name","external_name":"name","restriction":"String"},{"name":"using","default_value":"nil","external_name":"using","restriction":"String | ::Nil"},{"name":"unique","default_value":"false","external_name":"unique","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(fields, name, using, unique)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@fields.clone, @name.clone, @using.clone, @unique.clone)"}},{"html_id":"copy_with(fields_fields=@fields,name_name=@name,using_using=@using,unique_unique=@unique)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_using","default_value":"@using","external_name":"using","restriction":""},{"name":"_unique","default_value":"@unique","external_name":"unique","restriction":""}],"args_string":"(fields _fields = @fields, name _name = @name, using _using = @using, unique _unique = @unique)","args_html":"(fields _fields = @fields, name _name = @name, using _using = @using, unique _unique = @unique)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"},"def":{"name":"copy_with","args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_using","default_value":"@using","external_name":"using","restriction":""},{"name":"_unique","default_value":"@unique","external_name":"unique","restriction":""}],"visibility":"Public","body":"self.class.new(_fields, _name, _using, _unique)"}},{"html_id":"fields:Array(String)-instance-method","name":"fields","abstract":false,"def":{"name":"fields","return_type":"Array(String)","visibility":"Public","body":"@fields"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"unique:Bool-instance-method","name":"unique","abstract":false,"def":{"name":"unique","return_type":"Bool","visibility":"Public","body":"@unique"}},{"html_id":"using:String|Nil-instance-method","name":"using","abstract":false,"def":{"name":"using","return_type":"String | ::Nil","visibility":"Public","body":"@using"}}]}]}]},{"html_id":"clear/Clear/Model","path":"Clear/Model.html","kind":"module","full_name":"Clear::Model","name":"Model","abstract":false,"ancestors":[{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Validation/Helper","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/full_text_searchable.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/full_text_searchable.cr#L3"},{"filename":"src/clear/model/collection.cr","line_number":158,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L158"},{"filename":"src/clear/model/errors.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L1"},{"filename":"src/clear/model/model.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L9"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"}],"including_types":[{"html_id":"clear/Clear/Reflection/Column","kind":"class","full_name":"Clear::Reflection::Column","name":"Column"},{"html_id":"clear/Clear/Reflection/Table","kind":"class","full_name":"Clear::Reflection::Table","name":"Table"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"Model definition is made by adding the `Clear::Model` mixin in your class.\n## Simple Model\n\n```\nclass MyModel\n include Clear::Model\n\n column my_column : String\nend\n```\n\nWe just created a new model, linked to your database, mapping the column `my_column` of type String (`text` in postgres).\n\nNow, you can play with your model:\n\n```\nrow = MyModel.new # create an empty row\nrow.my_column = \"This is a content\"\nrow.save! # insert the new row in the database !\n```\n\nBy convention, the table name will follow an underscore, plural version of your model: `my_models`.\nA model into a module will prepend the module name before, so `Logistic::MyModel` will check for `logistic_my_models` in your database.\nYou can force a specific table name using:\n\n```\nclass MyModel\n include Clear::Model\n self.table = \"another_table_name\"\nend\n```\n\n## Presence validation\n\nUnlike many ORM around, Clear carry about non-nullable pattern in crystal. Meaning `column my_column : String` assume than a call to `row.my_column` will return a String.\n\nBut it exists cases where the column is not yet initialized:\n- When the object is built with constructor without providing the value (See above).\n- When an object is semi-fetched through the database query. This is useful to ignore some large fields non-interesting in the body of the current operation.\n\nFor example, this code will compile:\n\n```\nrow = MyModel.new # create an empty row\nputs row.my_column\n```\n\nHowever, it will throw a runtime exception `You cannot access to the field 'my_column' because it never has been initialized`\n\nSame way, trying to save the object will raise an error:\n\n```\nrow.save # Will return false\npp row.errors # Will tell you than `my_column` presence is mandatory.\n```\n\nThanks to expressiveness of the Crystal language, we can handle presence validation by simply using the `Nilable` type in crystal:\n\n```\nclass MyModel\n include Clear::Model\n\n column my_column : String? # Now, the column can be NULL or text in postgres.\nend\n```\n\nThis time, the code above will works; in case of no value, my_column will be `nil` by default.\n\n## Querying your code\n\nWhenever you want to fetch data from your database, you must create a new collection query:\n\n`MyModel.query #Will setup a vanilla 'SELECT * FROM my_models'`\n\nQueries are fetchable using `each`:\n\n```\nMyModel.query.each do |model|\n # Do something with your model here.\nend\n```\n\n## Refining your query\n\nA collection query offers a lot of functionalities. You can read the [API](https://anykeyh.github.io/clear/Clear/Model/CollectionBase.html) for more informations.\n\n## Column type\n\nBy default, Clear map theses columns types:\n\n- `String` => `text`\n- `Numbers` (any from 8 to 64 bits, float, double, big number, big float) => `int, large int etc... (depends of your choice)`\n- `Bool` => `text or bool`\n- `Time` => `timestamp without timezone or text`\n- `JSON::Any` => `json and jsonb`\n- `Nilable` => `NULL` (treated as special !)\n\n_NOTE_: The `crystal-pg` gems map also some structures like GIS coordinates, but their implementation is not tested in Clear. Use them at your own risk. Tell me if it's working 😉\n\nIf you need to map special structure, see [Mapping Your Data](Mapping) guides for more informations.\n\n## Primary key\n\nPrimary key is essential for relational mapping. Currently Clear support only one column primary key.\n\nA model without primary key can work in sort of degraded mode, throwing error in case of using some methods on them:\n- `collection#first` will be throwing error if no `order_by` has been setup\n\nTo setup a primary key, you can add the modifier `primary: true` to the column:\n\n```\nclass MyModel\n include Clear::Model\n\n column id : Int32, primary: true, presence: false\n column my_column : String?\nend\n```\n\nNote the flag `presence: false` added to the column. This tells Clear than presence checking on save is not mandatory. Usually this happens if you setup a default value in postgres. In the case of our primary key `id`, we use a serial auto-increment default value.\nTherefore, saving the model without primary key will works. The id will be fetched after insertion:\n\n```\nm = MyModel\nm.save!\nm.id # Now the id value is setup.\n```\n\n## Helpers\n\nClear provides various built-in helpers to facilitate your life:\n\n### Timestamps\n\n```\nclass MyModel\n include Clear::Model\n timestamps # Will map the two columns 'created_at' and 'updated_at', and map some hooks to update their values.\nend\n```\n\nTheses fields are automatically updated whenever you call `save` methods, and works as Rails ActiveRecord.\n\n### With Serial Pkey\n\n```\nclass MyModel\n include Clear::Model\n primary_key \"my_primary_key\"\nend\n```\n\nBasically rewrite `column id : UInt64, primary: true, presence: false`\n\nArgument is optional (default = id)","summary":"Model definition is made by adding the Clear::Model
mixin in your class.
Alias method for primary key.
","abstract":false,"location":{"filename":"src/clear/model/model.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L33"},"def":{"name":"__pkey__","visibility":"Public","body":"raise(lack_of_primary_key(self.class.name))"}},{"html_id":"cache:Clear::Model::QueryCache|Nil-instance-method","name":"cache","abstract":false,"location":{"filename":"src/clear/model/model.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L25"},"def":{"name":"cache","return_type":"Clear::Model::QueryCache | ::Nil","visibility":"Public","body":"@cache"}}],"macros":[{"html_id":"scope(name,&block)-macro","name":"scope","doc":"A scope allow you to filter in a very human way a set of data.\n\nUsage:\n\n```\nscope(\"admin\") { where({role: \"admin\"}) }\n```\n\nfor example, instead of writing:\n\n```\nUser.query.where { (role == \"admin\") & (active == true) }\n```\n\nYou can write:\n\n```\nUser.admin.active\n```\n\nScope can be used for other purpose than just filter (e.g. ordering),\nbut I would not recommend it.","summary":"A scope allow you to filter in a very human way a set of data.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name, &block)","args_html":"(name, &block)","location":{"filename":"src/clear/model/model.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L19"},"def":{"name":"scope","args":[{"name":"name","external_name":"name","restriction":""}],"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" \n{% parameters = \"\" %}\n\n \n{% for arg, idx in block.args %}\n {% if (block.splat_index && (idx == block.splat_index))\n parameters = parameters + \"*\"\nend %}\n {% parameters = parameters + \"#{arg}\" %}\n {% unless (idx == (block.args.size - 1))\n parameters = parameters + \", \"\nend %}\n {% end %}\n\n \n{% parameters = parameters.id %}\n\n\n def self.\n{{ name.id }}\n(\n{{ parameters }}\n)\n query.\n{{ name.id }}\n(\n{{ parameters }}\n)\n \nend\n\n class Collection < Clear::Model::CollectionBase(\n{{ @type }}\n);\n def \n{{ name.id }}\n(\n{{ parameters }}\n)\n \n{{ yield }}\n\n\n return self\n \nend\n \nend\n \n"}}],"types":[{"html_id":"clear/Clear/Model/ClassMethods","path":"Clear/Model/ClassMethods.html","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/clear/model/modules/class_methods.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/class_methods.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}},{"html_id":"clear/Clear/Model/CollectionBase","path":"Clear/Model/CollectionBase.html","kind":"class","full_name":"Clear::Model::CollectionBase(T)","name":"CollectionBase","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/collection.cr","line_number":168,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L168"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"}],"subclasses":[{"html_id":"clear/Clear/Reflection/Column/Collection","kind":"class","full_name":"Clear::Reflection::Column::Collection","name":"Collection"},{"html_id":"clear/Clear/Reflection/Table/Collection","kind":"class","full_name":"Clear::Reflection::Table::Collection","name":"Collection"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"`CollectionBase(T)` is the base class for collection of model.\nCollection of model are a SQL `SELECT` query mapping & building system. They are Enumerable and are\n`Clear::SQL::SelectBuilder` behavior; therefore, they can be used array-like and are working with low-level SQL\nBuilding.\n\nThe `CollectionBase(T)` is extended by each model. For example, generating the model `MyModel` will generate the\nclass `MyModel::Collection` which inherits from `CollectionBase(MyModel)`\n\nCollection are instantiated using `Model.query` method.","summary":"CollectionBase(T)
is the base class for collection of model.
Add an item to the current collection.
","abstract":false,"args":[{"name":"item","external_name":"item","restriction":"T"}],"args_string":"(item : T)","args_html":"(item : T)","location":{"filename":"src/clear/model/collection.cr","line_number":494,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L494"},"def":{"name":"<<","args":[{"name":"item","external_name":"item","restriction":"T"}],"visibility":"Public","body":"append_operation = self.append_operation\nif append_operation\nelse\n raise(\"Operation not permitted on this collection.\")\nend\nappend_operation.call(item)\n@cached_result.try(&.<<(item))\nself\n"}},{"html_id":"[](range:Range(Number,Number),fetch_columns=false):Array(T)-instance-method","name":"[]","doc":"Get a range of models","summary":"Get a range of models
","abstract":false,"args":[{"name":"range","external_name":"range","restriction":"Range(Number, Number)"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(range : Range(Number, Number), fetch_columns = false) : Array(T)","args_html":"(range : Range(Number, Number), fetch_columns = false) : Array(T)","location":{"filename":"src/clear/model/collection.cr","line_number":550,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L550"},"def":{"name":"[]","args":[{"name":"range","external_name":"range","restriction":"Range(Number, Number)"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"Array(T)","visibility":"Public","body":"((offset(range.begin)).limit(range.end - range.begin)).to_a(fetch_columns)"}},{"html_id":"[](off,fetch_columns=false):T-instance-method","name":"[]","doc":"Basically a fancy way to write `OFFSET x LIMIT 1`","summary":"Basically a fancy way to write OFFSET x LIMIT 1
Basically a fancy way to write OFFSET x LIMIT 1
Alias for Collection#<<
Check whether the query return any row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":464,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L464"},"def":{"name":"any?","visibility":"Public","body":"cr = @cached_result\nif cr\n return !cr.empty?\nend\n((clear_select.select(\"1\")).limit(1)).fetch do |_|\n return true\nend\nfalse\n"}},{"html_id":"build(x:NamedTuple,&block:T->Nil):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":405,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L405"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"build(**x, &block)"}},{"html_id":"build(**tuple,&:T->Nil):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":383,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L383"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"str_hash = @tags.dup\ntuple.map do |k, v|\n str_hash[k.to_s] = v\nend\nr = Clear::Model::Factory.build(T, str_hash, persisted: false)\nyield(r)\nr\n"}},{"html_id":"build(x:NamedTuple):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":400,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L400"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"build(**x) do\nend"}},{"html_id":"build(**tuple):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":395,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L395"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"build(**tuple) do\nend"}},{"html_id":"count(type:X.class=Int64)forallX-instance-method","name":"count","doc":"Use SQL `COUNT` over your query, and return this number as a Int64","summary":"Use SQL COUNT
over your query, and return this number as a Int64
Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":431,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L431"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create(**tuple,&:T->Nil):T-instance-method","name":"create","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":412,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L412"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save\nr\n"}},{"html_id":"create(x:NamedTuple):T-instance-method","name":"create","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":426,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L426"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"create(**x)"}},{"html_id":"create(**tuple):T-instance-method","name":"create","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":421,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L421"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"create(**tuple) do\nend"}},{"html_id":"create!(x:NamedTuple,&block:T->Nil):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":459,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L459"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create!(**tuple,&:T->Nil):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":440,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L440"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"create!(x:NamedTuple):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":454,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L454"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"create(**x)"}},{"html_id":"create!(**tuple):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":449,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L449"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"create!(**tuple) do\nend"}},{"html_id":"delete_all:self-instance-method","name":"delete_all","doc":"Delete all the rows which would have been returned by this collection.\nIs equivalent to `collection.to_delete.execute`","summary":"Delete all the rows which would have been returned by this collection.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":704,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L704"},"def":{"name":"delete_all","return_type":"self","visibility":"Public","body":"to_delete.execute\nchange!\n"}},{"html_id":"dup-instance-method","name":"dup","doc":"Duplicate the query","summary":"Duplicate the query
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":220,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L220"},"def":{"name":"dup","visibility":"Public","body":"if (@polymorphic && (polymorphic_key = @polymorphic_key)) && (polymorphic_scope = @polymorphic_scope)\n super().flag_as_polymorphic!(polymorphic_key, polymorphic_scope)\nelse\n super()\nend"}},{"html_id":"each(fetch_columns=false,&:T->):Nil-instance-method","name":"each","doc":"Build the SQL, send the query then iterate through each models\ngathered by the request.","summary":"Build the SQL, send the query then iterate through each models gathered by the request.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, & : T -> ) : Nil","args_html":"(fetch_columns = false, & : T -> ) : Nil","location":{"filename":"src/clear/model/collection.cr","line_number":322,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L322"},"def":{"name":"each","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T ->)"},"return_type":"Nil","visibility":"Public","body":"result = @cached_result\nif result\nelse\n result = [] of T\n if @polymorphic\n fetch(fetch_all: false) do |hash|\n type = hash[@polymorphic_key].as(String)\n result << ((Clear::Model::Factory.build(type, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache)).as(T))\n end\n else\n fetch(fetch_all: false) do |hash|\n result << (Clear::Model::Factory.build(T, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache))\n end\n end\nend\nresult.each do |value|\n yield value\nend\n"}},{"html_id":"each_with_cursor(batch=1000,fetch_columns=false,&block:T->)-instance-method","name":"each_with_cursor","doc":"Build the SQL, send the query then iterate through each models\ngathered by the request.\nUse a postgres cursor to avoid memory bloating.\nUseful to fetch millions of rows at once.","summary":"Build the SQL, send the query then iterate through each models gathered by the request.
","abstract":false,"args":[{"name":"batch","default_value":"1000","external_name":"batch","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(batch = 1000, fetch_columns = false, &block : T -> )","args_html":"(batch = 1000, fetch_columns = false, &block : T -> )","location":{"filename":"src/clear/model/collection.cr","line_number":358,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L358"},"def":{"name":"each_with_cursor","args":[{"name":"batch","default_value":"1000","external_name":"batch","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T ->)"},"visibility":"Public","body":"cr = @cached_result\nif cr\n cr.each(&block)\nelse\n if @polymorphic\n fetch_with_cursor(count: batch) do |hash|\n type = hash[@polymorphic_key].as(String)\n yield((Clear::Model::Factory.build(type, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache)).as(T))\n end\n else\n fetch_with_cursor(count: batch) do |hash|\n yield(Clear::Model::Factory.build(T, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache))\n end\n end\nend\n"}},{"html_id":"empty?-instance-method","name":"empty?","doc":"Inverse of `any?`, return true if the request return no rows.","summary":"Inverse of #any?
, return true if the request return no rows.
A convenient way to write where { condition }.first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first
A convenient way to write where { condition }.first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!
Try to fetch a row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":590,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L590"},"def":{"name":"find_or_build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"if tuple.size == 0\nelse\n where(tuple)\nend\nr = first\nif r\n return r\nend\nstr_hash = @tags.dup\ntuple.map do |k, v|\n str_hash[k.to_s] = v\nend\nr = Clear::Model::Factory.build(T, str_hash)\nyield(r)\nr\n"}},{"html_id":"find_or_build(x:NamedTuple):T-instance-method","name":"find_or_build","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":610,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L610"},"def":{"name":"find_or_build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"find_or_build(**x)"}},{"html_id":"find_or_build(**tuple):T-instance-method","name":"find_or_build","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":605,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L605"},"def":{"name":"find_or_build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"find_or_build(**tuple) do\nend"}},{"html_id":"find_or_create(x:NamedTuple,&block:T->Nil):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":641,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L641"},"def":{"name":"find_or_create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"find_or_create(**x, &block)"}},{"html_id":"find_or_create(**tuple,&:T->Nil):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":622,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L622"},"def":{"name":"find_or_create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"r = find_or_build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"find_or_create(x:NamedTuple):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":636,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L636"},"def":{"name":"find_or_create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"find_or_create(**x)"}},{"html_id":"find_or_create(**tuple):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":631,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L631"},"def":{"name":"find_or_create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"find_or_create(**tuple) do\nend"}},{"html_id":"first(fetch_columns=false):T|Nil-instance-method","name":"first","doc":"Get the first row from the collection query.\nif not found, return `nil`","summary":"Get the first row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T | Nil","args_html":"(fetch_columns = false) : T | Nil","location":{"filename":"src/clear/model/collection.cr","line_number":647,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L647"},"def":{"name":"first","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T | ::Nil","visibility":"Public","body":"if T.__pkey__ || order_bys.empty?\n order_by(Clear::SQL.escape(\"#{T.__pkey__}\"), :asc)\nend\n(limit(1)).fetch do |hash|\n return Clear::Model::Factory.build(T, hash, persisted: true, cache: @cache, fetch_columns: fetch_columns)\nend\nnil\n"}},{"html_id":"first!(fetch_columns=false):T-instance-method","name":"first!","doc":"Get the first row from the collection query.\nif not found, throw an error","summary":"Get the first row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T","args_html":"(fetch_columns = false) : T","location":{"filename":"src/clear/model/collection.cr","line_number":659,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L659"},"def":{"name":"first!","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T","visibility":"Public","body":"(first(fetch_columns)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"item_class-instance-method","name":"item_class","doc":"Return the model class for this collection","summary":"Return the model class for this collection
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":235,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L235"},"def":{"name":"item_class","visibility":"Public","body":"T"}},{"html_id":"last(fetch_columns=false):T|Nil-instance-method","name":"last","doc":"Get the last row from the collection query.\nif not found, return `nil`","summary":"Get the last row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T | Nil","args_html":"(fetch_columns = false) : T | Nil","location":{"filename":"src/clear/model/collection.cr","line_number":665,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L665"},"def":{"name":"last","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T | ::Nil","visibility":"Public","body":"if T.__pkey__ || order_bys.empty?\n order_by(\"#{T.__pkey__}\", :asc)\nend\narr = order_bys.dup\nbegin\n new_order = arr.map do |x|\n Clear::SQL::Query::OrderBy::Record.new(x.op, (x.dir == (:asc) ? :desc : :asc), nil)\n end\n clear_order_bys.order_by(new_order)\n (limit(1)).fetch do |hash|\n return Clear::Model::Factory.build(T, hash, persisted: true, cache: @cache, fetch_columns: fetch_columns)\n end\n nil\nensure\n clear_order_bys.order_by(order_bys)\nend\n"}},{"html_id":"last!(fetch_columns=false):T-instance-method","name":"last!","doc":"Get the last row from the collection query.\nif not found, throw an error","summary":"Get the last row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T","args_html":"(fetch_columns = false) : T","location":{"filename":"src/clear/model/collection.cr","line_number":690,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L690"},"def":{"name":"last!","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T","visibility":"Public","body":"(last(fetch_columns)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"map(fetch_columns=false,&block:T->X):Array(X)forallX-instance-method","name":"map","doc":"Build the SQL, send the query then build and array by applying the\nblock transformation over it.","summary":"Build the SQL, send the query then build and array by applying the block transformation over it.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, &block : T -> X) : Array(X) forall X","args_html":"(fetch_columns = false, &block : T -> X) : Array(X) forall X","location":{"filename":"src/clear/model/collection.cr","line_number":347,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L347"},"def":{"name":"map","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> X)"},"return_type":"Array(X)","visibility":"Public","body":"o = [] of X\neach(fetch_columns) do |mdl|\n o << (block.call(mdl))\nend\no\n"}},{"html_id":"tags-instance-method","name":"tags","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":292,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L292"},"def":{"name":"tags","visibility":"Public","body":"@tags"}},{"html_id":"to_a(fetch_columns=false):Array(T)-instance-method","name":"to_a","doc":"Create an array from the query.","summary":"Create an array from the query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : Array(T)","args_html":"(fetch_columns = false) : Array(T)","location":{"filename":"src/clear/model/collection.cr","line_number":528,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L528"},"def":{"name":"to_a","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"Array(T)","visibility":"Public","body":"cr = @cached_result\nif cr\n return cr\nend\no = [] of T\neach(fetch_columns: fetch_columns) do |m|\n o << m\nend\no\n"}},{"html_id":"unlink(item:T)-instance-method","name":"unlink","doc":"Unlink the model currently referenced through a relation `has_many through`\n\nIf the current colleciton doesn't come from a `has_many through` relation,\nthis method will throw `Clear::SQL::OperationNotPermittedError`\n\nReturns `true` if unlinking is successful (e.g. one or more rows have been updated), or `false` otherwise","summary":"Unlink the model currently referenced through a relation has_many through
A column of a Model Provide some methods like: - Informations persistance (value before, value changed?) - Raise error if we try to access the value of a field which is not gathered through the query system (uninitialized column).
","constructors":[{"html_id":"new(name:String,value:T|UnknownClass=UNKNOWN,has_db_default:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"value","default_value":"UNKNOWN","external_name":"value","restriction":"T | UnknownClass"},{"name":"has_db_default","default_value":"false","external_name":"has_db_default","restriction":"::Bool"}],"args_string":"(name : String, value : T | UnknownClass = UNKNOWN, has_db_default : Bool = false)","args_html":"(name : String, value : T | UnknownClass = UNKNOWN, has_db_default : Bool = false)","location":{"filename":"src/clear/model/column.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L24"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"value","default_value":"UNKNOWN","external_name":"value","restriction":"T | UnknownClass"},{"name":"has_db_default","default_value":"false","external_name":"has_db_default","restriction":"::Bool"}],"visibility":"Public","body":"_ = Column(T, C).allocate\n_.initialize(name, value, has_db_default)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"changed?:Bool-instance-method","name":"changed?","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L21"},"def":{"name":"changed?","return_type":"Bool","visibility":"Public","body":"@changed"}},{"html_id":"clear-instance-method","name":"clear","doc":"Completely clear the column, remove both `value` and `old_value` and turning the column in a non-defined state.","summary":"Completely clear the column, remove both #value
and #old_value
and turning the column in a non-defined state.
Reset #changed?
flag to false
.
Check whether the column is defined or not.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":128,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L128"},"def":{"name":"defined?","visibility":"Public","body":"UNKNOWN != @value"}},{"html_id":"dirty!-instance-method","name":"dirty!","doc":"Reset `changed?` flag to `true`. See `Column(T)#clear_change_flag` for the counter part.","summary":"Reset #changed?
flag to true
.
Inspect this column.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":114,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L114"},"def":{"name":"inspect","visibility":"Public","body":"if defined?\n @value.inspect + (changed? ? \"*\" : \"\")\nelse\n \"#undef\"\nend"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L20"},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"nilable?-instance-method","name":"nilable?","doc":"Return `true` if the value is an union of a Type with Nilable, `false` otherwise.","summary":"Return true
if the value is an union of a Type with Nilable, false
otherwise.
Reset the current field.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"args_string":"(x : T | Nil)","args_html":"(x : T | Nil)","location":{"filename":"src/clear/model/column.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L79"},"def":{"name":"reset","args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"visibility":"Public","body":"{% if T.nilable? %}\n @value = x.as(T)\n {% else %}\n raise null_column_mapping_error(@name, T) if x.nil?\n @value = x.not_nil!\n {% end %}\n@changed = false\n@old_value = @value\n"}},{"html_id":"reset_convert(x)-instance-method","name":"reset_convert","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/column.cr","line_number":55,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L55"},"def":{"name":"reset_convert","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"reset(C.to_column(x))"}},{"html_id":"revert-instance-method","name":"revert","doc":"If the column is dirty (e.g the value has been changed), return to the previous state.","summary":"If the column is dirty (e.g the value has been changed), return to the previous state.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":46,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L46"},"def":{"name":"revert","visibility":"Public","body":"if (@value != @old_value) && (@old_value != UNKNOWN)\n @changed = true\n @value = @old_value\nend\n@value\n"}},{"html_id":"set(x:T|Nil)-instance-method","name":"set","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"args_string":"(x : T | Nil)","args_html":"(x : T | Nil)","location":{"filename":"src/clear/model/column.cr","line_number":63,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L63"},"def":{"name":"set","args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"visibility":"Public","body":"old_value = @value\n{% if T.nilable? %}\n @value = x.as(T)\n {% else %}\n raise null_column_mapping_error(@name, T) if x.nil?\n @value = x.not_nil!\n {% end %}\n@old_value = old_value\n@changed = true\n"}},{"html_id":"set_convert(x)-instance-method","name":"set_convert","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/column.cr","line_number":59,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L59"},"def":{"name":"set_convert","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"set(C.to_column(x))"}},{"html_id":"to_sql_value(default=nil):Clear::SQL::Any-instance-method","name":"to_sql_value","doc":"Return the database converted value using the converter","summary":"Return the database converted value using the converter
","abstract":false,"args":[{"name":"default","default_value":"nil","external_name":"default","restriction":""}],"args_string":"(default = nil) : Clear::SQL::Any","args_html":"(default = nil) : Clear::SQL::Any","location":{"filename":"src/clear/model/column.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L36"},"def":{"name":"to_sql_value","args":[{"name":"default","default_value":"nil","external_name":"default","restriction":""}],"return_type":"Clear::SQL::Any","visibility":"Public","body":"C.to_db(value(default))"}},{"html_id":"value(default:X):T|XforallX-instance-method","name":"value","doc":"Returns the current value of this column or `default` if the value is undefined.","summary":"Returns the current value of this column or default
if the value is undefined.
Returns the current value of this column.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L30"},"def":{"name":"value","return_type":"T","visibility":"Public","body":"if defined?\nelse\n raise(illegal_setter_access_to_undefined_column(@name))\nend\n@value.as(T)\n"}},{"html_id":"value=(x:T)-instance-method","name":"value=","doc":"Set the value of the column to the value `x`. If `x` is not equal to the old value, then the column `changed?`\nflag is set to `true`.","summary":"Set the value of the column to the value x
.
Convert from and to BigDecimal
","class_methods":[{"html_id":"to_column(x):BigDecimal|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : BigDecimal | Nil","args_html":"(x) : BigDecimal | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L43"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"BigDecimal | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n BigDecimal.new(x)\nelse\n BigDecimal.new(x.to_s)\nend"}},{"html_id":"to_db(x:BigDecimal|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"BigDecimal | ::Nil"}],"args_string":"(x : BigDecimal | Nil)","args_html":"(x : BigDecimal | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L43"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"BigDecimal | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/BigFloatConverter","path":"Clear/Model/Converter/BigFloatConverter.html","kind":"class","full_name":"Clear::Model::Converter::BigFloatConverter","name":"BigFloatConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L42"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to BigFloat","summary":"Convert from and to BigFloat
","class_methods":[{"html_id":"to_column(x):BigFloat|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : BigFloat | Nil","args_html":"(x) : BigFloat | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L42"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"BigFloat | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n BigFloat.new(x)\nelse\n BigFloat.new(x.to_s)\nend"}},{"html_id":"to_db(x:BigFloat|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"BigFloat | ::Nil"}],"args_string":"(x : BigFloat | Nil)","args_html":"(x : BigFloat | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L42"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"BigFloat | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/BigIntConverter","path":"Clear/Model/Converter/BigIntConverter.html","kind":"class","full_name":"Clear::Model::Converter::BigIntConverter","name":"BigIntConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L41"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to BigInt","summary":"Convert from and to BigInt
","class_methods":[{"html_id":"to_column(x):BigInt|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : BigInt | Nil","args_html":"(x) : BigInt | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L41"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"BigInt | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n BigInt.new(x)\nelse\n BigInt.new(x.to_s)\nend"}},{"html_id":"to_db(x:BigInt|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"BigInt | ::Nil"}],"args_string":"(x : BigInt | Nil)","args_html":"(x : BigInt | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L41"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"BigInt | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/BoolConverter","path":"Clear/Model/Converter/BoolConverter.html","kind":"module","full_name":"Clear::Model::Converter::BoolConverter","name":"BoolConverter","abstract":false,"locations":[{"filename":"src/clear/model/converters/bool_converter.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/bool_converter.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert the column to a boolean\nIf value is not boolean (e.g. string or number), rules of `falsey`\nvalue is used:\n\nfalsey's values are:\n`false`, `nil`, `0`, `\"0\"`, `\"\"` (empty string), `\"false\"`, `\"f\"`\n\nAnything else is considered `true`","summary":"Convert the column to a boolean If value is not boolean (e.g.
","class_methods":[{"html_id":"to_column(x):Bool|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Bool | Nil","args_html":"(x) : Bool | Nil","location":{"filename":"src/clear/model/converters/bool_converter.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/bool_converter.cr#L12"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Bool | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Bool\n x\nwhen Number\n x != 0\nwhen String\n x = x.downcase\n (((x != \"f\") && (x != \"false\")) && (x != \"\")) && (x != \"0\")\nelse\n true\nend"}},{"html_id":"to_db(x:Bool|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Bool | ::Nil"}],"args_string":"(x : Bool | Nil)","args_html":"(x : Bool | Nil)","location":{"filename":"src/clear/model/converters/bool_converter.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/bool_converter.cr#L28"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Bool | ::Nil"}],"visibility":"Public","body":"x.nil? ? nil : (x ? \"t\" : \"f\")"}}]},{"html_id":"clear/Clear/Model/Converter/Float32Converter","path":"Clear/Model/Converter/Float32Converter.html","kind":"class","full_name":"Clear::Model::Converter::Float32Converter","name":"Float32Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L38"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Float32","summary":"Convert from and to Float32
","class_methods":[{"html_id":"to_column(x):Float32|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Float32 | Nil","args_html":"(x) : Float32 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L38"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Float32 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Float32.new(x)\nelse\n Float32.new(x.to_s)\nend"}},{"html_id":"to_db(x:Float32|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Float32 | ::Nil"}],"args_string":"(x : Float32 | Nil)","args_html":"(x : Float32 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L38"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Float32 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Float64Converter","path":"Clear/Model/Converter/Float64Converter.html","kind":"class","full_name":"Clear::Model::Converter::Float64Converter","name":"Float64Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L39"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Float64","summary":"Convert from and to Float64
","class_methods":[{"html_id":"to_column(x):Float64|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Float64 | Nil","args_html":"(x) : Float64 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L39"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Float64 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Float64.new(x)\nelse\n Float64.new(x.to_s)\nend"}},{"html_id":"to_db(x:Float64|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Float64 | ::Nil"}],"args_string":"(x : Float64 | Nil)","args_html":"(x : Float64 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L39"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Float64 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int16Converter","path":"Clear/Model/Converter/Int16Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int16Converter","name":"Int16Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L29"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int16","summary":"Convert from and to Int16
","class_methods":[{"html_id":"to_column(x):Int16|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int16 | Nil","args_html":"(x) : Int16 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L29"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int16 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int16.new(x)\nelse\n Int16.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int16|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int16 | ::Nil"}],"args_string":"(x : Int16 | Nil)","args_html":"(x : Int16 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L29"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int16 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int32Converter","path":"Clear/Model/Converter/Int32Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int32Converter","name":"Int32Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L30"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int32","summary":"Convert from and to Int32
","class_methods":[{"html_id":"to_column(x):Int32|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int32 | Nil","args_html":"(x) : Int32 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L30"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int32 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int32.new(x)\nelse\n Int32.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int32|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32 | ::Nil"}],"args_string":"(x : Int32 | Nil)","args_html":"(x : Int32 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L30"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int32 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int64Converter","path":"Clear/Model/Converter/Int64Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int64Converter","name":"Int64Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L31"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int64","summary":"Convert from and to Int64
","class_methods":[{"html_id":"to_column(x):Int64|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int64 | Nil","args_html":"(x) : Int64 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L31"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int64 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int64.new(x)\nelse\n Int64.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int64|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int64 | ::Nil"}],"args_string":"(x : Int64 | Nil)","args_html":"(x : Int64 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L31"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int8Converter","path":"Clear/Model/Converter/Int8Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int8Converter","name":"Int8Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L28"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int8","summary":"Convert from and to Int8
","class_methods":[{"html_id":"to_column(x):Int8|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int8 | Nil","args_html":"(x) : Int8 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L28"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int8 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int8.new(x)\nelse\n Int8.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int8|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int8 | ::Nil"}],"args_string":"(x : Int8 | Nil)","args_html":"(x : Int8 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L28"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int8 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/JSON","path":"Clear/Model/Converter/JSON.html","kind":"module","full_name":"Clear::Model::Converter::JSON","name":"JSON","abstract":false,"locations":[{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"types":[{"html_id":"clear/Clear/Model/Converter/JSON/AnyConverter","path":"Clear/Model/Converter/JSON/AnyConverter.html","kind":"module","full_name":"Clear::Model::Converter::JSON::AnyConverter","name":"AnyConverter","abstract":false,"locations":[{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter/JSON","kind":"module","full_name":"Clear::Model::Converter::JSON","name":"JSON"},"class_methods":[{"html_id":"to_column(x):::JSON::Any|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : ::JSON::Any | Nil","args_html":"(x) : ::JSON::Any | Nil","location":{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L4"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"::JSON::Any | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen ::JSON::Any\n x\nwhen ::JSON::PullParser\n ::JSON::Any.new(x)\nelse\n ::JSON.parse(x.to_s)\nend"}},{"html_id":"to_db(x:::JSON::Any|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"::JSON::Any | ::Nil"}],"args_string":"(x : ::JSON::Any | Nil)","args_html":"(x : ::JSON::Any | Nil)","location":{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L17"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"::JSON::Any | ::Nil"}],"visibility":"Public","body":"x.to_json"}}]}]},{"html_id":"clear/Clear/Model/Converter/StringConverter","path":"Clear/Model/Converter/StringConverter.html","kind":"class","full_name":"Clear::Model::Converter::StringConverter","name":"StringConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/string_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/string_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"class_methods":[{"html_id":"to_column(x):String|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : String | Nil","args_html":"(x) : String | Nil","location":{"filename":"src/clear/model/converters/string_converter.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/string_converter.cr#L4"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"String | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Slice(UInt8)\n String.new(x)\nelse\n x.to_s\nend"}},{"html_id":"to_db(x:String|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | ::Nil"}],"args_string":"(x : String | Nil)","args_html":"(x : String | Nil)","location":{"filename":"src/clear/model/converters/string_converter.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/string_converter.cr#L15"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"String | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/TimeConverter","path":"Clear/Model/Converter/TimeConverter.html","kind":"class","full_name":"Clear::Model::Converter::TimeConverter","name":"TimeConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/time_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/time_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"class_methods":[{"html_id":"to_column(x):Time|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Time | Nil","args_html":"(x) : Time | Nil","location":{"filename":"src/clear/model/converters/time_converter.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/time_converter.cr#L4"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Time | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Time\n x.to_local\nelse\n time = x.to_s\n case time\n when /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]+/\n Time.parse_local(x.to_s, \"%F %X.%L\")\n else\n Time::Format::RFC_3339.parse(time)\n end\nend"}},{"html_id":"to_db(x:Time|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Time | ::Nil"}],"args_string":"(x : Time | Nil)","args_html":"(x : Time | Nil)","location":{"filename":"src/clear/model/converters/time_converter.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/time_converter.cr#L21"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Time | ::Nil"}],"visibility":"Public","body":"case x\nwhen Nil\n nil\nelse\n x.to_utc.to_s(Clear::Expression::DATABASE_DATE_TIME_FORMAT)\nend"}}]},{"html_id":"clear/Clear/Model/Converter/UInt16Converter","path":"Clear/Model/Converter/UInt16Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt16Converter","name":"UInt16Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L34"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt16","summary":"Convert from and to UInt16
","class_methods":[{"html_id":"to_column(x):UInt16|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt16 | Nil","args_html":"(x) : UInt16 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L34"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt16 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt16.new(x)\nelse\n UInt16.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt16|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16 | ::Nil"}],"args_string":"(x : UInt16 | Nil)","args_html":"(x : UInt16 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L34"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt16 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UInt32Converter","path":"Clear/Model/Converter/UInt32Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt32Converter","name":"UInt32Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L35"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt32","summary":"Convert from and to UInt32
","class_methods":[{"html_id":"to_column(x):UInt32|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt32 | Nil","args_html":"(x) : UInt32 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L35"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt32 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt32.new(x)\nelse\n UInt32.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt32|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt32 | ::Nil"}],"args_string":"(x : UInt32 | Nil)","args_html":"(x : UInt32 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L35"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt32 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UInt64Converter","path":"Clear/Model/Converter/UInt64Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt64Converter","name":"UInt64Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L36"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt64","summary":"Convert from and to UInt64
","class_methods":[{"html_id":"to_column(x):UInt64|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt64 | Nil","args_html":"(x) : UInt64 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L36"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt64 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt64.new(x)\nelse\n UInt64.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt64|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt64 | ::Nil"}],"args_string":"(x : UInt64 | Nil)","args_html":"(x : UInt64 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L36"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt64 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UInt8Converter","path":"Clear/Model/Converter/UInt8Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt8Converter","name":"UInt8Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L33"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt8","summary":"Convert from and to UInt8
","class_methods":[{"html_id":"to_column(x):UInt8|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt8 | Nil","args_html":"(x) : UInt8 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L33"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt8 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt8.new(x)\nelse\n UInt8.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt8|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt8 | ::Nil"}],"args_string":"(x : UInt8 | Nil)","args_html":"(x : UInt8 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L33"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt8 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UUIDConverter","path":"Clear/Model/Converter/UUIDConverter.html","kind":"class","full_name":"Clear::Model::Converter::UUIDConverter","name":"UUIDConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from UUID column to Crystal's UUID","summary":"Convert from UUID column to Crystal's UUID
","class_methods":[{"html_id":"to_column(x):UUID|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UUID | Nil","args_html":"(x) : UUID | Nil","location":{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L9"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UUID | ::Nil","visibility":"Public","body":"case x\nwhen String\n UUID.new(x)\nwhen Slice(UInt8)\n UUID.new(x)\nwhen UUID\n x\nwhen Nil\n nil\nelse\n raise(Clear::ErrorMessages.converter_error(x.class.name, \"UUID\"))\nend"}},{"html_id":"to_db(x:UUID|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UUID | ::Nil"}],"args_string":"(x : UUID | Nil)","args_html":"(x : UUID | Nil)","location":{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L24"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UUID | ::Nil"}],"visibility":"Public","body":"if x.nil?\n nil\nelse\n x.to_s\nend"}}]}]},{"html_id":"clear/Clear/Model/Error","path":"Clear/Model/Error.html","kind":"class","full_name":"Clear::Model::Error","name":"Error","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/errors.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"clear/Clear/Model/InvalidError","kind":"class","full_name":"Clear::Model::InvalidError","name":"InvalidError"},{"html_id":"clear/Clear/Model/ReadOnlyError","kind":"class","full_name":"Clear::Model::ReadOnlyError","name":"ReadOnlyError"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}},{"html_id":"clear/Clear/Model/EventManager","path":"Clear/Model/EventManager.html","kind":"class","full_name":"Clear::Model::EventManager","name":"EventManager","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/event_manager.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"EVENT_CALLBACKS","name":"EVENT_CALLBACKS","value":"{} of EventKey => Array(HookFunction)"},{"id":"INHERITANCE_MAP","name":"INHERITANCE_MAP","value":"{} of String => String"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"Global storage for model lifecycle event management\n\nThis class acts as a storage and can trigger events\nThis class a singleton.","summary":"Global storage for model lifecycle event management
","class_methods":[{"html_id":"add_inheritance(parent,child)-class-method","name":"add_inheritance","doc":"Map the inheritance between models. Events which belongs to parent model are triggered when child model lifecycle\nactions occurs","summary":"Map the inheritance between models.
","abstract":false,"args":[{"name":"parent","external_name":"parent","restriction":""},{"name":"child","external_name":"child","restriction":""}],"args_string":"(parent, child)","args_html":"(parent, child)","location":{"filename":"src/clear/model/event_manager.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L43"},"def":{"name":"add_inheritance","args":[{"name":"parent","external_name":"parent","restriction":""},{"name":"child","external_name":"child","restriction":""}],"visibility":"Public","body":"INHERITANCE_MAP[child.to_s] = parent.to_s"}},{"html_id":"attach(klazz,direction:Symbol,event:Symbol,block:HookFunction)-class-method","name":"attach","doc":"Add an event for a specific class, to a specific direction (after or before), a specific event Symbol (validate, save, commit...)","summary":"Add an event for a specific class, to a specific direction (after or before), a specific event Symbol (validate, save, commit...)
","abstract":false,"args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"block","external_name":"block","restriction":"HookFunction"}],"args_string":"(klazz, direction : Symbol, event : Symbol, block : HookFunction)","args_html":"(klazz, direction : Symbol, event : Symbol, block : HookFunction)","location":{"filename":"src/clear/model/event_manager.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L48"},"def":{"name":"attach","args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"block","external_name":"block","restriction":"HookFunction"}],"visibility":"Public","body":"tuple = {klazz.to_s, direction, event}\narr = EVENT_CALLBACKS.fetch(tuple) do\n [] of HookFunction\nend\narr.push(block)\nEVENT_CALLBACKS[tuple] = arr\n"}},{"html_id":"trigger(klazz,direction:Symbol,event:Symbol,mdl:Clear::Model)-class-method","name":"trigger","doc":"Trigger events callback for a specific model.\nDirection can be `:before` and `:after`\nIn case of `:before` direction, the events are called in reverse order:\n\n```\nbefore:\n- Last defined event\n- First defined event\naction\nafter:\n- First defined events\n- Last defined events\n```","summary":"Trigger events callback for a specific model.
","abstract":false,"args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"mdl","external_name":"mdl","restriction":"Clear::Model"}],"args_string":"(klazz, direction : Symbol, event : Symbol, mdl : Clear::Model)","args_html":"(klazz, direction : Symbol, event : Symbol, mdl : Clear::Model)","location":{"filename":"src/clear/model/event_manager.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L25"},"def":{"name":"trigger","args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"mdl","external_name":"mdl","restriction":"Clear::Model"}],"visibility":"Public","body":"arr = EVENT_CALLBACKS.fetch({klazz.to_s, direction, event}) do\n [] of HookFunction\nend\nparent = INHERITANCE_MAP[klazz.to_s]?\nif direction == (:after)\n arr = arr.reverse\n arr.each(&.call(mdl))\n if parent.nil?\n else\n trigger(parent, direction, event, mdl)\n end\nelse\n if parent.nil?\n else\n trigger(parent, direction, event, mdl)\n end\n arr.each(&.call(mdl))\nend\n"}}],"types":[{"html_id":"clear/Clear/Model/EventManager/EventKey","path":"Clear/Model/EventManager/EventKey.html","kind":"alias","full_name":"Clear::Model::EventManager::EventKey","name":"EventKey","abstract":false,"locations":[{"filename":"src/clear/model/event_manager.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Tuple(String, Symbol, Symbol)","aliased_html":"{String, Symbol, Symbol}","const":false,"namespace":{"html_id":"clear/Clear/Model/EventManager","kind":"class","full_name":"Clear::Model::EventManager","name":"EventManager"}},{"html_id":"clear/Clear/Model/EventManager/HookFunction","path":"Clear/Model/EventManager/HookFunction.html","kind":"alias","full_name":"Clear::Model::EventManager::HookFunction","name":"HookFunction","abstract":false,"locations":[{"filename":"src/clear/model/event_manager.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Proc(Clear::Model, Nil)","aliased_html":"Clear::Model -> Nil","const":false,"namespace":{"html_id":"clear/Clear/Model/EventManager","kind":"class","full_name":"Clear::Model::EventManager","name":"EventManager"}}]},{"html_id":"clear/Clear/Model/Factory","path":"Clear/Model/Factory.html","kind":"module","full_name":"Clear::Model::Factory","name":"Factory","abstract":false,"locations":[{"filename":"src/clear/model/factories/base.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/base.cr#L1"},{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L3"},{"filename":"src/clear/model/factories/simple_factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/simple_factory.cr#L3"},{"filename":"src/clear/model/factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"FACTORIES","name":"FACTORIES","value":"{\"Clear::Reflection::Column\" => ::Clear::Model::Factory::SimpleFactory(Clear::Reflection::Column).new, \"Clear::Reflection::Table\" => ::Clear::Model::Factory::SimpleFactory(Clear::Reflection::Table).new} of String => Clear::Model::Factory::Base"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"class_methods":[{"html_id":"build(type:String,h:Hash,cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false):Clear::Model-class-method","name":"build","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(type : String, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : Clear::Model","args_html":"(type : String, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : Clear::Model","location":{"filename":"src/clear/model/factory.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L10"},"def":{"name":"build","args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"Clear::Model","visibility":"Public","body":"factory = FACTORIES[type].as(Base)\nfactory.build(h, cache, persisted, fetch_columns)\n"}},{"html_id":"build(type:T.class,h:Hash,cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false):TforallT-class-method","name":"build","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"T.class"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(type : T.class, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : T forall T","args_html":"(type : T.class, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : T forall T","location":{"filename":"src/clear/model/factory.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L22"},"def":{"name":"build","args":[{"name":"type","external_name":"type","restriction":"T.class"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T","visibility":"Public","body":"(build(T.name, h, cache, persisted, fetch_columns)).as(T)"}}],"macros":[{"html_id":"add(type,factory)-macro","name":"add","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""},{"name":"factory","external_name":"factory","restriction":""}],"args_string":"(type, factory)","args_html":"(type, factory)","location":{"filename":"src/clear/model/factory.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L6"},"def":{"name":"add","args":[{"name":"type","external_name":"type","restriction":""},{"name":"factory","external_name":"factory","restriction":""}],"visibility":"Public","body":" \n{% Clear::Model::Factory::FACTORIES[type] = factory %}\n\n \n"}}],"types":[{"html_id":"clear/Clear/Model/Factory/Base","path":"Clear/Model/Factory/Base.html","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base","abstract":false,"locations":[{"filename":"src/clear/model/factories/base.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/base.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model/Factory/PolymorphicFactory","kind":"class","full_name":"Clear::Model::Factory::PolymorphicFactory(T)","name":"PolymorphicFactory"},{"html_id":"clear/Clear/Model/Factory/SimpleFactory","kind":"class","full_name":"Clear::Model::Factory::SimpleFactory(T)","name":"SimpleFactory"}],"namespace":{"html_id":"clear/Clear/Model/Factory","kind":"module","full_name":"Clear::Model::Factory","name":"Factory"},"instance_methods":[{"html_id":"build(h:Hash(String,Clear::SQL::Any),cache:Clear::Model::QueryCache|Nil=nil,persisted:Bool=false,fetch_columns:Bool=false):Clear::Model-instance-method","name":"build","abstract":true,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"args_string":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","args_html":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","location":{"filename":"src/clear/model/factories/base.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/base.cr#L3"},"def":{"name":"build","args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"return_type":"Clear::Model","visibility":"Public","body":""}}]},{"html_id":"clear/Clear/Model/Factory/PolymorphicFactory","path":"Clear/Model/Factory/PolymorphicFactory.html","kind":"class","full_name":"Clear::Model::Factory::PolymorphicFactory(T)","name":"PolymorphicFactory","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"}],"namespace":{"html_id":"clear/Clear/Model/Factory","kind":"module","full_name":"Clear::Model::Factory","name":"Factory"},"constructors":[{"html_id":"new(type_field:String,self_class:String)-class-method","name":"new","abstract":false,"args":[{"name":"type_field","external_name":"type_field","restriction":"::String"},{"name":"self_class","external_name":"self_class","restriction":"::String"}],"args_string":"(type_field : String, self_class : String)","args_html":"(type_field : String, self_class : String)","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L9"},"def":{"name":"new","args":[{"name":"type_field","external_name":"type_field","restriction":"::String"},{"name":"self_class","external_name":"self_class","restriction":"::String"}],"visibility":"Public","body":"_ = PolymorphicFactory(T).allocate\n_.initialize(type_field, self_class)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build(h:Hash(String,Clear::SQL::Any),cache:Clear::Model::QueryCache|Nil=nil,persisted:Bool=false,fetch_columns:Bool=false):Clear::Model-instance-method","name":"build","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"args_string":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","args_html":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L12"},"def":{"name":"build","args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"return_type":"Clear::Model","visibility":"Public","body":"v = h[@type_field]\ncase v\nwhen String\n if v == T.name\n {% if T.abstract? %}\n raise \"Cannot instantiate #{@type_field} because it is abstract class\"\n {% else %}\n T.new(v, h, cache, persisted, fetch_columns).as(Clear::Model)\n {% end %}\n else\n (Clear::Model::Factory.build(v, h, cache, persisted, fetch_columns)).as(Clear::Model)\n end\nwhen Nil\n raise(Clear::ErrorMessages.polymorphic_nil(@type_field))\nelse\n raise(Clear::ErrorMessages.polymorphic_nil(@type_field))\nend\n"}},{"html_id":"self_class:String-instance-method","name":"self_class","abstract":false,"location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L7"},"def":{"name":"self_class","return_type":"String","visibility":"Public","body":"@self_class"}},{"html_id":"self_class=(self_class:String)-instance-method","name":"self_class=","abstract":false,"args":[{"name":"self_class","external_name":"self_class","restriction":"String"}],"args_string":"(self_class : String)","args_html":"(self_class : String)","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L7"},"def":{"name":"self_class=","args":[{"name":"self_class","external_name":"self_class","restriction":"String"}],"visibility":"Public","body":"@self_class = self_class"}},{"html_id":"type_field:String-instance-method","name":"type_field","abstract":false,"location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L6"},"def":{"name":"type_field","return_type":"String","visibility":"Public","body":"@type_field"}},{"html_id":"type_field=(type_field:String)-instance-method","name":"type_field=","abstract":false,"args":[{"name":"type_field","external_name":"type_field","restriction":"String"}],"args_string":"(type_field : String)","args_html":"(type_field : String)","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L6"},"def":{"name":"type_field=","args":[{"name":"type_field","external_name":"type_field","restriction":"String"}],"visibility":"Public","body":"@type_field = type_field"}}]},{"html_id":"clear/Clear/Model/Factory/SimpleFactory","path":"Clear/Model/Factory/SimpleFactory.html","kind":"class","full_name":"Clear::Model::Factory::SimpleFactory(T)","name":"SimpleFactory","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/factories/simple_factory.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/simple_factory.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"}],"namespace":{"html_id":"clear/Clear/Model/Factory","kind":"module","full_name":"Clear::Model::Factory","name":"Factory"},"instance_methods":[{"html_id":"build(h:Hash(String,Clear::SQL::Any),cache:Clear::Model::QueryCache|Nil=nil,persisted:Bool=false,fetch_columns:Bool=false):Clear::Model-instance-method","name":"build","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"args_string":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","args_html":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","location":{"filename":"src/clear/model/factories/simple_factory.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/simple_factory.cr#L7"},"def":{"name":"build","args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"return_type":"Clear::Model","visibility":"Public","body":"(T.new(h, cache, persisted, fetch_columns)).as(Clear::Model)"}}]}]},{"html_id":"clear/Clear/Model/FullTextSearchable","path":"Clear/Model/FullTextSearchable.html","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable","abstract":false,"locations":[{"filename":"src/clear/extensions/full_text_searchable/model.cr","line_number":87,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/model.cr#L87"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"Full text search plugin offers full integration with `tsvector` capabilities of\nPostgresql.\n\nIt allows you to query models through the text content of one or multiple fields.\n\n### The blog example\n\nLet's assume we have a blog and want to implement full text search over title and content:\n\n```\ncreate_table \"posts\" do |t|\n t.column :title, :string, null: false\n t.column :content, :string, null: false\n\n t.full_text_searchable on: [{\"title\", 'A'}, {\"content\", 'C'}]\nend\n```\n\nThis migration will create a 3rd column named `full_text_vector` of type `tsvector`,\na gin index, a trigger and a function to update automatically this column.\n\nOver the `on` keyword, `'{\"title\", 'A'}'` means it allows search of the content of \"title\", with level of priority (weight) \"A\", which tells postgres than title content is more meaningful than the article content itself.\n\nNow, let's build some models:\n\n```\n\n model Post\n include Clear::Model\n #...\n\n full_text_searchable\n end\n\n Post.create!({title: \"About poney\", content: \"Poney are cool\"})\n Post.create!({title: \"About dog and cat\", content: \"Cat and dog are cool. But not as much as poney\"})\n Post.create!({title: \"You won't believe: She raises her poney like as star!\", content: \"She's cool because poney are cool\"})\n```\n\nSearch is now easily done\n\n```\nPost.query.search(\"poney\") # Return all the articles !\n```\n\nObviously, search call can be chained:\n\n```\nuser = User.find! { email == \"some_email@example.com\" }\nPost.query.from_user(user).search(\"orm\")\n```\n\n### Additional parameters\n\n#### `catalog`\n\nSelect the catalog to use to build the tsquery. By default, `pg_catalog.english` is used.\n\n```\n# in your migration:\nt.full_text_searchable on: [{\"title\", 'A'}, {\"content\", 'C'}], catalog: \"pg_catalog.french\"\n\n# in your model\nfull_text_searchable catalog: \"pg_catalog.french\"\n```\n\nNote: For now, Clear doesn't offers dynamic selection of catalog (for let's say multi-lang service).\nIf your app need this feature, do not hesitate to open an issue.\n\n#### `trigger_name`, `function_name`\n\nIn migration, you can change the name generated for the trigger and the function, using theses two keys.\n\n#### `dest_field`\n\nThe field created in the database, which will contains your ts vector. Default is `full_text_vector`.\n\n```\n# in your migration\nt.full_text_searchable on: [{\"title\", 'A'}, {\"content\", 'C'}], dest_field: \"tsv\"\n\n# in your model\nfull_text_searchable \"tsv\"\n```","summary":"Full text search plugin offers full integration with tsvector
capabilities of Postgresql.
Parse client side text and generate string ready to be ingested by PG's to_tsquery
.
Set this model as searchable using tsvector
","abstract":false,"args":[{"name":"through","default_value":"\"full_text_vector\"","external_name":"through","restriction":""},{"name":"catalog","default_value":"\"pg_catalog.english\"","external_name":"catalog","restriction":""},{"name":"scope_name","default_value":"\"search\"","external_name":"scope_name","restriction":""}],"args_string":"(through = \"full_text_vector\", catalog = \"pg_catalog.english\", scope_name = \"search\")","args_html":"(through = "full_text_vector", catalog = "pg_catalog.english", scope_name = "search")","location":{"filename":"src/clear/extensions/full_text_searchable/model.cr","line_number":89,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/model.cr#L89"},"def":{"name":"full_text_searchable","args":[{"name":"through","default_value":"\"full_text_vector\"","external_name":"through","restriction":""},{"name":"catalog","default_value":"\"pg_catalog.english\"","external_name":"catalog","restriction":""},{"name":"scope_name","default_value":"\"search\"","external_name":"scope_name","restriction":""}],"visibility":"Public","body":" column( \n{{ through.id }}\n : Clear::TSVector, presence: false)\n\n scope \"\n{{ scope_name.id }}\n\" do |str|\n table = self.item_class.table\n where \n{\n op(\n var(table, \"\n{{ through.id }}\n\"),\n to_tsquery(\n{{ catalog }}\n, Clear::Model::FullTextSearchable.to_tsq(str)),\n \"@@\"\n )\n }\n \nend\n \n"}}]},{"html_id":"clear/Clear/Model/HasColumns","path":"Clear/Model/HasColumns.html","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_columns.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"This module declare all the methods and macro related to columns in `Clear::Model`","summary":"This module declare all the methods and macro related to columns in Clear::Model
Access to direct SQL attributes given by the request used to build the model.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Clear::SQL::Any","args_html":"(x) : Clear::SQL::Any","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L72"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"::Clear::SQL::Any","visibility":"Public","body":"attributes[x]"}},{"html_id":"[]?(x):Clear::SQL::Any-instance-method","name":"[]?","doc":"Access to direct SQL attributes given by the request and used to build the model\nor Nil if not found.\n\nAccess is read only and updating the model columns will not apply change to theses columns.\nYou must set `fetch_column: true` in your model to access the attributes.","summary":"Access to direct SQL attributes given by the request and used to build the model or Nil if not found.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Clear::SQL::Any","args_html":"(x) : Clear::SQL::Any","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":81,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L81"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"::Clear::SQL::Any","visibility":"Public","body":"attributes[x]?"}},{"html_id":"reset(h:Hash(String,_))-instance-method","name":"reset","doc":"See `reset(**t : **T)`","summary":"","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L35"},"def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":""}},{"html_id":"reset(h:Hash(Symbol,_))-instance-method","name":"reset","doc":"See `reset(**t : **T)`","summary":"","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L39"},"def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":""}},{"html_id":"reset(**t:**T)forallT-instance-method","name":"reset","doc":"Reset one or multiple columns; Reseting set the current value of the column\nto the given value, while the `changed?` flag remains false.\nIf you call save on a persisted model, the reset columns won't be\ncommited in the UPDATE query.","summary":"Reset one or multiple columns; Reseting set the current value of the column to the given value, while the changed?
flag remains false.
See #set(**t : **T)
See #set(**t : **T)
Set one or multiple columns to a specific value This two are equivalents:
","abstract":false,"location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L49"},"def":{"name":"set","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":""}},{"html_id":"to_h(full=false)-instance-method","name":"to_h","doc":"Returns the model columns as Hash.\nCalling `to_h` will returns only the defined columns, while settings the optional parameter `full` to `true`\n will return all the column and fill the undefined columns by `nil` values.\nExample:\n\n```\n# Assuming our model has a primary key, a first name and last name and two timestamp columns:\nmodel = Model.query.select(\"first_name, last_name\").first!\nmodel.to_h # => { \"first_name\" => \"Johnny\", \"last_name\" => \"Walker\" }\nmodel.to_h(full: true) # => {\"id\" => nil, \"first_name\" => \"Johnny\", \"last_name\" => \"Walker\", \"created_at\" => nil, \"updated_at\" => nil}\n```","summary":"Returns the model columns as Hash.
","abstract":false,"args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"args_string":"(full = false)","args_html":"(full = false)","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":110,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L110"},"def":{"name":"to_h","args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"visibility":"Public","body":"{} of String => ::Clear::SQL::Any"}},{"html_id":"update_h-instance-method","name":"update_h","doc":"Returns the current hash of the modified values:\n\n```\nmodel = Model.query.first!\nmodel.update_h # => {}\nmodel.first_name = \"hello\"\nmodel.update_h # => { \"first_name\" => \"hello\" }\nmodel.save!\nmodel.update_h # => {}\n```","summary":"Returns the current hash of the modified values:
","abstract":false,"location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L95"},"def":{"name":"update_h","visibility":"Public","body":"{} of String => ::Clear::SQL::Any"}}],"macros":[{"html_id":"column(name,primary=false,converter=nil,column_name=nil,presence=true,mass_assign=true)-macro","name":"column","doc":"Bind a column to the model.\n\nSimple example:\n\n```\nclass MyModel\n include Clear::Model\n\n column some_id : Int32, primary: true\n column nullable_column : String?\nend\n```\noptions:\n\n* `primary : Bool`: Let Clear ORM know which column is the primary key.\nCurrently compound primary key are not compatible with Clear ORM.\n\n* `converter : Class | Module`: Use this class to convert the data from the\nSQL. This class must possess the class methods\n`to_column(::Clear::SQL::Any) : T` and `to_db(T) : ::Clear::SQL::Any`\nwith `T` the type of the column.\n\n* `column_name : String`: If the name of the column in the model doesn't fit the name of the\n column in the SQL, you can use the parameter `column_name` to tell Clear about\n which db column is linked to current field.\n\n* `presence : Bool (default = true)`: Use this option to let know Clear that\n your column is not nullable but with default value generated by the database\n on insert (e.g. serial)\nDuring validation before saving, the presence will not be checked on this field\n and Clear will try to insert without the field value.\n\n* `mass_assign : Bool (default = true)`: Use this option to turn on/ off mass assignment\n when instantiating or updating a new model from json through `.from_json` methods from\n the `Clear::Model::JSONDeserialize` module.\n","summary":"Bind a column to the model.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"converter","default_value":"nil","external_name":"converter","restriction":""},{"name":"column_name","default_value":"nil","external_name":"column_name","restriction":""},{"name":"presence","default_value":"true","external_name":"presence","restriction":""},{"name":"mass_assign","default_value":"true","external_name":"mass_assign","restriction":""}],"args_string":"(name, primary = false, converter = nil, column_name = nil, presence = true, mass_assign = true)","args_html":"(name, primary = false, converter = nil, column_name = nil, presence = true, mass_assign = true)","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":150,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L150"},"def":{"name":"column","args":[{"name":"name","external_name":"name","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"converter","default_value":"nil","external_name":"converter","restriction":""},{"name":"column_name","default_value":"nil","external_name":"column_name","restriction":""},{"name":"presence","default_value":"true","external_name":"presence","restriction":""},{"name":"mass_assign","default_value":"true","external_name":"mass_assign","restriction":""}],"visibility":"Public","body":" \n{% _type = name.type %}\n\n \n{% unless converter\n if _type.is_a?(Path)\n if _type.resolve.stringify =~ (/\\(/)\n converter = _type.stringify\n else\n converter = _type.resolve.stringify\n end\n else\n if _type.is_a?(Generic)\n if _type.name.stringify == \"::Union\"\n converter = (_type.type_vars.map(&.resolve).map(&.stringify).sort.reject do |x|\n (x == \"Nil\") || (x == \"::Nil\")\n end.join(\"\")).id.stringify\n else\n converter = _type.resolve.stringify\n end\n else\n if _type.is_a?(Union)\n converter = (_type.types.map(&.resolve).map(&.stringify).sort.reject do |x|\n (x == \"Nil\") || (x == \"::Nil\")\n end.join(\"\")).id.stringify\n else\n raise(\"Unknown: #{_type}, #{_type.class}\")\n end\n end\n end\nend %}\n\n\n \n{% db_column_name = column_name == nil ? name.var : column_name.id\nCOLUMNS[\"#{db_column_name.id}\"] = {type: _type, primary: primary, converter: converter, db_column_name: \"#{db_column_name.id}\", crystal_variable_name: name.var, presence: presence, mass_assign: mass_assign}\n %}\n\n \n"}}]},{"html_id":"clear/Clear/Model/HasFactory","path":"Clear/Model/HasFactory.html","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_factory.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"macros":[{"html_id":"polymorphic(through=\"type\")-macro","name":"polymorphic","doc":"Define a polymorphic factory, if the model is tagged as polymorphic","summary":"Define a polymorphic factory, if the model is tagged as polymorphic
","abstract":false,"args":[{"name":"through","default_value":"\"type\"","external_name":"through","restriction":""}],"args_string":"(through = \"type\")","args_html":"(through = "type")","location":{"filename":"src/clear/model/modules/has_factory.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_factory.cr#L36"},"def":{"name":"polymorphic","args":[{"name":"through","default_value":"\"type\"","external_name":"through","restriction":""}],"visibility":"Public","body":" \n{% POLYMORPHISM_SETTINGS[:has_factory] = true %}\n\n\n column \n{{ through.id }}\n : String\n\n before(:validate) do |model|\n model = model.as(self)\n model.\n{{ through.id }}\n = model.class.name\n \nend\n\n \n# Subclasses are refined using a default scope\n\n \n# to filter by type.\n\n macro inherited\n class Collection < Clear::Model::CollectionBase(\n\\{\n{@type}}); \nend\n\n def self.query\n Collection.new.from(table).where \n{ \n{{ through.id }}\n == self.name }\n \nend\n \nend\n\n \n# Base class can be refined too, only if the baseclass is not abstract.\n\n \n{% if @type.abstract? %}{% else %}\n def self.query\n Collection.new.from(table).where { {{ through.id }} == self.name }\n end\n {% end %}\n\n\n def self.polymorphic?\n true\n \nend\n\n Clear::Model::Factory.add(\n \"\n{{ @type }}\n\",\n Clear::Model::Factory::PolymorphicFactory(\n{{ @type }}\n).new(\n{{ through.id.stringify }}\n, \"\n{{ @type }}\n\")\n )\n\n macro inherited\n Clear::Model::Factory.add(\n \"\n\\{\n{@type}}\",\n Clear::Model::Factory::SimpleFactory(\n\\{\n{@type}}).new\n )\n \nend\n \n"}}]},{"html_id":"clear/Clear/Model/HasHooks","path":"Clear/Model/HasHooks.html","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_hooks.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"instance_methods":[{"html_id":"trigger_after_events(event_name)-instance-method","name":"trigger_after_events","doc":"Triggers the events hooked after `event_name`","summary":"Triggers the events hooked after event_name
Triggers the events hooked before event_name
This performs theses operations:
","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":""}],"args_string":"(event_name, &)","args_html":"(event_name, &)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L15"},"def":{"name":"with_triggers","args":[{"name":"event_name","external_name":"event_name","restriction":""}],"yields":1,"block_arity":1,"visibility":"Public","body":"Clear::SQL.transaction do |cnx|\n trigger_before_events(event_name)\n yield(cnx)\n trigger_after_events(event_name)\nend\nself\n"}}],"macros":[{"html_id":"after(event_name,method_name)-macro","name":"after","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"args_string":"(event_name, method_name)","args_html":"(event_name, method_name)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L50"},"def":{"name":"after","args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"visibility":"Public","body":" after(\n{{ event_name }}\n) \n{ |mdl|\n mdl.as(\n{{ @type }}\n).\n{{ method_name.id }}\n\n }\n \n"}},{"html_id":"before(event_name,method_name)-macro","name":"before","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"args_string":"(event_name, method_name)","args_html":"(event_name, method_name)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L44"},"def":{"name":"before","args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"visibility":"Public","body":" before(\n{{ event_name }}\n) \n{ |mdl|\n mdl.as(\n{{ @type }}\n).\n{{ method_name.id }}\n\n }\n \n"}}],"types":[{"html_id":"clear/Clear/Model/HasHooks/ClassMethods","path":"Clear/Model/HasHooks/ClassMethods.html","kind":"module","full_name":"Clear::Model::HasHooks::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_hooks.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L34"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},"instance_methods":[{"html_id":"after(event_name:Symbol,&block:Clear::Model->Nil)-instance-method","name":"after","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"args_string":"(event_name : Symbol, &block : Clear::Model -> Nil)","args_html":"(event_name : Symbol, &block : Clear::Model -> Nil)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L39"},"def":{"name":"after","args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Model -> Nil)"},"visibility":"Public","body":"Clear::Model::EventManager.attach(self, :after, event_name, block)"}},{"html_id":"before(event_name:Symbol,&block:Clear::Model->Nil)-instance-method","name":"before","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"args_string":"(event_name : Symbol, &block : Clear::Model -> Nil)","args_html":"(event_name : Symbol, &block : Clear::Model -> Nil)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L35"},"def":{"name":"before","args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Model -> Nil)"},"visibility":"Public","body":"Clear::Model::EventManager.attach(self, :before, event_name, block)"}}]}]},{"html_id":"clear/Clear/Model/HasRelations","path":"Clear/Model/HasRelations.html","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_relations.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_relations.cr#L13"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"```\nclass Model\n include Clear::Model\n\n has_many posts : Post, foreign_key: Model.underscore_name + \"_id\", no_cache : false\n\n has_one passport : Passport\n has_many posts\nend\n```","summary":"
","macros":[{"html_id":"belongs_to(name,foreign_key=nil,no_cache=false,primary=false,foreign_key_type=Int64)-macro","name":"belongs_to","doc":"```\nclass Model\n include Clear::Model\n\n belongs_to user : User, foreign_key: \"the_user_id\"\nend\n```","summary":"
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"foreign_key_type","default_value":"Int64","external_name":"foreign_key_type","restriction":""}],"args_string":"(name, foreign_key = nil, no_cache = false, primary = false, foreign_key_type = Int64)","args_html":"(name, foreign_key = nil, no_cache = false, primary = false, foreign_key_type = Int64)","location":{"filename":"src/clear/model/modules/has_relations.cr","line_number":120,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_relations.cr#L120"},"def":{"name":"belongs_to","args":[{"name":"name","external_name":"name","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"foreign_key_type","default_value":"Int64","external_name":"foreign_key_type","restriction":""}],"visibility":"Public","body":" \n{% if foreign_key.is_a?(SymbolLiteral) || foreign_key.is_a?(StringLiteral)\n foreign_key = foreign_key.id\nend\nnilable = false\nif name.type.is_a?(Union)\n types = name.type.types.map do |x|\n \"#{x.id}\"\n end\n nilable = types.includes?(\"Nil\")\n type = name.type.types.first\nelse\n type = name.type\nend\nif nilable\n unless foreign_key_type.resolve.nilable?\n foreign_key_type = \"#{foreign_key_type.id}?\".id\n end\nend\nRELATIONS[name.var.id] = {relation_type: :belongs_to, type: type, foreign_key: foreign_key, nilable: nilable, primary: primary, no_cache: no_cache, foreign_key_type: foreign_key_type}\n %}\n\n \n"}},{"html_id":"has_many(name,through=nil,foreign_key=nil,own_key=nil,primary_key=nil,no_cache=false,polymorphic=false,foreign_key_type=nil)-macro","name":"has_many","doc":"Has Many and Has One are the relations where the model share its primary key into a foreign table. In our example above, we can assume than a User has many Post as author.\n\nBasically, for each `belongs_to` declaration, you must have a `has_many` or `has_one` declaration on the other model.\n\nWhile `has_many` relation returns a list of models, `has_one` returns only one model when called.\n\nExample:\n\n```\nclass User\n include Clear::Model\n\n has_many posts : Post, foreign_key: \"author_id\"\nend\n```","summary":"Has Many and Has One are the relations where the model share its primary key into a foreign table.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"through","default_value":"nil","external_name":"through","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"own_key","default_value":"nil","external_name":"own_key","restriction":""},{"name":"primary_key","default_value":"nil","external_name":"primary_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"polymorphic","default_value":"false","external_name":"polymorphic","restriction":""},{"name":"foreign_key_type","default_value":"nil","external_name":"foreign_key_type","restriction":""}],"args_string":"(name, through = nil, foreign_key = nil, own_key = nil, primary_key = nil, no_cache = false, polymorphic = false, foreign_key_type = nil)","args_html":"(name, through = nil, foreign_key = nil, own_key = nil, primary_key = nil, no_cache = false, polymorphic = false, foreign_key_type = nil)","location":{"filename":"src/clear/model/modules/has_relations.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_relations.cr#L72"},"def":{"name":"has_many","args":[{"name":"name","external_name":"name","restriction":""},{"name":"through","default_value":"nil","external_name":"through","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"own_key","default_value":"nil","external_name":"own_key","restriction":""},{"name":"primary_key","default_value":"nil","external_name":"primary_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"polymorphic","default_value":"false","external_name":"polymorphic","restriction":""},{"name":"foreign_key_type","default_value":"nil","external_name":"foreign_key_type","restriction":""}],"visibility":"Public","body":" \n{% if through != nil\n if through.is_a?(SymbolLiteral) || through.is_a?(StringLiteral)\n through = through.id\n end\n if own_key.is_a?(SymbolLiteral) || own_key.is_a?(StringLiteral)\n own_key = own_key.id\n end\n if foreign_key.is_a?(SymbolLiteral) || foreign_key.is_a?(StringLiteral)\n foreign_key = foreign_key.id\n end\n if foreign_key_type.is_a?(SymbolLiteral) || foreign_key_type.is_a?(StringLiteral)\n foreign_key_type = foreign_key_type.id\n end\n RELATIONS[name.var.id] = {relation_type: :has_many_through, type: name.type, through: through, own_key: own_key, foreign_key: foreign_key, foreign_key_type: foreign_key_type, polymorphic: polymorphic}\nelse\n if foreign_key.is_a?(SymbolLiteral) || foreign_key.is_a?(StringLiteral)\n foreign_key = foreign_key.id\n end\n if primary_key.is_a?(SymbolLiteral) || primary_key.is_a?(StringLiteral)\n primary_key = primary_key.id\n end\n if foreign_key_type.is_a?(SymbolLiteral) || foreign_key_type.is_a?(StringLiteral)\n foreign_key_type = foreign_key_type.id\n end\n RELATIONS[name.var.id] = {relation_type: :has_many, type: name.type, foreign_key: foreign_key, primary_key: primary_key, foreign_key_type: foreign_key_type, no_cache: no_cache, polymorphic: polymorphic}\nend %}\n\n \n"}},{"html_id":"has_one(name,foreign_key=nil,primary_key=nil,no_cache=false,polymorphic=false,foreign_key_type=nil)-macro","name":"has_one","doc":"The method `has_one` declare a relation 1 to [0,1]\nwhere the current model primary key is stored in the foreign table.\n`primary_key` method (default: `self#__pkey__`) and `foreign_key` method\n(default: table_name in singular, plus \"_id\" appended)\ncan be redefined\n\nExample:\n\n```\nmodel Passport\n column id : Int32, primary : true\n has_one user : User It assumes the table `users` have a column `passport_id`\nend\n\nmodel Passport\n column id : Int32, primary : true\n has_one owner : User # It assumes the table `users` have a column `passport_id`\nend\n```","summary":"The method has_one
declare a relation 1 to [0,1] where the current model primary key is stored in the foreign table.
Delete the model by building and executing a DELETE
query.
Save the model.
","abstract":false,"args":[{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"args_string":"(on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","args_html":"(on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","location":{"filename":"src/clear/model/modules/has_saving.cr","line_number":93,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_saving.cr#L93"},"def":{"name":"save","args":[{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"visibility":"Public","body":"if self.class.read_only?\n return false\nend\nwith_triggers(:save) do\n if valid?\n if persisted?\n h = update_h\n if h.empty?\n else\n with_triggers(:update) do\n ((Clear::SQL.update(self.class.full_table_name)).set(update_h)).where do\n (var(\"#{self.class.__pkey__}\")) == __pkey__\n end.execute(@@connection)\n end\n end\n else\n with_triggers(:create) do\n query = (Clear::SQL.insert_into(self.class.full_table_name, to_h)).returning(\"*\")\n if on_conflict\n on_conflict.call(query)\n end\n hash = query.execute(@@connection)\n reset(hash)\n @persisted = true\n end\n end\n clear_change_flags\n return true\n else\n return false\n end\nend\n"}},{"html_id":"save(&block)-instance-method","name":"save","abstract":false,"location":{"filename":"src/clear/model/modules/has_saving.cr","line_number":125,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_saving.cr#L125"},"def":{"name":"save","yields":0,"block_arity":0,"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":"save(on_conflict: block)"}},{"html_id":"save!(on_conflict:Clear::SQL::InsertQuery->|Nil=nil)-instance-method","name":"save!","doc":"Performs `save` call, but instead of returning `false` if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Performs #save
call, but instead of returning false
if validation failed, raise Clear::Model::InvalidError
exception
Pass the on_conflict
optional parameter via block.
Set the fields passed as argument and call #save
on the object
Set the fields passed as argument and call #save!
on the object
Add a hook for the primary_key
In the hook, name will be replaced by the column name required by calling primary_key
Macro used to define serializable primary keys.
","abstract":false,"args":[{"name":"name","default_value":"\"id\"","external_name":"name","restriction":""},{"name":"type","default_value":":bigserial","external_name":"type","restriction":""}],"args_string":"(name = \"id\", type = :bigserial)","args_html":"(name = "id", type = :bigserial)","location":{"filename":"src/clear/model/modules/has_serial_pkey.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_serial_pkey.cr#L11"},"def":{"name":"primary_key","args":[{"name":"name","default_value":"\"id\"","external_name":"name","restriction":""},{"name":"type","default_value":":bigserial","external_name":"type","restriction":""}],"visibility":"Public","body":" \n# Transform symbols to string\n\n \n{% name = \"#{name.id}\"\ntype = \"#{type.id}\"\n %}\n\n\n \n{% cb = PKEY_TYPE[type] %}\n\n\n \n{% if cb %}\n {{ (cb.gsub(/__name__/, name)).id }}\n {% else %}\n {% raise(\"Cannot define primary key of type #{type}. Candidates are: #{PKEY_TYPE.keys.join(\", \")}\") %}\n {% end %}\n\n \n"}}]},{"html_id":"clear/Clear/Model/HasTimestamps","path":"Clear/Model/HasTimestamps.html","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_timestamps.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_timestamps.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"macros":[{"html_id":"timestamps-macro","name":"timestamps","doc":"Generate the columns `updated_at` and `created_at`\nThe two column values are automatically set during insertion\n or update of the model.","summary":"Generate the columns updated_at
and created_at
The two column values are automatically set during insertion or update of the model.
Add validation error related to a specific column
","abstract":false,"args":[{"name":"column","external_name":"column","restriction":""},{"name":"reason","external_name":"reason","restriction":""}],"args_string":"(column, reason)","args_html":"(column, reason)","location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L15"},"def":{"name":"add_error","args":[{"name":"column","external_name":"column","restriction":""},{"name":"reason","external_name":"reason","restriction":""}],"visibility":"Public","body":"@errors << Error.new(reason: reason, column: column.to_s)"}},{"html_id":"add_error(reason)-instance-method","name":"add_error","doc":"Add validation error not related to a specific column","summary":"Add validation error not related to a specific column
","abstract":false,"args":[{"name":"reason","external_name":"reason","restriction":""}],"args_string":"(reason)","args_html":"(reason)","location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L10"},"def":{"name":"add_error","args":[{"name":"reason","external_name":"reason","restriction":""}],"visibility":"Public","body":"@errors << Error.new(reason: reason, column: nil)"}},{"html_id":"clear_errors-instance-method","name":"clear_errors","doc":"Clear the errors log (if any) of the model and return itself","summary":"Clear the errors log (if any) of the model and return itself
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L26"},"def":{"name":"clear_errors","visibility":"Public","body":"@errors.clear\nself\n"}},{"html_id":"error?-instance-method","name":"error?","doc":"Return `true` if saving has been declined because of validation issues.\nThe error list can be found by calling `Clear::Model#errors`","summary":"Return true
if saving has been declined because of validation issues.
List of errors raised during validation, in case the model hasn't been saved properly.
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L7"},"def":{"name":"errors","return_type":"Array(Error)","visibility":"Public","body":"@errors"}},{"html_id":"print_errors-instance-method","name":"print_errors","doc":"Print the errors in string. Useful for debugging or simple error handling.","summary":"Print the errors in string.
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L33"},"def":{"name":"print_errors","visibility":"Public","body":"@errors.group_by(&.column).to_a.sort do |__temp_92, __temp_93|\n f1, _ = __temp_92\n f2, _ = __temp_93\n (f1 || \"\") <=> (f2 || \"\")\nend.join(\"\\n\") do |column, errors|\n [column, errors.join(\", \", &.reason)].compact.join(\": \")\nend"}},{"html_id":"valid!-instance-method","name":"valid!","doc":"Check whether the model is valid. If not, raise `InvalidModelError`.\nReturn the model itself","summary":"Check whether the model is valid.
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L47"},"def":{"name":"valid!","visibility":"Public","body":"if valid?\nelse\n raise(InvalidError.new(self))\nend\nself\n"}},{"html_id":"valid?-instance-method","name":"valid?","doc":"Return `true` if the model","summary":"Return true
if the model
This method is called whenever #valid?
or save
is called.
This module declare all the methods and macro related to deserializing json in Clear::Model
The Clear::Model::QueryCache is a fire-and-forget cache used when caching associations and preventing N+1 queries anti-pattern.
","instance_methods":[{"html_id":"active(relation_name)-instance-method","name":"active","doc":"Tell this cache than we active the cache over a specific relation name.\nReturns `self`","summary":"Tell this cache than we active the cache over a specific relation name.
","abstract":false,"args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"args_string":"(relation_name)","args_html":"(relation_name)","location":{"filename":"src/clear/model/query_cache.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L28"},"def":{"name":"active","args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"visibility":"Public","body":"@cache_activation.add(relation_name)\nself\n"}},{"html_id":"active?(relation_name)-instance-method","name":"active?","doc":"Check whether the cache is active on a certain association.\nReturns `true` if `relation_name` is flagged as encached, or `false` otherwise.","summary":"Check whether the cache is active on a certain association.
","abstract":false,"args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"args_string":"(relation_name)","args_html":"(relation_name)","location":{"filename":"src/clear/model/query_cache.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L36"},"def":{"name":"active?","args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"visibility":"Public","body":"@cache_activation.includes?(relation_name)"}},{"html_id":"clear-instance-method","name":"clear","doc":"Empty the cache and flag all relations has unactive","summary":"Empty the cache and flag all relations has unactive
","abstract":false,"location":{"filename":"src/clear/model/query_cache.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L70"},"def":{"name":"clear","visibility":"Public","body":"@cache.clear\n@cache_activation.clear\n"}},{"html_id":"fetch-instance-method","name":"fetch","abstract":false,"location":{"filename":"src/clear/model/query_cache.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L22"},"def":{"name":"fetch","visibility":"Public","body":"query"}},{"html_id":"hit(relation_name,relation_value,klass:T.class):Array(T)forallT-instance-method","name":"hit","doc":"Try to hit the cache. If an array is found, it will be returned.\nOtherwise, empty array is returned.\n\nThis methods do not check if a relation flagged as is actively cached or not. Therefore, hitting a non-cached\nrelation will return always an empty-array.","summary":"Try to hit the cache.
","abstract":false,"args":[{"name":"relation_name","external_name":"relation_name","restriction":""},{"name":"relation_value","external_name":"relation_value","restriction":""},{"name":"klass","external_name":"klass","restriction":"T.class"}],"args_string":"(relation_name, relation_value, klass : T.class) : Array(T) forall T","args_html":"(relation_name, relation_value, klass : T.class) : Array(T) forall T","location":{"filename":"src/clear/model/query_cache.cr","line_number":45,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L45"},"def":{"name":"hit","args":[{"name":"relation_name","external_name":"relation_name","restriction":""},{"name":"relation_value","external_name":"relation_value","restriction":""},{"name":"klass","external_name":"klass","restriction":"T.class"}],"return_type":"Array(T)","visibility":"Public","body":"(@cache.fetch(CacheKey.new(relation_name, relation_value, T.name)) do\n [] of T\nend).unsafe_as(Array(T))"}},{"html_id":"set(relation_name,relation_value,arr:Array(T))forallT-instance-method","name":"set","doc":"Set the cached array for a specific key `{relation_name,relation_value}`","summary":"Set the cached array for a specific key {relation_name,relation_value}
Perform some operations with the cache then eventually clear the cache.
","abstract":false,"location":{"filename":"src/clear/model/query_cache.cr","line_number":63,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L63"},"def":{"name":"with_cache","yields":0,"block_arity":0,"visibility":"Public","body":"begin\n yield\nensure\n clear\nend"}}]},{"html_id":"clear/Clear/Model/ReadOnlyError","path":"Clear/Model/ReadOnlyError.html","kind":"class","full_name":"Clear::Model::ReadOnlyError","name":"ReadOnlyError","abstract":false,"superclass":{"html_id":"clear/Clear/Model/Error","kind":"class","full_name":"Clear::Model::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/Model/Error","kind":"class","full_name":"Clear::Model::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/errors.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L12"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"constructors":[{"html_id":"new(model:Clear::Model)-class-method","name":"new","abstract":false,"args":[{"name":"model","external_name":"model","restriction":"Clear::Model"}],"args_string":"(model : Clear::Model)","args_html":"(model : Clear::Model)","location":{"filename":"src/clear/model/errors.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L15"},"def":{"name":"new","args":[{"name":"model","external_name":"model","restriction":"Clear::Model"}],"visibility":"Public","body":"_ = allocate\n_.initialize(model)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"model:Clear::Model-instance-method","name":"model","abstract":false,"location":{"filename":"src/clear/model/errors.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L13"},"def":{"name":"model","return_type":"Clear::Model","visibility":"Public","body":"@model"}}]},{"html_id":"clear/Clear/Model/Relations","path":"Clear/Model/Relations.html","kind":"module","full_name":"Clear::Model::Relations","name":"Relations","abstract":false,"locations":[{"filename":"src/clear/model/modules/relations/belongs_to_macro.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/relations/belongs_to_macro.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}}]},{"html_id":"clear/Clear/Reflection","path":"Clear/Reflection.html","kind":"module","full_name":"Clear::Reflection","name":"Reflection","abstract":false,"locations":[{"filename":"src/clear/model/reflection/column.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"types":[{"html_id":"clear/Clear/Reflection/Column","path":"Clear/Reflection/Column.html","kind":"class","full_name":"Clear::Reflection::Column","name":"Column","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Validation/Helper","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/column.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"COLUMNS","name":"COLUMNS","value":"{\"table_catalog\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_catalog\", crystal_variable_name: table_catalog, presence: true, mass_assign: true}, \"table_schema\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_schema\", crystal_variable_name: table_schema, presence: true, mass_assign: true}, \"table_name\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_name\", crystal_variable_name: table_name, presence: false, mass_assign: true}, \"column_name\" => {type: String, primary: true, converter: \"String\", db_column_name: \"column_name\", crystal_variable_name: column_name, presence: true, mass_assign: true}} of Nil => Nil"},{"id":"POLYMORPHISM_SETTINGS","name":"POLYMORPHISM_SETTINGS","value":"{} of Nil => Nil"}],"included_modules":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"extended_modules":[{"html_id":"clear/Clear/Model/HasHooks/ClassMethods","kind":"module","full_name":"Clear::Model::HasHooks::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"clear/Clear/Reflection","kind":"module","full_name":"Clear::Reflection","name":"Reflection"},"doc":"Reflection of the columns using information_schema in postgreSQL.\nTODO: Usage of view instead of model","summary":"Reflection of the columns using information_schema in postgreSQL.
","class_methods":[{"html_id":"build(**tuple:**T)forallT-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":"**T"},"visibility":"Public","body":"{% if T.size > 0 %}\n self.new(tuple)\n {% else %}\n self.new\n {% end %}"}},{"html_id":"build(**tuple)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"build(**tuple) do\nend"}},{"html_id":"build(**tuple,&)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"visibility":"Public","body":"r = build(**tuple)\nyield(r)\nr\n"}},{"html_id":"columns-class-method","name":"columns","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"columns","visibility":"Public","body":"@@columns"}},{"html_id":"connection:String-class-method","name":"connection","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"def":{"name":"connection","return_type":"String","visibility":"Public","body":"@@connection"}},{"html_id":"connection=(connection:String)-class-method","name":"connection=","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":"String"}],"args_string":"(connection : String)","args_html":"(connection : String)","def":{"name":"connection=","args":[{"name":"connection","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"@@connection = connection"}},{"html_id":"create_from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json","doc":"Create a new model from json and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"mdl = self.from_json(string_or_io, trusted)\nmdl.save\nmdl\n"}},{"html_id":"create_from_json!(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json!","doc":"Create a new model from json and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json!","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(self.from_json(string_or_io, trusted)).save!"}},{"html_id":"find(x)-class-method","name":"find","doc":"Returns a model using primary key equality\nReturns `nil` if not found.","summary":"Returns a model using primary key equality Returns nil
if not found.
Returns a model using primary key equality.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"find!","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"(find(x)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"from_json","doc":"Create a new empty model and fill the columns from json. Returns the new model\n\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new empty model and fill the columns from json.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).create(trusted)"}},{"html_id":"full_table_name-class-method","name":"full_table_name","doc":"returns the fully qualified and escaped name for this table.\nadd schema if schema is different from 'public' (default schema)\n\nex: \"schema\".\"table\"","summary":"returns the fully qualified and escaped name for this table.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"full_table_name","visibility":"Public","body":"if s = schema\n {schema, table}.map do |x|\n Clear::SQL.escape(x.to_s)\n end.join(\".\")\nelse\n Clear::SQL.escape(table)\nend"}},{"html_id":"import(array:Enumerable(self),on_conflict:Clear::SQL::InsertQuery->|Nil=nil)-class-method","name":"import","doc":"Import a bulk of models in one SQL insert query.\nEach model must be non-persisted.\n\n`on_conflict` callback can be optionnaly turned on\nto manage constraints of the database.\n\nNote: Old models are not modified. This method return a copy of the\nmodels as saved in the database.\n\n## Example:\n\n```\nusers = [User.new(id: 1), User.new(id: 2), User.new(id: 3)]\nusers = User.import(users)\n```","summary":"Import a bulk of models in one SQL insert query.
","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"args_string":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","args_html":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"import","args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"visibility":"Public","body":"array.each do |item|\n if item.persisted?\n raise(\"One of your model is persisted while calling import\")\n end\nend\nhashes = array.map do |item|\n item.trigger_before_events(:save)\n if item.valid?\n else\n raise(\"import: Validation failed for `#{item}`\")\n end\n item.trigger_before_events(:create)\n item.to_h\nend\nquery = (Clear::SQL.insert_into(self.table, hashes)).returning(\"*\")\nif on_conflict\n on_conflict.call(query)\nend\no = [] of self\nquery.fetch(@@connection) do |hash|\n o << ((Clear::Model::Factory.build(self.name, hash, persisted: true, fetch_columns: false, cache: nil)).as(self))\nend\no.each(&.trigger_after_events(:create))\no.each(&.trigger_after_events(:save))\no\n"}},{"html_id":"polymorphic?:Bool-class-method","name":"polymorphic?","abstract":false,"def":{"name":"polymorphic?","return_type":"Bool","visibility":"Public","body":"@@polymorphic"}},{"html_id":"query-class-method","name":"query","doc":"Return a new empty query `SELECT * FROM [my_model_table]`. Can be refined after that.","summary":"Return a new empty query SELECT * FROM [my_model_table]
.
Define the current schema used in PostgreSQL.
","abstract":false,"def":{"name":"schema","return_type":"Clear::SQL::Symbolic | ::Nil","visibility":"Public","body":"@@schema"}},{"html_id":"schema=(schema:Clear::SQL::Symbolic|Nil)-class-method","name":"schema=","doc":"Define the current schema used in PostgreSQL. The value is `nil` by default, which lead to non-specified\n schema during the querying, and usage of \"public\" by PostgreSQL.\n\nThis property can be redefined on initialization. Example:\n\n```\nclass MyModel\n include Clear::Model\n\n self.schema = \"my_schema\"\nend\nMyModel.query.to_sql # SELECT * FROM \"my_schema\".\"my_models\"\n```","summary":"Define the current schema used in PostgreSQL.
","abstract":false,"args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"args_string":"(schema : Clear::SQL::Symbolic | Nil)","args_html":"(schema : Clear::SQL::Symbolic | Nil)","def":{"name":"schema=","args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"visibility":"Public","body":"@@schema = schema"}},{"html_id":"table:Clear::SQL::Symbolic-class-method","name":"table","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"def":{"name":"table","return_type":"Clear::SQL::Symbolic","visibility":"Public","body":"@@table"}},{"html_id":"table=(table:Clear::SQL::Symbolic)-class-method","name":"table=","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"args_string":"(table : Clear::SQL::Symbolic)","args_html":"(table : Clear::SQL::Symbolic)","def":{"name":"table=","args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"visibility":"Public","body":"@@table = table"}}],"constructors":[{"html_id":"build(x:NamedTuple):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"build(**x) do\nend"}},{"html_id":"build(x:NamedTuple,&block:self->Nil):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"build(**x, &block)"}},{"html_id":"create(x:NamedTuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create(**tuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save\nr\n"}},{"html_id":"create(x:NamedTuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create(**x) do\nend"}},{"html_id":"create(**tuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create(**tuple) do\nend"}},{"html_id":"create!(x:NamedTuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create!(**x, &block)"}},{"html_id":"create!(**tuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"create!(x:NamedTuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create!(**x) do\nend"}},{"html_id":"create!(**tuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create!(**tuple) do\nend"}},{"html_id":"new(h:Hash(String,_),cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false)-class-method","name":"new","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","args_html":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(h, cache, persisted, fetch_columns)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(json:JSON::Any,cache:Clear::Model::QueryCache|Nil=nil,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","args_html":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(json, cache, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(t:NamedTuple,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(t : NamedTuple, persisted = false)","args_html":"(t : NamedTuple, persisted = false)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(t, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"_cached_table:Clear::Reflection::Table|Nil-instance-method","name":"_cached_table","abstract":false,"def":{"name":"_cached_table","return_type":"Clear::Reflection::Table | ::Nil","visibility":"Public","body":"@_cached_table"}},{"html_id":"attributes:Hash(String,Clear::SQL::Any)-instance-method","name":"attributes","doc":"Attributes, used when fetch_columns is true","summary":"Attributes, used when fetch_columns is true
","abstract":false,"def":{"name":"attributes","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"@attributes"}},{"html_id":"cache:Clear::Model::QueryCache|Nil-instance-method","name":"cache","abstract":false,"def":{"name":"cache","return_type":"Clear::Model::QueryCache | ::Nil","visibility":"Public","body":"@cache"}},{"html_id":"changed?-instance-method","name":"changed?","doc":"Return `true` if the model is dirty (e.g. one or more fields\n have been changed.). Return `false` otherwise.","summary":"Return true
if the model is dirty (e.g.
Reset the #changed?
flag on all columns
Returns the value of #column_name
column or throw an exception if the column is not defined.
Setter for #column_name
column.
Returns the column object used to manage #column_name
field
Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:\\{{settings[:db_column_name]}}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(h:Hash(String,_))-instance-method","name":"reset","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(t:NamedTuple)-instance-method","name":"reset","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"reset","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"reset(**t)"}},{"html_id":"reset(from_json:JSON::Any)-instance-method","name":"reset","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"reset","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"reset(from_json.as_h)"}},{"html_id":"reset(**t:**T)forallT-instance-method","name":"reset","doc":"reset flavors","summary":"reset flavors
","abstract":false,"def":{"name":"reset","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n\n {% if settings = COLUMNS[\"#{name}\"] %}\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"Cannot find the column `#{name}` of the model `#{@type}`\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(Symbol,_))-instance-method","name":"set","doc":"Set the columns from hash","summary":"Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:{{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(String,_))-instance-method","name":"set","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(t:NamedTuple)-instance-method","name":"set","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"set","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"set(**t)"}},{"html_id":"set(from_json:JSON::Any)-instance-method","name":"set","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"set","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"set(from_json.as_h)"}},{"html_id":"set(**t:**T)forallT-instance-method","name":"set","doc":"Set one or multiple columns to a specific value\nThis two are equivalents:\n\n```\nmodel.set(a: 1)\nmodel.a = 1\n```","summary":"Set one or multiple columns to a specific value This two are equivalents:
","abstract":false,"def":{"name":"set","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n {% if settings = COLUMNS[\"#{name}\".id] %}\n @{{ settings[:crystal_variable_name] }}_column.set_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"No method #{@type}##{name}= while trying to set value of #{name}\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"set_from_json","doc":"Set the fields from json passed as argument\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument Trusted flag set to true will allow mass assignment without protection, FALSE by default
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"set_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).update(self, trusted)"}},{"html_id":"table:Clear::Reflection::Table-instance-method","name":"table","doc":"The method table is a `belongs_to` relation to Clear::Reflection::Table","summary":"The method table is a belongs_to
relation to Clear::Reflection::Table
Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Setter for #table_name
column.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Setter for #table_schema
column.
Returns the column object used to manage #table_schema
field
Return a hash version of the columns of this model.
","abstract":false,"args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"args_string":"(full = false) : Hash(String, Clear::SQL::Any)","args_html":"(full = false) : Hash(String, Clear::SQL::Any)","def":{"name":"to_h","args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"out = super(full)\nif full || @table_catalog_column.defined?\n out[\"table_catalog\"] = @table_catalog_column.to_sql_value(nil)\nend\nif full || @table_schema_column.defined?\n out[\"table_schema\"] = @table_schema_column.to_sql_value(nil)\nend\nif full || @table_name_column.defined?\n out[\"table_name\"] = @table_name_column.to_sql_value(nil)\nend\nif full || @column_name_column.defined?\n out[\"column_name\"] = @column_name_column.to_sql_value(nil)\nend\nout\n"}},{"html_id":"to_json(emit_nulls:Bool=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"args_string":"(emit_nulls : Bool = false)","args_html":"(emit_nulls : Bool = false)","def":{"name":"to_json","args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"visibility":"Public","body":"JSON.build do |json|\n to_json(json, emit_nulls)\nend"}},{"html_id":"to_json(json,emit_nulls=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"args_string":"(json, emit_nulls = false)","args_html":"(json, emit_nulls = false)","def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"visibility":"Public","body":"json.object do\n if emit_nulls || @table_catalog_column.defined?\n json.field(\"table_catalog\") do\n (@table_catalog_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_schema_column.defined?\n json.field(\"table_schema\") do\n (@table_schema_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_name_column.defined?\n json.field(\"table_name\") do\n (@table_name_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @column_name_column.defined?\n json.field(\"column_name\") do\n (@column_name_column.value(nil)).to_json(json)\n end\n end\nend"}},{"html_id":"update_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"update_from_json","doc":"Set the fields from json passed as argument and call `save` on the object\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument and call save
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
","abstract":false,"def":{"name":"update_h","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"o = super()\nif @table_catalog_column.defined? && @table_catalog_column.changed?\n o[\"table_catalog\"] = @table_catalog_column.to_sql_value\nend\nif @table_schema_column.defined? && @table_schema_column.changed?\n o[\"table_schema\"] = @table_schema_column.to_sql_value\nend\nif @table_name_column.defined? && @table_name_column.changed?\n o[\"table_name\"] = @table_name_column.to_sql_value\nend\nif @column_name_column.defined? && @column_name_column.changed?\n o[\"column_name\"] = @column_name_column.to_sql_value\nend\no\n"}},{"html_id":"validate_fields_presence-instance-method","name":"validate_fields_presence","doc":"For each column, ensure than when needed the column has present\ninformation into it.\n\nThis method is called on validation.","summary":"For each column, ensure than when needed the column has present information into it.
","abstract":false,"def":{"name":"validate_fields_presence","visibility":"Public","body":"if persisted?\nelse\n if @table_catalog_column.failed_to_be_present?\n add_error(\"table_catalog\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_schema_column.failed_to_be_present?\n add_error(\"table_schema\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_name_column.failed_to_be_present?\n add_error(\"table_name\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @column_name_column.failed_to_be_present?\n add_error(\"column_name\", \"must be present\")\n end\nend\n"}}],"types":[{"html_id":"clear/Clear/Reflection/Column/Collection","path":"Clear/Reflection/Column/Collection.html","kind":"class","full_name":"Clear::Reflection::Column::Collection","name":"Collection","abstract":false,"superclass":{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},"ancestors":[{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Reflection/Column","kind":"class","full_name":"Clear::Reflection::Column","name":"Column"},"doc":":doc:\nClear::Model::Collection\n\nThis is the object managing a `SELECT` request.\nA new collection is created by calling `Clear::Model.query`\n\nCollection are mutable and refining the SQL will mutate the collection.\nYou may want to copy the collection by calling `dup`\n\nSee `Clear::Model::CollectionBase`","summary":":doc: Clear::Model::Collection
","instance_methods":[{"html_id":"with_table(fetch_columns=false,&block:Clear::Reflection::Table::Collection->):self-instance-method","name":"with_table","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self","args_html":"(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self","def":{"name":"with_table","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Reflection::Table::Collection ->)"},"return_type":"self","visibility":"Public","body":"before_query do\n sub_query = self.dup.clear_select.select(\"#{Clear::Reflection::Column.table}.table_name\")\n cached_qry = Clear::Reflection::Table.query.where do\n (raw(\"#{Clear::Reflection::Table.table}.#{Clear::Reflection::Table.__pkey__}\")).in?(sub_query)\n end\n block.call(cached_qry)\n @cache.active(\"table\")\n cached_qry.each(fetch_columns: fetch_columns) do |mdl|\n @cache.set(\"table\", mdl.__pkey__, [mdl])\n end\nend\nself\n"}},{"html_id":"with_table(fetch_columns=false):self-instance-method","name":"with_table","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : self","args_html":"(fetch_columns = false) : self","def":{"name":"with_table","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"self","visibility":"Public","body":"with_table(fetch_columns) do\nend\nself\n"}}]}]},{"html_id":"clear/Clear/Reflection/Table","path":"Clear/Reflection/Table.html","kind":"class","full_name":"Clear::Reflection::Table","name":"Table","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Validation/Helper","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/table.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"COLUMNS","name":"COLUMNS","value":"{\"table_catalog\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_catalog\", crystal_variable_name: table_catalog, presence: true, mass_assign: true}, \"table_schema\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_schema\", crystal_variable_name: table_schema, presence: true, mass_assign: true}, \"table_name\" => {type: String, primary: true, converter: \"String\", db_column_name: \"table_name\", crystal_variable_name: table_name, presence: true, mass_assign: true}, \"table_type\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_type\", crystal_variable_name: table_type, presence: true, mass_assign: true}} of Nil => Nil"},{"id":"POLYMORPHISM_SETTINGS","name":"POLYMORPHISM_SETTINGS","value":"{} of Nil => Nil"}],"included_modules":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"extended_modules":[{"html_id":"clear/Clear/Model/HasHooks/ClassMethods","kind":"module","full_name":"Clear::Model::HasHooks::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"clear/Clear/Reflection","kind":"module","full_name":"Clear::Reflection","name":"Reflection"},"doc":"Reflection of the tables using information_schema in postgreSQL.\nTODO: Usage of view instead of model","summary":"Reflection of the tables using information_schema in postgreSQL.
","class_methods":[{"html_id":"build(**tuple:**T)forallT-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":"**T"},"visibility":"Public","body":"{% if T.size > 0 %}\n self.new(tuple)\n {% else %}\n self.new\n {% end %}"}},{"html_id":"build(**tuple)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"build(**tuple) do\nend"}},{"html_id":"build(**tuple,&)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"visibility":"Public","body":"r = build(**tuple)\nyield(r)\nr\n"}},{"html_id":"columns-class-method","name":"columns","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"columns","visibility":"Public","body":"@@columns"}},{"html_id":"connection:String-class-method","name":"connection","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"def":{"name":"connection","return_type":"String","visibility":"Public","body":"@@connection"}},{"html_id":"connection=(connection:String)-class-method","name":"connection=","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":"String"}],"args_string":"(connection : String)","args_html":"(connection : String)","def":{"name":"connection=","args":[{"name":"connection","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"@@connection = connection"}},{"html_id":"create_from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json","doc":"Create a new model from json and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"mdl = self.from_json(string_or_io, trusted)\nmdl.save\nmdl\n"}},{"html_id":"create_from_json!(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json!","doc":"Create a new model from json and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json!","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(self.from_json(string_or_io, trusted)).save!"}},{"html_id":"find(x)-class-method","name":"find","doc":"Returns a model using primary key equality\nReturns `nil` if not found.","summary":"Returns a model using primary key equality Returns nil
if not found.
Returns a model using primary key equality.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"find!","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"(find(x)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"from_json","doc":"Create a new empty model and fill the columns from json. Returns the new model\n\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new empty model and fill the columns from json.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).create(trusted)"}},{"html_id":"full_table_name-class-method","name":"full_table_name","doc":"returns the fully qualified and escaped name for this table.\nadd schema if schema is different from 'public' (default schema)\n\nex: \"schema\".\"table\"","summary":"returns the fully qualified and escaped name for this table.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"full_table_name","visibility":"Public","body":"if s = schema\n {schema, table}.map do |x|\n Clear::SQL.escape(x.to_s)\n end.join(\".\")\nelse\n Clear::SQL.escape(table)\nend"}},{"html_id":"import(array:Enumerable(self),on_conflict:Clear::SQL::InsertQuery->|Nil=nil)-class-method","name":"import","doc":"Import a bulk of models in one SQL insert query.\nEach model must be non-persisted.\n\n`on_conflict` callback can be optionnaly turned on\nto manage constraints of the database.\n\nNote: Old models are not modified. This method return a copy of the\nmodels as saved in the database.\n\n## Example:\n\n```\nusers = [User.new(id: 1), User.new(id: 2), User.new(id: 3)]\nusers = User.import(users)\n```","summary":"Import a bulk of models in one SQL insert query.
","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"args_string":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","args_html":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"import","args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"visibility":"Public","body":"array.each do |item|\n if item.persisted?\n raise(\"One of your model is persisted while calling import\")\n end\nend\nhashes = array.map do |item|\n item.trigger_before_events(:save)\n if item.valid?\n else\n raise(\"import: Validation failed for `#{item}`\")\n end\n item.trigger_before_events(:create)\n item.to_h\nend\nquery = (Clear::SQL.insert_into(self.table, hashes)).returning(\"*\")\nif on_conflict\n on_conflict.call(query)\nend\no = [] of self\nquery.fetch(@@connection) do |hash|\n o << ((Clear::Model::Factory.build(self.name, hash, persisted: true, fetch_columns: false, cache: nil)).as(self))\nend\no.each(&.trigger_after_events(:create))\no.each(&.trigger_after_events(:save))\no\n"}},{"html_id":"polymorphic?:Bool-class-method","name":"polymorphic?","abstract":false,"def":{"name":"polymorphic?","return_type":"Bool","visibility":"Public","body":"@@polymorphic"}},{"html_id":"public-class-method","name":"public","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L16"},"def":{"name":"public","visibility":"Public","body":"query.public()"}},{"html_id":"query-class-method","name":"query","doc":"Return a new empty query `SELECT * FROM [my_model_table]`. Can be refined after that.","summary":"Return a new empty query SELECT * FROM [my_model_table]
.
Define the current schema used in PostgreSQL.
","abstract":false,"def":{"name":"schema","return_type":"Clear::SQL::Symbolic | ::Nil","visibility":"Public","body":"@@schema"}},{"html_id":"schema=(schema:Clear::SQL::Symbolic|Nil)-class-method","name":"schema=","doc":"Define the current schema used in PostgreSQL. The value is `nil` by default, which lead to non-specified\n schema during the querying, and usage of \"public\" by PostgreSQL.\n\nThis property can be redefined on initialization. Example:\n\n```\nclass MyModel\n include Clear::Model\n\n self.schema = \"my_schema\"\nend\nMyModel.query.to_sql # SELECT * FROM \"my_schema\".\"my_models\"\n```","summary":"Define the current schema used in PostgreSQL.
","abstract":false,"args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"args_string":"(schema : Clear::SQL::Symbolic | Nil)","args_html":"(schema : Clear::SQL::Symbolic | Nil)","def":{"name":"schema=","args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"visibility":"Public","body":"@@schema = schema"}},{"html_id":"table:Clear::SQL::Symbolic-class-method","name":"table","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"def":{"name":"table","return_type":"Clear::SQL::Symbolic","visibility":"Public","body":"@@table"}},{"html_id":"table=(table:Clear::SQL::Symbolic)-class-method","name":"table=","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"args_string":"(table : Clear::SQL::Symbolic)","args_html":"(table : Clear::SQL::Symbolic)","def":{"name":"table=","args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"visibility":"Public","body":"@@table = table"}},{"html_id":"tables_only-class-method","name":"tables_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L18"},"def":{"name":"tables_only","visibility":"Public","body":"query.tables_only()"}},{"html_id":"views_only-class-method","name":"views_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L19"},"def":{"name":"views_only","visibility":"Public","body":"query.views_only()"}}],"constructors":[{"html_id":"build(x:NamedTuple):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"build(**x) do\nend"}},{"html_id":"build(x:NamedTuple,&block:self->Nil):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"build(**x, &block)"}},{"html_id":"create(x:NamedTuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create(**tuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save\nr\n"}},{"html_id":"create(x:NamedTuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create(**x) do\nend"}},{"html_id":"create(**tuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create(**tuple) do\nend"}},{"html_id":"create!(x:NamedTuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create!(**x, &block)"}},{"html_id":"create!(**tuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"create!(x:NamedTuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create!(**x) do\nend"}},{"html_id":"create!(**tuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create!(**tuple) do\nend"}},{"html_id":"new(h:Hash(String,_),cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false)-class-method","name":"new","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","args_html":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(h, cache, persisted, fetch_columns)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(json:JSON::Any,cache:Clear::Model::QueryCache|Nil=nil,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","args_html":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(json, cache, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(t:NamedTuple,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(t : NamedTuple, persisted = false)","args_html":"(t : NamedTuple, persisted = false)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(t, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"attributes:Hash(String,Clear::SQL::Any)-instance-method","name":"attributes","doc":"Attributes, used when fetch_columns is true","summary":"Attributes, used when fetch_columns is true
","abstract":false,"def":{"name":"attributes","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"@attributes"}},{"html_id":"cache:Clear::Model::QueryCache|Nil-instance-method","name":"cache","abstract":false,"def":{"name":"cache","return_type":"Clear::Model::QueryCache | ::Nil","visibility":"Public","body":"@cache"}},{"html_id":"changed?-instance-method","name":"changed?","doc":"Return `true` if the model is dirty (e.g. one or more fields\n have been changed.). Return `false` otherwise.","summary":"Return true
if the model is dirty (e.g.
Reset the #changed?
flag on all columns
The method columns is a has_many
relation to Clear::Reflection::Column
List all the indexes related to the current table.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L27"},"def":{"name":"indexes","return_type":"Hash(String, Array(String))","visibility":"Public","body":"o = {} of String => Array(String)\n((((SQL.select({index_name: \"i.relname\", column_name: \"a.attname\"})).from({t: \"pg_class\", i: \"pg_class\", ix: \"pg_index\", a: \"pg_attribute\"})).where do\n (((((t.oid == ix.indrelid) & (i.oid == ix.indexrelid)) & (a.attrelid == t.oid)) & (a.attnum == (raw(\"ANY(ix.indkey)\")))) & (t.relkind == \"r\")) & (t.relname == self.table_name)\nend.order_by(\"t.relname\")).order_by(\"i.relname\")).fetch do |h|\n col = h[\"column_name\"].to_s\n v = h[\"index_name\"].to_s\n arr = o[col]? ? o[col] : (o[col] = [] of String)\n arr << v\nend\no\n"}},{"html_id":"invalidate_caching:self-instance-method","name":"invalidate_caching","doc":"Force to clean-up the caches for the relations\nconnected to this model.","summary":"Force to clean-up the caches for the relations connected to this model.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"invalidate_caching","return_type":"self","visibility":"Public","body":"@cache = nil\nself\n"}},{"html_id":"reset(h:Hash(Symbol,_))-instance-method","name":"reset","doc":"Set the columns from hash","summary":"Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:\\{{settings[:db_column_name]}}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(h:Hash(String,_))-instance-method","name":"reset","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(t:NamedTuple)-instance-method","name":"reset","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"reset","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"reset(**t)"}},{"html_id":"reset(from_json:JSON::Any)-instance-method","name":"reset","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"reset","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"reset(from_json.as_h)"}},{"html_id":"reset(**t:**T)forallT-instance-method","name":"reset","doc":"reset flavors","summary":"reset flavors
","abstract":false,"def":{"name":"reset","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n\n {% if settings = COLUMNS[\"#{name}\"] %}\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"Cannot find the column `#{name}` of the model `#{@type}`\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(Symbol,_))-instance-method","name":"set","doc":"Set the columns from hash","summary":"Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:{{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(String,_))-instance-method","name":"set","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(t:NamedTuple)-instance-method","name":"set","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"set","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"set(**t)"}},{"html_id":"set(from_json:JSON::Any)-instance-method","name":"set","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"set","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"set(from_json.as_h)"}},{"html_id":"set(**t:**T)forallT-instance-method","name":"set","doc":"Set one or multiple columns to a specific value\nThis two are equivalents:\n\n```\nmodel.set(a: 1)\nmodel.a = 1\n```","summary":"Set one or multiple columns to a specific value This two are equivalents:
","abstract":false,"def":{"name":"set","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n {% if settings = COLUMNS[\"#{name}\".id] %}\n @{{ settings[:crystal_variable_name] }}_column.set_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"No method #{@type}##{name}= while trying to set value of #{name}\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"set_from_json","doc":"Set the fields from json passed as argument\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument Trusted flag set to true will allow mass assignment without protection, FALSE by default
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"set_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).update(self, trusted)"}},{"html_id":"table_catalog:String-instance-method","name":"table_catalog","doc":"Returns the value of `table_catalog` column or throw an exception if the column is not defined.","summary":"Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Setter for #table_name
column.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Setter for #table_schema
column.
Returns the column object used to manage #table_schema
field
Returns the value of #table_type
column or throw an exception if the column is not defined.
Setter for #table_type
column.
Returns the column object used to manage #table_type
field
Return a hash version of the columns of this model.
","abstract":false,"args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"args_string":"(full = false) : Hash(String, Clear::SQL::Any)","args_html":"(full = false) : Hash(String, Clear::SQL::Any)","def":{"name":"to_h","args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"out = super(full)\nif full || @table_catalog_column.defined?\n out[\"table_catalog\"] = @table_catalog_column.to_sql_value(nil)\nend\nif full || @table_schema_column.defined?\n out[\"table_schema\"] = @table_schema_column.to_sql_value(nil)\nend\nif full || @table_name_column.defined?\n out[\"table_name\"] = @table_name_column.to_sql_value(nil)\nend\nif full || @table_type_column.defined?\n out[\"table_type\"] = @table_type_column.to_sql_value(nil)\nend\nout\n"}},{"html_id":"to_json(emit_nulls:Bool=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"args_string":"(emit_nulls : Bool = false)","args_html":"(emit_nulls : Bool = false)","def":{"name":"to_json","args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"visibility":"Public","body":"JSON.build do |json|\n to_json(json, emit_nulls)\nend"}},{"html_id":"to_json(json,emit_nulls=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"args_string":"(json, emit_nulls = false)","args_html":"(json, emit_nulls = false)","def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"visibility":"Public","body":"json.object do\n if emit_nulls || @table_catalog_column.defined?\n json.field(\"table_catalog\") do\n (@table_catalog_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_schema_column.defined?\n json.field(\"table_schema\") do\n (@table_schema_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_name_column.defined?\n json.field(\"table_name\") do\n (@table_name_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_type_column.defined?\n json.field(\"table_type\") do\n (@table_type_column.value(nil)).to_json(json)\n end\n end\nend"}},{"html_id":"update_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"update_from_json","doc":"Set the fields from json passed as argument and call `save` on the object\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument and call save
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
","abstract":false,"def":{"name":"update_h","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"o = super()\nif @table_catalog_column.defined? && @table_catalog_column.changed?\n o[\"table_catalog\"] = @table_catalog_column.to_sql_value\nend\nif @table_schema_column.defined? && @table_schema_column.changed?\n o[\"table_schema\"] = @table_schema_column.to_sql_value\nend\nif @table_name_column.defined? && @table_name_column.changed?\n o[\"table_name\"] = @table_name_column.to_sql_value\nend\nif @table_type_column.defined? && @table_type_column.changed?\n o[\"table_type\"] = @table_type_column.to_sql_value\nend\no\n"}},{"html_id":"validate_fields_presence-instance-method","name":"validate_fields_presence","doc":"For each column, ensure than when needed the column has present\ninformation into it.\n\nThis method is called on validation.","summary":"For each column, ensure than when needed the column has present information into it.
","abstract":false,"def":{"name":"validate_fields_presence","visibility":"Public","body":"if persisted?\nelse\n if @table_catalog_column.failed_to_be_present?\n add_error(\"table_catalog\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_schema_column.failed_to_be_present?\n add_error(\"table_schema\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_name_column.failed_to_be_present?\n add_error(\"table_name\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_type_column.failed_to_be_present?\n add_error(\"table_type\", \"must be present\")\n end\nend\n"}}],"types":[{"html_id":"clear/Clear/Reflection/Table/Collection","path":"Clear/Reflection/Table/Collection.html","kind":"class","full_name":"Clear::Reflection::Table::Collection","name":"Collection","abstract":false,"superclass":{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},"ancestors":[{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},{"filename":"src/clear/model/reflection/table.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L16"},{"filename":"src/clear/model/reflection/table.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L18"},{"filename":"src/clear/model/reflection/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L19"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Reflection/Table","kind":"class","full_name":"Clear::Reflection::Table","name":"Table"},"doc":"Addition of the method for eager loading and N+1 avoidance.","summary":"Addition of the method for eager loading and N+1 avoidance.
","instance_methods":[{"html_id":"public-instance-method","name":"public","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L16"},"def":{"name":"public","visibility":"Public","body":"where do\n table_schema == \"public\"\nend\nreturn self\n"}},{"html_id":"tables_only-instance-method","name":"tables_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L18"},"def":{"name":"tables_only","visibility":"Public","body":"where do\n table_type == \"BASE TABLE\"\nend\nreturn self\n"}},{"html_id":"views_only-instance-method","name":"views_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L19"},"def":{"name":"views_only","visibility":"Public","body":"where do\n table_type == \"VIEW\"\nend\nreturn self\n"}},{"html_id":"with_columns(fetch_columns=false,&block:Clear::Reflection::Column::Collection->):self-instance-method","name":"with_columns","doc":"Eager load the has many relation columns.\nUse it to avoid N+1 queries.","summary":"Eager load the has many relation columns.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, &block : Clear::Reflection::Column::Collection -> ) : self","args_html":"(fetch_columns = false, &block : Clear::Reflection::Column::Collection -> ) : self","def":{"name":"with_columns","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Reflection::Column::Collection ->)"},"return_type":"self","visibility":"Public","body":"before_query do\n __temp_99 = table_name\n __temp_100 = \"table_name\"\n sub_query = self.dup.clear_select.select(\"#{Clear::Reflection::Table.table}.#{__temp_99}\")\n qry = Clear::Reflection::Column.query.where do\n (raw(__temp_100)).in?(sub_query)\n end\n block.call(qry)\n @cache.active(\"columns\")\n h = {} of Clear::SQL::Any => Array(Clear::Reflection::Column)\n qry.each(fetch_columns: true) do |mdl|\n if h[mdl.attributes[__temp_100]]?\n else\n h[mdl.attributes[__temp_100]] = [] of Clear::Reflection::Column\n end\n h[mdl.attributes[__temp_100]] << mdl\n end\n h.each do |key, value|\n @cache.set(\"columns\", key, value)\n end\nend\nself\n"}},{"html_id":"with_columns(fetch_columns=false)-instance-method","name":"with_columns","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false)","args_html":"(fetch_columns = false)","def":{"name":"with_columns","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"visibility":"Public","body":"with_columns(fetch_columns) do\nend"}}]}]}]},{"html_id":"clear/Clear/SQL","path":"Clear/SQL.html","kind":"module","full_name":"Clear::SQL","name":"SQL","abstract":false,"ancestors":[{"html_id":"clear/Clear/SQL/Transaction","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction"},{"html_id":"clear/Clear/SQL/Logger","kind":"module","full_name":"Clear::SQL::Logger","name":"Logger"}],"locations":[{"filename":"src/clear/sql/connection_pool.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L1"},{"filename":"src/clear/sql/errors.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L1"},{"filename":"src/clear/sql/fragment/column.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L9"},{"filename":"src/clear/sql/fragment/fragment.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L1"},{"filename":"src/clear/sql/fragment/from.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L3"},{"filename":"src/clear/sql/fragment/join.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L3"},{"filename":"src/clear/sql/lock.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/lock.cr#L2"},{"filename":"src/clear/sql/query/connection.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/connection.cr#L1"},{"filename":"src/clear/sql/query/from.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L1"},{"filename":"src/clear/sql/sql.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L50"},{"filename":"src/clear/sql/truncate.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/truncate.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Logger","kind":"module","full_name":"Clear::SQL::Logger","name":"Logger"},{"html_id":"clear/Clear/SQL/Transaction","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction"}],"extended_modules":[{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"\n## Clear::SQL\n\nClear is made like an onion:\n\n```\n+------------------------------------+\n| THE ORM STACK +\n+------------------------------------+\n| Model | DB Views | Migrations | < High Level Tools\n+---------------+--------------------+\n| Columns | Validation | Converters | < Mapping system\n+---------------+--------------------+\n| Clear::SQL | Clear::Expression | < Low Level SQL Builder\n+------------------------------------+\n| Crystal DB | Crystal PG | < Low Level connection\n+------------------------------------+\n```\n\nOn the bottom stack, Clear offer SQL query building.\nTheses features are then used by top level parts of the engine.\n\nThe SQL module provide a simple API to generate `delete`, `insert`, `select`\nand `update` methods.\n\nEach requests can be duplicated then modified and executed.\n\nNote: Each request object is mutable. Therefore, to update and store a request,\nyou must use manually the `dup` method.\n","summary":"Lock completetly a table.
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"String | Symbol"},{"name":"mode","default_value":"\"ACCESS EXCLUSIVE\"","external_name":"mode","restriction":""},{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":""}],"args_string":"(table : String | Symbol, mode = \"ACCESS EXCLUSIVE\", connection = \"default\", &)","args_html":"(table : String | Symbol, mode = "ACCESS EXCLUSIVE", connection = "default", &)","location":{"filename":"src/clear/sql/lock.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/lock.cr#L23"},"def":{"name":"lock","args":[{"name":"table","external_name":"table","restriction":"String | Symbol"},{"name":"mode","default_value":"\"ACCESS EXCLUSIVE\"","external_name":"mode","restriction":""},{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":""}],"yields":1,"block_arity":1,"visibility":"Public","body":"Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|\n transaction do\n execute(\"LOCK TABLE #{table} IN #{mode} MODE\")\n return yield(cnx)\n end\nend"}},{"html_id":"truncate(tablename:Clear::Model.class|String|Symbol,restart_sequence:Bool=false,cascade:Bool=false,truncate_inherited:Bool=true,connection_name:String=\"default\")forallT-class-method","name":"truncate","doc":"Truncate a table or a model\n\n```\nUser.query.count # => 200\nClear::SQL.truncate(User) # equivalent to Clear::SQL.truncate(User.table, connection_name: User.connection)\nUser.query.count # => 0\n```\n\nSEE https://www.postgresql.org/docs/current/sql-truncate.html\nfor more information.\n\n- `restart_sequence` set to true will append `RESTART IDENTITY` to the query\n- `cascade` set to true will append `CASCADE` to the query\n- `truncate_inherited` set to false will append `ONLY` to the query\n- `connection_name` will be: `Model.connection` or `default` unless optionally defined.","summary":"Truncate a table or a model
","abstract":false,"args":[{"name":"tablename","external_name":"tablename","restriction":"Clear::Model.class | String | Symbol"},{"name":"restart_sequence","default_value":"false","external_name":"restart_sequence","restriction":"Bool"},{"name":"cascade","default_value":"false","external_name":"cascade","restriction":"Bool"},{"name":"truncate_inherited","default_value":"true","external_name":"truncate_inherited","restriction":"Bool"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(tablename : Clear::Model.class | String | Symbol, restart_sequence : Bool = false, cascade : Bool = false, truncate_inherited : Bool = true, connection_name : String = \"default\") forall T","args_html":"(tablename : Clear::Model.class | String | Symbol, restart_sequence : Bool = false, cascade : Bool = false, truncate_inherited : Bool = true, connection_name : String = "default") forall T","location":{"filename":"src/clear/sql/truncate.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/truncate.cr#L18"},"def":{"name":"truncate","args":[{"name":"tablename","external_name":"tablename","restriction":"Clear::Model.class | String | Symbol"},{"name":"restart_sequence","default_value":"false","external_name":"restart_sequence","restriction":"Bool"},{"name":"cascade","default_value":"false","external_name":"cascade","restriction":"Bool"},{"name":"truncate_inherited","default_value":"true","external_name":"truncate_inherited","restriction":"Bool"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"visibility":"Public","body":"case tablename\nwhen String\nwhen Symbol\n tablename = Clear::SQL.escape(tablename.to_s)\nelse\n connection_name = tablename.connection\n tablename = tablename.full_table_name\nend\nonly = truncate_inherited ? \"\" : \" ONLY \"\nrestart_sequence = restart_sequence ? \" RESTART IDENTITY \" : \"\"\ncascade = cascade ? \" CASCADE \" : \"\"\nexecute(connection_name, {\"TRUNCATE TABLE \", only, tablename, restart_sequence, cascade}.join)\n"}}],"instance_methods":[{"html_id":"add_connection(name:String,url:String)-instance-method","name":"add_connection","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"args_string":"(name : String, url : String)","args_html":"(name : String, url : String)","location":{"filename":"src/clear/sql/sql.cr","line_number":125,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L125"},"def":{"name":"add_connection","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.init(url, name)"}},{"html_id":"delete(table:Symbolic)-instance-method","name":"delete","doc":"Start a DELETE table query","summary":"Start a DELETE table query
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"args_string":"(table : Symbolic)","args_html":"(table : Symbolic)","location":{"filename":"src/clear/sql/sql.cr","line_number":185,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L185"},"def":{"name":"delete","args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"visibility":"Public","body":"Clear::SQL::DeleteQuery.new.from(table)"}},{"html_id":"escape(x:String|Symbol)-instance-method","name":"escape","doc":"Escape the expression, double quoting it.\n\nIt allows use of reserved keywords as table or column name\nNOTE: Escape is used for escaping postgresql keyword. For example\nif you have a column named order (which is a reserved word), you want\nto escape it by double-quoting it.\n\nFor escaping STRING value, please use Clear::SQL.sanitize","summary":"Escape the expression, double quoting it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | Symbol"}],"args_string":"(x : String | Symbol)","args_html":"(x : String | Symbol)","location":{"filename":"src/clear/sql/sql.cr","line_number":103,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L103"},"def":{"name":"escape","args":[{"name":"x","external_name":"x","restriction":"String | Symbol"}],"visibility":"Public","body":"(\"\\\"\" + (x.to_s.gsub(\"\\\"\", \"\\\"\\\"\"))) + \"\\\"\""}},{"html_id":"execute(connection_name:String,sql)-instance-method","name":"execute","doc":"Execute a SQL statement on a specific connection.\n\nUsage:\nClear::SQL.execute(\"seconddatabase\", \"SELECT 1 FROM users\")","summary":"Execute a SQL statement on a specific connection.
","abstract":false,"args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"},{"name":"sql","external_name":"sql","restriction":""}],"args_string":"(connection_name : String, sql)","args_html":"(connection_name : String, sql)","location":{"filename":"src/clear/sql/sql.cr","line_number":175,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L175"},"def":{"name":"execute","args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"},{"name":"sql","external_name":"sql","restriction":""}],"visibility":"Public","body":"log_query(sql) do\n Clear::SQL::ConnectionPool.with_connection(connection_name, &.exec_all(sql))\nend"}},{"html_id":"execute(sql)-instance-method","name":"execute","doc":"Execute a SQL statement.\n\nUsage:\nClear::SQL.execute(\"SELECT 1 FROM users\")\n","summary":"Execute a SQL statement.
","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":""}],"args_string":"(sql)","args_html":"(sql)","location":{"filename":"src/clear/sql/sql.cr","line_number":167,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L167"},"def":{"name":"execute","args":[{"name":"sql","external_name":"sql","restriction":""}],"visibility":"Public","body":"execute(\"default\", sql)"}},{"html_id":"init(name:String,url:String)-instance-method","name":"init","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"args_string":"(name : String, url : String)","args_html":"(name : String, url : String)","location":{"filename":"src/clear/sql/sql.cr","line_number":115,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L115"},"def":{"name":"init","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.init(url, name)"}},{"html_id":"init(url:String)-instance-method","name":"init","abstract":false,"args":[{"name":"url","external_name":"url","restriction":"String"}],"args_string":"(url : String)","args_html":"(url : String)","location":{"filename":"src/clear/sql/sql.cr","line_number":111,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L111"},"def":{"name":"init","args":[{"name":"url","external_name":"url","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.init(url, \"default\")"}},{"html_id":"init(connections:Hash(Symbolic,String))-instance-method","name":"init","abstract":false,"args":[{"name":"connections","external_name":"connections","restriction":"Hash(Symbolic, String)"}],"args_string":"(connections : Hash(Symbolic, String))","args_html":"(connections : Hash(Symbolic, String))","location":{"filename":"src/clear/sql/sql.cr","line_number":119,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L119"},"def":{"name":"init","args":[{"name":"connections","external_name":"connections","restriction":"Hash(Symbolic, String)"}],"visibility":"Public","body":"connections.each do |name, url|\n Clear::SQL::ConnectionPool.init(url, name)\nend"}},{"html_id":"insert(table,args:NamedTuple)-instance-method","name":"insert","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"args","external_name":"args","restriction":"NamedTuple"}],"args_string":"(table, args : NamedTuple)","args_html":"(table, args : NamedTuple)","location":{"filename":"src/clear/sql/sql.cr","line_number":214,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L214"},"def":{"name":"insert","args":[{"name":"table","external_name":"table","restriction":""},{"name":"args","external_name":"args","restriction":"NamedTuple"}],"visibility":"Public","body":"insert_into(table, args)"}},{"html_id":"insert(table,*args)-instance-method","name":"insert","doc":"Alias of `insert_into`, for hurry developers","summary":"Alias of #insert_into
, for hurry developers
Create a new INSERT query
","abstract":false,"location":{"filename":"src/clear/sql/sql.cr","line_number":205,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L205"},"def":{"name":"insert","visibility":"Public","body":"Clear::SQL::InsertQuery.new"}},{"html_id":"insert_into(table:Symbolic)-instance-method","name":"insert_into","doc":"Prepare a new INSERT INTO table query\n:ditto:","summary":"Prepare a new INSERT INTO table query :ditto:
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"args_string":"(table : Symbolic)","args_html":"(table : Symbolic)","location":{"filename":"src/clear/sql/sql.cr","line_number":200,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L200"},"def":{"name":"insert_into","args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"visibility":"Public","body":"Clear::SQL::InsertQuery.new(table)"}},{"html_id":"insert_into(table:Symbolic,*args)-instance-method","name":"insert_into","doc":"Start an INSERT INTO table query\n\n```\nClear::SQL.insert_into(\"table\", {id: 1, name: \"hello\"}, {id: 2, name: \"World\"})\n```","summary":"Start an INSERT INTO table query
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbolic"},{"name":"args","external_name":"args","restriction":""}],"args_string":"(table : Symbolic, *args)","args_html":"(table : Symbolic, *args)","location":{"filename":"src/clear/sql/sql.cr","line_number":194,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L194"},"def":{"name":"insert_into","args":[{"name":"table","external_name":"table","restriction":"Symbolic"},{"name":"args","external_name":"args","restriction":""}],"splat_index":1,"visibility":"Public","body":"(Clear::SQL::InsertQuery.new(table)).values(*args)"}},{"html_id":"raw(x,*params)-instance-method","name":"raw","doc":"This provide a fast way to create SQL fragment while escaping items, both with `?` and `:key` system:\n\n```\nquery = Mode.query.select(Clear::SQL.raw(\"CASE WHEN x=:x THEN 1 ELSE 0 END as check\", x: \"blabla\"))\nquery = Mode.query.select(Clear::SQL.raw(\"CASE WHEN x=? THEN 1 ELSE 0 END as check\", \"blabla\"))\n```","summary":"This provide a fast way to create SQL fragment while escaping items, both with ?
and :key
system:
See self.raw
Can pass an array to this version
Raise a rollback, in case of transaction
","abstract":false,"location":{"filename":"src/clear/sql/sql.cr","line_number":158,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L158"},"def":{"name":"rollback","visibility":"Public","body":"raise(RollbackError.new)"}},{"html_id":"sanitize(x)-instance-method","name":"sanitize","doc":"Sanitize string and convert some literals (e.g. `Time`)","summary":"Sanitize string and convert some literals (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/sql/sql.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L71"},"def":{"name":"sanitize","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"Clear::Expression[x]"}},{"html_id":"select(*args)-instance-method","name":"select","doc":"Start a SELECT FROM table query","summary":"Start a SELECT FROM table query
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/sql.cr","line_number":224,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L224"},"def":{"name":"select","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"if args.size > 0\n Clear::SQL::SelectQuery.new.select(*args)\nelse\n Clear::SQL::SelectQuery.new\nend"}},{"html_id":"unsafe(x)-instance-method","name":"unsafe","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/sql/sql.cr","line_number":107,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L107"},"def":{"name":"unsafe","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"Clear::Expression::UnsafeSql.new(x)"}},{"html_id":"update(table)-instance-method","name":"update","doc":"Start a UPDATE table query","summary":"Start a UPDATE table query
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""}],"args_string":"(table)","args_html":"(table)","location":{"filename":"src/clear/sql/sql.cr","line_number":219,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L219"},"def":{"name":"update","args":[{"name":"table","external_name":"table","restriction":""}],"visibility":"Public","body":"Clear::SQL::UpdateQuery.new(table)"}},{"html_id":"with_savepoint(connection_name=\"default\",&)-instance-method","name":"with_savepoint","doc":"Create a transaction, but this one is stackable\nusing savepoints.\n\nExample:\n\n```\nClear::SQL.with_savepoint do\n # do something\n Clear::SQL.with_savepoint do\n rollback # < Rollback only the last `with_savepoint` block\n end\nend\n```","summary":"Create a transaction, but this one is stackable using savepoints.
","abstract":false,"args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":""}],"args_string":"(connection_name = \"default\", &)","args_html":"(connection_name = "default", &)","location":{"filename":"src/clear/sql/sql.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L144"},"def":{"name":"with_savepoint","args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"transaction do |cnx|\n sp_name = \"sp_#{@@savepoint_uid = @@savepoint_uid + 1}\"\n begin\n execute(connection_name, \"SAVEPOINT #{sp_name}\")\n yield\n if cnx._clear_in_transaction?\n execute(connection_name, \"RELEASE SAVEPOINT #{sp_name}\")\n end\n rescue e : RollbackError\n if cnx._clear_in_transaction?\n execute(connection_name, \"ROLLBACK TO SAVEPOINT #{sp_name}\")\n end\n end\nend"}}],"types":[{"html_id":"clear/Clear/SQL/Any","path":"Clear/SQL/Any.html","kind":"alias","full_name":"Clear::SQL::Any","name":"Any","abstract":false,"locations":[{"filename":"src/clear/sql/sql.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L56"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil)","aliased_html":"Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/CancelTransactionError","path":"Clear/SQL/CancelTransactionError.html","kind":"class","full_name":"Clear::SQL::CancelTransactionError","name":"CancelTransactionError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L16"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"Like rollback, but used into savepoint, it will revert completely the transaction","summary":"Like rollback, but used into savepoint, it will revert completely the transaction
"},{"html_id":"clear/Clear/SQL/Column","path":"Clear/SQL/Column.html","kind":"struct","full_name":"Clear::SQL::Column","name":"Column","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},"ancestors":[{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/column.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L10"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(value:Clear::SQL::SelectBuilder|String|Symbol,var:String|Symbol|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"args_string":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","args_html":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","location":{"filename":"src/clear/sql/fragment/column.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L14"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value, var)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/fragment/column.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L17"},"def":{"name":"to_sql","visibility":"Public","body":"v = value\ncase v\nwhen String\n [v, @var].compact.join(\" AS \")\nwhen Symbol\n [SQL.escape(v.to_s), @var].compact.join(\" AS \")\nwhen SQL::SelectBuilder\n [\"( #{v.to_sql} )\", @var].compact.join(\" AS \")\nelse\n raise(QueryBuildingError.new(\"Only String and SelectQuery are allowed as column declaration\"))\nend\n"}},{"html_id":"value:Selectable-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/sql/fragment/column.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L11"},"def":{"name":"value","return_type":"Selectable","visibility":"Public","body":"@value"}},{"html_id":"value=(value:Selectable)-instance-method","name":"value=","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"args_string":"(value : Selectable)","args_html":"(value : Selectable)","location":{"filename":"src/clear/sql/fragment/column.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L11"},"def":{"name":"value=","args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"visibility":"Public","body":"@value = value"}},{"html_id":"var:Symbolic|Nil-instance-method","name":"var","abstract":false,"location":{"filename":"src/clear/sql/fragment/column.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L12"},"def":{"name":"var","return_type":"Symbolic | ::Nil","visibility":"Public","body":"@var"}},{"html_id":"var=(var:Symbolic|Nil)-instance-method","name":"var=","abstract":false,"args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"args_string":"(var : Symbolic | Nil)","args_html":"(var : Symbolic | Nil)","location":{"filename":"src/clear/sql/fragment/column.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L12"},"def":{"name":"var=","args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"visibility":"Public","body":"@var = var"}}]},{"html_id":"clear/Clear/SQL/ConnectionPool","path":"Clear/SQL/ConnectionPool.html","kind":"class","full_name":"Clear::SQL::ConnectionPool","name":"ConnectionPool","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/connection_pool.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"class_methods":[{"html_id":"init(uri,name)-class-method","name":"init","abstract":false,"args":[{"name":"uri","external_name":"uri","restriction":""},{"name":"name","external_name":"name","restriction":""}],"args_string":"(uri, name)","args_html":"(uri, name)","location":{"filename":"src/clear/sql/connection_pool.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L6"},"def":{"name":"init","args":[{"name":"uri","external_name":"uri","restriction":""},{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"@@databases[name] = DB.open(uri)"}},{"html_id":"with_connection(target:String,&)-class-method","name":"with_connection","doc":"Retrieve a connection from the connection pool, or wait for it.\nIf the current Fiber already has a connection, the connection is returned;\n this strategy provides easy usage of multiple statement connection (like BEGIN/ROLLBACK features).","summary":"Retrieve a connection from the connection pool, or wait for it.
","abstract":false,"args":[{"name":"target","external_name":"target","restriction":"String"}],"args_string":"(target : String, &)","args_html":"(target : String, &)","location":{"filename":"src/clear/sql/connection_pool.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L13"},"def":{"name":"with_connection","args":[{"name":"target","external_name":"target","restriction":"String"}],"yields":1,"block_arity":1,"visibility":"Public","body":"fiber_target = {target, Fiber.current}\ndatabase = @@databases.fetch(target) do\n raise(Clear::ErrorMessages.uninitialized_db_connection(target))\nend\ncnx = @@fiber_connections[fiber_target]?\nif cnx\n yield cnx\nelse\n database.using_connection do |new_connection|\n begin\n @@fiber_connections[fiber_target] = new_connection\n yield new_connection\n ensure\n @@fiber_connections.delete(fiber_target)\n end\n end\nend\n"}}]},{"html_id":"clear/Clear/SQL/DeleteQuery","path":"Clear/SQL/DeleteQuery.html","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/delete_query.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(table:String|Symbol|Nil=nil,wheres:Array(Clear::Expression::Node)=[]ofClear::Expression::Node)-class-method","name":"new","abstract":false,"args":[{"name":"table","default_value":"nil","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"args_string":"(table : String | Symbol | Nil = nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","args_html":"(table : String | Symbol | Nil = nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","location":{"filename":"src/clear/sql/delete_query.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L11"},"def":{"name":"new","args":[{"name":"table","default_value":"nil","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, wheres)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"from(table:String|Symbol|Nil)-instance-method","name":"from","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"}],"args_string":"(table : String | Symbol | Nil)","args_html":"(table : String | Symbol | Nil)","location":{"filename":"src/clear/sql/delete_query.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L14"},"def":{"name":"from","args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"}],"visibility":"Public","body":"@table = table\nchange!\n"}},{"html_id":"table:Symbolic|Nil-instance-method","name":"table","abstract":false,"location":{"filename":"src/clear/sql/delete_query.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L4"},"def":{"name":"table","return_type":"Symbolic | ::Nil","visibility":"Public","body":"@table"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/delete_query.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L19"},"def":{"name":"to_sql","visibility":"Public","body":"if table = @table\nelse\n raise(Clear::ErrorMessages.query_building_error(\"Delete Query must have a `from` clause.\"))\nend\ntable = table.is_a?(Symbol) ? SQL.escape(table.to_s) : table\n[\"DELETE FROM\", table, print_wheres].compact.join(\" \")\n"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}]},{"html_id":"clear/Clear/SQL/Error","path":"Clear/SQL/Error.html","kind":"class","full_name":"Clear::SQL::Error","name":"Error","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"clear/Clear/SQL/CancelTransactionError","kind":"class","full_name":"Clear::SQL::CancelTransactionError","name":"CancelTransactionError"},{"html_id":"clear/Clear/SQL/ExecutionError","kind":"class","full_name":"Clear::SQL::ExecutionError","name":"ExecutionError"},{"html_id":"clear/Clear/SQL/OperationNotPermittedError","kind":"class","full_name":"Clear::SQL::OperationNotPermittedError","name":"OperationNotPermittedError"},{"html_id":"clear/Clear/SQL/QueryBuildingError","kind":"class","full_name":"Clear::SQL::QueryBuildingError","name":"QueryBuildingError"},{"html_id":"clear/Clear/SQL/RecordNotFoundError","kind":"class","full_name":"Clear::SQL::RecordNotFoundError","name":"RecordNotFoundError"},{"html_id":"clear/Clear/SQL/RollbackError","kind":"class","full_name":"Clear::SQL::RollbackError","name":"RollbackError"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/ExecutionError","path":"Clear/SQL/ExecutionError.html","kind":"class","full_name":"Clear::SQL::ExecutionError","name":"ExecutionError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/Fragment","path":"Clear/SQL/Fragment.html","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment","abstract":true,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/fragment.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"clear/Clear/SQL/Column","kind":"struct","full_name":"Clear::SQL::Column","name":"Column"},{"html_id":"clear/Clear/SQL/From","kind":"struct","full_name":"Clear::SQL::From","name":"From"},{"html_id":"clear/Clear/SQL/Join","kind":"struct","full_name":"Clear::SQL::Join","name":"Join"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/sql/fragment/fragment.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L2"},"def":{"name":"new","visibility":"Public","body":"x = allocate\nif x.responds_to?(:finalize)\n ::GC.add_finalizer(x)\nend\nx\n"}}],"instance_methods":[{"html_id":"initialize-instance-method","name":"initialize","abstract":false,"location":{"filename":"src/clear/sql/fragment/fragment.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L2"},"def":{"name":"initialize","visibility":"Public","body":""}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":true,"location":{"filename":"src/clear/sql/fragment/fragment.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L3"},"def":{"name":"to_sql","visibility":"Public","body":""}}]},{"html_id":"clear/Clear/SQL/From","path":"Clear/SQL/From.html","kind":"struct","full_name":"Clear::SQL::From","name":"From","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},"ancestors":[{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/from.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(value:Clear::SQL::SelectBuilder|String|Symbol,var:String|Symbol|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"args_string":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","args_html":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","location":{"filename":"src/clear/sql/fragment/from.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L8"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value, var)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/fragment/from.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L11"},"def":{"name":"to_sql","visibility":"Public","body":"v = value\ncase v\nwhen Symbol\n [Clear::SQL.escape(v), @var].compact.join(\" AS \")\nwhen String\n [v, @var].compact.join(\" AS \")\nwhen SQL::SelectBuilder\n if @var.nil?\n raise(Clear::ErrorMessages.query_building_error(\"Subquery `from` clause must have variable name\"))\n end\n [\"(#{v.to_sql})\", @var].compact.join(\" \")\nelse\n raise(Clear::ErrorMessages.query_building_error(\"Only String and SelectQuery objects are allowed as `from` declaration\"))\nend\n"}},{"html_id":"value:Selectable-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/sql/fragment/from.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L5"},"def":{"name":"value","return_type":"Selectable","visibility":"Public","body":"@value"}},{"html_id":"value=(value:Selectable)-instance-method","name":"value=","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"args_string":"(value : Selectable)","args_html":"(value : Selectable)","location":{"filename":"src/clear/sql/fragment/from.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L5"},"def":{"name":"value=","args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"visibility":"Public","body":"@value = value"}},{"html_id":"var:Symbolic|Nil-instance-method","name":"var","abstract":false,"location":{"filename":"src/clear/sql/fragment/from.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L6"},"def":{"name":"var","return_type":"Symbolic | ::Nil","visibility":"Public","body":"@var"}},{"html_id":"var=(var:Symbolic|Nil)-instance-method","name":"var=","abstract":false,"args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"args_string":"(var : Symbolic | Nil)","args_html":"(var : Symbolic | Nil)","location":{"filename":"src/clear/sql/fragment/from.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L6"},"def":{"name":"var=","args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"visibility":"Public","body":"@var = var"}}]},{"html_id":"clear/Clear/SQL/InsertQuery","path":"Clear/SQL/InsertQuery.html","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/OnConflict","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/insert_query.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L18"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/OnConflict","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"\nAn insert query\n\ncf. postgres documentation\n\n```\n[ WITH [ RECURSIVE ] with_query [, ...] ]\nINSERT INTO table_name [ AS alias ] [ ( column_name [, ...] ) ]\n { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }\n [ ON CONFLICT [ conflict_target ] conflict_action ]\n [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]\n```","summary":"An insert query
","constructors":[{"html_id":"new(table:Symbol|String,values)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbol | String"},{"name":"values","external_name":"values","restriction":""}],"args_string":"(table : Symbol | String, values)","args_html":"(table : Symbol | String, values)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L33"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"Symbol | String"},{"name":"values","external_name":"values","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, values)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(table:Symbol|String)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"args_string":"(table : Symbol | String)","args_html":"(table : Symbol | String)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L30"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clear_values-instance-method","name":"clear_values","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":85,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L85"},"def":{"name":"clear_values","visibility":"Public","body":"@values = [] of Array(Inserable)\nchange!\n"}},{"html_id":"columns(*args:Array(String|Symbol))-instance-method","name":"columns","doc":"Used with values","summary":"Used with values
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":"::Array(::String | ::Symbol)"}],"args_string":"(*args : Array(String | Symbol))","args_html":"(*args : Array(String | Symbol))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":138,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L138"},"def":{"name":"columns","args":[{"name":"args","external_name":"args","restriction":"::Array(::String | ::Symbol)"}],"splat_index":0,"visibility":"Public","body":"@keys = args\nchange!\n"}},{"html_id":"execute(connection_name:String=\"default\"):Hash(String,Clear::SQL::Any)-instance-method","name":"execute","abstract":false,"args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(connection_name : String = \"default\") : Hash(String, Clear::SQL::Any)","args_html":"(connection_name : String = "default") : Hash(String, Clear::SQL::Any)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L71"},"def":{"name":"execute","args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"o = {} of String => ::Clear::SQL::Any\nif @returning.nil?\n s = to_sql\n Clear::SQL.execute(connection_name, s)\nelse\n fetch(connection_name) do |x|\n o = x\n end\nend\no\n"}},{"html_id":"fetch(connection_name:String=\"default\",&:Hash(String,Clear::SQL::Any)->Nil)-instance-method","name":"fetch","abstract":false,"args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(connection_name : String = \"default\", & : Hash(String, Clear::SQL::Any) -> Nil)","args_html":"(connection_name : String = "default", & : Hash(String, Clear::SQL::Any) -> Nil)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L40"},"def":{"name":"fetch","args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(Hash(String, ::Clear::SQL::Any) -> Nil)"},"visibility":"Public","body":"h = {} of String => ::Clear::SQL::Any\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n sql = to_sql\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n fetch_result_set(h, rs) do |x|\n yield(x)\n end\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"into(table:Symbol|String)-instance-method","name":"into","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"args_string":"(table : Symbol | String)","args_html":"(table : Symbol | String)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L37"},"def":{"name":"into","args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"visibility":"Public","body":"@table = table"}},{"html_id":"keys:Array(Symbolic)-instance-method","name":"keys","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L25"},"def":{"name":"keys","return_type":"Array(Symbolic)","visibility":"Public","body":"@keys"}},{"html_id":"returning(str:String)-instance-method","name":"returning","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String)","args_html":"(str : String)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":161,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L161"},"def":{"name":"returning","args":[{"name":"str","external_name":"str","restriction":"String"}],"visibility":"Public","body":"@returning = str\nchange!\n"}},{"html_id":"returning:String|Nil-instance-method","name":"returning","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L28"},"def":{"name":"returning","return_type":"String | ::Nil","visibility":"Public","body":"@returning"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Number of rows of this insertion request","summary":"Number of rows of this insertion request
","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":168,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L168"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"v = @values\nv.is_a?(Array) ? v.size : -1\n"}},{"html_id":"table:Symbol|String-instance-method","name":"table","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L27"},"def":{"name":"table","return_type":"Symbol | String","visibility":"Public","body":"if (__temp_1 = @table).nil?\n ::raise(::NilAssertionError.new(\"Clear::SQL::InsertQuery#table cannot be nil\"))\nelse\n __temp_1\nend"}},{"html_id":"table?:Symbol|String|Nil-instance-method","name":"table?","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L27"},"def":{"name":"table?","return_type":"Symbol | String | ::Nil","visibility":"Public","body":"@table"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":187,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L187"},"def":{"name":"to_sql","visibility":"Public","body":"if table = @table\nelse\n raise(QueryBuildingError.new(\"You must provide a `into` clause\"))\nend\ntable = table.is_a?(Symbol) ? Clear::SQL.escape(table) : table\no = [print_ctes, \"INSERT INTO\", table, print_keys]\nv = @values\ncase v\nwhen SelectBuilder\n o << ((\"(\" + v.to_sql) + \")\")\nelse\n if v.empty? || ((v.size == 1) && v[0].empty?)\n o << \"DEFAULT VALUES\"\n else\n o << \"VALUES\"\n o << print_values\n end\nend\nprint_on_conflict(o)\nif @returning\n o << \"RETURNING\"\n o << @returning\nend\no.compact.join(\" \")\n"}},{"html_id":"values(row:Hash(Symbolic,Inserable))-instance-method","name":"values","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"Hash(Symbolic, Inserable)"}],"args_string":"(row : Hash(Symbolic, Inserable))","args_html":"(row : Hash(Symbolic, Inserable))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L108"},"def":{"name":"values","args":[{"name":"row","external_name":"row","restriction":"Hash(Symbolic, Inserable)"}],"visibility":"Public","body":"@keys = row.keys.to_a.map() do |__arg3|\n __arg3.as(Symbolic)\nend\ncase v = @values\nwhen Array(Array(Inserable))\n v << row.values.to_a.map() do |__arg4|\n __arg4.as(Inserable)\n end\nelse\n raise(\"Cannot insert both from SELECT query and from data\")\nend\nchange!\n"}},{"html_id":"values(rows:Array(Hash(Symbolic,Inserable)))-instance-method","name":"values","abstract":false,"args":[{"name":"rows","external_name":"rows","restriction":"Array(Hash(Symbolic, Inserable))"}],"args_string":"(rows : Array(Hash(Symbolic, Inserable)))","args_html":"(rows : Array(Hash(Symbolic, Inserable)))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":129,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L129"},"def":{"name":"values","args":[{"name":"rows","external_name":"rows","restriction":"Array(Hash(Symbolic, Inserable))"}],"visibility":"Public","body":"rows.each do |nt|\n values(nt)\nend\nchange!\n"}},{"html_id":"values(row:NamedTuple)-instance-method","name":"values","doc":"Fast insert system\n\ninsert({field: \"value\"}).into(:table)\n","summary":"Fast insert system
","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"args_string":"(row : NamedTuple)","args_html":"(row : NamedTuple)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L95"},"def":{"name":"values","args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"visibility":"Public","body":"@keys = row.keys.to_a.map() do |__arg1|\n __arg1.as(Symbolic)\nend\ncase v = @values\nwhen Array(Array(Inserable))\n v << row.values.to_a.map() do |__arg2|\n __arg2.as(Inserable)\n end\nelse\n raise(\"Cannot insert both from SELECT query and from data\")\nend\nchange!\n"}},{"html_id":"values(rows:Array(NamedTuple))-instance-method","name":"values","abstract":false,"args":[{"name":"rows","external_name":"rows","restriction":"Array(NamedTuple)"}],"args_string":"(rows : Array(NamedTuple))","args_html":"(rows : Array(NamedTuple))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":121,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L121"},"def":{"name":"values","args":[{"name":"rows","external_name":"rows","restriction":"Array(NamedTuple)"}],"visibility":"Public","body":"rows.each do |nt|\n values(nt)\nend\nchange!\n"}},{"html_id":"values(select_query:SelectBuilder)-instance-method","name":"values","doc":"Insert into ... (...) SELECT","summary":"Insert into ...
","abstract":false,"args":[{"name":"select_query","external_name":"select_query","restriction":"SelectBuilder"}],"args_string":"(select_query : SelectBuilder)","args_html":"(select_query : SelectBuilder)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":151,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L151"},"def":{"name":"values","args":[{"name":"select_query","external_name":"select_query","restriction":"SelectBuilder"}],"visibility":"Public","body":"if @values.is_a?(Array) && (@values.as(Array)).present?\n raise(QueryBuildingError.new(\"Cannot insert both from SELECT and from data\"))\nend\n@values = select_query\nchange!\n"}},{"html_id":"values:SelectBuilder|Array(Array(Inserable))-instance-method","name":"values","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L26"},"def":{"name":"values","return_type":"SelectBuilder | Array(Array(Inserable))","visibility":"Public","body":"@values"}},{"html_id":"values(*args)-instance-method","name":"values","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L144"},"def":{"name":"values","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"@values << args\nchange!\n"}}],"types":[{"html_id":"clear/Clear/SQL/InsertQuery/Inserable","path":"Clear/SQL/InsertQuery/Inserable.html","kind":"alias","full_name":"Clear::SQL::InsertQuery::Inserable","name":"Inserable","abstract":false,"locations":[{"filename":"src/clear/sql/insert_query.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L24"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil)","aliased_html":"Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"}}]},{"html_id":"clear/Clear/SQL/Join","path":"Clear/SQL/Join.html","kind":"struct","full_name":"Clear::SQL::Join","name":"Join","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},"ancestors":[{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/join.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"TYPE","name":"TYPE","value":"{left: \"LEFT JOIN\", inner: \"INNER JOIN\", right: \"RIGHT JOIN\", full_outer: \"FULL OUTER JOIN\", cross: \"CROSS JOIN\"}"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(from:Clear::SQL::SelectBuilder|String|Symbol,condition:Clear::Expression::Node|Nil=nil,lateral:Bool=false,type:Symbol=:inner)-class-method","name":"new","abstract":false,"args":[{"name":"from","external_name":"from","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"condition","default_value":"nil","external_name":"condition","restriction":"::Clear::Expression::Node | ::Nil"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":"::Bool"},{"name":"type","default_value":":inner","external_name":"type","restriction":"Symbol"}],"args_string":"(from : Clear::SQL::SelectBuilder | String | Symbol, condition : Clear::Expression::Node | Nil = nil, lateral : Bool = false, type : Symbol = :inner)","args_html":"(from : Clear::SQL::SelectBuilder | String | Symbol, condition : Clear::Expression::Node | Nil = nil, lateral : Bool = false, type : Symbol = :inner)","location":{"filename":"src/clear/sql/fragment/join.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L16"},"def":{"name":"new","args":[{"name":"from","external_name":"from","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"condition","default_value":"nil","external_name":"condition","restriction":"::Clear::Expression::Node | ::Nil"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":"::Bool"},{"name":"type","default_value":":inner","external_name":"type","restriction":"Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(from, condition, lateral, type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"condition:Clear::Expression::Node|Nil-instance-method","name":"condition","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L13"},"def":{"name":"condition","return_type":"Clear::Expression::Node | ::Nil","visibility":"Public","body":"@condition"}},{"html_id":"from:Selectable-instance-method","name":"from","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L12"},"def":{"name":"from","return_type":"Selectable","visibility":"Public","body":"@from"}},{"html_id":"lateral?:Bool-instance-method","name":"lateral?","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L14"},"def":{"name":"lateral?","return_type":"Bool","visibility":"Public","body":"@lateral"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L20"},"def":{"name":"to_sql","visibility":"Public","body":"from = @from\nfrom = case from\nwhen SQL::SelectBuilder\n \"(#{from.to_sql})\"\nelse\n from.to_s\nend\nif c = @condition\n [type, lateral? ? \"LATERAL\" : nil, from, \"ON\", c.resolve].compact.join(\" \")\nelse\n [type, lateral? ? \"LATERAL\" : nil, SQL.sel_str(from)].compact.join(\" \")\nend\n"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L11"},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"clear/Clear/SQL/JSONB","path":"Clear/SQL/JSONB.html","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L32"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}],"including_types":[{"html_id":"clear/Clear/Expression/Node/JSONB/Equality","kind":"class","full_name":"Clear::Expression::Node::JSONB::Equality","name":"Equality"},{"html_id":"clear/Clear/Expression/Node/JSONB/Field","kind":"class","full_name":"Clear::Expression::Node::JSONB::Field","name":"Field"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"instance_methods":[{"html_id":"jsonb_all_exists?(field,keys:Array(String))-instance-method","name":"jsonb_all_exists?","doc":"jsonb `?&` operator\nDo all of these array strings exist as top-level keys?","summary":"jsonb ?&
operator Do all of these array strings exist as top-level keys?
jsonb ?|
operator Do any of these array strings exist as top-level keys?
Test equality using the @>
operator
Does the string exist as a top-level key within the JSON value?
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"value","external_name":"value","restriction":""}],"args_string":"(field, value)","args_html":"(field, value)","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L50"},"def":{"name":"jsonb_exists?","args":[{"name":"field","external_name":"field","restriction":""},{"name":"value","external_name":"value","restriction":""}],"visibility":"Public","body":"{field, Clear::SQL.sanitize(value)}.join(\" ? \")"}},{"html_id":"jsonb_k2h(key:String,value:JSONBKey):JSONBHash-instance-method","name":"jsonb_k2h","doc":"Transform a key to a hash","summary":"Transform a key to a hash
","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"JSONBKey"}],"args_string":"(key : String, value : JSONBKey) : JSONBHash","args_html":"(key : String, value : JSONBKey) : JSONBHash","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L39"},"def":{"name":"jsonb_k2h","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"JSONBKey"}],"return_type":"JSONBHash","visibility":"Public","body":"jsonb_arr2h(jsonb_k2a(key), value)"}},{"html_id":"jsonb_resolve(field,arr:Array(String),cast=nil):String-instance-method","name":"jsonb_resolve","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"arr","external_name":"arr","restriction":"Array(String)"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"args_string":"(field, arr : Array(String), cast = nil) : String","args_html":"(field, arr : Array(String), cast = nil) : String","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":122,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L122"},"def":{"name":"jsonb_resolve","args":[{"name":"field","external_name":"field","restriction":""},{"name":"arr","external_name":"arr","restriction":"Array(String)"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"return_type":"String","visibility":"Public","body":"if arr.empty?\n return field\nend\no = ([field] + Clear::Expression[arr]).join(\"->\")\nif cast\n o = \"(#{o})::#{cast}\"\nend\no\n"}},{"html_id":"jsonb_resolve(field,key:String,cast=nil)-instance-method","name":"jsonb_resolve","doc":"Return text selector for the field/key :\n\n```\njsonb_text(\"data\", \"sub.key\").like(\"user%\")\n# => \"data->'sub'->>'key' LIKE 'user%'\"\n```","summary":"Return text selector for the field/key :
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"key","external_name":"key","restriction":"String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"args_string":"(field, key : String, cast = nil)","args_html":"(field, key : String, cast = nil)","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":138,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L138"},"def":{"name":"jsonb_resolve","args":[{"name":"field","external_name":"field","restriction":""},{"name":"key","external_name":"key","restriction":"String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"visibility":"Public","body":"arr = jsonb_k2a(key)\njsonb_resolve(field, arr, cast)\n"}}],"types":[{"html_id":"clear/Clear/SQL/JSONB/JSONBHash","path":"Clear/SQL/JSONB/JSONBHash.html","kind":"alias","full_name":"Clear::SQL::JSONB::JSONBHash","name":"JSONBHash","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L36"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Hash(String, Clear::SQL::JSONB::JSONBKey)","aliased_html":"Hash(String, Clear::SQL::JSONB::JSONBKey)","const":false,"namespace":{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}},{"html_id":"clear/Clear/SQL/JSONB/JSONBKey","path":"Clear/SQL/JSONB/JSONBKey.html","kind":"alias","full_name":"Clear::SQL::JSONB::JSONBKey","name":"JSONBKey","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L35"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Bool | Clear::Expression::Literal | Float32 | Float64 | Hash(String, Clear::SQL::JSONB::JSONBKey) | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)","aliased_html":"Bool | Clear::Expression::Literal | Float32 | Float64 | Hash(String, Clear::SQL::JSONB::JSONBKey) | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}}]},{"html_id":"clear/Clear/SQL/Logger","path":"Clear/SQL/Logger.html","kind":"module","full_name":"Clear::SQL::Logger","name":"Logger","abstract":false,"locations":[{"filename":"src/clear/sql/logger.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"class_methods":[{"html_id":"colorize=(colorize:Bool)-class-method","name":"colorize=","abstract":false,"args":[{"name":"colorize","external_name":"colorize","restriction":"Bool"}],"args_string":"(colorize : Bool)","args_html":"(colorize : Bool)","location":{"filename":"src/clear/sql/logger.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L5"},"def":{"name":"colorize=","args":[{"name":"colorize","external_name":"colorize","restriction":"Bool"}],"visibility":"Public","body":"@@colorize = colorize"}},{"html_id":"colorize?:Bool-class-method","name":"colorize?","abstract":false,"location":{"filename":"src/clear/sql/logger.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L5"},"def":{"name":"colorize?","return_type":"Bool","visibility":"Public","body":"@@colorize"}},{"html_id":"colorize_query(qry:String)-class-method","name":"colorize_query","abstract":false,"args":[{"name":"qry","external_name":"qry","restriction":"String"}],"args_string":"(qry : String)","args_html":"(qry : String)","location":{"filename":"src/clear/sql/logger.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L21"},"def":{"name":"colorize_query","args":[{"name":"qry","external_name":"qry","restriction":"String"}],"visibility":"Public","body":"if @@colorize\nelse\n return qry\nend\no = (qry.to_s.split(/([a-zA-Z0-9_]+)/)).join(\"\") do |word|\n if SQL_KEYWORDS.includes?(word.upcase)\n word.colorize.bold.blue.to_s\n else\n if word =~ (/\\d+/)\n word.colorize.red\n else\n word.colorize.white\n end\n end\nend\no.gsub(/(--.*)$/) do |__arg0|\n __arg0.colorize.dark_gray\nend\n"}},{"html_id":"display_mn_sec(x):String-class-method","name":"display_mn_sec","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : String","args_html":"(x) : String","location":{"filename":"src/clear/sql/logger.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L37"},"def":{"name":"display_mn_sec","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"String","visibility":"Public","body":"mn = x.to_i / 60\nsc = x.to_i % 60\n({mn > 9 ? mn : \"0#{mn}\", sc > 9 ? sc : \"0#{sc}\"}.join(\"mn\")) + \"s\"\n"}},{"html_id":"display_time(x):String-class-method","name":"display_time","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : String","args_html":"(x) : String","location":{"filename":"src/clear/sql/logger.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L44"},"def":{"name":"display_time","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"String","visibility":"Public","body":"if x > 60\n display_mn_sec(x)\nelse\n if x > 1\n (\"%.2f\" % x) + \"s\"\n else\n if x > 0.001\n (1000 * x).to_i.to_s + \"ms\"\n else\n (1000000 * x).to_i.to_s + \"µs\"\n end\n end\nend"}}],"instance_methods":[{"html_id":"log_query(sql,&)-instance-method","name":"log_query","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":""}],"args_string":"(sql, &)","args_html":"(sql, &)","location":{"filename":"src/clear/sql/logger.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L56"},"def":{"name":"log_query","args":[{"name":"sql","external_name":"sql","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"begin\n start_time = Time.monotonic\n o = yield\n elapsed_time = Time.monotonic - start_time\n Log.debug do\n (\"[\" + (Clear::SQL::Logger.display_time(elapsed_time.to_f)).colorize.bold.white.to_s) + \"] #{SQL::Logger.colorize_query(sql)}\"\n end\n o\nrescue e\n raise(Clear::SQL::Error.new(message: [e.message, \"Error caught, last query was:\", Clear::SQL::Logger.colorize_query(sql)].compact.join(\"\\n\"), cause: e))\nend"}}]},{"html_id":"clear/Clear/SQL/OperationNotPermittedError","path":"Clear/SQL/OperationNotPermittedError.html","kind":"class","full_name":"Clear::SQL::OperationNotPermittedError","name":"OperationNotPermittedError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/Query","path":"Clear/SQL/Query.html","kind":"module","full_name":"Clear::SQL::Query","name":"Query","abstract":false,"locations":[{"filename":"src/clear/sql/query/aggregate.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"types":[{"html_id":"clear/Clear/SQL/Query/Aggregate","path":"Clear/SQL/Query/Aggregate.html","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate","abstract":false,"locations":[{"filename":"src/clear/sql/query/aggregate.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"agg(field,x:X.class)forallX-instance-method","name":"agg","doc":"Call an custom aggregation function, like MEDIAN or other:\n\n```\nquery.agg(\"MEDIAN(age)\", Int64)\n```\n\nNote than COUNT, MIN, MAX, SUM and AVG are already conveniently mapped.\n\nThis return only one row, and should not be used with `group_by` (prefer pluck or fetch)","summary":"Call an custom aggregation function, like MEDIAN or other:
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L38"},"def":{"name":"agg","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"(clear_select.select(field)).scalar(X)"}},{"html_id":"avg(field,x:X.class)forallX-instance-method","name":"avg","doc":"SQL aggregation function \"AVG\":\n\n```\nquery.avg(\"field\", Int64)\n```","summary":"SQL aggregation function "AVG":
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L48"},"def":{"name":"avg","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"agg(\"AVG(#{field})\", X)"}},{"html_id":"count(type:X.class=Int64)forallX-instance-method","name":"count","doc":"Use SQL `COUNT` over your query, and return this number as a Int64\n\nas count return always a scalar, the usage of `COUNT(*) OVER GROUP BY` can be done by\nusing `pluck` or `select`","summary":"Use SQL COUNT
over your query, and return this number as a Int64
SQL aggregation function "MAX":
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L48"},"def":{"name":"max","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"agg(\"MAX(#{field})\", X)"}},{"html_id":"min(field,x:X.class)forallX-instance-method","name":"min","doc":"SQL aggregation function \"MIN\":\n\n```\nquery.min(\"field\", Int64)\n```","summary":"SQL aggregation function "MIN":
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L48"},"def":{"name":"min","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"agg(\"MIN(#{field})\", X)"}},{"html_id":"sum(field):Float64-instance-method","name":"sum","doc":"SUM through a field and return a Float64\nNote: This function is not safe injection-wise, so beware !.","summary":"SUM through a field and return a Float64 Note: This function is not safe injection-wise, so beware !.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""}],"args_string":"(field) : Float64","args_html":"(field) : Float64","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L44"},"def":{"name":"sum","args":[{"name":"field","external_name":"field","restriction":""}],"return_type":"Float64","visibility":"Public","body":"(agg(\"SUM(#{field})\", Union(Int64 | PG::Numeric | Nil))).try(&.to_f) || 0.0"}}]},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","path":"Clear/SQL/Query/BeforeQuery.html","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery","abstract":false,"locations":[{"filename":"src/clear/sql/query/before_query.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/before_query.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"}},{"html_id":"clear/Clear/SQL/Query/Change","path":"Clear/SQL/Query/Change.html","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change","abstract":false,"locations":[{"filename":"src/clear/sql/query/change.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/change.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/DeleteQuery","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery"},{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"change!:self-instance-method","name":"change!","doc":"This method is called everytime the request has been changed\nBy default, this do nothing and return `self`. However, it can be\nreimplemented to change some behavior when the query is changed\n\n(eg. it is by `Clear::Model::Collection`, to discard cache over collection)","summary":"This method is called everytime the request has been changed By default, this do nothing and return self
.
Connection used by the query.
","abstract":false,"location":{"filename":"src/clear/sql/query/connection.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/connection.cr#L5"},"def":{"name":"connection_name","return_type":"String","visibility":"Public","body":"@connection_name"}},{"html_id":"use_connection(connection_name:String)-instance-method","name":"use_connection","doc":"Change the connection used by the query on execution","summary":"Change the connection used by the query on execution
","abstract":false,"args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"}],"args_string":"(connection_name : String)","args_html":"(connection_name : String)","location":{"filename":"src/clear/sql/query/connection.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/connection.cr#L8"},"def":{"name":"use_connection","args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"}],"visibility":"Public","body":"@connection_name = connection_name\nself\n"}}]},{"html_id":"clear/Clear/SQL/Query/CTE","path":"Clear/SQL/Query/CTE.html","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE","abstract":false,"locations":[{"filename":"src/clear/sql/query/cte.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"doc":"Allow usage of Common Table Expressions (CTE) in the query building","summary":"Allow usage of Common Table Expressions (CTE) in the query building
","instance_methods":[{"html_id":"cte:Hash(String,CTEAuthorized)-instance-method","name":"cte","doc":"List the current CTE of the query. The key is the name of the CTE,\nwhile the value is the fragment (string or Sub-select)","summary":"List the current CTE of the query.
","abstract":false,"location":{"filename":"src/clear/sql/query/cte.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L8"},"def":{"name":"cte","return_type":"Hash(String, CTEAuthorized)","visibility":"Public","body":"@cte"}},{"html_id":"with_cte(name,request:CTEAuthorized)-instance-method","name":"with_cte","doc":"Add a CTE to the query.\n\n```\nClear::SQL.select.with_cte(\"full_year\",\n \"SELECT DATE(date)\"\n \"FROM generate_series(NOW() - INTERVAL '1 year', NOW(), '1 day'::interval) date\")\n .select(\"*\").from(\"full_year\")\n# WITH full_year AS ( SELECT DATE(date) ... ) SELECT * FROM full_year;\n```","summary":"Add a CTE to the query.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"request","external_name":"request","restriction":"CTEAuthorized"}],"args_string":"(name, request : CTEAuthorized)","args_html":"(name, request : CTEAuthorized)","location":{"filename":"src/clear/sql/query/cte.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L19"},"def":{"name":"with_cte","args":[{"name":"name","external_name":"name","restriction":""},{"name":"request","external_name":"request","restriction":"CTEAuthorized"}],"visibility":"Public","body":"cte[name] = request\nchange!\n"}},{"html_id":"with_cte(tuple:NamedTuple)-instance-method","name":"with_cte","doc":"Add a CTE to the query. Use NamedTuple convention:\n\n```\nClear::SQL.select.with_cte(cte: \"xxx\")\n# WITH cte AS xxx SELECT...\n```","summary":"Add a CTE to the query.
","abstract":false,"args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"args_string":"(tuple : NamedTuple)","args_html":"(tuple : NamedTuple)","location":{"filename":"src/clear/sql/query/cte.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L30"},"def":{"name":"with_cte","args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"visibility":"Public","body":"tuple.each do |k, v|\n cte[k.to_s] = v\nend\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/Execute","path":"Clear/SQL/Query/Execute.html","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute","abstract":false,"locations":[{"filename":"src/clear/sql/query/execute.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/execute.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/DeleteQuery","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"execute(connection_name:String|Nil=nil)-instance-method","name":"execute","doc":"\nExecute an SQL statement which does not return anything.\n\nIf an optional `connection_name` parameter is given, this will\n override the connection used by the query.\n\n```\n%(default secondary).each do |cnx|\n Clear::SQL.select(\"pg_shards('xxx')\").execute(cnx)\nend\n```","summary":"Execute an SQL statement which does not return anything.
","abstract":false,"args":[{"name":"connection_name","default_value":"nil","external_name":"connection_name","restriction":"String | ::Nil"}],"args_string":"(connection_name : String | Nil = nil)","args_html":"(connection_name : String | Nil = nil)","location":{"filename":"src/clear/sql/query/execute.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/execute.cr#L15"},"def":{"name":"execute","args":[{"name":"connection_name","default_value":"nil","external_name":"connection_name","restriction":"String | ::Nil"}],"visibility":"Public","body":"Clear::SQL.execute(connection_name || self.connection_name, to_sql)"}}]},{"html_id":"clear/Clear/SQL/Query/Fetch","path":"Clear/SQL/Query/Fetch.html","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch","abstract":false,"locations":[{"filename":"src/clear/sql/query/fetch.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"fetch(fetch_all=false,&:Hash(String,Clear::SQL::Any)->Nil)-instance-method","name":"fetch","doc":"Fetch the result set row per row\n`fetch_all` optional parameter is helpful in transactional environment, so it stores\nthe result and close the resultset before starting to call yield over the data\npreventing creation of a new connection if you need to call SQL into the\nyielded block.\n\n```\n# This is wrong: The connection is still busy retrieving the users:\nClear::SQL.select.from(\"users\").fetch do |u|\n Clear::SQL.select.from(\"posts\").where { u[\"id\"] == posts.id }\nend\n\n# Instead, use `fetch_all`\n# Clear will store the value of the result set in memory\n# before calling the block, and the connection is now ready to handle\n# another query.\nClear::SQL.select.from(\"users\").fetch(fetch_all: true) do |u|\n Clear::SQL.select.from(\"posts\").where { u[\"id\"] == posts.id }\nend\n```","summary":"Fetch the result set row per row fetch_all
optional parameter is helpful in transactional environment, so it stores the result and close the resultset before starting to call yield over the data preventing creation of a new connection if you need to call SQL into the yielded block.
Alias for #first
because first is redefined in Collection::Base object to return a model instead.
Fetch the data using CURSOR.
","abstract":false,"args":[{"name":"count","default_value":"1000","external_name":"count","restriction":""}],"args_string":"(count = 1000, & : Hash(String, Clear::SQL::Any) -> Nil)","args_html":"(count = 1000, & : Hash(String, Clear::SQL::Any) -> Nil)","location":{"filename":"src/clear/sql/query/fetch.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L24"},"def":{"name":"fetch_with_cursor","args":[{"name":"count","default_value":"1000","external_name":"count","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(Hash(String, ::Clear::SQL::Any) -> Nil)"},"visibility":"Public","body":"trigger_before_query\nClear::SQL.transaction do |cnx|\n cursor_name = \"__cursor_#{Time.local.to_unix ^ (rand * 268435455).to_i}__\"\n cursor_declaration = \"DECLARE #{cursor_name} CURSOR FOR #{to_sql}\"\n Clear::SQL.log_query(cursor_declaration) do\n cnx.exec(cursor_declaration)\n end\n h = {} of String => ::Clear::SQL::Any\n we_loop = true\n while we_loop\n fetch_query = \"FETCH #{count} FROM #{cursor_name}\"\n rs = Clear::SQL.log_query(fetch_query) do\n cnx.query(fetch_query)\n end\n o = Array(Hash(String, ::Clear::SQL::Any)).new(initial_capacity: count)\n we_loop = fetch_result_set(h, rs) do |x|\n o << x.dup\n end\n o.each do |hash|\n yield(hash)\n end\n end\nend\n"}},{"html_id":"first-instance-method","name":"first","doc":"Return the first line of the query as Hash(String, ::Clear::SQL::Any), or nil\nif not found","summary":"Return the first line of the query as Hash(String, ::Clear::SQL::Any), or nil if not found
","abstract":false,"location":{"filename":"src/clear/sql/query/fetch.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L65"},"def":{"name":"first","visibility":"Public","body":"fetch_first"}},{"html_id":"first!-instance-method","name":"first!","abstract":false,"location":{"filename":"src/clear/sql/query/fetch.cr","line_number":69,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L69"},"def":{"name":"first!","visibility":"Public","body":"fetch_first!"}},{"html_id":"scalar(type:T.class)forallT-instance-method","name":"scalar","doc":"Helpers to fetch a SELECT with only one row and one column return.","summary":"Helpers to fetch a SELECT with only one row and one column return.
","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"T.class"}],"args_string":"(type : T.class) forall T","args_html":"(type : T.class) forall T","location":{"filename":"src/clear/sql/query/fetch.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L53"},"def":{"name":"scalar","args":[{"name":"type","external_name":"type","restriction":"T.class"}],"visibility":"Public","body":"trigger_before_query\nsql = to_sql\nClear::SQL.log_query(sql) do\n (Clear::SQL::ConnectionPool.with_connection(connection_name, &.scalar(sql))).as(T)\nend\n"}},{"html_id":"to_a:Array(Hash(String,Clear::SQL::Any))-instance-method","name":"to_a","doc":"Return an array with all the rows fetched.","summary":"Return an array with all the rows fetched.
","abstract":false,"location":{"filename":"src/clear/sql/query/fetch.cr","line_number":90,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L90"},"def":{"name":"to_a","return_type":"Array(Hash(String, ::Clear::SQL::Any))","visibility":"Public","body":"trigger_before_query\nh = {} of String => ::Clear::SQL::Any\nsql = to_sql\nrs = Clear::SQL.log_query(sql) do\n Clear::SQL::ConnectionPool.with_connection(connection_name, &.query(sql))\nend\no = [] of Hash(String, ::Clear::SQL::Any)\nfetch_result_set(h, rs) do |x|\n o << x.dup\nend\no\n"}}]},{"html_id":"clear/Clear/SQL/Query/From","path":"Clear/SQL/Query/From.html","kind":"module","full_name":"Clear::SQL::Query::From","name":"From","abstract":false,"locations":[{"filename":"src/clear/sql/query/from.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_from-instance-method","name":"clear_from","doc":"Clear the FROM clause and return `self`","summary":"Clear the FROM clause and return self
FROM fragment of the SQL query
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/query/from.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L10"},"def":{"name":"from","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"args.each do |arg|\n case arg\n when NamedTuple\n arg.each do |k, v|\n @froms << (Clear::SQL::From.new(v, k.to_s))\n end\n else\n @froms << (Clear::SQL::From.new(arg))\n end\nend\nchange!\n"}},{"html_id":"from(**tuple)-instance-method","name":"from","abstract":false,"location":{"filename":"src/clear/sql/query/from.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L23"},"def":{"name":"from","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"tuple.each do |k, v|\n @froms << (Clear::SQL::From.new(v, k.to_s))\nend\nchange!\n"}},{"html_id":"froms:Array(SQL::From)-instance-method","name":"froms","abstract":false,"location":{"filename":"src/clear/sql/query/from.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L3"},"def":{"name":"froms","return_type":"Array(SQL::From)","visibility":"Public","body":"@froms"}}]},{"html_id":"clear/Clear/SQL/Query/GroupBy","path":"Clear/SQL/Query/GroupBy.html","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy","abstract":false,"locations":[{"filename":"src/clear/sql/query/group_by.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_group_bys-instance-method","name":"clear_group_bys","abstract":false,"location":{"filename":"src/clear/sql/query/group_by.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L4"},"def":{"name":"clear_group_bys","visibility":"Public","body":"@group_bys.clear\nchange!\n"}},{"html_id":"group_by(column:Symbolic)-instance-method","name":"group_by","abstract":false,"args":[{"name":"column","external_name":"column","restriction":"Symbolic"}],"args_string":"(column : Symbolic)","args_html":"(column : Symbolic)","location":{"filename":"src/clear/sql/query/group_by.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L9"},"def":{"name":"group_by","args":[{"name":"column","external_name":"column","restriction":"Symbolic"}],"visibility":"Public","body":"@group_bys << column\nchange!\n"}},{"html_id":"group_bys:Array(Symbolic)-instance-method","name":"group_bys","abstract":false,"location":{"filename":"src/clear/sql/query/group_by.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L2"},"def":{"name":"group_bys","return_type":"Array(Symbolic)","visibility":"Public","body":"@group_bys"}}]},{"html_id":"clear/Clear/SQL/Query/Having","path":"Clear/SQL/Query/Having.html","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having","abstract":false,"locations":[{"filename":"src/clear/sql/query/having.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/having.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_havings-instance-method","name":"clear_havings","doc":"Clear all the having clauses and return `self`","summary":"Clear all the having clauses and return self
Build SQL #having
condition using a Clear::Expression::Node
Build SQL #having
condition using the Expression engine.
Build SQL #having
condition using a NamedTuple.
Build SQL #having
condition using a template string and interpolating ?
characters with parameters given in a tuple or array.
Build SQL #having
interpolating :keyword
with the NamedTuple passed in argument.
Build SQL #or_having
condition using a Clear::Expression::Node
Build SQL #having
condition using the Expression engine.
Add a "FULL_OUTER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"full_outer_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :full_outer, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"full_outer_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"full_outer_join","doc":"Add a \"FULL_OUTER\" JOIN directive to the query","summary":"Add a "FULL_OUTER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"full_outer_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :full_outer, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"inner_join(name:Selectable,lateral=false,&)-instance-method","name":"inner_join","doc":"Add a \"INNER\" JOIN directive to the query","summary":"Add a "INNER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"inner_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :inner, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"inner_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"inner_join","doc":"Add a \"INNER\" JOIN directive to the query","summary":"Add a "INNER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"inner_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :inner, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"join(name:Selectable,type=:inner,lateral=false,&)-instance-method","name":"join","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, type = :inner, lateral = false, &)","args_html":"(name : Selectable, type = :inner, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L14"},"def":{"name":"join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, type, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"join(name:Selectable,type=:inner,condition:String=\"true\",lateral=false)-instance-method","name":"join","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, type = :inner, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, type = :inner, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L18"},"def":{"name":"join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, type, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"join(name:Selectable,type=:inner,lateral=false)-instance-method","name":"join","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, type = :inner, lateral = false)","args_html":"(name : Selectable, type = :inner, lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L22"},"def":{"name":"join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, type, lateral, nil)"}},{"html_id":"left_join(name:Selectable,lateral=false,&)-instance-method","name":"left_join","doc":"Add a \"LEFT\" JOIN directive to the query","summary":"Add a "LEFT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"left_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :left, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"left_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"left_join","doc":"Add a \"LEFT\" JOIN directive to the query","summary":"Add a "LEFT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"left_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :left, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"right_join(name:Selectable,lateral=false,&)-instance-method","name":"right_join","doc":"Add a \"RIGHT\" JOIN directive to the query","summary":"Add a "RIGHT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"right_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :right, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"right_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"right_join","doc":"Add a \"RIGHT\" JOIN directive to the query","summary":"Add a "RIGHT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"right_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :right, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}}]},{"html_id":"clear/Clear/SQL/Query/Lock","path":"Clear/SQL/Query/Lock.html","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock","abstract":false,"locations":[{"filename":"src/clear/sql/query/lock.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/lock.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"with_lock(str:String=\"FORUPDATE\")-instance-method","name":"with_lock","abstract":false,"args":[{"name":"str","default_value":"\"FOR UPDATE\"","external_name":"str","restriction":"String"}],"args_string":"(str : String = \"FOR UPDATE\")","args_html":"(str : String = "FOR UPDATE")","location":{"filename":"src/clear/sql/query/lock.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/lock.cr#L11"},"def":{"name":"with_lock","args":[{"name":"str","default_value":"\"FOR UPDATE\"","external_name":"str","restriction":"String"}],"visibility":"Public","body":"@lock = str\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","path":"Clear/SQL/Query/OffsetLimit.html","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit","abstract":false,"locations":[{"filename":"src/clear/sql/query/offset_limit.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_limit-instance-method","name":"clear_limit","abstract":false,"location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L12"},"def":{"name":"clear_limit","visibility":"Public","body":"@limit = nil\nchange!\n"}},{"html_id":"clear_offset-instance-method","name":"clear_offset","abstract":false,"location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L17"},"def":{"name":"clear_offset","visibility":"Public","body":"@offset = nil\nchange!\n"}},{"html_id":"limit(x:Int|Nil)-instance-method","name":"limit","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"args_string":"(x : Int | Nil)","args_html":"(x : Int | Nil)","location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L7"},"def":{"name":"limit","args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"visibility":"Public","body":"@limit = Int64.new(x)\nchange!\n"}},{"html_id":"offset(x:Int|Nil)-instance-method","name":"offset","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"args_string":"(x : Int | Nil)","args_html":"(x : Int | Nil)","location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L22"},"def":{"name":"offset","args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"visibility":"Public","body":"@offset = Int64.new(x)\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/OnConflict","path":"Clear/SQL/Query/OnConflict.html","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict","abstract":false,"locations":[{"filename":"src/clear/sql/query/on_conflict.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_conflict-instance-method","name":"clear_conflict","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":58,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L58"},"def":{"name":"clear_conflict","visibility":"Public","body":"@on_conflict_condition = false"}},{"html_id":"conflict?-instance-method","name":"conflict?","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L54"},"def":{"name":"conflict?","visibility":"Public","body":"!!@on_conflict_condition"}},{"html_id":"do_conflict_action(str)-instance-method","name":"do_conflict_action","abstract":false,"args":[{"name":"str","external_name":"str","restriction":""}],"args_string":"(str)","args_html":"(str)","location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L23"},"def":{"name":"do_conflict_action","args":[{"name":"str","external_name":"str","restriction":""}],"visibility":"Public","body":"@on_conflict_action = \"#{str}\"\nchange!\n"}},{"html_id":"do_nothing-instance-method","name":"do_nothing","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L35"},"def":{"name":"do_nothing","visibility":"Public","body":"@on_conflict_action = \"NOTHING\"\nchange!\n"}},{"html_id":"do_update(&)-instance-method","name":"do_update","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L28"},"def":{"name":"do_update","yields":1,"block_arity":1,"visibility":"Public","body":"action = Clear::SQL::UpdateQuery.new(nil)\nyield(action)\n@on_conflict_action = action\nchange!\n"}},{"html_id":"on_conflict(constraint:String|Bool|OnConflictWhereClause=true)-instance-method","name":"on_conflict","abstract":false,"args":[{"name":"constraint","default_value":"true","external_name":"constraint","restriction":"String | Bool | OnConflictWhereClause"}],"args_string":"(constraint : String | Bool | OnConflictWhereClause = true)","args_html":"(constraint : String | Bool | OnConflictWhereClause = true)","location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L40"},"def":{"name":"on_conflict","args":[{"name":"constraint","default_value":"true","external_name":"constraint","restriction":"String | Bool | OnConflictWhereClause"}],"visibility":"Public","body":"@on_conflict_condition = constraint\nchange!\n"}},{"html_id":"on_conflict(&)-instance-method","name":"on_conflict","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":45,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L45"},"def":{"name":"on_conflict","yields":0,"block_arity":0,"visibility":"Public","body":"condition = OnConflictWhereClause.new\ncondition.where(Clear::Expression.ensure_node!(with Clear::Expression.new yield))\n@on_conflict_condition = condition\nchange!\n"}},{"html_id":"on_conflict_action:String|Clear::SQL::UpdateQuery-instance-method","name":"on_conflict_action","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L5"},"def":{"name":"on_conflict_action","return_type":"String | Clear::SQL::UpdateQuery","visibility":"Public","body":"@on_conflict_action"}},{"html_id":"on_conflict_condition:String|OnConflictWhereClause|Bool-instance-method","name":"on_conflict_condition","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L4"},"def":{"name":"on_conflict_condition","return_type":"String | OnConflictWhereClause | Bool","visibility":"Public","body":"@on_conflict_condition"}}],"types":[{"html_id":"clear/Clear/SQL/Query/OnConflict/OnConflictWhereClause","path":"Clear/SQL/Query/OnConflict/OnConflictWhereClause.html","kind":"class","full_name":"Clear::SQL::Query::OnConflict::OnConflictWhereClause","name":"OnConflictWhereClause","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/query/on_conflict.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"}],"namespace":{"html_id":"clear/Clear/SQL/Query/OnConflict","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict"},"doc":"Fragment used when ON CONFLICT WHERE ...","summary":"Fragment used when ON CONFLICT WHERE ...
","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L11"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"change!-instance-method","name":"change!","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L19"},"def":{"name":"change!","visibility":"Public","body":""}},{"html_id":"to_s-instance-method","name":"to_s","doc":"Returns a nicely readable and concise string representation of this object,\ntypically intended for users.\n\nThis method should usually **not** be overridden. It delegates to\n`#to_s(IO)` which can be overridden for custom implementations.\n\nAlso see `#inspect`.","summary":"Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L15"},"def":{"name":"to_s","visibility":"Public","body":"print_wheres"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}]}]},{"html_id":"clear/Clear/SQL/Query/OrderBy","path":"Clear/SQL/Query/OrderBy.html","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy","abstract":false,"locations":[{"filename":"src/clear/sql/query/order_by.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"doc":"Encode for:\n\n`ORDER BY expression [ASC | DESC | USING operator] [NULLS FIRST | NULLS LAST];`\n\nCurrent implementation:\n\n[x] Multiple Order by clauses\n[x] ASC/DESC\n[x] NULLS FIRST / NULLS LAST\n[ ] NOT IMPLEMENTED: USING OPERATOR","summary":"Encode for:
","instance_methods":[{"html_id":"clear_order_bys-instance-method","name":"clear_order_bys","doc":"Remove all order by clauses","summary":"Remove all order by clauses
","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L19"},"def":{"name":"clear_order_bys","visibility":"Public","body":"@order_bys.clear\nchange!\n"}},{"html_id":"order_by(tuple:NamedTuple)-instance-method","name":"order_by","doc":"Add multiple ORDER BY clause using a tuple:\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(id: :desc, name: {:asc, :nulls_last})\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC, \"name\" ASC NULLS LAST\n```\n","summary":"Add multiple ORDER BY clause using a tuple:
","abstract":false,"args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"args_string":"(tuple : NamedTuple)","args_html":"(tuple : NamedTuple)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":81,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L81"},"def":{"name":"order_by","args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"visibility":"Public","body":"tuple.each do |k, v|\n case v\n when Symbol, String\n order_by(k, v, nil)\n when Tuple\n order_by(k, v[0], v[1])\n else\n raise(\"order_by with namedtuple must be called with value of the tuple as Symbol, String or Tuple describing direction and nulls directive\")\n end\nend\nself\n"}},{"html_id":"order_by(expression:Symbol,direction:Symbol=:asc,nulls:Symbol|Nil=nil)-instance-method","name":"order_by","doc":"Add one ORDER BY clause\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(:id, :desc, nulls_last)\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC NULLS LAST\n```","summary":"Add one ORDER BY clause
","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Symbol"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"args_string":"(expression : Symbol, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","args_html":"(expression : Symbol, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":102,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L102"},"def":{"name":"order_by","args":[{"name":"expression","external_name":"expression","restriction":"Symbol"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"visibility":"Public","body":"@order_bys << (Record.new(SQL.escape(expression.to_s), sanitize_direction(direction), sanitize_nulls(nulls)))\nchange!\n"}},{"html_id":"order_by(expression:String,direction:Symbol=:asc,nulls:Symbol|Nil=nil)-instance-method","name":"order_by","doc":"Add one ORDER BY clause\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(:id, :desc, nulls_last)\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC NULLS LAST\n```","summary":"Add one ORDER BY clause
","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"String"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"args_string":"(expression : String, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","args_html":"(expression : String, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L108"},"def":{"name":"order_by","args":[{"name":"expression","external_name":"expression","restriction":"String"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"visibility":"Public","body":"@order_bys << (Record.new(expression, sanitize_direction(direction), sanitize_nulls(nulls)))\nchange!\n"}},{"html_id":"order_by(**tuple)-instance-method","name":"order_by","doc":"Add multiple ORDER BY clause using a tuple:\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(id: :desc, name: {:asc, :nulls_last})\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC, \"name\" ASC NULLS LAST\n```\n","summary":"Add multiple ORDER BY clause using a tuple:
","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":76,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L76"},"def":{"name":"order_by","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"order_by(tuple)"}},{"html_id":"reverse_order_by-instance-method","name":"reverse_order_by","doc":"Flip over all order bys by switching the ASC direction to DESC and the NULLS FIRST to NULLS LAST\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(id: :desc, name: :asc, company: {:asc, :nulls_last})\nquery.reverse_order_by\nquery.to_sql # SELECT * FROM users ORDER BY \"id\" ASC, \"name\" DESC, \"company\" DESC NULLS FIRST\n```\n\nreturn `self`","summary":"Flip over all order bys by switching the ASC direction to DESC and the NULLS FIRST to NULLS LAST
","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L53"},"def":{"name":"reverse_order_by","visibility":"Public","body":"@order_bys = @order_bys.map do |rec|\n Record.new(rec.op, rec.dir == (:desc) ? :asc : :desc, rec.nulls.try do |n|\n n == (:nulls_last) ? :nulls_first : :nulls_last\n end)\nend\nchange!\n"}}],"types":[{"html_id":"clear/Clear/SQL/Query/OrderBy/Record","path":"Clear/SQL/Query/OrderBy/Record.html","kind":"struct","full_name":"Clear::SQL::Query::OrderBy::Record","name":"Record","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},"constructors":[{"html_id":"new(op:String,dir:Symbol,nulls:Symbol|Nil)-class-method","name":"new","abstract":false,"args":[{"name":"op","external_name":"op","restriction":"String"},{"name":"dir","external_name":"dir","restriction":"Symbol"},{"name":"nulls","external_name":"nulls","restriction":"Symbol | ::Nil"}],"args_string":"(op : String, dir : Symbol, nulls : Symbol | Nil)","args_html":"(op : String, dir : Symbol, nulls : Symbol | Nil)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"},"def":{"name":"new","args":[{"name":"op","external_name":"op","restriction":"String"},{"name":"dir","external_name":"dir","restriction":"Symbol"},{"name":"nulls","external_name":"nulls","restriction":"Symbol | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(op, dir, nulls)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@op.clone, @dir.clone, @nulls.clone)"}},{"html_id":"copy_with(op_op=@op,dir_dir=@dir,nulls_nulls=@nulls)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_op","default_value":"@op","external_name":"op","restriction":""},{"name":"_dir","default_value":"@dir","external_name":"dir","restriction":""},{"name":"_nulls","default_value":"@nulls","external_name":"nulls","restriction":""}],"args_string":"(op _op = @op, dir _dir = @dir, nulls _nulls = @nulls)","args_html":"(op _op = @op, dir _dir = @dir, nulls _nulls = @nulls)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"},"def":{"name":"copy_with","args":[{"name":"_op","default_value":"@op","external_name":"op","restriction":""},{"name":"_dir","default_value":"@dir","external_name":"dir","restriction":""},{"name":"_nulls","default_value":"@nulls","external_name":"nulls","restriction":""}],"visibility":"Public","body":"self.class.new(_op, _dir, _nulls)"}},{"html_id":"dir:Symbol-instance-method","name":"dir","abstract":false,"def":{"name":"dir","return_type":"Symbol","visibility":"Public","body":"@dir"}},{"html_id":"nulls:Symbol|Nil-instance-method","name":"nulls","abstract":false,"def":{"name":"nulls","return_type":"Symbol | ::Nil","visibility":"Public","body":"@nulls"}},{"html_id":"op:String-instance-method","name":"op","abstract":false,"def":{"name":"op","return_type":"String","visibility":"Public","body":"@op"}}]}]},{"html_id":"clear/Clear/SQL/Query/Pluck","path":"Clear/SQL/Query/Pluck.html","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck","abstract":false,"locations":[{"filename":"src/clear/sql/query/pluck.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"pluck(fields:Tuple(*T))forallT-instance-method","name":"pluck","doc":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected\narguments:\n\n```\nUser.query.pluck(\"first_name\", \"last_name\").each do |(first_name, last_name)|\n # ...\nend\n```","summary":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected arguments:
","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Tuple(*T)"}],"args_string":"(fields : Tuple(*T)) forall T","args_html":"(fields : Tuple(*T)) forall T","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":77,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L77"},"def":{"name":"pluck","args":[{"name":"fields","external_name":"fields","restriction":"Tuple(*T)"}],"visibility":"Public","body":"select_clause = fields.join(\", \") do |f|\n f.is_a?(Symbol) ? Clear::SQL.escape(f) : f.to_s\nend\nsql = (clear_select.select(select_clause)).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n {% if true %}\n o = [] of Tuple({% for t in T %}Clear::SQL::Any,{% end %})\n\n while rs.move_next\n o << { {% for t in T %} rs.read.as(Clear::SQL::Any), {% end %} }\n end\n o\n {% end %}\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"pluck(*fields)-instance-method","name":"pluck","doc":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected\narguments:\n\n```\nUser.query.pluck(\"first_name\", \"last_name\").each do |(first_name, last_name)|\n # ...\nend\n```","summary":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected arguments:
","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":""}],"args_string":"(*fields)","args_html":"(*fields)","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L72"},"def":{"name":"pluck","args":[{"name":"fields","external_name":"fields","restriction":""}],"splat_index":0,"visibility":"Public","body":"pluck(fields)"}},{"html_id":"pluck(**fields:**T)forallT-instance-method","name":"pluck","doc":"Select specifics columns and returns on array of tuple of type of the named tuple passed as parameter:\n\n```\nUser.query.pluck(id: Int64, \"UPPER(last_name)\": String).each do #...\n```","summary":"Select specifics columns and returns on array of tuple of type of the named tuple passed as parameter:
","abstract":false,"location":{"filename":"src/clear/sql/query/pluck.cr","line_number":102,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L102"},"def":{"name":"pluck","double_splat":{"name":"fields","external_name":"fields","restriction":"**T"},"visibility":"Public","body":"sql = (clear_select.select(fields.keys.join(\", \"))).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n {% if true %}\n o = [] of Tuple({% for k, v in T %}{{ v.instance }},{% end %})\n\n while rs.move_next\n o << { {% for k, v in T %} rs.read({{ v.instance }}), {% end %}}\n end\n o\n {% end %}\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"pluck_col(field:Clear::SQL::Symbolic,type:T.class)forallT-instance-method","name":"pluck_col","doc":"Select a specific column of your SQL query, execute the query\nand return an array containing this field.\n\n```\nUser.query.pluck_col(\"id\") # [1,2,3,4...]\n```\n\nNote: It returns an array of `Clear::SQL::Any`. Therefore, you may want to use `pluck_col(str, Type)` to return\n an array of `Type`:\n\n```\nUser.query.pluck_col(\"id\", Int64)\n```\n\nThe field argument is a SQL fragment; it's not escaped (beware SQL injection) and allow call to functions\nand aggregate methods:\n\n```\n# ...\nUser.query.pluck_col(\"CASE WHEN id % 2 = 0 THEN id ELSE NULL END AS id\").each do\n# ...\n```","summary":"Select a specific column of your SQL query, execute the query and return an array containing this field.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"},{"name":"type","external_name":"type","restriction":"T.class"}],"args_string":"(field : Clear::SQL::Symbolic, type : T.class) forall T","args_html":"(field : Clear::SQL::Symbolic, type : T.class) forall T","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L44"},"def":{"name":"pluck_col","args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"},{"name":"type","external_name":"type","restriction":"T.class"}],"visibility":"Public","body":"if field.is_a?(Symbol)\n field = Clear::SQL.escape(field)\nend\nsql = (clear_select.select(field)).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n o = [] of T\n while rs.move_next\n o << (rs.read(T))\n end\n o\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"pluck_col(field:Clear::SQL::Symbolic)-instance-method","name":"pluck_col","doc":"Select a specific column of your SQL query, execute the query\nand return an array containing this field.\n\n```\nUser.query.pluck_col(\"id\") # [1,2,3,4...]\n```\n\nNote: It returns an array of `Clear::SQL::Any`. Therefore, you may want to use `pluck_col(str, Type)` to return\n an array of `Type`:\n\n```\nUser.query.pluck_col(\"id\", Int64)\n```\n\nThe field argument is a SQL fragment; it's not escaped (beware SQL injection) and allow call to functions\nand aggregate methods:\n\n```\n# ...\nUser.query.pluck_col(\"CASE WHEN id % 2 = 0 THEN id ELSE NULL END AS id\").each do\n# ...\n```","summary":"Select a specific column of your SQL query, execute the query and return an array containing this field.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"}],"args_string":"(field : Clear::SQL::Symbolic)","args_html":"(field : Clear::SQL::Symbolic)","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L24"},"def":{"name":"pluck_col","args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"}],"visibility":"Public","body":"if field.is_a?(Symbol)\n field = Clear::SQL.escape(field)\nend\nsql = (clear_select.select(field)).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n o = [] of Clear::SQL::Any\n while rs.move_next\n o << (rs.read.as(Clear::SQL::Any))\n end\n o\n ensure\n rs.try(&.close)\n end\nend\n"}}]},{"html_id":"clear/Clear/SQL/Query/Select","path":"Clear/SQL/Query/Select.html","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select","abstract":false,"locations":[{"filename":"src/clear/sql/query/select.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_distinct-instance-method","name":"clear_distinct","doc":"Remove distinct","summary":"Remove distinct
","abstract":false,"location":{"filename":"src/clear/sql/query/select.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L43"},"def":{"name":"clear_distinct","visibility":"Public","body":"distinct(nil)"}},{"html_id":"clear_select-instance-method","name":"clear_select","abstract":false,"location":{"filename":"src/clear/sql/query/select.cr","line_number":66,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L66"},"def":{"name":"clear_select","visibility":"Public","body":"@columns.clear\nchange!\n"}},{"html_id":"default_wildcard_table=(table:String|Nil=nil)-instance-method","name":"default_wildcard_table=","doc":"In some case you want you query to return `table.*` instead of `*`\n if no select parameters has been set. This occurs in the case of joins\n between models.","summary":"In some case you want you query to return table.*
instead of *
if no select parameters has been set.
Add DISTINCT to the SELECT part of the query
","abstract":false,"args":[{"name":"on","default_value":"\"\"","external_name":"on","restriction":"String | ::Nil"}],"args_string":"(on : String | Nil = \"\")","args_html":"(on : String | Nil = "")","location":{"filename":"src/clear/sql/query/select.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L37"},"def":{"name":"distinct","args":[{"name":"on","default_value":"\"\"","external_name":"on","restriction":"String | ::Nil"}],"visibility":"Public","body":"@distinct_value = on\nchange!\n"}},{"html_id":"distinct_value:String|Nil-instance-method","name":"distinct_value","abstract":false,"location":{"filename":"src/clear/sql/query/select.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L12"},"def":{"name":"distinct_value","return_type":"String | ::Nil","visibility":"Public","body":"@distinct_value"}},{"html_id":"select(c:Column)-instance-method","name":"select","doc":"def select(name : Symbolic, var = nil)\n @columns << Column.new(name, var)\n self\nend","summary":"def select(name : Symbolic, var = nil) @columns << Column.new(name, var) self end
","abstract":false,"args":[{"name":"c","external_name":"c","restriction":"Column"}],"args_string":"(c : Column)","args_html":"(c : Column)","location":{"filename":"src/clear/sql/query/select.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L26"},"def":{"name":"select","args":[{"name":"c","external_name":"c","restriction":"Column"}],"visibility":"Public","body":"@columns << c\nchange!\n"}},{"html_id":"select(*args)-instance-method","name":"select","doc":"Add field(s) to selection from tuple\n\n```\nselect({user_id: \"uid\", updated_at: \"updated_at\"})\n# => Output \"SELECT user_id as uid, updated_at as updated_at\"\n```","summary":"Add field(s) to selection from tuple
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/query/select.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L53"},"def":{"name":"select","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"args.each do |arg|\n case arg\n when NamedTuple\n arg.each do |k, v|\n @columns << (Column.new(v, k.to_s))\n end\n else\n @columns << (Column.new(arg))\n end\nend\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/Where","path":"Clear/SQL/Query/Where.html","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where","abstract":false,"locations":[{"filename":"src/clear/sql/query/where.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/where.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/DeleteQuery","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery"},{"html_id":"clear/Clear/SQL/Query/OnConflict/OnConflictWhereClause","kind":"class","full_name":"Clear::SQL::Query::OnConflict::OnConflictWhereClause","name":"OnConflictWhereClause"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"doc":"Feature WHERE clause building.\neach call to where method stack where clause.\nTheses clauses are then combined together using the `AND` operator.\nTherefore, `query.where(\"a\").where(\"b\")` will return `a AND b`\n","summary":"Feature WHERE clause building.
","instance_methods":[{"html_id":"clear_wheres-instance-method","name":"clear_wheres","doc":"Clear all the where clauses and return `self`","summary":"Clear all the where clauses and return self
Build SQL #or_where
condition using a Clear::Expression::Node
Build SQL #where
condition using the Expression engine.
Build SQL #where
condition using a Clear::Expression::Node
Build SQL #where
condition using the Expression engine.
Build SQL #where
condition using a NamedTuple.
Build custom SQL #where
beware of SQL injections!
Build SQL #where
condition using a template string and interpolating ?
characters with parameters given in a tuple or array.
Build SQL #where
interpolating :keyword
with the NamedTuple passed in argument.
eq.
","abstract":false,"location":{"filename":"src/clear/sql/query/window.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/window.cr#L5"},"def":{"name":"windows","return_type":"Array(WindowDeclaration)","visibility":"Public","body":"@windows"}}],"types":[{"html_id":"clear/Clear/SQL/Query/Window/WindowDeclaration","path":"Clear/SQL/Query/Window/WindowDeclaration.html","kind":"alias","full_name":"Clear::SQL::Query::Window::WindowDeclaration","name":"WindowDeclaration","abstract":false,"locations":[{"filename":"src/clear/sql/query/window.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/window.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Tuple(String, String)","aliased_html":"{String, String}","const":false,"namespace":{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"}}]},{"html_id":"clear/Clear/SQL/Query/WithPagination","path":"Clear/SQL/Query/WithPagination.html","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination","abstract":false,"locations":[{"filename":"src/clear/sql/query/with_pagination.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DEFAULT_LIMIT","name":"DEFAULT_LIMIT","value":"50"},{"id":"DEFAULT_PAGE","name":"DEFAULT_PAGE","value":"1"}],"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"current_page-instance-method","name":"current_page","doc":"Return the current page","summary":"Return the current page
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L33"},"def":{"name":"current_page","visibility":"Public","body":"if offset.nil? || limit.nil?\n 1\nelse\n ((offset.as(Int64)) / (limit.as(Int64))) + 1\nend"}},{"html_id":"first_page?-instance-method","name":"first_page?","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":64,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L64"},"def":{"name":"first_page?","visibility":"Public","body":"current_page <= 1"}},{"html_id":"last_page?-instance-method","name":"last_page?","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":60,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L60"},"def":{"name":"last_page?","visibility":"Public","body":"next_page.nil?"}},{"html_id":"next_page-instance-method","name":"next_page","doc":"Return `current_page + 1` or `nil` if there is no next page","summary":"Return current_page + 1
or nil
if there is no next page
Helper method that is true when someone tries to fetch a page with a larger number than the last page.
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L71"},"def":{"name":"out_of_bounds?","visibility":"Public","body":"current_page > total_pages"}},{"html_id":"paginate(page:Int32=DEFAULT_PAGE,per_page:Int32=DEFAULT_LIMIT)-instance-method","name":"paginate","doc":"Enter pagination mode.\nThis is helpful to manage paginated table.\nPagination will handle the page progression automatically and update\n`offset` and `limit` parameters by his own.\n\n```\npage = query.paginate(2, 50)\n```","summary":"Enter pagination mode.
","abstract":false,"args":[{"name":"page","default_value":"DEFAULT_PAGE","external_name":"page","restriction":"Int32"},{"name":"per_page","default_value":"DEFAULT_LIMIT","external_name":"per_page","restriction":"Int32"}],"args_string":"(page : Int32 = DEFAULT_PAGE, per_page : Int32 = DEFAULT_LIMIT)","args_html":"(page : Int32 = DEFAULT_PAGE, per_page : Int32 = DEFAULT_LIMIT)","location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L17"},"def":{"name":"paginate","args":[{"name":"page","default_value":"DEFAULT_PAGE","external_name":"page","restriction":"Int32"},{"name":"per_page","default_value":"DEFAULT_LIMIT","external_name":"per_page","restriction":"Int32"}],"visibility":"Public","body":"clear_limit.clear_offset\n@total_entries = count\npage = {1, page}.max\n@limit = per_page.to_i64\n@offset = (per_page * (page - 1)).to_i64\nchange!\n"}},{"html_id":"per_page-instance-method","name":"per_page","doc":"Return the number of items maximum per page.","summary":"Return the number of items maximum per page.
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L28"},"def":{"name":"per_page","visibility":"Public","body":"limit"}},{"html_id":"previous_page-instance-method","name":"previous_page","doc":"Return `current_page - 1` or `nil` if there is no previous page","summary":"Return current_page - 1
or nil
if there is no previous page
Return the total number of pages.
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L42"},"def":{"name":"total_pages","visibility":"Public","body":"if limit.nil? || total_entries.nil?\n 1\nelse\n ((total_entries.as(Int64)) / (limit.as(Int64)).to_f).ceil.to_i\nend"}}]}]},{"html_id":"clear/Clear/SQL/QueryBuildingError","path":"Clear/SQL/QueryBuildingError.html","kind":"class","full_name":"Clear::SQL::QueryBuildingError","name":"QueryBuildingError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/RecordNotFoundError","path":"Clear/SQL/RecordNotFoundError.html","kind":"class","full_name":"Clear::SQL::RecordNotFoundError","name":"RecordNotFoundError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L10"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/RollbackError","path":"Clear/SQL/RollbackError.html","kind":"class","full_name":"Clear::SQL::RollbackError","name":"RollbackError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L13"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"Rollback the transaction or the last savepoint.","summary":"Rollback the transaction or the last savepoint.
"},{"html_id":"clear/Clear/SQL/Selectable","path":"Clear/SQL/Selectable.html","kind":"alias","full_name":"Clear::SQL::Selectable","name":"Selectable","abstract":false,"locations":[{"filename":"src/clear/sql/sql.cr","line_number":68,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L68"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Clear::SQL::SelectBuilder | String | Symbol)","aliased_html":"Clear::SQL::SelectBuilder | String | Symbol","const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/SelectBuilder","path":"Clear/SQL/SelectBuilder.html","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder","abstract":false,"ancestors":[{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"}],"locations":[{"filename":"src/clear/sql/select_builder.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"}],"including_types":[{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase(T)","name":"CollectionBase"},{"html_id":"clear/Clear/SQL/SelectQuery","kind":"class","full_name":"Clear::SQL::SelectQuery","name":"SelectQuery"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(distinct_value=nil,cte={}ofString=>Clear::SQL::SelectBuilder|String,columns=[]ofSQL::Column,froms=[]ofSQL::From,joins=[]ofSQL::Join,wheres=[]ofClear::Expression::Node,havings=[]ofClear::Expression::Node,windows=[]of::Tuple(String,String),group_bys=[]ofSymbolic,order_bys=[]ofClear::SQL::Query::OrderBy::Record,limit=nil,offset=nil,lock=nil,before_query_triggers=[]of(->Nil))-class-method","name":"new","abstract":false,"args":[{"name":"distinct_value","default_value":"nil","external_name":"distinct_value","restriction":""},{"name":"cte","default_value":"{} of String => Clear::SQL::SelectBuilder | String","external_name":"cte","restriction":""},{"name":"columns","default_value":"[] of SQL::Column","external_name":"columns","restriction":""},{"name":"froms","default_value":"[] of SQL::From","external_name":"froms","restriction":""},{"name":"joins","default_value":"[] of SQL::Join","external_name":"joins","restriction":""},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":""},{"name":"havings","default_value":"[] of Clear::Expression::Node","external_name":"havings","restriction":""},{"name":"windows","default_value":"[] of ::Tuple(String, String)","external_name":"windows","restriction":""},{"name":"group_bys","default_value":"[] of Symbolic","external_name":"group_bys","restriction":""},{"name":"order_bys","default_value":"[] of Clear::SQL::Query::OrderBy::Record","external_name":"order_bys","restriction":""},{"name":"limit","default_value":"nil","external_name":"limit","restriction":""},{"name":"offset","default_value":"nil","external_name":"offset","restriction":""},{"name":"lock","default_value":"nil","external_name":"lock","restriction":""},{"name":"before_query_triggers","default_value":"[] of (-> Nil)","external_name":"before_query_triggers","restriction":""}],"args_string":"(distinct_value = nil, cte = {} of String => Clear::SQL::SelectBuilder | String, columns = [] of SQL::Column, froms = [] of SQL::From, joins = [] of SQL::Join, wheres = [] of Clear::Expression::Node, havings = [] of Clear::Expression::Node, windows = [] of ::Tuple(String, String), group_bys = [] of Symbolic, order_bys = [] of Clear::SQL::Query::OrderBy::Record, limit = nil, offset = nil, lock = nil, before_query_triggers = [] of (-> Nil))","args_html":"(distinct_value = nil, cte = {} of String => Clear::SQL::SelectBuilder | String, columns = [] of SQL::Column, froms = [] of SQL::From, joins = [] of SQL::Join, wheres = [] of Clear::Expression::Node, havings = [] of Clear::Expression::Node, windows = [] of ::Tuple(String, String), group_bys = [] of Symbolic, order_bys = [] of Clear::SQL::Query::OrderBy::Record, limit = nil, offset = nil, lock = nil, before_query_triggers = [] of (-> Nil))","location":{"filename":"src/clear/sql/select_builder.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L29"},"def":{"name":"new","args":[{"name":"distinct_value","default_value":"nil","external_name":"distinct_value","restriction":""},{"name":"cte","default_value":"{} of String => Clear::SQL::SelectBuilder | String","external_name":"cte","restriction":""},{"name":"columns","default_value":"[] of SQL::Column","external_name":"columns","restriction":""},{"name":"froms","default_value":"[] of SQL::From","external_name":"froms","restriction":""},{"name":"joins","default_value":"[] of SQL::Join","external_name":"joins","restriction":""},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":""},{"name":"havings","default_value":"[] of Clear::Expression::Node","external_name":"havings","restriction":""},{"name":"windows","default_value":"[] of ::Tuple(String, String)","external_name":"windows","restriction":""},{"name":"group_bys","default_value":"[] of Symbolic","external_name":"group_bys","restriction":""},{"name":"order_bys","default_value":"[] of Clear::SQL::Query::OrderBy::Record","external_name":"order_bys","restriction":""},{"name":"limit","default_value":"nil","external_name":"limit","restriction":""},{"name":"offset","default_value":"nil","external_name":"offset","restriction":""},{"name":"lock","default_value":"nil","external_name":"lock","restriction":""},{"name":"before_query_triggers","default_value":"[] of (-> Nil)","external_name":"before_query_triggers","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(distinct_value, cte, columns, froms, joins, wheres, havings, windows, group_bys, order_bys, limit, offset, lock, before_query_triggers)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"before_query(&block:->Nil)-instance-method","name":"before_query","doc":"A hook to apply some operation just before the query is executed.\n\n```\ncall = 0\nreq = Clear::SQL.select(\"1\").before_query { call += 1 }\n10.times { req.execute }\npp call # 10\n```","summary":"A hook to apply some operation just before the query is executed.
","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L26"},"def":{"name":"before_query","yields":0,"block_arity":0,"block_arg":{"name":"block","external_name":"block","restriction":"(-> Nil)"},"visibility":"Public","body":"@before_query_triggers << block\nself\n"}},{"html_id":"columns:Array(SQL::Column)-instance-method","name":"columns","abstract":false,"def":{"name":"columns","return_type":"Array(SQL::Column)","visibility":"Public","body":"@columns"}},{"html_id":"default_wildcard_table-instance-method","name":"default_wildcard_table","abstract":false,"def":{"name":"default_wildcard_table","visibility":"Public","body":"@default_wildcard_table"}},{"html_id":"dup:self-instance-method","name":"dup","doc":"Duplicate the query","summary":"Duplicate the query
","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":46,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L46"},"def":{"name":"dup","return_type":"self","visibility":"Public","body":"self.class.new(distinct_value: @distinct_value, cte: @cte.dup, columns: @columns.dup, froms: @froms.dup, joins: @joins.dup, wheres: @wheres.dup, havings: @havings.dup, windows: @windows.dup, group_bys: @group_bys.dup, order_bys: @order_bys.dup, limit: @limit, offset: @offset, lock: @lock, before_query_triggers: @before_query_triggers).use_connection(connection_name)"}},{"html_id":"havings:Array(Clear::Expression::Node)-instance-method","name":"havings","abstract":false,"def":{"name":"havings","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@havings"}},{"html_id":"is_distinct?-instance-method","name":"is_distinct?","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L4"},"def":{"name":"is_distinct?","visibility":"Public","body":"!!@distinct_value"}},{"html_id":"joins:Array(SQL::Join)-instance-method","name":"joins","abstract":false,"def":{"name":"joins","return_type":"Array(SQL::Join)","visibility":"Public","body":"@joins"}},{"html_id":"limit:Int64|Nil-instance-method","name":"limit","abstract":false,"def":{"name":"limit","return_type":"Int64 | ::Nil","visibility":"Public","body":"@limit"}},{"html_id":"lock:String|Nil-instance-method","name":"lock","abstract":false,"def":{"name":"lock","return_type":"String | ::Nil","visibility":"Public","body":"@lock"}},{"html_id":"offset:Int64|Nil-instance-method","name":"offset","abstract":false,"def":{"name":"offset","return_type":"Int64 | ::Nil","visibility":"Public","body":"@offset"}},{"html_id":"order_bys:Array(Clear::SQL::Query::OrderBy::Record)-instance-method","name":"order_bys","abstract":false,"def":{"name":"order_bys","return_type":"Array(Clear::SQL::Query::OrderBy::Record)","visibility":"Public","body":"@order_bys"}},{"html_id":"to_delete-instance-method","name":"to_delete","doc":"Construct a delete query from this select query.\nIt uses only the `from` and the `where` clause fo the current select request.\nCan be useful in some case, but\n use at your own risk !","summary":"Construct a delete query from this select query.
","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":83,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L83"},"def":{"name":"to_delete","visibility":"Public","body":"if @froms.size == 1\nelse\n raise(QueryBuildingError.new(\"Cannot build a delete query \" + \"from a select with multiple or none `from` clauses\"))\nend\nv = @froms[0].value\nif v.is_a?(SelectBuilder)\n raise(QueryBuildingError.new(\"Cannot delete from a select with sub-select as `from` clause\"))\nend\nDeleteQuery.new(v.dup, @wheres.dup)\n"}},{"html_id":"to_sql:String-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L65"},"def":{"name":"to_sql","return_type":"String","visibility":"Public","body":"[print_ctes, print_select, print_froms, print_joins, print_wheres, print_windows, print_group_bys, print_havings, print_order_bys, print_limit_offsets, print_lock].compact.reject(&.empty?).join(\" \")"}},{"html_id":"to_update-instance-method","name":"to_update","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":94,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L94"},"def":{"name":"to_update","visibility":"Public","body":"if @froms.size == 1\nelse\n raise(QueryBuildingError.new(\"Cannot build a update query \" + \"from a select with multiple or none `from` clauses\"))\nend\nv = @froms[0].value\nif v.is_a?(SelectBuilder)\n raise(QueryBuildingError.new(\"Cannot delete from a select with sub-select as `from` clause\"))\nend\nUpdateQuery.new(table: v.dup, wheres: @wheres.dup)\n"}},{"html_id":"total_entries:Int64|Nil-instance-method","name":"total_entries","abstract":false,"def":{"name":"total_entries","return_type":"Int64 | ::Nil","visibility":"Public","body":"@total_entries"}},{"html_id":"total_entries=(total_entries:Int64|Nil)-instance-method","name":"total_entries=","abstract":false,"args":[{"name":"total_entries","external_name":"total_entries","restriction":"Int64 | ::Nil"}],"args_string":"(total_entries : Int64 | Nil)","args_html":"(total_entries : Int64 | Nil)","def":{"name":"total_entries=","args":[{"name":"total_entries","external_name":"total_entries","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"@total_entries = total_entries"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}]},{"html_id":"clear/Clear/SQL/SelectQuery","path":"Clear/SQL/SelectQuery.html","kind":"class","full_name":"Clear::SQL::SelectQuery","name":"SelectQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/select_query.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_query.cr#L25"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"A Select Query builder\n\nPostgres documentation:\n\n```\n[ WITH [ RECURSIVE ] with_query [, ...] ]\nSELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]\n [ * | expression [ [ AS ] output_name ] [, ...] ]\n [ FROM from_item [, ...] ]\n [ WHERE condition ]\n [ GROUP BY grouping_element [, ...] ]\n [ HAVING condition [, ...] ]\n [ WINDOW window_name AS ( window_definition ) [, ...] ]\n [ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]\n [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] ]\n [ LIMIT { count | ALL } ]\n [ OFFSET start [ ROW | ROWS ] ]\n [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]\n [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ]\n```","summary":"A Select Query builder
","instance_methods":[{"html_id":"each(&):Nil-instance-method","name":"each","doc":"Must yield this collection's elements to the block.","summary":"Must yield this collection's elements to the block.
","abstract":false,"location":{"filename":"src/clear/sql/select_query.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_query.cr#L29"},"def":{"name":"each","yields":1,"block_arity":1,"return_type":"Nil","visibility":"Public","body":"fetch do |h|\n yield(h)\nend"}}]},{"html_id":"clear/Clear/SQL/Symbolic","path":"Clear/SQL/Symbolic.html","kind":"alias","full_name":"Clear::SQL::Symbolic","name":"Symbolic","abstract":false,"locations":[{"filename":"src/clear/sql/sql.cr","line_number":67,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L67"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(String | Symbol)","aliased_html":"String | Symbol","const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/Transaction","path":"Clear/SQL/Transaction.html","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction","abstract":false,"locations":[{"filename":"src/clear/sql/transaction.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"instance_methods":[{"html_id":"after_commit(connection:String=\"default\",&block:DB::Connection->Nil)-instance-method","name":"after_commit","doc":"Register a callback function which will be fired once when SQL `COMMIT`\noperation is called\n\nThis can be used for example to send email, or perform others tasks\nwhen you want to be sure the data is secured in the database.\n\n```\ntransaction do\n @user = User.find(1)\n @user.subscribe!\n Clear::SQL.after_commit { Email.deliver(ConfirmationMail.new(@user)) }\nend\n```\n\nIn case the transaction fail and eventually rollback, the code won't be called.\n","summary":"Register a callback function which will be fired once when SQL COMMIT
operation is called
Check whether the current pair of fiber/connection is in transaction block or not.
","abstract":false,"args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"}],"args_string":"(connection : String = \"default\")","args_html":"(connection : String = "default")","location":{"filename":"src/clear/sql/transaction.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L29"},"def":{"name":"in_transaction?","args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.with_connection(connection, &._clear_in_transaction?)"}},{"html_id":"rollback(to=nil)-instance-method","name":"rollback","doc":"Rollback a transaction or return to the previous savepoint in case of a\nwith_savepoint block.\nThe params `to` offer","summary":"Rollback a transaction or return to the previous savepoint in case of a with_savepoint block.
","abstract":false,"args":[{"name":"to","default_value":"nil","external_name":"to","restriction":""}],"args_string":"(to = nil)","args_html":"(to = nil)","location":{"filename":"src/clear/sql/transaction.cr","line_number":138,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L138"},"def":{"name":"rollback","args":[{"name":"to","default_value":"nil","external_name":"to","restriction":""}],"visibility":"Public","body":"raise(RollbackError.new(to))"}},{"html_id":"rollback_transaction-instance-method","name":"rollback_transaction","doc":"Rollback the transaction. In case the call is made inside a savepoint block\nrollback everything.","summary":"Rollback the transaction.
","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L144"},"def":{"name":"rollback_transaction","visibility":"Public","body":"raise(CancelTransactionError.new)"}},{"html_id":"transaction(connection:String=\"default\",level:Level=Level::Serializable,&)-instance-method","name":"transaction","doc":"Enter new transaction block for the current connection/fiber pair.\n\nExample:\n\n```\nClear::SQL.transaction do\n # do something\n Clear::SQL.transaction do # Technically, this block do nothing, since we already are in transaction\n rollback # < Rollback the up-most `transaction` block.\n end\nend\n```\n\nsee #with_savepoint to use a stackable version using savepoints.\n","summary":"Enter new transaction block for the current connection/fiber pair.
","abstract":false,"args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"},{"name":"level","default_value":"Level::Serializable","external_name":"level","restriction":"Level"}],"args_string":"(connection : String = \"default\", level : Level = Level::Serializable, &)","args_html":"(connection : String = "default", level : Level = Level::Serializable, &)","location":{"filename":"src/clear/sql/transaction.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L48"},"def":{"name":"transaction","args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"},{"name":"level","default_value":"Level::Serializable","external_name":"level","restriction":"Level"}],"yields":1,"block_arity":1,"visibility":"Public","body":"Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|\n has_rollback = false\n if cnx._clear_in_transaction?\n return yield(cnx)\n else\n cnx._clear_in_transaction = true\n execute(level.to_begin_operation)\n begin\n return yield(cnx)\n rescue e\n has_rollback = true\n is_rollback_error = e.is_a?(RollbackError) || e.is_a?(CancelTransactionError)\n begin\n execute(\"ROLLBACK --\" + (is_rollback_error ? \"normal\" : \"program error\"))\n rescue\n nil\n end\n if is_rollback_error\n else\n raise(e)\n end\n ensure\n cnx._clear_in_transaction = false\n callbacks = @@commit_callbacks.delete(cnx)\n if has_rollback\n else\n execute(\"COMMIT\")\n callbacks.try(&.each(&.call(cnx)))\n end\n end\n end\nend"}},{"html_id":"with_savepoint(sp_name:Symbolic|Nil=nil,connection_name:String=\"default\",&)-instance-method","name":"with_savepoint","doc":"Create a transaction, but this one is stackable\nusing savepoints.\n\nExample:\n\n```\nClear::SQL.with_savepoint do\n # do something\n Clear::SQL.with_savepoint do\n rollback # < Rollback only the last `with_savepoint` block\n end\nend\n```","summary":"Create a transaction, but this one is stackable using savepoints.
","abstract":false,"args":[{"name":"sp_name","default_value":"nil","external_name":"sp_name","restriction":"Symbolic | ::Nil"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(sp_name : Symbolic | Nil = nil, connection_name : String = \"default\", &)","args_html":"(sp_name : Symbolic | Nil = nil, connection_name : String = "default", &)","location":{"filename":"src/clear/sql/transaction.cr","line_number":121,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L121"},"def":{"name":"with_savepoint","args":[{"name":"sp_name","default_value":"nil","external_name":"sp_name","restriction":"Symbolic | ::Nil"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"yields":0,"block_arity":0,"visibility":"Public","body":"transaction do |cnx|\n begin\n sp_name || (sp_name = \"sp_#{@@savepoint_uid = @@savepoint_uid + 1}\")\n execute(connection_name, \"SAVEPOINT #{sp_name}\")\n yield\n if cnx._clear_in_transaction?\n execute(connection_name, \"RELEASE SAVEPOINT #{sp_name}\")\n end\n rescue e : RollbackError\n if cnx._clear_in_transaction?\n execute(connection_name, \"ROLLBACK TO SAVEPOINT #{sp_name}\")\n if e.savepoint_id.try(&.!=(sp_name))\n raise(e)\n end\n end\n end\nend"}}],"types":[{"html_id":"clear/Clear/SQL/Transaction/Level","path":"Clear/SQL/Transaction/Level.html","kind":"enum","full_name":"Clear::SQL::Transaction::Level","name":"Level","abstract":false,"ancestors":[{"html_id":"clear/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/transaction.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L6"}],"repository_name":"clear","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"ReadCommitted","name":"ReadCommitted","value":"0"},{"id":"RepeatableRead","name":"RepeatableRead","value":"1"},{"id":"Serializable","name":"Serializable","value":"2"}],"namespace":{"html_id":"clear/Clear/SQL/Transaction","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction"},"doc":"Represents the differents levels of transactions\n as described in https://www.postgresql.org/docs/9.5/transaction-iso.html\n\n ReadUncommited is voluntarly ommited as it fallback to ReadCommited in PostgreSQL","summary":"Represents the differents levels of transactions as described in https://www.postgresql.org/docs/9.5/transaction-iso.html
","instance_methods":[{"html_id":"read_committed?-instance-method","name":"read_committed?","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L7"},"def":{"name":"read_committed?","visibility":"Public","body":"self == ReadCommitted"}},{"html_id":"repeatable_read?-instance-method","name":"repeatable_read?","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L8"},"def":{"name":"repeatable_read?","visibility":"Public","body":"self == RepeatableRead"}},{"html_id":"serializable?-instance-method","name":"serializable?","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L9"},"def":{"name":"serializable?","visibility":"Public","body":"self == Serializable"}}]}]},{"html_id":"clear/Clear/SQL/UpdateQuery","path":"Clear/SQL/UpdateQuery.html","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/update_query.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"TODO: Documentation","summary":"TODO Documentation
","constructors":[{"html_id":"new(table:String|Symbol|Nil,wheres:Array(Clear::Expression::Node)=[]ofClear::Expression::Node)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"args_string":"(table : String | Symbol | Nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","args_html":"(table : String | Symbol | Nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","location":{"filename":"src/clear/sql/update_query.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L19"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, wheres)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"set(row:NamedTuple)-instance-method","name":"set","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"args_string":"(row : NamedTuple)","args_html":"(row : NamedTuple)","location":{"filename":"src/clear/sql/update_query.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L22"},"def":{"name":"set","args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"visibility":"Public","body":"h = {} of String => Updatable\nrow.each do |k, v|\n h[k.to_s] = v\nend\nset(h)\nchange!\n"}},{"html_id":"set(row:String)-instance-method","name":"set","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"String"}],"args_string":"(row : String)","args_html":"(row : String)","location":{"filename":"src/clear/sql/update_query.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L33"},"def":{"name":"set","args":[{"name":"row","external_name":"row","restriction":"String"}],"visibility":"Public","body":"@values << row\nchange!\n"}},{"html_id":"set(row:Hash(String,Updatable))-instance-method","name":"set","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"Hash(String, Updatable)"}],"args_string":"(row : Hash(String, Updatable))","args_html":"(row : Hash(String, Updatable))","location":{"filename":"src/clear/sql/update_query.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L38"},"def":{"name":"set","args":[{"name":"row","external_name":"row","restriction":"Hash(String, Updatable)"}],"visibility":"Public","body":"@values << (Hash(String, Updatable).new.merge(row))\nchange!\n"}},{"html_id":"set(**row)-instance-method","name":"set","abstract":false,"location":{"filename":"src/clear/sql/update_query.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L29"},"def":{"name":"set","double_splat":{"name":"row","external_name":"row","restriction":""},"visibility":"Public","body":"set(row)"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/update_query.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L62"},"def":{"name":"to_sql","visibility":"Public","body":"table = @table.is_a?(Symbol) ? SQL.escape(@table.to_s) : @table\n[print_ctes, \"UPDATE\", table, \"SET\", print_values, print_wheres].compact.join(\" \")\n"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}],"types":[{"html_id":"clear/Clear/SQL/UpdateQuery/Updatable","path":"Clear/SQL/UpdateQuery/Updatable.html","kind":"alias","full_name":"Clear::SQL::UpdateQuery::Updatable","name":"Updatable","abstract":false,"locations":[{"filename":"src/clear/sql/update_query.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil)","aliased_html":"Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}},{"html_id":"clear/Clear/SQL/UpdateQuery/UpdateInstruction","path":"Clear/SQL/UpdateQuery/UpdateInstruction.html","kind":"alias","full_name":"Clear::SQL::UpdateQuery::UpdateInstruction","name":"UpdateInstruction","abstract":false,"locations":[{"filename":"src/clear/sql/update_query.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Hash(String, Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil) | String)","aliased_html":"Hash(String, Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil) | String","const":false,"namespace":{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}}]}]},{"html_id":"clear/Clear/TimeInDay","path":"Clear/TimeInDay.html","kind":"struct","full_name":"Clear::TimeInDay","name":"TimeInDay","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L29"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"`Clear::TimeInDay` represents the \"time\" object of PostgreSQL\n\nIt can be converted automatically from/to a `time` column.\nIt offers helpers which makes it usable also as a stand alone.\n\n## Usage example\n\n```\ntime = Clear::TimeInDay.parse(\"12:33\")\nputs time.hour # 12\nputs time.minutes # 0\n\nTime.local.at(time) # Today at 12:33:00\ntime.to_s # 12:33:00\ntime.to_s(false) # don't show seconds => 12:33\n\ntime = time + 2.minutes # 12:35\n```\n\nAs with Interval, you might wanna use it as a column (use underlying `time` type in PostgreSQL):\n\n```\nclass MyModel\n include Clear::Model\n\n column time_in_day : Clear::TimeInDay\nend\n```","summary":"Clear::TimeInDay
represents the "time" object of PostgreSQL
Parse a string, of format HH:MM or HH:MM:SS
","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String)","args_html":"(str : String)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":113,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L113"},"def":{"name":"parse","args":[{"name":"str","external_name":"str","restriction":"String"}],"visibility":"Public","body":"if str =~ (/^[0-9]+:[0-9]{2}(:[0-9]{2})?$/)\nelse\n raise(\"Wrong format\")\nend\narr = (str.split(/\\:/)).map(&.try(&.to_i))\nhours = arr[0]\nminutes = arr[1]\nseconds = arr[2]?\nif seconds\n return Clear::TimeInDay.new(hours, minutes, seconds)\nend\nClear::TimeInDay.new(hours, minutes)\n"}}],"constructors":[{"html_id":"new(hours,minutes,seconds=0)-class-method","name":"new","abstract":false,"args":[{"name":"hours","external_name":"hours","restriction":""},{"name":"minutes","external_name":"minutes","restriction":""},{"name":"seconds","default_value":"0","external_name":"seconds","restriction":""}],"args_string":"(hours, minutes, seconds = 0)","args_html":"(hours, minutes, seconds = 0)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L36"},"def":{"name":"new","args":[{"name":"hours","external_name":"hours","restriction":""},{"name":"minutes","external_name":"minutes","restriction":""},{"name":"seconds","default_value":"0","external_name":"seconds","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(hours, minutes, seconds)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(microseconds:UInt64=0)-class-method","name":"new","abstract":false,"args":[{"name":"microseconds","default_value":"0","external_name":"microseconds","restriction":"UInt64"}],"args_string":"(microseconds : UInt64 = 0)","args_html":"(microseconds : UInt64 = 0)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L40"},"def":{"name":"new","args":[{"name":"microseconds","default_value":"0","external_name":"microseconds","restriction":"UInt64"}],"visibility":"Public","body":"_ = allocate\n_.initialize(microseconds)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"+(t:Time::Span)-instance-method","name":"+","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"args_string":"(t : Time::Span)","args_html":"(t : Time::Span)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L43"},"def":{"name":"+","args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"visibility":"Public","body":"Clear::TimeInDay.new(microseconds: @microseconds + (t.total_nanoseconds.to_i64 // 1000))"}},{"html_id":"+(x:self)-instance-method","name":"+","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"self"}],"args_string":"(x : self)","args_html":"(x : self)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L51"},"def":{"name":"+","args":[{"name":"x","external_name":"x","restriction":"self"}],"visibility":"Public","body":"TimeInDay.new(@microseconds + x.ms)"}},{"html_id":"-(t:Time::Span)-instance-method","name":"-","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"args_string":"(t : Time::Span)","args_html":"(t : Time::Span)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L47"},"def":{"name":"-","args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"visibility":"Public","body":"Clear::TimeInDay.new(microseconds: @microseconds - (t.total_nanoseconds.to_i64 // 1000))"}},{"html_id":"hour-instance-method","name":"hour","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":55,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L55"},"def":{"name":"hour","visibility":"Public","body":"(@microseconds // HOUR)"}},{"html_id":"inspect-instance-method","name":"inspect","doc":"Returns an unambiguous and information-rich string representation of this\nobject, typically intended for developers.\n\nThis method should usually **not** be overridden. It delegates to\n`#inspect(IO)` which can be overridden for custom implementations.\n\nAlso see `#to_s`.","summary":"Returns an unambiguous and information-rich string representation of this object, typically intended for developers.
","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L79"},"def":{"name":"inspect","visibility":"Public","body":"\"#{self.class.name}(#{self})\""}},{"html_id":"microseconds:UInt64-instance-method","name":"microseconds","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L30"},"def":{"name":"microseconds","return_type":"UInt64","visibility":"Public","body":"@microseconds"}},{"html_id":"minutes-instance-method","name":"minutes","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":59,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L59"},"def":{"name":"minutes","visibility":"Public","body":"(@microseconds % HOUR) // MINUTE"}},{"html_id":"seconds-instance-method","name":"seconds","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":63,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L63"},"def":{"name":"seconds","visibility":"Public","body":"(@microseconds % MINUTE) // SECOND"}},{"html_id":"to_json(json:JSON::Builder):Nil-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"args_string":"(json : JSON::Builder) : Nil","args_html":"(json : JSON::Builder) : Nil","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L108"},"def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"return_type":"Nil","visibility":"Public","body":"json.string(to_s)"}},{"html_id":"to_s(show_seconds:Bool=true)-instance-method","name":"to_s","doc":"Returns a nicely readable and concise string representation of this object,\ntypically intended for users.\n\nThis method should usually **not** be overridden. It delegates to\n`#to_s(IO)` which can be overridden for custom implementations.\n\nAlso see `#inspect`.","summary":"Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"args":[{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"args_string":"(show_seconds : Bool = true)","args_html":"(show_seconds : Bool = true)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":83,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L83"},"def":{"name":"to_s","args":[{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"visibility":"Public","body":"io = IO::Memory.new\nto_s(io, show_seconds)\nio.rewind\nio.to_s\n"}},{"html_id":"to_s(io,show_seconds:Bool=true)-instance-method","name":"to_s","doc":"Return a string","summary":"Return a string
","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""},{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"args_string":"(io, show_seconds : Bool = true)","args_html":"(io, show_seconds : Bool = true)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":91,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L91"},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""},{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"visibility":"Public","body":"hours, minutes, seconds = to_tuple\nif show_seconds\n io << ({hours.to_s.rjust(2, '0'), minutes.to_s.rjust(2, '0'), seconds.to_s.rjust(2, '0')}.join(':'))\nelse\n io << ({hours.to_s.rjust(2, '0'), minutes.to_s.rjust(2, '0')}.join(':'))\nend\n"}},{"html_id":"to_tuple-instance-method","name":"to_tuple","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L71"},"def":{"name":"to_tuple","visibility":"Public","body":"hours, left = @microseconds.divmod(HOUR)\nminutes, left = left.divmod(MINUTE)\nseconds = left // SECOND\n{hours, minutes, seconds}\n"}},{"html_id":"total_seconds-instance-method","name":"total_seconds","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":67,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L67"},"def":{"name":"total_seconds","visibility":"Public","body":"@microseconds // SECOND"}}],"types":[{"html_id":"clear/Clear/TimeInDay/Converter","path":"Clear/TimeInDay/Converter.html","kind":"module","full_name":"Clear::TimeInDay::Converter","name":"Converter","abstract":false,"locations":[{"filename":"src/clear/extensions/time_in_days/time_in_day_converter.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day_converter.cr#L23"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/TimeInDay","kind":"struct","full_name":"Clear::TimeInDay","name":"TimeInDay"},"class_methods":[{"html_id":"to_column(x):TimeInDay|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : TimeInDay | Nil","args_html":"(x) : TimeInDay | Nil","location":{"filename":"src/clear/extensions/time_in_days/time_in_day_converter.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day_converter.cr#L24"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"TimeInDay | ::Nil","visibility":"Public","body":"case x\nwhen TimeInDay\n x\nwhen UInt64\n TimeInDay.new(x)\nwhen Slice\n mem = IO::Memory.new(x, writeable: false)\n TimeInDay.new(mem.read_bytes(UInt64, IO::ByteFormat::BigEndian))\nwhen String\n TimeInDay.parse(x)\nwhen Nil\n nil\nelse\n raise(\"Cannot convert to TimeInDay from #{x.class}\")\nend"}},{"html_id":"to_db(x:TimeInDay|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"TimeInDay | ::Nil"}],"args_string":"(x : TimeInDay | Nil)","args_html":"(x : TimeInDay | Nil)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day_converter.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day_converter.cr#L42"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"TimeInDay | ::Nil"}],"visibility":"Public","body":"x ? x.to_s : nil"}}]}]},{"html_id":"clear/Clear/TSVector","path":"Clear/TSVector.html","kind":"class","full_name":"Clear::TSVector","name":"TSVector","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"class_methods":[{"html_id":"decode(x:Slice(UInt8))-class-method","name":"decode","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Slice(UInt8)"}],"args_string":"(x : Slice(UInt8))","args_html":"(x : Slice(UInt8))","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L70"},"def":{"name":"decode","args":[{"name":"x","external_name":"x","restriction":"Slice(UInt8)"}],"visibility":"Public","body":"io = IO::Memory.new(x, writeable: false)\nClear::TSVector.new(io)\n"}}],"constructors":[{"html_id":"new(io)-class-method","name":"new","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L56"},"def":{"name":"new","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(io)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](key:String)-instance-method","name":"[]","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L39"},"def":{"name":"[]","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"lexems[key]"}},{"html_id":"[]?(key:String)-instance-method","name":"[]?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L43"},"def":{"name":"[]?","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"lexems[key]?"}},{"html_id":"lexems:Hash(String,Lexem)-instance-method","name":"lexems","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L37"},"def":{"name":"lexems","return_type":"Hash(String, Lexem)","visibility":"Public","body":"@lexems"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L47"},"def":{"name":"to_sql","visibility":"Public","body":"@lexems.values.join(\" \") do |v|\n {Clear::Expression[v.value], v.positions.join(\",\") do |p|\n {p.position, p.weight}.join\n end}.join(\":\")\nend"}}],"types":[{"html_id":"clear/Clear/TSVector/Converter","path":"Clear/TSVector/Converter.html","kind":"module","full_name":"Clear::TSVector::Converter","name":"Converter","abstract":false,"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":75,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L75"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/TSVector","kind":"class","full_name":"Clear::TSVector","name":"TSVector"},"class_methods":[{"html_id":"to_column(x):Clear::TSVector|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Clear::TSVector | Nil","args_html":"(x) : Clear::TSVector | Nil","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":76,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L76"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Clear::TSVector | ::Nil","visibility":"Public","body":"case x\nwhen Slice\n Clear::TSVector.decode(x.as(Slice(UInt8)))\nwhen Clear::TSVector\n x\nwhen Nil\n nil\nelse\n raise(Clear::ErrorMessages.converter_error(x.class, \"TSVector\"))\nend"}},{"html_id":"to_db(x:TSVector|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"TSVector | ::Nil"}],"args_string":"(x : TSVector | Nil)","args_html":"(x : TSVector | Nil)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":89,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L89"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"TSVector | ::Nil"}],"visibility":"Public","body":"x.try(&.to_sql)"}}]},{"html_id":"clear/Clear/TSVector/Lexem","path":"Clear/TSVector/Lexem.html","kind":"struct","full_name":"Clear::TSVector::Lexem","name":"Lexem","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"WEIGHTS","name":"WEIGHTS","value":"['A', 'B', 'C', 'D']"}],"namespace":{"html_id":"clear/Clear/TSVector","kind":"class","full_name":"Clear::TSVector","name":"TSVector"},"constructors":[{"html_id":"new(io)-class-method","name":"new","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L10"},"def":{"name":"new","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(io)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"positions:Array(Position)-instance-method","name":"positions","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L6"},"def":{"name":"positions","return_type":"Array(Position)","visibility":"Public","body":"@positions"}},{"html_id":"value:String-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L5"},"def":{"name":"value","return_type":"String","visibility":"Public","body":"@value"}}],"types":[{"html_id":"clear/Clear/TSVector/Lexem/Position","path":"Clear/TSVector/Lexem/Position.html","kind":"struct","full_name":"Clear::TSVector::Lexem::Position","name":"Position","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/TSVector/Lexem","kind":"struct","full_name":"Clear::TSVector::Lexem","name":"Lexem"},"constructors":[{"html_id":"new(weight:Char,position:UInt16)-class-method","name":"new","abstract":false,"args":[{"name":"weight","external_name":"weight","restriction":"Char"},{"name":"position","external_name":"position","restriction":"UInt16"}],"args_string":"(weight : Char, position : UInt16)","args_html":"(weight : Char, position : UInt16)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"},"def":{"name":"new","args":[{"name":"weight","external_name":"weight","restriction":"Char"},{"name":"position","external_name":"position","restriction":"UInt16"}],"visibility":"Public","body":"_ = allocate\n_.initialize(weight, position)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@weight.clone, @position.clone)"}},{"html_id":"copy_with(weight_weight=@weight,position_position=@position)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_weight","default_value":"@weight","external_name":"weight","restriction":""},{"name":"_position","default_value":"@position","external_name":"position","restriction":""}],"args_string":"(weight _weight = @weight, position _position = @position)","args_html":"(weight _weight = @weight, position _position = @position)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"},"def":{"name":"copy_with","args":[{"name":"_weight","default_value":"@weight","external_name":"weight","restriction":""},{"name":"_position","default_value":"@position","external_name":"position","restriction":""}],"visibility":"Public","body":"self.class.new(_weight, _position)"}},{"html_id":"position:UInt16-instance-method","name":"position","abstract":false,"def":{"name":"position","return_type":"UInt16","visibility":"Public","body":"@position"}},{"html_id":"weight:Char-instance-method","name":"weight","abstract":false,"def":{"name":"weight","return_type":"Char","visibility":"Public","body":"@weight"}}]}]}]},{"html_id":"clear/Clear/Util","path":"Clear/Util.html","kind":"module","full_name":"Clear::Util","name":"Util","abstract":false,"locations":[{"filename":"src/clear/util.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/util.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"clear/Clear/Util","kind":"module","full_name":"Clear::Util","name":"Util"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"A set of method(s) useful for building Clear ORM.","summary":"A set of method(s) useful for building Clear ORM.
","instance_methods":[{"html_id":"hash_union(h1:Hash(A,B),h2:Hash(C,D))forallA,B,C,D-instance-method","name":"hash_union","doc":"Return a new hash which is union of two hash (some kind of deep merge)","summary":"Return a new hash which is union of two hash (some kind of deep merge)
","abstract":false,"args":[{"name":"h1","external_name":"h1","restriction":"Hash(A, B)"},{"name":"h2","external_name":"h2","restriction":"Hash(C, D)"}],"args_string":"(h1 : Hash(A, B), h2 : Hash(C, D)) forall A, B, C, D","args_html":"(h1 : Hash(A, B), h2 : Hash(C, D)) forall A, B, C, D","location":{"filename":"src/clear/util.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/util.cr#L12"},"def":{"name":"hash_union","args":[{"name":"h1","external_name":"h1","restriction":"Hash(A, B)"},{"name":"h2","external_name":"h2","restriction":"Hash(C, D)"}],"visibility":"Public","body":"o = Hash(A | C, B | D).new\nh1.each do |k, v|\n o[k] = v\nend\nh2.each do |k, v|\n case v\n when Hash\n if (v1 = o[k]).is_a?(Hash)\n o[k] = hash_union(v1, v)\n else\n o[k] = v\n end\n else\n o[k] = v\n end\nend\no\n"}},{"html_id":"lambda(u:U.class,v:V.class,&block:U->V)forallU,V-instance-method","name":"lambda","doc":"Equivalent to ruby's lambda with one parameter.\nThis method is useful combined with the macro system of Crystal.","summary":"Equivalent to ruby's lambda with one parameter.
","abstract":false,"args":[{"name":"u","external_name":"u","restriction":"U.class"},{"name":"v","external_name":"v","restriction":"V.class"}],"args_string":"(u : U.class, v : V.class, &block : U -> V) forall U, V","args_html":"(u : U.class, v : V.class, &block : U -> V) forall U, V","location":{"filename":"src/clear/util.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/util.cr#L7"},"def":{"name":"lambda","args":[{"name":"u","external_name":"u","restriction":"U.class"},{"name":"v","external_name":"v","restriction":"V.class"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(U -> V)"},"visibility":"Public","body":"block"}}]},{"html_id":"clear/Clear/Validation","path":"Clear/Validation.html","kind":"module","full_name":"Clear::Validation","name":"Validation","abstract":false,"locations":[{"filename":"src/clear/model/validation/helper.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"types":[{"html_id":"clear/Clear/Validation/Helper","path":"Clear/Validation/Helper.html","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper","abstract":false,"locations":[{"filename":"src/clear/model/validation/helper.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"}],"namespace":{"html_id":"clear/Clear/Validation","kind":"module","full_name":"Clear::Validation","name":"Validation"},"macros":[{"html_id":"ensure_than(field,message,&block)-macro","name":"ensure_than","doc":"Usage example:\n\n```\nensure_than email, \"must be an email\" do |v|\n EmailRegexp.valid?(v)\nend\n```","summary":"Usage example:
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"message","external_name":"message","restriction":""}],"args_string":"(field, message, &block)","args_html":"(field, message, &block)","location":{"filename":"src/clear/model/validation/helper.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L15"},"def":{"name":"ensure_than","args":[{"name":"field","external_name":"field","restriction":""},{"name":"message","external_name":"message","restriction":""}],"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" if \n{{ field.id }}\n_column.defined?\n o = \n{{ field.id }}\n\n\n fn = Clear::Util.lambda(typeof(o), Object) \n{{ block }}\n\n\n unless fn.call(o)\n add_error(\n{{ field.stringify }}\n, \n{{ message }}\n)\n \nend\n \nend\n\n \n"}},{"html_id":"on_presence(*fields,&block)-macro","name":"on_presence","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":""}],"args_string":"(*fields, &block)","args_html":"(*fields, &block)","location":{"filename":"src/clear/model/validation/helper.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L2"},"def":{"name":"on_presence","args":[{"name":"fields","external_name":"fields","restriction":""}],"splat_index":0,"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" if \n{{ (fields.map do |x|\n \"self.#{x.id}_column.defined?\"\nend.join(\" && \")).id }}\n\n \n{{ yield }}\n\n \nend\n \n"}}]}]},{"html_id":"clear/Clear/View","path":"Clear/View.html","kind":"class","full_name":"Clear::View","name":"View","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/view/base.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L48"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"Create and maintain your database views directly in the code.\n\nYou could use the migration system to create and drop your views. However this\nis proven to be difficult, even more if you want to update a view which depends on\nanother subviews.\n\n## How it works ?\n\nWhen you migrate using the migration system, all the views registered\nare going to be destroyed and recreated again.\nOrder of creation depends of the requirement for each views\n\n## Example\n\n```\nClear::View.register :room_per_days do |view|\n view.require(:rooms, :year_days)\n\n view.query <<-SQL\n SELECT room_id, day\n FROM year_days\n CROSS JOIN rooms\n SQL\nend\n\nClear::View.register :rooms do |view|\n view.query <<-SQL\n SELECT room.id as room_id\n FROM generate_series(1, 4) AS room(id)\n SQL\nend\n\nClear::View.register :year_days do |view|\n view.query <<-SQL\n SELECT date.day::date as day\n FROM generate_series(\n date_trunc('day', NOW()),\n date_trunc('day', NOW() + INTERVAL '364 days'),\n INTERVAL '1 day'\n ) AS date(day)\n SQL\nend\n```\n\nIn the example above, room_per_days will be first dropped before a migration\nstart and last created after the migration finished, to prevent issue where some\nviews are linked to others","summary":"Create and maintain your database views directly in the code.
","class_methods":[{"html_id":"apply(direction:Symbol,view_name:String,apply_cache:Set(String))-class-method","name":"apply","doc":"install the view into postgresql using CREATE VIEW","summary":"install the view into postgresql using CREATE VIEW
","abstract":false,"args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"view_name","external_name":"view_name","restriction":"String"},{"name":"apply_cache","external_name":"apply_cache","restriction":"Set(String)"}],"args_string":"(direction : Symbol, view_name : String, apply_cache : Set(String))","args_html":"(direction : Symbol, view_name : String, apply_cache : Set(String))","location":{"filename":"src/clear/view/base.cr","line_number":76,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L76"},"def":{"name":"apply","args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"view_name","external_name":"view_name","restriction":"String"},{"name":"apply_cache","external_name":"apply_cache","restriction":"Set(String)"}],"visibility":"Public","body":"if apply_cache.includes?(view_name)\n return\nend\nview = @@views[view_name]\nview.requirement.each do |dep_view|\n apply(direction, dep_view, apply_cache)\nend\nClear::SQL.execute(view.connection, direction == (:drop) ? view.to_drop_sql : view.to_create_sql)\napply_cache << view_name\n"}},{"html_id":"apply(direction:Symbol,apply_cache=Set(String).new)-class-method","name":"apply","doc":"install the view into postgresql using CREATE VIEW","summary":"install the view into postgresql using CREATE VIEW
","abstract":false,"args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"apply_cache","default_value":"Set(String).new","external_name":"apply_cache","restriction":""}],"args_string":"(direction : Symbol, apply_cache = Set(String).new)","args_html":"(direction : Symbol, apply_cache = Set(String).new)","location":{"filename":"src/clear/view/base.cr","line_number":68,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L68"},"def":{"name":"apply","args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"apply_cache","default_value":"Set(String).new","external_name":"apply_cache","restriction":""}],"visibility":"Public","body":"@@views.values.each do |view|\n if apply_cache.includes?(view.name)\n next\n end\n apply(direction, view.name, apply_cache)\nend"}},{"html_id":"register(name:Clear::SQL::Symbolic,&)-class-method","name":"register","doc":"Call the DSL to register a new view\n\n```\nClear::View.register(:name) do |view|\n # describe the view here.\nend\n```","summary":"Call the DSL to register a new view
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Clear::SQL::Symbolic"}],"args_string":"(name : Clear::SQL::Symbolic, &)","args_html":"(name : Clear::SQL::Symbolic, &)","location":{"filename":"src/clear/view/base.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L56"},"def":{"name":"register","args":[{"name":"name","external_name":"name","restriction":"Clear::SQL::Symbolic"}],"yields":1,"block_arity":1,"visibility":"Public","body":"view = Clear::View.new\nview.name(name)\nyield view\nif view.name == \"\"\n raise(\"Your view need to have a name\")\nend\nif view.query == \"\"\n raise(\"View `#{view.name}` need to have a query body\")\nend\n@@views[view.name] = view\n"}}],"instance_methods":[{"html_id":"connection(connection:String)-instance-method","name":"connection","doc":"database connection where is installed the view","summary":"database connection where is installed the view
","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":"String"}],"args_string":"(connection : String)","args_html":"(connection : String)","location":{"filename":"src/clear/view/base.cr","line_number":118,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L118"},"def":{"name":"connection","args":[{"name":"connection","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"@connection = connection"}},{"html_id":"connection:String-instance-method","name":"connection","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":99,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L99"},"def":{"name":"connection","return_type":"String","visibility":"Public","body":"@connection"}},{"html_id":"full_name-instance-method","name":"full_name","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":137,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L137"},"def":{"name":"full_name","visibility":"Public","body":"{@schema, @name}.join(\".\") do |x|\n Clear::SQL.escape(x)\nend"}},{"html_id":"materialized(mat:Bool)-instance-method","name":"materialized","doc":"whether the view is materialized or not. I would recommend to use\nmigration execute create/drop whenever the view is a materialized view","summary":"whether the view is materialized or not.
","abstract":false,"args":[{"name":"mat","external_name":"mat","restriction":"Bool"}],"args_string":"(mat : Bool)","args_html":"(mat : Bool)","location":{"filename":"src/clear/view/base.cr","line_number":124,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L124"},"def":{"name":"materialized","args":[{"name":"mat","external_name":"mat","restriction":"Bool"}],"visibility":"Public","body":"@materialized = mat"}},{"html_id":"materialized?:Bool-instance-method","name":"materialized?","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":100,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L100"},"def":{"name":"materialized?","return_type":"Bool","visibility":"Public","body":"@materialized"}},{"html_id":"name(value:String|Symbol)-instance-method","name":"name","doc":"name of the view","summary":"name of the view
","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"args_string":"(value : String | Symbol)","args_html":"(value : String | Symbol)","location":{"filename":"src/clear/view/base.cr","line_number":103,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L103"},"def":{"name":"name","args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"visibility":"Public","body":"@name = value.to_s"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L95"},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"query(query:String)-instance-method","name":"query","doc":"query body related to the view. Must be a SELECT clause","summary":"query body related to the view.
","abstract":false,"args":[{"name":"query","external_name":"query","restriction":"String"}],"args_string":"(query : String)","args_html":"(query : String)","location":{"filename":"src/clear/view/base.cr","line_number":113,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L113"},"def":{"name":"query","args":[{"name":"query","external_name":"query","restriction":"String"}],"visibility":"Public","body":"@query = query"}},{"html_id":"query:String-instance-method","name":"query","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":97,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L97"},"def":{"name":"query","return_type":"String","visibility":"Public","body":"@query"}},{"html_id":"require(*req)-instance-method","name":"require","doc":"list of dependencies from the other view related to this view","summary":"list of dependencies from the other view related to this view
","abstract":false,"args":[{"name":"req","external_name":"req","restriction":""}],"args_string":"(*req)","args_html":"(*req)","location":{"filename":"src/clear/view/base.cr","line_number":129,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L129"},"def":{"name":"require","args":[{"name":"req","external_name":"req","restriction":""}],"splat_index":0,"visibility":"Public","body":"req.map(&.to_s).each do |s|\n @requirement.add(s)\nend"}},{"html_id":"requirement:Set(String)-instance-method","name":"requirement","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":98,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L98"},"def":{"name":"requirement","visibility":"Public","body":"@requirement"}},{"html_id":"schema(value:String|Symbol)-instance-method","name":"schema","doc":"schema to store the view (default public)","summary":"schema to store the view (default public)
","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"args_string":"(value : String | Symbol)","args_html":"(value : String | Symbol)","location":{"filename":"src/clear/view/base.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L108"},"def":{"name":"schema","args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"visibility":"Public","body":"@schema = value.to_s"}},{"html_id":"schema:String-instance-method","name":"schema","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":96,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L96"},"def":{"name":"schema","return_type":"String","visibility":"Public","body":"@schema"}},{"html_id":"to_create_sql-instance-method","name":"to_create_sql","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":141,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L141"},"def":{"name":"to_create_sql","visibility":"Public","body":"{\"CREATE OR REPLACE\", (materialized? ? \"MATERIALIZED VIEW\" : \"VIEW\"), full_name, \"AS (\", @query, \")\"}.join(' ')"}},{"html_id":"to_drop_sql-instance-method","name":"to_drop_sql","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":133,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L133"},"def":{"name":"to_drop_sql","visibility":"Public","body":"\"DROP VIEW IF EXISTS #{@name}\""}}]}]},{"html_id":"clear/Slice","path":"Slice.html","kind":"struct","full_name":"Slice(T)","name":"Slice","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Indexable/Mutable","kind":"module","full_name":"Indexable::Mutable","name":"Mutable"},{"html_id":"clear/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/core_ext.cr","line_number":109,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/core_ext.cr#L109"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Indexable/Mutable","kind":"module","full_name":"Indexable::Mutable","name":"Mutable"}],"doc":"A `Slice` is a `Pointer` with an associated size.\n\nWhile a pointer is unsafe because no bound checks are performed when reading from and writing to it,\nreading from and writing to a slice involve bound checks.\nIn this way, a slice is a safe alternative to `Pointer`.\n\nA Slice can be created as read-only: trying to write to it\nwill raise. For example the slice of bytes returned by\n`String#to_slice` is read-only.","summary":"A Slice
is a Pointer
with an associated size.
Time
represents a date-time instant in incremental time observed in a specific time zone.
Represents a UUID (Universally Unique IDentifier).
","instance_methods":[{"html_id":"to_json(json:JSON::Builder)-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"args_string":"(json : JSON::Builder)","args_html":"(json : JSON::Builder)","location":{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L2"},"def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"visibility":"Public","body":"json.string(to_s)"}}]}]}} \ No newline at end of file diff --git a/js/doc.js b/js/doc.js new file mode 100644 index 000000000..eaedd5c32 --- /dev/null +++ b/js/doc.js @@ -0,0 +1,1099 @@ +window.CrystalDocs = (window.CrystalDocs || {}); + +CrystalDocs.base_path = (CrystalDocs.base_path || ""); + +CrystalDocs.searchIndex = (CrystalDocs.searchIndex || false); +CrystalDocs.MAX_RESULTS_DISPLAY = 140; + +CrystalDocs.runQuery = function(query) { + function searchType(type, query, results) { + var matches = []; + var matchedFields = []; + var name = type.full_name; + var i = name.lastIndexOf("::"); + if (i > 0) { + name = name.substring(i + 2); + } + var nameMatches = query.matches(name); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + + var namespaceMatches = query.matchesNamespace(type.full_name); + if(namespaceMatches){ + matches = matches.concat(namespaceMatches); + matchedFields.push("name"); + } + + var docMatches = query.matches(type.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + if (matches.length > 0) { + results.push({ + id: type.html_id, + result_type: "type", + kind: type.kind, + name: name, + full_name: type.full_name, + href: type.path, + summary: type.summary, + matched_fields: matchedFields, + matched_terms: matches + }); + } + + if (type.instance_methods) { + type.instance_methods.forEach(function(method) { + searchMethod(method, type, "instance_method", query, results); + }) + } + if (type.class_methods) { + type.class_methods.forEach(function(method) { + searchMethod(method, type, "class_method", query, results); + }) + } + if (type.constructors) { + type.constructors.forEach(function(constructor) { + searchMethod(constructor, type, "constructor", query, results); + }) + } + if (type.macros) { + type.macros.forEach(function(macro) { + searchMethod(macro, type, "macro", query, results); + }) + } + if (type.constants) { + type.constants.forEach(function(constant){ + searchConstant(constant, type, query, results); + }); + } + if (type.types) { + type.types.forEach(function(subtype){ + searchType(subtype, query, results); + }); + } + }; + + function searchMethod(method, type, kind, query, results) { + var matches = []; + var matchedFields = []; + var nameMatches = query.matchesMethod(method.name, kind, type); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + + if (method.args) { + method.args.forEach(function(arg){ + var argMatches = query.matches(arg.external_name); + if (argMatches) { + matches = matches.concat(argMatches); + matchedFields.push("args"); + } + }); + } + + var docMatches = query.matches(type.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + + if (matches.length > 0) { + var typeMatches = query.matches(type.full_name); + if (typeMatches) { + matchedFields.push("type"); + matches = matches.concat(typeMatches); + } + results.push({ + id: method.html_id, + type: type.full_name, + result_type: kind, + name: method.name, + full_name: type.full_name + "#" + method.name, + args_string: method.args_string, + summary: method.summary, + href: type.path + "#" + method.html_id, + matched_fields: matchedFields, + matched_terms: matches + }); + } + } + + function searchConstant(constant, type, query, results) { + var matches = []; + var matchedFields = []; + var nameMatches = query.matches(constant.name); + if (nameMatches){ + matches = matches.concat(nameMatches); + matchedFields.push("name"); + } + var docMatches = query.matches(constant.doc); + if(docMatches){ + matches = matches.concat(docMatches); + matchedFields.push("doc"); + } + if (matches.length > 0) { + var typeMatches = query.matches(type.full_name); + if (typeMatches) { + matchedFields.push("type"); + matches = matches.concat(typeMatches); + } + results.push({ + id: constant.id, + type: type.full_name, + result_type: "constant", + name: constant.name, + full_name: type.full_name + "#" + constant.name, + value: constant.value, + summary: constant.summary, + href: type.path + "#" + constant.id, + matched_fields: matchedFields, + matched_terms: matches + }); + } + } + + var results = []; + searchType(CrystalDocs.searchIndex.program, query, results); + return results; +}; + +CrystalDocs.rankResults = function(results, query) { + function uniqueArray(ar) { + var j = {}; + + ar.forEach(function(v) { + j[v + "::" + typeof v] = v; + }); + + return Object.keys(j).map(function(v) { + return j[v]; + }); + } + + results = results.sort(function(a, b) { + var matchedTermsDiff = uniqueArray(b.matched_terms).length - uniqueArray(a.matched_terms).length; + var aHasDocs = b.matched_fields.includes("doc"); + var bHasDocs = b.matched_fields.includes("doc"); + + var aOnlyDocs = aHasDocs && a.matched_fields.length == 1; + var bOnlyDocs = bHasDocs && b.matched_fields.length == 1; + + if (a.result_type == "type" && b.result_type != "type" && !aOnlyDocs) { + if(CrystalDocs.DEBUG) { console.log("a is type b not"); } + return -1; + } else if (b.result_type == "type" && a.result_type != "type" && !bOnlyDocs) { + if(CrystalDocs.DEBUG) { console.log("b is type, a not"); } + return 1; + } + if (a.matched_fields.includes("name")) { + if (b.matched_fields.includes("name")) { + var a_name = (CrystalDocs.prefixForType(a.result_type) || "") + ((a.result_type == "type") ? a.full_name : a.name); + var b_name = (CrystalDocs.prefixForType(b.result_type) || "") + ((b.result_type == "type") ? b.full_name : b.name); + a_name = a_name.toLowerCase(); + b_name = b_name.toLowerCase(); + for(var i = 0; i < query.normalizedTerms.length; i++) { + var term = query.terms[i].replace(/^::?|::?$/, ""); + var a_orig_index = a_name.indexOf(term); + var b_orig_index = b_name.indexOf(term); + if(CrystalDocs.DEBUG) { console.log("term: " + term + " a: " + a_name + " b: " + b_name); } + if(CrystalDocs.DEBUG) { console.log(a_orig_index, b_orig_index, a_orig_index - b_orig_index); } + if (a_orig_index >= 0) { + if (b_orig_index >= 0) { + if(CrystalDocs.DEBUG) { console.log("both have exact match", a_orig_index > b_orig_index ? -1 : 1); } + if(a_orig_index != b_orig_index) { + if(CrystalDocs.DEBUG) { console.log("both have exact match at different positions", a_orig_index > b_orig_index ? 1 : -1); } + return a_orig_index > b_orig_index ? 1 : -1; + } + } else { + if(CrystalDocs.DEBUG) { console.log("a has exact match, b not"); } + return -1; + } + } else if (b_orig_index >= 0) { + if(CrystalDocs.DEBUG) { console.log("b has exact match, a not"); } + return 1; + } + } + } else { + if(CrystalDocs.DEBUG) { console.log("a has match in name, b not"); } + return -1; + } + } else if ( + !a.matched_fields.includes("name") && + b.matched_fields.includes("name") + ) { + return 1; + } + + if (matchedTermsDiff != 0 || (aHasDocs != bHasDocs)) { + if(CrystalDocs.DEBUG) { console.log("matchedTermsDiff: " + matchedTermsDiff, aHasDocs, bHasDocs); } + return matchedTermsDiff; + } + + var matchedFieldsDiff = b.matched_fields.length - a.matched_fields.length; + if (matchedFieldsDiff != 0) { + if(CrystalDocs.DEBUG) { console.log("matched to different number of fields: " + matchedFieldsDiff); } + return matchedFieldsDiff > 0 ? 1 : -1; + } + + var nameCompare = a.name.localeCompare(b.name); + if(nameCompare != 0){ + if(CrystalDocs.DEBUG) { console.log("nameCompare resulted in: " + a.name + "<=>" + b.name + ": " + nameCompare); } + return nameCompare > 0 ? 1 : -1; + } + + if(a.matched_fields.includes("args") && b.matched_fields.includes("args")) { + for(var i = 0; i < query.terms.length; i++) { + var term = query.terms[i]; + var aIndex = a.args_string.indexOf(term); + var bIndex = b.args_string.indexOf(term); + if(CrystalDocs.DEBUG) { console.log("index of " + term + " in args_string: " + aIndex + " - " + bIndex); } + if(aIndex >= 0){ + if(bIndex >= 0){ + if(aIndex != bIndex){ + return aIndex > bIndex ? 1 : -1; + } + }else{ + return -1; + } + }else if(bIndex >= 0) { + return 1; + } + } + } + + return 0; + }); + + if (results.length > 1) { + // if we have more than two search terms, only include results with the most matches + var bestMatchedTerms = uniqueArray(results[0].matched_terms).length; + + results = results.filter(function(result) { + return uniqueArray(result.matched_terms).length + 1 >= bestMatchedTerms; + }); + } + return results; +}; + +CrystalDocs.prefixForType = function(type) { + switch (type) { + case "instance_method": + return "#"; + + case "class_method": + case "macro": + case "constructor": + return "."; + + default: + return false; + } +}; + +CrystalDocs.displaySearchResults = function(results, query) { + function sanitize(html){ + return html.replace(/<(?!\/?code)[^>]+>/g, ""); + } + + // limit results + if (results.length > CrystalDocs.MAX_RESULTS_DISPLAY) { + results = results.slice(0, CrystalDocs.MAX_RESULTS_DISPLAY); + } + + var $frag = document.createDocumentFragment(); + var $resultsElem = document.querySelector(".search-list"); + $resultsElem.innerHTML = ""; + + results.forEach(function(result, i) { + var url = CrystalDocs.base_path + result.href; + var type = false; + + var title = query.highlight(result.result_type == "type" ? result.full_name : result.name); + + var prefix = CrystalDocs.prefixForType(result.result_type); + if (prefix) { + title = "" + prefix + "" + title; + } + + title = "" + title + ""; + + if (result.args_string) { + title += + "" + query.highlight(result.args_string) + ""; + } + + $elem = document.createElement("li"); + $elem.className = "search-result search-result--" + result.result_type; + $elem.dataset.href = url; + $elem.setAttribute("title", result.full_name + " docs page"); + + var $title = document.createElement("div"); + $title.setAttribute("class", "search-result__title"); + var $titleLink = document.createElement("a"); + $titleLink.setAttribute("href", url); + + $titleLink.innerHTML = title; + $title.appendChild($titleLink); + $elem.appendChild($title); + $elem.addEventListener("click", function() { + $titleLink.click(); + }); + + if (result.result_type !== "type") { + var $type = document.createElement("div"); + $type.setAttribute("class", "search-result__type"); + $type.innerHTML = query.highlight(result.type); + $elem.appendChild($type); + } + + if(result.summary){ + var $doc = document.createElement("div"); + $doc.setAttribute("class", "search-result__doc"); + $doc.innerHTML = query.highlight(sanitize(result.summary)); + $elem.appendChild($doc); + } + + $elem.appendChild(document.createComment(JSON.stringify(result))); + $frag.appendChild($elem); + }); + + $resultsElem.appendChild($frag); + + CrystalDocs.toggleResultsList(true); +}; + +CrystalDocs.toggleResultsList = function(visible) { + if (visible) { + document.querySelector(".types-list").classList.add("hidden"); + document.querySelector(".search-results").classList.remove("hidden"); + } else { + document.querySelector(".types-list").classList.remove("hidden"); + document.querySelector(".search-results").classList.add("hidden"); + } +}; + +CrystalDocs.Query = function(string) { + this.original = string; + this.terms = string.split(/\s+/).filter(function(word) { + return CrystalDocs.Query.stripModifiers(word).length > 0; + }); + + var normalized = this.terms.map(CrystalDocs.Query.normalizeTerm); + this.normalizedTerms = normalized; + + function runMatcher(field, matcher) { + if (!field) { + return false; + } + var normalizedValue = CrystalDocs.Query.normalizeTerm(field); + + var matches = []; + normalized.forEach(function(term) { + if (matcher(normalizedValue, term)) { + matches.push(term); + } + }); + return matches.length > 0 ? matches : false; + } + + this.matches = function(field) { + return runMatcher(field, function(normalized, term) { + if (term[0] == "#" || term[0] == ".") { + return false; + } + return normalized.indexOf(term) >= 0; + }); + }; + + function namespaceMatcher(normalized, term){ + var i = term.indexOf(":"); + if(i >= 0){ + term = term.replace(/^::?|::?$/, ""); + var index = normalized.indexOf(term); + if((index == 0) || (index > 0 && normalized[index-1] == ":")){ + return true; + } + } + return false; + } + this.matchesMethod = function(name, kind, type) { + return runMatcher(name, function(normalized, term) { + var i = term.indexOf("#"); + if(i >= 0){ + if (kind != "instance_method") { + return false; + } + }else{ + i = term.indexOf("."); + if(i >= 0){ + if (kind != "class_method" && kind != "macro" && kind != "constructor") { + return false; + } + }else{ + //neither # nor . + if(term.indexOf(":") && namespaceMatcher(normalized, term)){ + return true; + } + } + } + + var methodName = term; + if(i >= 0){ + var termType = term.substring(0, i); + methodName = term.substring(i+1); + + if(termType != "") { + if(CrystalDocs.Query.normalizeTerm(type.full_name).indexOf(termType) < 0){ + return false; + } + } + } + return normalized.indexOf(methodName) >= 0; + }); + }; + + this.matchesNamespace = function(namespace){ + return runMatcher(namespace, namespaceMatcher); + }; + + this.highlight = function(string) { + if (typeof string == "undefined") { + return ""; + } + function escapeRegExp(s) { + return s.replace(/[.*+?\^${}()|\[\]\\]/g, "\\$&").replace(/^[#\.:]+/, ""); + } + return string.replace( + new RegExp("(" + this.normalizedTerms.map(escapeRegExp).join("|") + ")", "gi"), + "$1" + ); + }; +}; +CrystalDocs.Query.normalizeTerm = function(term) { + return term.toLowerCase(); +}; +CrystalDocs.Query.stripModifiers = function(term) { + switch (term[0]) { + case "#": + case ".": + case ":": + return term.substr(1); + + default: + return term; + } +} + +CrystalDocs.search = function(string) { + if(!CrystalDocs.searchIndex) { + console.log("CrystalDocs search index not initialized, delaying search"); + + document.addEventListener("CrystalDocs:loaded", function listener(){ + document.removeEventListener("CrystalDocs:loaded", listener); + CrystalDocs.search(string); + }); + return; + } + + document.dispatchEvent(new Event("CrystalDocs:searchStarted")); + + var query = new CrystalDocs.Query(string); + var results = CrystalDocs.runQuery(query); + results = CrystalDocs.rankResults(results, query); + CrystalDocs.displaySearchResults(results, query); + + document.dispatchEvent(new Event("CrystalDocs:searchPerformed")); +}; + +CrystalDocs.initializeIndex = function(data) { + CrystalDocs.searchIndex = data; + + document.dispatchEvent(new Event("CrystalDocs:loaded")); +}; + +CrystalDocs.loadIndex = function() { + function loadJSON(file, callback) { + var xobj = new XMLHttpRequest(); + xobj.overrideMimeType("application/json"); + xobj.open("GET", file, true); + xobj.onreadystatechange = function() { + if (xobj.readyState == 4 && xobj.status == "200") { + callback(xobj.responseText); + } + }; + xobj.send(null); + } + + function loadScript(file) { + script = document.createElement("script"); + script.src = file; + document.body.appendChild(script); + } + + function parseJSON(json) { + CrystalDocs.initializeIndex(JSON.parse(json)); + } + + for(var i = 0; i < document.scripts.length; i++){ + var script = document.scripts[i]; + if (script.src && script.src.indexOf("js/doc.js") >= 0) { + if (script.src.indexOf("file://") == 0) { + // We need to support JSONP files for the search to work on local file system. + var jsonPath = script.src.replace("js/doc.js", "search-index.js"); + loadScript(jsonPath); + return; + } else { + var jsonPath = script.src.replace("js/doc.js", "index.json"); + loadJSON(jsonPath, parseJSON); + return; + } + } + } + console.error("Could not find location of js/doc.js"); +}; + +// Callback for jsonp +function crystal_doc_search_index_callback(data) { + CrystalDocs.initializeIndex(data); +} + +Navigator = function(sidebar, searchInput, list, leaveSearchScope){ + this.list = list; + var self = this; + + var performingSearch = false; + + document.addEventListener('CrystalDocs:searchStarted', function(){ + performingSearch = true; + }); + document.addEventListener('CrystalDocs:searchDebounceStarted', function(){ + performingSearch = true; + }); + document.addEventListener('CrystalDocs:searchPerformed', function(){ + performingSearch = false; + }); + document.addEventListener('CrystalDocs:searchDebounceStopped', function(event){ + performingSearch = false; + }); + + function delayWhileSearching(callback) { + if(performingSearch){ + document.addEventListener('CrystalDocs:searchPerformed', function listener(){ + document.removeEventListener('CrystalDocs:searchPerformed', listener); + + // add some delay to let search results display kick in + setTimeout(callback, 100); + }); + }else{ + callback(); + } + } + + function clearMoveTimeout() { + clearTimeout(self.moveTimeout); + self.moveTimeout = null; + } + + function startMoveTimeout(upwards){ + /*if(self.moveTimeout) { + clearMoveTimeout(); + } + + var go = function() { + if (!self.moveTimeout) return; + self.move(upwards); + self.moveTimeout = setTimeout(go, 600); + }; + self.moveTimeout = setTimeout(go, 800);*/ + } + + function scrollCenter(element) { + var rect = element.getBoundingClientRect(); + var middle = sidebar.clientHeight / 2; + sidebar.scrollTop += rect.top + rect.height / 2 - middle; + } + + var move = this.move = function(upwards){ + if(!this.current){ + this.highlightFirst(); + return true; + } + var next = upwards ? this.current.previousElementSibling : this.current.nextElementSibling; + if(next && next.classList) { + this.highlight(next); + scrollCenter(next); + return true; + } + return false; + }; + + this.moveRight = function(){ + }; + this.moveLeft = function(){ + }; + + this.highlight = function(elem) { + if(!elem){ + return; + } + this.removeHighlight(); + + this.current = elem; + this.current.classList.add("current"); + }; + + this.highlightFirst = function(){ + this.highlight(this.list.querySelector('li:first-child')); + }; + + this.removeHighlight = function() { + if(this.current){ + this.current.classList.remove("current"); + } + this.current = null; + } + + this.openSelectedResult = function() { + if(this.current) { + this.current.click(); + } + } + + this.focus = function() { + searchInput.focus(); + searchInput.select(); + this.highlightFirst(); + } + + function handleKeyUp(event) { + switch(event.key) { + case "ArrowUp": + case "ArrowDown": + case "i": + case "j": + case "k": + case "l": + case "c": + case "h": + case "t": + case "n": + event.stopPropagation(); + clearMoveTimeout(); + } + } + + function handleKeyDown(event) { + switch(event.key) { + case "Enter": + event.stopPropagation(); + event.preventDefault(); + leaveSearchScope(); + self.openSelectedResult(); + break; + case "Escape": + event.stopPropagation(); + event.preventDefault(); + leaveSearchScope(); + break; + case "j": + case "c": + case "ArrowUp": + if(event.ctrlKey || event.key == "ArrowUp") { + event.stopPropagation(); + self.move(true); + startMoveTimeout(true); + } + break; + case "k": + case "h": + case "ArrowDown": + if(event.ctrlKey || event.key == "ArrowDown") { + event.stopPropagation(); + self.move(false); + startMoveTimeout(false); + } + break; + case "k": + case "t": + case "ArrowLeft": + if(event.ctrlKey || event.key == "ArrowLeft") { + event.stopPropagation(); + self.moveLeft(); + } + break; + case "l": + case "n": + case "ArrowRight": + if(event.ctrlKey || event.key == "ArrowRight") { + event.stopPropagation(); + self.moveRight(); + } + break; + } + } + + function handleInputKeyUp(event) { + switch(event.key) { + case "ArrowUp": + case "ArrowDown": + event.stopPropagation(); + event.preventDefault(); + clearMoveTimeout(); + } + } + + function handleInputKeyDown(event) { + switch(event.key) { + case "Enter": + event.stopPropagation(); + event.preventDefault(); + delayWhileSearching(function(){ + self.openSelectedResult(); + leaveSearchScope(); + }); + break; + case "Escape": + event.stopPropagation(); + event.preventDefault(); + // remove focus from search input + leaveSearchScope(); + sidebar.focus(); + break; + case "ArrowUp": + event.stopPropagation(); + event.preventDefault(); + self.move(true); + startMoveTimeout(true); + break; + + case "ArrowDown": + event.stopPropagation(); + event.preventDefault(); + self.move(false); + startMoveTimeout(false); + break; + } + } + + sidebar.tabIndex = 100; // set tabIndex to enable keylistener + sidebar.addEventListener('keyup', function(event) { + handleKeyUp(event); + }); + sidebar.addEventListener('keydown', function(event) { + handleKeyDown(event); + }); + searchInput.addEventListener('keydown', function(event) { + handleInputKeyDown(event); + }); + searchInput.addEventListener('keyup', function(event) { + handleInputKeyUp(event); + }); + this.move(); +}; + +CrystalDocs.initializeVersions = function () { + function loadJSON(file, callback) { + var xobj = new XMLHttpRequest(); + xobj.overrideMimeType("application/json"); + xobj.open("GET", file, true); + xobj.onreadystatechange = function() { + if (xobj.readyState == 4 && xobj.status == "200") { + callback(xobj.responseText); + } + }; + xobj.send(null); + } + + function parseJSON(json) { + CrystalDocs.loadConfig(JSON.parse(json)); + } + + $elem = document.querySelector("html > head > meta[name=\"crystal_docs.json_config_url\"]") + if ($elem == undefined) { + return + } + jsonURL = $elem.getAttribute("content") + if (jsonURL && jsonURL != "") { + loadJSON(jsonURL, parseJSON); + } +} + +CrystalDocs.loadConfig = function (config) { + var projectVersions = config["versions"] + var currentVersion = document.querySelector("html > head > meta[name=\"crystal_docs.project_version\"]").getAttribute("content") + + var currentVersionInList = projectVersions.find(function (element) { + return element.name == currentVersion + }) + + if (!currentVersionInList) { + projectVersions.unshift({ name: currentVersion, url: '#' }) + } + + $version = document.querySelector(".project-summary > .project-version") + $version.innerHTML = "" + + $select = document.createElement("select") + $select.classList.add("project-versions-nav") + $select.addEventListener("change", function () { + window.location.href = this.value + }) + projectVersions.forEach(function (version) { + $item = document.createElement("option") + $item.setAttribute("value", version.url) + $item.append(document.createTextNode(version.name)) + + if (version.name == currentVersion) { + $item.setAttribute("selected", true) + $item.setAttribute("disabled", true) + } + $select.append($item) + }); + $form = document.createElement("form") + $form.setAttribute("autocomplete", "off") + $form.append($select) + $version.append($form) +} + +document.addEventListener("DOMContentLoaded", function () { + CrystalDocs.initializeVersions() +}) + +var UsageModal = function(title, content) { + var $body = document.body; + var self = this; + var $modalBackground = document.createElement("div"); + $modalBackground.classList.add("modal-background"); + var $usageModal = document.createElement("div"); + $usageModal.classList.add("usage-modal"); + $modalBackground.appendChild($usageModal); + var $title = document.createElement("h3"); + $title.classList.add("modal-title"); + $title.innerHTML = title + $usageModal.appendChild($title); + var $closeButton = document.createElement("span"); + $closeButton.classList.add("close-button"); + $closeButton.setAttribute("title", "Close modal"); + $closeButton.innerText = '×'; + $usageModal.appendChild($closeButton); + $usageModal.insertAdjacentHTML("beforeend", content); + + $modalBackground.addEventListener('click', function(event) { + var element = event.target || event.srcElement; + + if(element == $modalBackground) { + self.hide(); + } + }); + $closeButton.addEventListener('click', function(event) { + self.hide(); + }); + + $body.insertAdjacentElement('beforeend', $modalBackground); + + this.show = function(){ + $body.classList.add("js-modal-visible"); + }; + this.hide = function(){ + $body.classList.remove("js-modal-visible"); + }; + this.isVisible = function(){ + return $body.classList.contains("js-modal-visible"); + } +} + + +document.addEventListener('DOMContentLoaded', function() { + var sessionStorage; + try { + sessionStorage = window.sessionStorage; + } catch (e) { } + if(!sessionStorage) { + sessionStorage = { + setItem: function() {}, + getItem: function() {}, + removeItem: function() {} + }; + } + + var repositoryName = document.querySelector('[name=repository-name]').getAttribute('content'); + var typesList = document.querySelector('.types-list'); + var searchInput = document.querySelector('.search-input'); + var parents = document.querySelectorAll('.types-list li.parent'); + + var scrollSidebarToOpenType = function(){ + var openTypes = typesList.querySelectorAll('.current'); + if (openTypes.length > 0) { + var lastOpenType = openTypes[openTypes.length - 1]; + lastOpenType.scrollIntoView(!(window.matchMedia('only screen and (max-width: 635px)')).matches); + } + } + + scrollSidebarToOpenType(); + + var setPersistentSearchQuery = function(value){ + sessionStorage.setItem(repositoryName + '::search-input:value', value); + } + + for(var i = 0; i < parents.length; i++) { + var _parent = parents[i]; + _parent.addEventListener('click', function(e) { + e.stopPropagation(); + + if(e.target.tagName.toLowerCase() == 'li') { + if(e.target.className.match(/open/)) { + sessionStorage.removeItem(e.target.getAttribute('data-id')); + e.target.className = e.target.className.replace(/ +open/g, ''); + } else { + sessionStorage.setItem(e.target.getAttribute('data-id'), '1'); + if(e.target.className.indexOf('open') == -1) { + e.target.className += ' open'; + } + } + } + }); + + if(sessionStorage.getItem(_parent.getAttribute('data-id')) == '1') { + _parent.className += ' open'; + } + } + + var leaveSearchScope = function(){ + CrystalDocs.toggleResultsList(false); + window.focus(); + } + + var navigator = new Navigator(document.querySelector('.types-list'), searchInput, document.querySelector(".search-results"), leaveSearchScope); + + CrystalDocs.loadIndex(); + var searchTimeout; + var lastSearchText = false; + var performSearch = function() { + document.dispatchEvent(new Event("CrystalDocs:searchDebounceStarted")); + + clearTimeout(searchTimeout); + searchTimeout = setTimeout(function() { + var text = searchInput.value; + + if(text == "") { + CrystalDocs.toggleResultsList(false); + }else if(text == lastSearchText){ + document.dispatchEvent(new Event("CrystalDocs:searchDebounceStopped")); + }else{ + CrystalDocs.search(text); + navigator.highlightFirst(); + searchInput.focus(); + } + lastSearchText = text; + setPersistentSearchQuery(text); + }, 200); + }; + + if(location.hash.length > 3 && location.hash.substring(0,3) == "#q="){ + // allows directly linking a search query which is then executed on the client + // this comes handy for establishing a custom browser search engine with https://crystal-lang.org/api/#q=%s as a search URL + // TODO: Add OpenSearch description + var searchQuery = location.hash.substring(3); + history.pushState({searchQuery: searchQuery}, "Search for " + searchQuery, location.href.replace(/#q=.*/, "")); + searchInput.value = decodeURIComponent(searchQuery); + document.addEventListener('CrystalDocs:loaded', performSearch); + } + + if (searchInput.value.length == 0) { + var searchText = sessionStorage.getItem(repositoryName + '::search-input:value'); + if(searchText){ + searchInput.value = searchText; + } + } + searchInput.addEventListener('keyup', performSearch); + searchInput.addEventListener('input', performSearch); + + var usageModal = new UsageModal('Keyboard Shortcuts', '' + + 'Used internally to deserialise json
","abstract":false,"location":{"filename":"src/clear/model/json_deserialize.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/json_deserialize.cr#L19"},"def":{"name":"columns_to_instance_vars","visibility":"Public","body":" \n# :nodoc:\n\n struct Assigner\n include JSON::Serializable\n\n \n{% for name, settings in COLUMNS %}\n @[JSON::Field(presence: true)]\n getter {{ name.id }} : {{ settings[:type] }} {% if settings[:type].resolve.nilable? %}{% else %} | Nil {% end %}\n @[JSON::Field(ignore: true)]\n getter? {{ name.id }}_present : Bool\n {% end %}\n\n\n \n# Create a new empty model and fill the columns with object's instance variables\n\n \n# Trusted flag set to true will allow mass assignment without protection\n\n def create(trusted : Bool)\n assign_columns(\n{{ @type }}\n.new, trusted)\n \nend\n\n \n# Update the inputted model and assign the columns with object's instance variables\n\n \n# Trusted flag set to true will allow mass assignment without protection\n\n def update(model, trusted : Bool)\n assign_columns(model, trusted)\n \nend\n\n macro finished\n \n# Assign properties to the model inputted with object's instance variables\n\n \n# Trusted flag set to true will allow mass assignment without protection\n\n protected def assign_columns(model, trusted : Bool)\n \n{% for name, settings in COLUMNS %}\n if ({{ settings[:mass_assign] }} || trusted) && self.{{ name.id }}_present?\n %value = self.{{ name.id }}\n {% if settings[:type].resolve.nilable? %}\n model.{{ name.id }} = %value\n {% else %}\n model.{{ name.id }} = %value unless %value.nil?\n {% end %}\n end\n {% end %}\n\n\n model\n \nend\n \nend\n \nend\n\n \n# Create a new empty model and fill the columns from json. Returns the new model\n\n \n#\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def self.from_json(string_or_io : String | IO, trusted : Bool = false)\n Assigner.from_json(string_or_io).create(trusted)\n \nend\n\n \n# Create a new model from json and save it. Returns the model.\n\n \n#\n\n \n# The model may not be saved due to validation failure;\n\n \n# check the returned model `errors?` and `persisted?` flags.\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def self.create_from_json(string_or_io : String | IO, trusted : Bool = false)\n mdl = self.from_json(string_or_io, trusted)\n mdl.save\n mdl\n \nend\n\n \n# Create a new model from json and save it. Returns the model.\n\n \n#\n\n \n# Returns the newly inserted model\n\n \n# Raises an exception if validation failed during the saving process.\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def self.create_from_json!(string_or_io : String | IO, trusted : Bool = false)\n self.from_json(string_or_io, trusted).save!\n \nend\n\n \n# Set the fields from json passed as argument\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def set_from_json(string_or_io : String | IO, trusted : Bool = false)\n Assigner.from_json(string_or_io).update(self, trusted)\n \nend\n\n \n# Set the fields from json passed as argument and call `save` on the object\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def update_from_json(string_or_io : String | IO, trusted : Bool = false)\n mdl = set_from_json(string_or_io, trusted)\n mdl.save\n mdl\n \nend\n\n \n# Set the fields from json passed as argument and call `save!` on the object\n\n \n# Trusted flag set to true will allow mass assignment without protection, FALSE by default\n\n def update_from_json!(string_or_io : String | IO, trusted : Bool = false)\n set_from_json(string_or_io, trusted).save!\n \nend\n\n"}}],"types":[{"html_id":"clear/BigDecimal","path":"BigDecimal.html","kind":"struct","full_name":"BigDecimal","name":"BigDecimal","abstract":false,"superclass":{"html_id":"clear/Number","kind":"struct","full_name":"Number","name":"Number"},"ancestors":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Number","kind":"struct","full_name":"Number","name":"Number"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Steppable","kind":"module","full_name":"Steppable","name":"Steppable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/core_ext.cr","line_number":121,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/core_ext.cr#L121"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"}],"doc":"A `BigDecimal` can represent arbitrarily large precision decimals.\n\nIt is internally represented by a pair of `BigInt` and `UInt64`: value and scale.\nValue contains the actual value, and scale tells the decimal point place.\nE.g. when value is `1234` and scale `2`, the result is `12.34`.\n\nNOTE: To use `BigDecimal`, you must explicitly import it with `require \"big\"`\n\nThe general idea and some of the arithmetic algorithms were adapted from\nthe MIT/APACHE-licensed [bigdecimal-rs](https://github.com/akubera/bigdecimal-rs).","summary":"A BigDecimal
can represent arbitrarily large precision decimals.
A Char
represents a Unicode code point.
Represents a case insensitive text, used by Postgres Wrap a string and basically change the equality check to make it case insensitive.s
","constructors":[{"html_id":"new(string:String)-class-method","name":"new","abstract":false,"args":[{"name":"string","external_name":"string","restriction":"::String"}],"args_string":"(string : String)","args_html":"(string : String)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L8"},"def":{"name":"new","args":[{"name":"string","external_name":"string","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(string)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"!=(x:String|Citext)-instance-method","name":"!=","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"args_string":"(x : String | Citext)","args_html":"(x : String | Citext)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L15"},"def":{"name":"!=","args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"visibility":"Public","body":"!(self == x)"}},{"html_id":"==(x:String|Citext)-instance-method","name":"==","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"args_string":"(x : String | Citext)","args_html":"(x : String | Citext)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L11"},"def":{"name":"==","args":[{"name":"x","external_name":"x","restriction":"String | Citext"}],"visibility":"Public","body":"(compare(x.to_s, true)) == 0"}},{"html_id":"string:String-instance-method","name":"string","abstract":false,"location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L4"},"def":{"name":"string","return_type":"String","visibility":"Public","body":"@string"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/clear/extensions/citext/citext.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/citext/citext.cr#L6"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" @string.\n{{ call }}\n\n \n"}}]},{"html_id":"clear/Clear","path":"Clear.html","kind":"module","full_name":"Clear","name":"Clear","abstract":false,"locations":[{"filename":"src/clear/cli.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L9"},{"filename":"src/clear/extensions/enum/enum.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L1"},{"filename":"src/clear/log.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/log.cr#L3"},{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L24"},{"filename":"src/clear/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/seed.cr#L1"},{"filename":"src/clear/sql/lock.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/lock.cr#L1"},{"filename":"src/clear/sql/sql.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L19"},{"filename":"src/clear/sql/truncate.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/truncate.cr#L1"},{"filename":"src/clear/version.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/version.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"Log","name":"Log","value":"::Log.for(\"clear\")"},{"id":"VERSION","name":"VERSION","value":"{{ (`shards version /home/runner/work/clear/clear/src/clear`).chomp.stringify }}"}],"class_methods":[{"html_id":"apply_seeds-class-method","name":"apply_seeds","abstract":false,"location":{"filename":"src/clear/seed.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/seed.cr#L12"},"def":{"name":"apply_seeds","visibility":"Public","body":"Clear::SQL.transaction do\n @@seed_list.each(&.call)\nend"}},{"html_id":"seed(&block)-class-method","name":"seed","doc":"Register a seed block.\nthis block will be called by `Clear.apply_seeds`\nor conveniently by the CLI\nusing `$cli_cmd migrate seeds`","summary":"Register a seed block.
","abstract":false,"location":{"filename":"src/clear/seed.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/seed.cr#L8"},"def":{"name":"seed","yields":0,"block_arity":0,"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":"@@seed_list << block"}},{"html_id":"with_cli(&)-class-method","name":"with_cli","doc":"Check for the CLI. If the CLI is not triggered, yield the block passed as parameter","summary":"Check for the CLI.
","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L32"},"def":{"name":"with_cli","yields":0,"block_arity":0,"visibility":"Public","body":"if ARGV.size > 0 && (ARGV[0] == \"clear\")\n ARGV.shift\n Clear::CLI.run\nelse\n yield\nend"}}],"macros":[{"html_id":"enum(name,*values,&block)-macro","name":"enum","doc":"## Enum\n\nClear offers full support of postgres enum strings.\n\n### Example\n\nLet's say you need to define an enum for genders:\n\n```\n# Define the enum\nClear.enum MyApp::Gender, \"male\", \"female\" # , ...\n```\n\nIn migration, we tell Postgres about the enum:\n\n```\ncreate_enum :gender, MyApp::Gender # < Create the new type `gender` in the database\n\ncreate_table :users do |t|\n # ...\n t.gender \"gender\" # < first `gender` is the type of column, while second is the name of the column\nend\n```\n\nFinally in your model, simply add the enum as column:\n\n```\nclass User\n include Clear::Model\n # ...\n\n column gender : MyApp::Gender\nend\n```\n\nNow, you can assign the enum:\n\n```\nu = User.new\nu.gender = MyApp::Gender::Male\n```\n\nYou can dynamically check and build the enumeration values:\n\n```\nMyApp::Gender.authorized_values # < return [\"male\", \"female\"]\nMyApp::Gender.all # < return [MyApp::Gender::Male, MyApp::Gender::Female]\n\nMyApp::Gender.from_string(\"male\") # < return MyApp::Gender::Male\nMyApp::Gender.from_string(\"unknown\") # < throw Clear::IllegalEnumValueError\n\nMyApp::Gender.valid?(\"female\") # < Return true\nMyApp::Gender.valid?(\"unknown\") # < Return false\n```\n\nHowever, you cannot write:\n\n```\nu = User.new\nu.gender = \"male\"\n```\n\nBut instead:\n\n```\nu = User.new\nu.gender = MyApp::Gender::Male\n```","summary":"Register a type to allow use in Clear column system.
","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""}],"args_string":"(type)","args_html":"(type)","location":{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L40"},"def":{"name":"json_serializable_converter","args":[{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":" \n{% type = type.resolve %}\n\n module ::Clear::Model::Converter::\n{{ type }}\nConverter\n def self.to_column(x) : ::\n{{ type }}\n?\n case x\n when ::\n{{ type }}\n\n x\n when String\n ::\n{{ type }}\n.new(::JSON::PullParser.new(x))\n when ::JSON::PullParser\n ::\n{{ type }}\n.new(x)\n when ::JSON::Any\n ::\n{{ type }}\n.new(::JSON::PullParser.new(x.to_json))\n \nelse\n raise \"Cannot convert to \n{{ type }}\n from #{x.class}\"\n \nend\n \nend\n\n def self.to_db(x : ::\n{{ type }}\n?)\n x ? x.to_json : nil\n \nend\n \nend\n\n ::Clear::Model::Converter.add_converter(\n{{ \"#{type}\" }}\n, ::Clear::Model::Converter::\n{{ type }}\nConverter)\n \n"}}],"types":[{"html_id":"clear/Clear/CLI","path":"Clear/CLI.html","kind":"module","full_name":"Clear::CLI","name":"CLI","abstract":false,"locations":[{"filename":"src/clear/cli.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L10"},{"filename":"src/clear/cli/command.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/command.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"class_methods":[{"html_id":"run-class-method","name":"run","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L11"},"def":{"name":"run","visibility":"Public","body":"Clear::CLI::Base.run"}}],"types":[{"html_id":"clear/Clear/CLI/Base","path":"Clear/CLI/Base.html","kind":"class","full_name":"Clear::CLI::Base","name":"Base","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L16"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L25"},"def":{"name":"run_impl","visibility":"Public","body":"STDOUT.puts(help)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"__version__-instance-method","name":"__version__","abstract":false,"def":{"name":"__version__","visibility":"Public","body":"@__version__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli.cr#L15"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__version__.nil?\n raise(Admiral::Error.new(\"Flag required: --version\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Command","path":"Clear/CLI/Command.html","kind":"module","full_name":"Clear::CLI::Command","name":"Command","abstract":false,"locations":[{"filename":"src/clear/cli/command.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/command.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/CLI/Base","kind":"class","full_name":"Clear::CLI::Base","name":"Base"},{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},{"html_id":"clear/Clear/CLI/Generator/Migration","kind":"class","full_name":"Clear::CLI::Generator::Migration","name":"Migration"},{"html_id":"clear/Clear/CLI/Generator/Model","kind":"class","full_name":"Clear::CLI::Generator::Model","name":"Model"},{"html_id":"clear/Clear/CLI/Generator/NewKemal","kind":"class","full_name":"Clear::CLI::Generator::NewKemal","name":"NewKemal"},{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},{"html_id":"clear/Clear/CLI/Migration/Down","kind":"class","full_name":"Clear::CLI::Migration::Down","name":"Down"},{"html_id":"clear/Clear/CLI/Migration/Migrate","kind":"class","full_name":"Clear::CLI::Migration::Migrate","name":"Migrate"},{"html_id":"clear/Clear/CLI/Migration/Rollback","kind":"class","full_name":"Clear::CLI::Migration::Rollback","name":"Rollback"},{"html_id":"clear/Clear/CLI/Migration/Seed","kind":"class","full_name":"Clear::CLI::Migration::Seed","name":"Seed"},{"html_id":"clear/Clear/CLI/Migration/Set","kind":"class","full_name":"Clear::CLI::Migration::Set","name":"Set"},{"html_id":"clear/Clear/CLI/Migration/Status","kind":"class","full_name":"Clear::CLI::Migration::Status","name":"Status"},{"html_id":"clear/Clear/CLI/Migration/Up","kind":"class","full_name":"Clear::CLI::Migration::Up","name":"Up"},{"html_id":"clear/Clear/CLI/Seed","kind":"class","full_name":"Clear::CLI::Seed","name":"Seed"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"}},{"html_id":"clear/Clear/CLI/Generator","path":"Clear/CLI/Generator.html","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},{"filename":"src/clear/cli/generators/migration.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L3"},{"filename":"src/clear/cli/generators/model.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L3"},{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"[](name)-class-method","name":"[]","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/clear/cli/generator.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L21"},"def":{"name":"[]","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"@@generators[name]"}},{"html_id":"[]?(name)-class-method","name":"[]?","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/clear/cli/generator.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L17"},"def":{"name":"[]?","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"@@generators[name]?"}},{"html_id":"add(name,desc,&block:Array(String)->Nil)-class-method","name":"add","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"desc","external_name":"desc","restriction":""}],"args_string":"(name, desc, &block : Array(String) -> Nil)","args_html":"(name, desc, &block : Array(String) -> Nil)","location":{"filename":"src/clear/cli/generator.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L13"},"def":{"name":"add","args":[{"name":"name","external_name":"name","restriction":""},{"name":"desc","external_name":"desc","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Array(String) -> Nil)"},"visibility":"Public","body":"@@generators[name] = Record.new(name, desc, block)"}},{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"generators-class-method","name":"generators","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L11"},"def":{"name":"generators","visibility":"Public","body":"@@generators"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L5"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L25"},"def":{"name":"run_impl","visibility":"Public","body":"puts(help)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generator.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L4"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]},{"html_id":"clear/Clear/CLI/Generator/Migration","path":"Clear/CLI/Generator/Migration.html","kind":"class","full_name":"Clear::CLI::Generator::Migration","name":"Migration","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L19"},"def":{"name":"run_impl","visibility":"Public","body":"g = Generate::Generator.new\ng.target_directory = flags.directory\nname = arguments.name\nif name\n name_underscore = name.underscore\n class_name = name.camelcase\n migration_uid = Time.local.to_unix.to_s.rjust(10, '0')\n g[\"migration_uid\"] = migration_uid\n g[\"class_name\"] = class_name\n migration_file = \"#{migration_uid}_#{name_underscore}.cr\"\n if Dir[File.join(g.target_directory, \"src/db/migrations/*_#{name_underscore}.cr\")].empty?\n else\n puts(\"A migration file `xxxx_#{name_underscore}.cr` already exists\")\n exit(1)\n end\n g.in_directory(\"src/db/migrations\") do\n g.file(migration_file, Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/../../../../templates/migration.cr.ecr\", g))\n end\nelse\n puts(\"Please provide a name for the migration\")\n exit(1)\nend\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"directory-instance-method","name":"directory","abstract":false,"location":{"filename":"src/clear/cli/generators/migration.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L11"},"def":{"name":"directory","visibility":"Public","body":"@directory.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generators/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/migration.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nif @directory.nil?\n raise(Admiral::Error.new(\"Flag required: --directory\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Generator/Model","path":"Clear/CLI/Generator/Model.html","kind":"class","full_name":"Clear::CLI::Generator::Model","name":"Model","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L19"},"def":{"name":"run_impl","visibility":"Public","body":"g = Generate::Generator.new\ng.target_directory = flags.directory\nname = arguments.name\nif name\n name_underscore = name.underscore\n model_table = name_underscore.pluralize\n class_name = name.camelcase\n fields = @argv.join(\"|\")\n migration_uid = Time.local.to_unix.to_s.rjust(10, '0')\n g[\"model_class\"] = class_name\n g[\"migration_uid\"] = migration_uid\n g[\"model_table\"] = model_table\n g[\"model_fields\"] = fields\n model_file = \"#{name_underscore}.cr\"\n migration_file = \"#{migration_uid}_create_#{name_underscore.pluralize}.cr\"\n if Dir[File.join(g.target_directory, \"src/db/migrations/*_create_#{name_underscore.pluralize}.cr\")].empty?\n else\n puts(\"A migration file `xxxx__create_#{name_underscore.pluralize}.cr` already exists\")\n exit(1)\n end\n g.in_directory(\"src/models\") do\n g.file(model_file, Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/../../../../templates/model/model.cr.ecr\", g))\n end\n g.in_directory(\"src/db/migrations\") do\n g.file(migration_file, Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/../../../../templates/model/migration.cr.ecr\", g))\n end\nelse\n puts(\"Please provide a name for the model\")\n exit(1)\nend\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"directory-instance-method","name":"directory","abstract":false,"location":{"filename":"src/clear/cli/generators/model.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L11"},"def":{"name":"directory","visibility":"Public","body":"@directory.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generators/model.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/model.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nif @directory.nil?\n raise(Admiral::Error.new(\"Flag required: --directory\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Generator/NewKemal","path":"Clear/CLI/Generator/NewKemal.html","kind":"class","full_name":"Clear::CLI::Generator::NewKemal","name":"NewKemal","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L17"},"def":{"name":"run_impl","visibility":"Public","body":"g = Generate::Generator.new\ng.target_directory = flags.directory\ng[\"app_name\"] = arguments.name || (File.basename(g.target_directory))\ng[\"app_name_underscore\"] = g[\"app_name\"].underscore\ng[\"app_name_camelcase\"] = g[\"app_name\"].camelcase\ng[\"git_username\"] = (`git config user.email`).chomp || \"email@example.com\"\ng[\"git_email\"] = (`git config user.name`).chomp || \"Your Name\"\ng.in_directory(\"bin\") do\n g.file(\"appctl\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/bin/appctl.ecr\", g))\n g.file(\"clear_cli.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/bin/clear_cli.cr.ecr\", g))\n g.file(\"server.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/bin/server.cr.ecr\", g))\nend\ng.in_directory(\"config\") do\n g.file(\"database.yml\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/config/database.yml.ecr\", g))\nend\ng.in_directory(\"src\") do\n g.in_directory(\"controllers\") do\n g.file(\"application_controller.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/controllers/application_controller.ecr\", g))\n g.file(\"welcome_controller.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/controllers/welcome_controller.ecr\", g))\n end\n g.in_directory(\"db\") do\n g.file(\"init.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/db/init.ecr\", g))\n end\n g.in_directory(\"models\") do\n g.file(\"init.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/models/application_model.ecr\", g))\n end\n g.in_directory(\"views\") do\n g.in_directory(\"components\") do\n g.file(\"footer.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/views/components/footer.ecr\", g))\n end\n g.in_directory(\"layouts\") do\n g.file(\"application.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/views/layouts/application.ecr\", g))\n end\n g.in_directory(\"welcome\") do\n g.file(\"index.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/views/welcome/index.ecr\", g))\n end\n end\n g.file(\"app.cr\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/src/app.ecr\", g))\nend\ng.file(\".gitignore\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/_gitignore.ecr\", g))\ng.file(\"shard.yml\", Clear::CLI::Generator.ecr_to_s(\"/home/runner/work/clear/clear/src/clear/cli/generators/new/../../../../../templates/kemal/shard.yml.ecr\", g))\nsystem(\"chmod +x #{g.target_directory}/bin/appctl\")\nsystem(\"cd #{g.target_directory} && shards\")\nputs(\"Clear + Kemal template is now generated. `cd #{g.target_directory} && clear-cli server` to play ! :-)\")\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"directory-instance-method","name":"directory","abstract":false,"location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L9"},"def":{"name":"directory","visibility":"Public","body":"@directory.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/generators/new/kemal.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generators/new/kemal.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @directory.nil?\n raise(Admiral::Error.new(\"Flag required: --directory\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Generator/Record","path":"Clear/CLI/Generator/Record.html","kind":"struct","full_name":"Clear::CLI::Generator::Record","name":"Record","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/CLI/Generator","kind":"class","full_name":"Clear::CLI::Generator","name":"Generator"},"constructors":[{"html_id":"new(name:String,desc:String,callback:Array(String)->Nil)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"desc","external_name":"desc","restriction":"String"},{"name":"callback","external_name":"callback","restriction":"(Array(String) -> Nil)"}],"args_string":"(name : String, desc : String, callback : Array(String) -> Nil)","args_html":"(name : String, desc : String, callback : Array(String) -> Nil)","location":{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"desc","external_name":"desc","restriction":"String"},{"name":"callback","external_name":"callback","restriction":"(Array(String) -> Nil)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, desc, callback)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"callback:Array(String)->Nil-instance-method","name":"callback","abstract":false,"def":{"name":"callback","return_type":"(Array(String) -> Nil)","visibility":"Public","body":"@callback"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@name.clone, @desc.clone, @callback.clone)"}},{"html_id":"copy_with(name_name=@name,desc_desc=@desc,callback_callback=@callback)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_desc","default_value":"@desc","external_name":"desc","restriction":""},{"name":"_callback","default_value":"@callback","external_name":"callback","restriction":""}],"args_string":"(name _name = @name, desc _desc = @desc, callback _callback = @callback)","args_html":"(name _name = @name, desc _desc = @desc, callback _callback = @callback)","location":{"filename":"src/clear/cli/generator.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/generator.cr#L7"},"def":{"name":"copy_with","args":[{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_desc","default_value":"@desc","external_name":"desc","restriction":""},{"name":"_callback","default_value":"@callback","external_name":"callback","restriction":""}],"visibility":"Public","body":"self.class.new(_name, _desc, _callback)"}},{"html_id":"desc:String-instance-method","name":"desc","abstract":false,"def":{"name":"desc","return_type":"String","visibility":"Public","body":"@desc"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}}]}]},{"html_id":"clear/Clear/CLI/Migration","path":"Clear/CLI/Migration.html","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Admiral/Command/Run","kind":"module","full_name":"Admiral::Command::Run","name":"Run"},{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L2"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L108"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.apply_all"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L38"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L43"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.down(arguments.migration_number)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L37"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Flags","path":"Clear/CLI/Migration/Flags.html","kind":"struct","full_name":"Clear::CLI::Migration::Flags","name":"Flags","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DESCRIPTIONS","name":"DESCRIPTIONS","value":"{} of String => String"},{"id":"SPECS","name":"SPECS","value":"{\"verbose\" => {kind: \"bool\", type: \"Bool\", default: \"false\", description: {\"--verbose, -v\", \"Display verbose informations during execution\"}, short: \"v\", long: \"verbose\", is_required: true}, \"no_color\" => {kind: \"bool\", type: \"Bool\", default: \"false\", description: {\"--no-color\", \"Cancel color output\"}, short: \"nil\", long: \"no-color\", is_required: true}, \"__help__\" => {kind: \"bool\", type: \"Bool\", default: \"false\", description: {\"--help\", \"Displays help for the current command.\"}, short: \"nil\", long: \"help\", is_required: true}} of String => NamedTuple(kind: String, type: String, default: String, description: Tuple(String, String | ::Nil), short: String | ::Nil, long: String, is_required: Bool)"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"doc":"Extend the flags struct to include the flag","summary":"Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L1"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]},{"html_id":"clear/Clear/CLI/Migration/Migrate","path":"Clear/CLI/Migration/Migrate.html","kind":"class","full_name":"Clear::CLI::Migration::Migrate","name":"Migrate","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L72"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":74,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L74"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.apply_all"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L71"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Rollback","path":"Clear/CLI/Migration/Rollback.html","kind":"class","full_name":"Clear::CLI::Migration::Rollback","name":"Rollback","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":80,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L80"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":85,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L85"},"def":{"name":"run_impl","visibility":"Public","body":"array = Clear::Migration::Manager.instance.migrations_up.to_a.sort\nnum = (arguments.num.try(&.to_i) || 1) + 1\nif num > array.size\n num = array.size - 1\nend\nClear::Migration::Manager.instance.apply_to(array[-num], direction: :down)\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L79"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Seed","path":"Clear/CLI/Migration/Seed.html","kind":"class","full_name":"Clear::CLI::Migration::Seed","name":"Seed","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L17"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L21"},"def":{"name":"run_impl","visibility":"Public","body":"Clear.apply_seeds"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L16"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Set","path":"Clear/CLI/Migration/Set.html","kind":"class","full_name":"Clear::CLI::Migration::Set","name":"Set","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L49"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L54"},"def":{"name":"run_impl","visibility":"Public","body":"dir_symbol = case flags.direction\nwhen \"up\"\n :up\nwhen \"down\"\n :down\nwhen \"both\"\n :both\nelse\n puts(\"Bad argument --direction : #{flags.direction}. Must be up|down|both\")\n exit(1)\nend\nClear::Migration::Manager.instance.apply_to(arguments.to, direction: dir_symbol)\n"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"direction-instance-method","name":"direction","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L51"},"def":{"name":"direction","visibility":"Public","body":"@direction.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L48"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @direction.nil?\n raise(Admiral::Error.new(\"Flag required: --direction\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Status","path":"Clear/CLI/Migration/Status.html","kind":"class","full_name":"Clear::CLI::Migration::Status","name":"Status","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L7"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L11"},"def":{"name":"run_impl","visibility":"Public","body":"puts(Clear::Migration::Manager.instance.print_status)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L6"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]},{"html_id":"clear/Clear/CLI/Migration/Up","path":"Clear/CLI/Migration/Up.html","kind":"class","full_name":"Clear::CLI::Migration::Up","name":"Up","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI/Migration","kind":"class","full_name":"Clear::CLI::Migration","name":"Migration"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L27"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/migration.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L32"},"def":{"name":"run_impl","visibility":"Public","body":"Clear::Migration::Manager.instance.up(arguments.migration_number)"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/migration.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/migration.cr#L26"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]}]},{"html_id":"clear/Clear/CLI/Seed","path":"Clear/CLI/Seed.html","kind":"class","full_name":"Clear::CLI::Seed","name":"Seed","abstract":false,"superclass":{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},"ancestors":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"},{"html_id":"clear/Admiral/Command","kind":"class","full_name":"Admiral::Command","name":"Command"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"HELP","name":"HELP","value":"{\"description\" => \"\"}"}],"included_modules":[{"html_id":"clear/Clear/CLI/Command","kind":"module","full_name":"Clear::CLI::Command","name":"Command"}],"namespace":{"html_id":"clear/Clear/CLI","kind":"module","full_name":"Clear::CLI","name":"CLI"},"class_methods":[{"html_id":"description-class-method","name":"description","abstract":false,"location":{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"},"def":{"name":"description","visibility":"Public","body":"HELP[\"description\"]"}},{"html_id":"run(*args,**params)-class-method","name":"run","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args, **params)","args_html":"(*args, **params)","location":{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"},"def":{"name":"run","args":[{"name":"args","external_name":"args","restriction":""}],"double_splat":{"name":"params","external_name":"params","restriction":""},"splat_index":0,"visibility":"Public","body":"(new(*args, **params)).parse_and_run"}}],"instance_methods":[{"html_id":"__rescue_from___Admiral__Error(e)-instance-method","name":"__rescue_from___Admiral__Error","abstract":false,"args":[{"name":"e","external_name":"e","restriction":""}],"args_string":"(e)","args_html":"(e)","def":{"name":"__rescue_from___Admiral__Error","args":[{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"panic(e.message.colorize(:red))"}},{"html_id":"arguments-instance-method","name":"arguments","doc":"Returns the commands `Arguments` object.\n\nYou can access names arguments by name.\nYou can also access the remaning arguments using `.arguments[index]`.","summary":"Returns the commands Arguments
object.
Returns the commands Flags
object.
The run command.
","abstract":false,"location":{"filename":"src/clear/cli/seed.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L2"},"def":{"name":"run","visibility":"Public","body":"Colorize.enabled = !flags.no_color\nrun_impl\n"}},{"html_id":"run_impl-instance-method","name":"run_impl","abstract":false,"location":{"filename":"src/clear/cli/seed.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L6"},"def":{"name":"run_impl","visibility":"Public","body":"Clear.apply_seeds"}},{"html_id":"sub(command,*args,**params)-instance-method","name":"sub","doc":"Invokes a sub command by name, passing `self` as the parent.","summary":"Invokes a sub command by name, passing self
as the parent.
Extend the flags struct to include the flag
","constructors":[{"html_id":"new(command:Admiral::Command)-class-method","name":"new","abstract":false,"args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"args_string":"(command : Admiral::Command)","args_html":"(command : Admiral::Command)","def":{"name":"new","args":[{"name":"command","external_name":"command","restriction":"::Admiral::Command"}],"visibility":"Public","body":"_ = allocate\n_.initialize(command)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"__help__-instance-method","name":"__help__","abstract":false,"def":{"name":"__help__","visibility":"Public","body":"@__help__.not_nil!"}},{"html_id":"inspect(io)-instance-method","name":"inspect","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/cli/seed.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/cli/seed.cr#L1"},"def":{"name":"inspect","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"io << \"<#{self.class}\"\nio << \"(\"\nif SPECS.empty?\nelse\n io << (SPECS.keys.join(\", \"))\nend\nio << \")\"\nio << \">\"\n"}},{"html_id":"no_color-instance-method","name":"no_color","abstract":false,"def":{"name":"no_color","visibility":"Public","body":"@no_color.not_nil!"}},{"html_id":"validate!(command)-instance-method","name":"validate!","abstract":false,"args":[{"name":"command","external_name":"command","restriction":""}],"args_string":"(command)","args_html":"(command)","def":{"name":"validate!","args":[{"name":"command","external_name":"command","restriction":""}],"visibility":"Public","body":"if @verbose.nil?\n raise(Admiral::Error.new(\"Flag required: --verbose\"))\nend\nif @no_color.nil?\n raise(Admiral::Error.new(\"Flag required: --no-color\"))\nend\nif @__help__.nil?\n raise(Admiral::Error.new(\"Flag required: --help\"))\nend\nraise_extra_flags!(command)\n"}},{"html_id":"verbose-instance-method","name":"verbose","abstract":false,"def":{"name":"verbose","visibility":"Public","body":"@verbose.not_nil!"}}]}]}]},{"html_id":"clear/Clear/Enum","path":"Clear/Enum.html","kind":"struct","full_name":"Clear::Enum","name":"Enum","abstract":true,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/enum/enum.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"Clear::Enum wrap the enums used in PostgreSQL.\nSee `Clear.enum` macro helper.","summary":"Clear::Enum wrap the enums used in PostgreSQL.
","constructors":[{"html_id":"new(value:JSON::PullParser|String)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::JSON::PullParser | ::String"}],"args_string":"(value : JSON::PullParser | String)","args_html":"(value : JSON::PullParser | String)","location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L12"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::JSON::PullParser | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(x)-instance-method","name":"==","doc":"Returns `true` if this struct is equal to *other*.\n\nBoth structs' instance vars are compared to each other. Thus, two\nstructs are considered equal if each of their instance variables are\nequal. Subclasses should override this method to provide specific\nequality semantics.\n\n```\nstruct Point\n def initialize(@x : Int32, @y : Int32)\n end\nend\n\np1 = Point.new 1, 2\np2 = Point.new 1, 2\np3 = Point.new 3, 4\n\np1 == p2 # => true\np1 == p3 # => false\n```","summary":"Returns true
if this struct is equal to other.
Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L15"},"def":{"name":"to_s","return_type":"String","visibility":"Public","body":"@value.to_s"}},{"html_id":"to_sql:String-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L19"},"def":{"name":"to_sql","return_type":"String","visibility":"Public","body":"@value.to_sql"}}],"types":[{"html_id":"clear/Clear/Enum/Converter","path":"Clear/Enum/Converter.html","kind":"module","full_name":"Clear::Enum::Converter(T)","name":"Converter","abstract":false,"locations":[{"filename":"src/clear/extensions/enum/enum.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L31"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Enum","kind":"struct","full_name":"Clear::Enum","name":"Enum"},"class_methods":[{"html_id":"to_column(x):T|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : T | Nil","args_html":"(x) : T | Nil","location":{"filename":"src/clear/extensions/enum/enum.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L32"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"T | ::Nil","visibility":"Public","body":"case x\nwhen String\n T.authorized_values[x]\nwhen Nil\n nil\nelse\n raise(converter_error(x.class.name, \"Enum: #{T.class.name}\"))\nend"}}]}]},{"html_id":"clear/Clear/ErrorMessages","path":"Clear/ErrorMessages.html","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages","abstract":false,"locations":[{"filename":"src/clear/error_messages.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"including_types":[{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},{"html_id":"clear/Clear/Migration/Manager","kind":"class","full_name":"Clear::Migration::Manager","name":"Manager"},{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},{"html_id":"clear/Clear/Model/Column","kind":"class","full_name":"Clear::Model::Column(T, C)","name":"Column"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"This module list most of the runtime errors happening in Clear.\nIt's an attempt to make Clear user friendly by enabling advanced resolution\nof problems when they raise.","summary":"This module list most of the runtime errors happening in Clear.
","instance_methods":[{"html_id":"build_error_message(message:String,ways_to_resolve:Tuple|Array=Tuple.new,manual_pages:Tuple|Array=Tuple.new)-instance-method","name":"build_error_message","abstract":false,"args":[{"name":"message","external_name":"message","restriction":"String"},{"name":"ways_to_resolve","default_value":"Tuple.new","external_name":"ways_to_resolve","restriction":"Tuple | Array"},{"name":"manual_pages","default_value":"Tuple.new","external_name":"manual_pages","restriction":"Tuple | Array"}],"args_string":"(message : String, ways_to_resolve : Tuple | Array = Tuple.new, manual_pages : Tuple | Array = Tuple.new)","args_html":"(message : String, ways_to_resolve : Tuple | Array = Tuple.new, manual_pages : Tuple | Array = Tuple.new)","location":{"filename":"src/clear/error_messages.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L65"},"def":{"name":"build_error_message","args":[{"name":"message","external_name":"message","restriction":"String"},{"name":"ways_to_resolve","default_value":"Tuple.new","external_name":"ways_to_resolve","restriction":"Tuple | Array"},{"name":"manual_pages","default_value":"Tuple.new","external_name":"manual_pages","restriction":"Tuple | Array"}],"visibility":"Public","body":"{% if flag?(:release) %}\n message\n {% else %}\n format_width({\n build_message(message),\n build_tips(ways_to_resolve),\n build_manual(manual_pages),\n (\n \"You may also have encountered a bug. \\n\" +\n \"Feel free to submit an issue: \\n#{build_url(\"https://github.com/anykeyh/clear/issues/new\")}\"\n ),\n \"\\n\\nStack trace:\\n\",\n }.join)\n {% end %}"}},{"html_id":"converter_error(from,to)-instance-method","name":"converter_error","abstract":false,"args":[{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"args_string":"(from, to)","args_html":"(from, to)","location":{"filename":"src/clear/error_messages.cr","line_number":209,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L209"},"def":{"name":"converter_error","args":[{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"visibility":"Public","body":"build_error_message(\"Clear cannot convert from `#{from}` to #{to}.\", {\"Ensure your database column type matches the column declaration in Clear\"}, {\"model/Definition.md\"})"}},{"html_id":"format_width(x,w=80)-instance-method","name":"format_width","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""},{"name":"w","default_value":"80","external_name":"w","restriction":""}],"args_string":"(x, w = 80)","args_html":"(x, w = 80)","location":{"filename":"src/clear/error_messages.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L11"},"def":{"name":"format_width","args":[{"name":"x","external_name":"x","restriction":""},{"name":"w","default_value":"80","external_name":"w","restriction":""}],"visibility":"Public","body":"counter = 0\no = [] of String\n(x.split(/([ \\n\\t])/)).each do |word|\n case word\n when \"\\n\"\n o << word\n counter = 0\n else\n counter = counter + word.size\n if counter > w\n o << \"\\n\"\n if word == \" \"\n counter = 0\n else\n o << word\n counter = word.size\n end\n else\n o << word\n end\n end\nend\no.join\n"}},{"html_id":"illegal_setter_access_to_undefined_column(name)-instance-method","name":"illegal_setter_access_to_undefined_column","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name)","args_html":"(name)","location":{"filename":"src/clear/error_messages.cr","line_number":177,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L177"},"def":{"name":"illegal_setter_access_to_undefined_column","args":[{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"build_error_message(\"You're trying to access to the column `#{name}` but it is not initialized.\", {\"Ensure that the column `#{name}` exists in your table\", \"If the model comes from a collection query, there was maybe a filtering on your `select` clause, \" + \"and you forgot to declare the column `#{name}`\", \"In the case of unpersisted models, please initialize by calling `#{name}=` first\", \"For validator, try `ensure_than` method, or use `#{name}_column.defined?` to avoid your validation code.\", \"Are you calling `#{name}_column.revert` somewhere before?\", \"If your model comes from JSON, please ensure the JSON source defines the column. Usage of `strict` mode will \" + \"trigger exception on JSON loading.\"}, {\"model/Definition.md\", \"model/Lifecycle.md\"})"}},{"html_id":"lack_of_primary_key(model_name)-instance-method","name":"lack_of_primary_key","abstract":false,"args":[{"name":"model_name","external_name":"model_name","restriction":""}],"args_string":"(model_name)","args_html":"(model_name)","location":{"filename":"src/clear/error_messages.cr","line_number":218,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L218"},"def":{"name":"lack_of_primary_key","args":[{"name":"model_name","external_name":"model_name","restriction":""}],"visibility":"Public","body":"build_error_message(\"Model `#{model_name}` lacks of primary key field\", {\"Define a column as primary key\", \"Only one column can be primary key (no compound keys are allowed in Clear for now)\", \"You can use the helpers for primary key (see manual page)\"}, {\"model/PrimaryKeyTweaking.md\"})"}},{"html_id":"migration_already_down(number)-instance-method","name":"migration_already_down","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/error_messages.cr","line_number":94,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L94"},"def":{"name":"migration_already_down","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"build_error_message(\"Migration already down: #{number}\", {\"You're trying to force a migration which is not set in your database yet. \" + \"You should up the migration first, then down it again.\"}, {\"migration/Migration.md\"})"}},{"html_id":"migration_already_up(number)-instance-method","name":"migration_already_up","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/error_messages.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L82"},"def":{"name":"migration_already_up","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"build_error_message(\"Migration already up: #{number}\", {\"You're trying to force a migration which is already existing in your database. \" + \"You should down the migration first, then up it again.\"}, {\"migration/Migration.md\"})"}},{"html_id":"migration_irreversible(name=nil,operation=nil)-instance-method","name":"migration_irreversible","abstract":false,"args":[{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"operation","default_value":"nil","external_name":"operation","restriction":""}],"args_string":"(name = nil, operation = nil)","args_html":"(name = nil, operation = nil)","location":{"filename":"src/clear/error_messages.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L144"},"def":{"name":"migration_irreversible","args":[{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"operation","default_value":"nil","external_name":"operation","restriction":""}],"visibility":"Public","body":"op_string = operation ? \"This is caused by the operation #{operation} which is irreversible.\" : nil\nmig_string = name ? \"The migration `#{name}` is irreversible. You're trying to down a migration which is not downable, \" + \"because the operations are one way only.\" : \"A migration is irreversible. You're trying to down a migration which is not downable, \" + \"because the operations are one way only.\"\nbuild_error_message(mig_string, [op_string, \"Build a way to revert the migration\", \"Do not revert the migration\", \"Maybe you need to manually flush the migration using Postgres. `__clear_metadatas` table store loaded \" + \"migrations. Good luck !\"].compact, {\"migration/Migration.md\"})\n"}},{"html_id":"migration_not_found(number)-instance-method","name":"migration_not_found","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/error_messages.cr","line_number":106,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L106"},"def":{"name":"migration_not_found","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"build_error_message(\"The migration number `#{number}` is not found.\", {\"Ensure your migration files are required\", \"Number of the migrations can be found in the filename, \" + \"in the classname or in the `uid` method of the migration.\"}, {\"migration/Migration.md\"})"}},{"html_id":"migration_not_unique(numbers)-instance-method","name":"migration_not_unique","abstract":false,"args":[{"name":"numbers","external_name":"numbers","restriction":""}],"args_string":"(numbers)","args_html":"(numbers)","location":{"filename":"src/clear/error_messages.cr","line_number":164,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L164"},"def":{"name":"migration_not_unique","args":[{"name":"numbers","external_name":"numbers","restriction":""}],"visibility":"Public","body":"build_error_message(\"The migration manage found collision on migration number. Migrations number are: #{numbers.join(\", \")}\", {\"It happens when migration share the same `uid`. Try to change the UID of one of your migrations\", \"By default, Clear has a `-1` migration used internally. Do not use this migration number.\", \"Migration numbers can be found in filename, classname or return of `uid` method\"}, {\"migration/Migration.md\"})"}},{"html_id":"no_migration_yet(version)-instance-method","name":"no_migration_yet","abstract":false,"args":[{"name":"version","external_name":"version","restriction":""}],"args_string":"(version)","args_html":"(version)","location":{"filename":"src/clear/error_messages.cr","line_number":119,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L119"},"def":{"name":"no_migration_yet","args":[{"name":"version","external_name":"version","restriction":""}],"visibility":"Public","body":"build_error_message(\"No migrations are registered yet, so we cannot go to version=#{version}\", {\"Ensure your migration files are required\", \"Ensure you have some migration files. Captain obvious to the rescue! ;-)\"}, {\"migration/Migration.md\"})"}},{"html_id":"null_column_mapping_error(name,type)-instance-method","name":"null_column_mapping_error","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""}],"args_string":"(name, type)","args_html":"(name, type)","location":{"filename":"src/clear/error_messages.cr","line_number":196,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L196"},"def":{"name":"null_column_mapping_error","args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":"build_error_message(\"Your field `#{name}` is declared as `#{type}` but `NULL` value has been found in the database.\", {\"In your model, declare your column `column #{name} : #{type}?` (note the `?` which allow nil value)\", \"In your database, adding `DEFAULT` value and/or `NOT NULL` constraint should disallow NULL fields \" + \"from your data.\"}, {\"model/Definition.md#presence-validation\"})"}},{"html_id":"order_by_error_invalid_order(current_order)-instance-method","name":"order_by_error_invalid_order","abstract":false,"args":[{"name":"current_order","external_name":"current_order","restriction":""}],"args_string":"(current_order)","args_html":"(current_order)","location":{"filename":"src/clear/error_messages.cr","line_number":259,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L259"},"def":{"name":"order_by_error_invalid_order","args":[{"name":"current_order","external_name":"current_order","restriction":""}],"visibility":"Public","body":"build_error_message(\"Order by allow only ASC and DESC directions. But #{current_order} was given.\", {\"Ensure to use :asc, :desc symbol (or string) when constructing your query.\", \"If the code is dynamic, force the casting to one of the two value above, to avoid SQL injection.\"}, {\"querying/RequestBuilding.md\"})"}},{"html_id":"polymorphic_nil(through)-instance-method","name":"polymorphic_nil","abstract":false,"args":[{"name":"through","external_name":"through","restriction":""}],"args_string":"(through)","args_html":"(through)","location":{"filename":"src/clear/error_messages.cr","line_number":229,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L229"},"def":{"name":"polymorphic_nil","args":[{"name":"through","external_name":"through","restriction":""}],"visibility":"Public","body":"build_error_message(\"Impossible to instantiate polymorphic object, because the type given by the data is nil.\", {\"The column `#{through}` contains NULL value, but is set as storage for \" + \"the type of the polymorphic object.\", \"Try to set DEFAULT value for your column `#{through}`\", \"In case of new implementation of polymorphic system, we recommend you to update the column to the previous \" + \"Class value. Value must be equal to the fully qualified model class name in Crystal (e.g. `MyApp::MyModel`)\"}, {\"model/Polymorphism.md\"})"}},{"html_id":"polymorphic_unknown_class(class_name)-instance-method","name":"polymorphic_unknown_class","abstract":false,"args":[{"name":"class_name","external_name":"class_name","restriction":""}],"args_string":"(class_name)","args_html":"(class_name)","location":{"filename":"src/clear/error_messages.cr","line_number":242,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L242"},"def":{"name":"polymorphic_unknown_class","args":[{"name":"class_name","external_name":"class_name","restriction":""}],"visibility":"Public","body":"build_error_message(\"Impossible to instantiate a new `#{class_name}` using polymorphism.\", {((\"Ensure the type is properly setup in your `polymorphic` helper. \" + \"Any model which can exists in your database needs to manually be setup as in the example below:\\n\") + \"`polymorphic Dog, Cat, through: \\\"type\\\"`\\n\") + \"In this case, if you have a `Cow` object in your database, then add it in the list of allowed polymorphic objects.\", (\"Ensure the name match a fully qualified, with full path, Clear model:\\n\" + \"`polymorphic ::Animal::Dog, ::Animal::Cat, through: \\\"type\\\"`\\n\") + \"The column should then contains `Animal::Dog` and not `Dog`\"}, {\"model/Polymorphism.md\"})"}},{"html_id":"query_building_error(message)-instance-method","name":"query_building_error","abstract":false,"args":[{"name":"message","external_name":"message","restriction":""}],"args_string":"(message)","args_html":"(message)","location":{"filename":"src/clear/error_messages.cr","line_number":271,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L271"},"def":{"name":"query_building_error","args":[{"name":"message","external_name":"message","restriction":""}],"visibility":"Public","body":"Clear::SQL::QueryBuildingError.new(build_error_message({\"You're trying to construct an invalid SQL request:\\n\", message}.join, manual_pages: {\"querying/RequestBuilding.md\"}))"}},{"html_id":"uid_not_found(class_name)-instance-method","name":"uid_not_found","abstract":false,"args":[{"name":"class_name","external_name":"class_name","restriction":""}],"args_string":"(class_name)","args_html":"(class_name)","location":{"filename":"src/clear/error_messages.cr","line_number":131,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L131"},"def":{"name":"uid_not_found","args":[{"name":"class_name","external_name":"class_name","restriction":""}],"visibility":"Public","body":"build_error_message(\"I don't know how to order the migration `#{class_name}`\", {\"Rename your migration class to have the migration UID at the end of the class name\", \"Rename the file where your migration stand to have the migration UID in front of the filename\", \"Override the method `uid`. Be sure the number is immutable (e.g. return constant)\"}, {\"migration/Migration.md\"})"}},{"html_id":"uninitialized_db_connection(connection)-instance-method","name":"uninitialized_db_connection","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":""}],"args_string":"(connection)","args_html":"(connection)","location":{"filename":"src/clear/error_messages.cr","line_number":278,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/error_messages.cr#L278"},"def":{"name":"uninitialized_db_connection","args":[{"name":"connection","external_name":"connection","restriction":""}],"visibility":"Public","body":"build_error_message(\"You're trying to access the connection #{connection} which is not initialized\", {\"Use `Clear::SQL.init(#{connection}: \\\"postgres://XXX...\\\" )` on startup of your application\", \"The name of the connection (#{connection}) can't be found. It may have been mistyped.\"}, {\"Setup.md\", \"model/MultiConnection.md\"})"}}]},{"html_id":"clear/Clear/Expression","path":"Clear/Expression.html","kind":"class","full_name":"Clear::Expression","name":"Expression","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/expression.cr","line_number":55,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L55"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DATABASE_DATE_FORMAT","name":"DATABASE_DATE_FORMAT","value":"\"%Y-%m-%d\""},{"id":"DATABASE_DATE_TIME_FORMAT","name":"DATABASE_DATE_TIME_FORMAT","value":"\"%Y-%m-%d %H:%M:%S.%L %:z\""}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"## Clear's Expression engine\n\nThe goal of this module is to offer the most natural way to write down your\nquery in crystal.\n\nIf you're familiar with Sequel on Ruby, then here you have !\n\nInstead of writing:\n\n```\nmodel_collection.where(\"created_at BETWEEN ? AND ?\", 1.day.ago, DateTime.local)\n```\n\nYou can write:\n```\nmodel_collection.where { created_at.between(1.day.ago, DateTime.local) }\n```\n\nor even:\n\n```\nmodel_collection.where { created_at.in?(1.day.ago..DateTime.local) }\n```\n\n(Note for the later, it will generate `created_at > 1.day.ago AND created_at < DateTime.local`)\n\n## Limitations\n\nDue to the use of `missing_method` macro, some case can be confusing.\n\n### Existing local variable / instance method\n\n```\nid = 1\nmodel_collection.where { id > 100 } # Will raise an error, because the expression is resolved by Crystal !\n# Should be:\nid = 1\nmodel_collection.where { var(\"id\") > 100 } # Will works\n```\n\n### Usage of AND / OR\n\nAnd/Or can be used using the bitwises operators `&` and `|`.\nDue to the impossibility to reuse `||` and `&&`, beware the operator precendance\nrules are changed.\n\n```\n# v-- This below will not works, as we cannot redefine the `or` operator\nmodel_collection.where { first_name == \"yacine\" || last_name == \"petitprez\" }\n# v-- This will works, but beware of the parenthesis between each terms, as `|` is prioritary on `==`\nmodel.collection.where { (firt_name == \"yacine\") | (last_name == \"petitprez\") }\n# ^-- ... WHERE first_name = 'yacine' OR last_name == ''\n```\n","summary":"A fast way to call self.safe_literal
See .safe_literal(x : _)
This method will raise error on compilation if discovered in the code.
","abstract":false,"args":[{"name":"any","external_name":"any","restriction":""}],"args_string":"(any)","args_html":"(any)","location":{"filename":"src/clear/expression/expression.cr","line_number":188,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L188"},"def":{"name":"ensure_node!","args":[{"name":"any","external_name":"any","restriction":""}],"visibility":"Public","body":"{% raise(((((\"The expression engine discovered a runtime-evaluable condition.\\n\" + \"It happens when a test is done with values on both sides.\\n\") + \"Maybe a local variable is breaking the expression engine like here:\\n\") + \"id = 1\\n\") + \"Users.where { id == nil }\\n\\n\") + \"In this case, please use `raw(\\\"id IS NULL\\\")` to allow the expression.\") %}"}},{"html_id":"raw(x:String,*args)-class-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(?, ?) = ?\", a, b, c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"args_string":"(x : String, *args)","args_html":"(x : String, *args)","location":{"filename":"src/clear/expression/expression.cr","line_number":252,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L252"},"def":{"name":"raw","args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"splat_index":1,"visibility":"Public","body":"raw_enum(x, args)"}},{"html_id":"raw(__template:String,**tuple)-class-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(:a, :b) = :c\", a: a, b: b, c: c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"__template","external_name":"__template","restriction":"String"}],"args_string":"(__template : String, **tuple)","args_html":"(__template : String, **tuple)","location":{"filename":"src/clear/expression/expression.cr","line_number":296,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L296"},"def":{"name":"raw","args":[{"name":"__template","external_name":"__template","restriction":"String"}],"double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"__template.gsub(/(^|[^:])\\:([a-zA-Z0-9_]+)/) do |_, match|\n begin\n sym = match[2]\n match[1] + Clear::Expression[tuple[sym]]\n rescue e : KeyError\n raise(Clear::ErrorMessages.query_building_error(e.message))\n end\nend"}},{"html_id":"raw_enum(x:String,args)-class-method","name":"raw_enum","doc":"See `self.raw`\nCan pass an array to this version","summary":"See self.raw
Can pass an array to this version
Transform multiple objects into a string which is SQL-Injection safe.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Enumerable(AvailableLiteral)"}],"args_string":"(x : Enumerable(AvailableLiteral)) : Enumerable(String)","args_html":"(x : Enumerable(AvailableLiteral)) : Enumerable(String)","location":{"filename":"src/clear/expression/expression.cr","line_number":127,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L127"},"def":{"name":"safe_literal","args":[{"name":"x","external_name":"x","restriction":"Enumerable(AvailableLiteral)"}],"return_type":"Enumerable(String)","visibility":"Public","body":"x.map do |item|\n safe_literal(item)\nend"}},{"html_id":"safe_literal(x:Time,date:Bool=false):String-class-method","name":"safe_literal","doc":"Safe literal of a time return a string representation of time in the format understood by postgresql.\n\nIf the optional parameter `date` is passed, the time is truncated and only the date is passed:\n\n## Example\n\n```\nClear::Expression[Time.local] # < \"2017-04-03 23:04:43.234 +08:00\"\nClear::Expression[Time.local, date: true] # < \"2017-04-03\"\n```","summary":"Safe literal of a time return a string representation of time in the format understood by postgresql.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Time"},{"name":"date","default_value":"false","external_name":"date","restriction":"Bool"}],"args_string":"(x : Time, date : Bool = false) : String","args_html":"(x : Time, date : Bool = false) : String","location":{"filename":"src/clear/expression/expression.cr","line_number":147,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L147"},"def":{"name":"safe_literal","args":[{"name":"x","external_name":"x","restriction":"Time"},{"name":"date","default_value":"false","external_name":"date","restriction":"Bool"}],"return_type":"String","visibility":"Public","body":"{\"'\", x.to_utc.to_s(date ? DATABASE_DATE_FORMAT : DATABASE_DATE_TIME_FORMAT), \"'\"}.join"}},{"html_id":"safe_literal(x:_):String-class-method","name":"safe_literal","doc":"Sanitize an object and return a `String` representation of itself which is proofed against SQL injections.","summary":"Sanitize an object and return a String
representation of itself which is proofed against SQL injections.
Return unsafe string injected to the query.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/expression/expression.cr","line_number":133,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L133"},"def":{"name":"unsafe","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"Clear::Expression::UnsafeSql.new(x)"}},{"html_id":"where(&):Node-class-method","name":"where","doc":"Return a node of the expression engine\nThis node can then be combined with others node\nin case of chain request creation `where {...}.where {...}`\nthrough the chaining engine","summary":"Return a node of the expression engine This node can then be combined with others node in case of chain request creation where {...}.where {...}
through the chaining engine
NOT
operator
Because many postgresql operators are not transcriptable in Crystal lang, this helpers helps to write the expressions:
","abstract":false,"args":[{"name":"a","external_name":"a","restriction":"Node | AvailableLiteral"},{"name":"b","external_name":"b","restriction":"Node | AvailableLiteral"},{"name":"op","external_name":"op","restriction":"String"}],"args_string":"(a : Node | AvailableLiteral, b : Node | AvailableLiteral, op : String)","args_html":"(a : Node | AvailableLiteral, b : Node | AvailableLiteral, op : String)","location":{"filename":"src/clear/expression/expression.cr","line_number":337,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L337"},"def":{"name":"op","args":[{"name":"a","external_name":"a","restriction":"Node | AvailableLiteral"},{"name":"b","external_name":"b","restriction":"Node | AvailableLiteral"},{"name":"op","external_name":"op","restriction":"String"}],"visibility":"Public","body":"if a.is_a?(AvailableLiteral)\n a = Node::Literal.new(a)\nend\nif b.is_a?(AvailableLiteral)\n b = Node::Literal.new(b)\nend\nNode::DoubleOperator.new(a, b, op)\n"}},{"html_id":"raw(x:String,*args)-instance-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(?, ?) = ?\", a, b, c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"args_string":"(x : String, *args)","args_html":"(x : String, *args)","location":{"filename":"src/clear/expression/expression.cr","line_number":237,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L237"},"def":{"name":"raw","args":[{"name":"x","external_name":"x","restriction":"String"},{"name":"args","external_name":"args","restriction":""}],"splat_index":1,"visibility":"Public","body":"Node::Raw.new(self.class.raw(x, *args))"}},{"html_id":"raw(__template:String,**tuple)-instance-method","name":"raw","doc":"In case the name of the variable is a reserved word (e.g. `not`, `var`, `raw`)\nor in case of a complex piece of computation impossible to express with the expression engine\n(e.g. usage of functions) you can use then raw to pass the String.\n\nBE AWARE than the String is pasted AS-IS and can lead to SQL injection if not used properly.\n\n```\nhaving { raw(\"COUNT(*)\") > 5 } # SELECT ... FROM ... HAVING COUNT(*) > 5\nwhere { raw(\"func(:a, :b) = :c\", a: a, b: b, c: c) } # SELECT ... FROM ... WHERE function(a, b) = c\n```\n","summary":"In case the name of the variable is a reserved word (e.g.
","abstract":false,"args":[{"name":"__template","external_name":"__template","restriction":"String"}],"args_string":"(__template : String, **tuple)","args_html":"(__template : String, **tuple)","location":{"filename":"src/clear/expression/expression.cr","line_number":281,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L281"},"def":{"name":"raw","args":[{"name":"__template","external_name":"__template","restriction":"String"}],"double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"Node::Raw.new(self.class.raw(__template, **tuple))"}},{"html_id":"var(*parts)-instance-method","name":"var","doc":"Use var to create expression of variable. Variables are columns with or without the namespace and tablename:\n\nIt escapes each part of the expression with double-quote as requested by PostgreSQL.\nThis is useful to escape SQL keywords or `.` and `\"` character in the name of a column.\n\n```\nvar(\"template1\", \"users\", \"name\") # \"template1\".\"users\".\"name\"\nvar(\"template1\", \"users.table2\", \"name\") # \"template1\".\"users.table2\".\"name\"\nvar(\"order\") # \"order\"\n```","summary":"Use var to create expression of variable.
","abstract":false,"args":[{"name":"parts","external_name":"parts","restriction":""}],"args_string":"(*parts)","args_html":"(*parts)","location":{"filename":"src/clear/expression/expression.cr","line_number":317,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L317"},"def":{"name":"var","args":[{"name":"parts","external_name":"parts","restriction":""}],"splat_index":0,"visibility":"Public","body":"_var(parts)"}}],"types":[{"html_id":"clear/Clear/Expression/AvailableLiteral","path":"Clear/Expression/AvailableLiteral.html","kind":"alias","full_name":"Clear::Expression::AvailableLiteral","name":"AvailableLiteral","abstract":false,"locations":[{"filename":"src/clear/expression/expression.cr","line_number":91,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L91"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Bool | Clear::Expression::Literal | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)","aliased_html":"Bool | Clear::Expression::Literal | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil","const":false,"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"}},{"html_id":"clear/Clear/Expression/JSONB","path":"Clear/Expression/JSONB.html","kind":"module","full_name":"Clear::Expression::JSONB","name":"JSONB","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/node.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"},"types":[{"html_id":"clear/Clear/Expression/JSONB/Node","path":"Clear/Expression/JSONB/Node.html","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/node.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"}],"namespace":{"html_id":"clear/Clear/Expression/JSONB","kind":"module","full_name":"Clear::Expression::JSONB","name":"JSONB"},"instance_methods":[{"html_id":"jsonb(key:String)-instance-method","name":"jsonb","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L21"},"def":{"name":"jsonb","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"Clear::Expression::Node::JSONB::Field.new(self, key)"}},{"html_id":"jsonb_all_keys_exists?(keys:Array(T))forallT-instance-method","name":"jsonb_all_keys_exists?","abstract":false,"args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"args_string":"(keys : Array(T)) forall T","args_html":"(keys : Array(T)) forall T","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L17"},"def":{"name":"jsonb_all_keys_exists?","args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"visibility":"Public","body":"_jsonb_keys_exists(keys, \"?&\")"}},{"html_id":"jsonb_any_key_exists?(keys:Array(T))forallT-instance-method","name":"jsonb_any_key_exists?","abstract":false,"args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"args_string":"(keys : Array(T)) forall T","args_html":"(keys : Array(T)) forall T","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L13"},"def":{"name":"jsonb_any_key_exists?","args":[{"name":"keys","external_name":"keys","restriction":"Array(T)"}],"visibility":"Public","body":"_jsonb_keys_exists(keys, \"?|\")"}},{"html_id":"jsonb_key_exists?(key:String)-instance-method","name":"jsonb_key_exists?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/jsonb/node.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/node.cr#L2"},"def":{"name":"jsonb_key_exists?","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"Clear::Expression::Node::DoubleOperator.new(self, Clear::Expression::Node::Literal.new(key), \"?\")"}}]}]},{"html_id":"clear/Clear/Expression/Literal","path":"Clear/Expression/Literal.html","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal","abstract":false,"locations":[{"filename":"src/clear/expression/expression.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L62"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Enum","kind":"struct","full_name":"Clear::Enum","name":"Enum"},{"html_id":"clear/Clear/Expression/UnsafeSql","kind":"class","full_name":"Clear::Expression::UnsafeSql","name":"UnsafeSql"}],"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"},"doc":"Allow any type to be used into the expression engine\n by including the module Clear::Expression::Literal\n and defining the method `to_sql`.","summary":"Allow any type to be used into the expression engine by including the module Clear::Expression::Literal and defining the method #to_sql
.
Mother class of all the rendering nodes
","instance_methods":[{"html_id":"!=(any:Node):Node-instance-method","name":"!=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L49"},"def":{"name":"!=","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"<>\")"}},{"html_id":"!=(some_nil:Nil):Node-instance-method","name":"!=","abstract":false,"args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"args_string":"(some_nil : Nil) : Node","args_html":"(some_nil : Nil) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L49"},"def":{"name":"!=","args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Null.new, \"IS NOT\")"}},{"html_id":"!=(any:T):NodeforallT-instance-method","name":"!=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L49"},"def":{"name":"!=","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"<>\")"}},{"html_id":"!~(any:Node):Node-instance-method","name":"!~","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L29"},"def":{"name":"!~","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"!~\")"}},{"html_id":"!~(regexp:Regex):Node-instance-method","name":"!~","abstract":false,"args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"args_string":"(regexp : Regex) : Node","args_html":"(regexp : Regex) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L41"},"def":{"name":"!~","args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"return_type":"Node","visibility":"Public","body":"if regexp.options.ignore_case?\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"!~*\")\nelse\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"!~\")\nend"}},{"html_id":"&(any:Node):Node-instance-method","name":"&","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L53"},"def":{"name":"&","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"AND\")"}},{"html_id":"&(any:T):NodeforallT-instance-method","name":"&","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L53"},"def":{"name":"&","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"AND\")"}},{"html_id":"*(any:Node):Node-instance-method","name":"*","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"*","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"*\")"}},{"html_id":"*(any:T):NodeforallT-instance-method","name":"*","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"*","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"*\")"}},{"html_id":"+(any:Node):Node-instance-method","name":"+","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"+","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"+\")"}},{"html_id":"+(any:T):NodeforallT-instance-method","name":"+","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"+","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"+\")"}},{"html_id":"-(any:Node):Node-instance-method","name":"-","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"-","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"-\")"}},{"html_id":"-(any:T):NodeforallT-instance-method","name":"-","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"-","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"-\")"}},{"html_id":"--instance-method","name":"-","abstract":false,"location":{"filename":"src/clear/expression/nodes/node.cr","line_number":78,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L78"},"def":{"name":"-","visibility":"Public","body":"Node::Minus.new(self)"}},{"html_id":"/(any:Node):Node-instance-method","name":"/","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"/","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"/\")"}},{"html_id":"/(any:T):NodeforallT-instance-method","name":"/","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"/","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"/\")"}},{"html_id":"<(any:Node):Node-instance-method","name":"<","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"<","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"<\")"}},{"html_id":"<(any:T):NodeforallT-instance-method","name":"<","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"<","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"<\")"}},{"html_id":"<=(any:Node):Node-instance-method","name":"<=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":"<=","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"<=\")"}},{"html_id":"<=(any:T):NodeforallT-instance-method","name":"<=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":"<=","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"<=\")"}},{"html_id":"==(any:Node):Node-instance-method","name":"==","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L50"},"def":{"name":"==","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"=\")"}},{"html_id":"==(some_nil:Nil):Node-instance-method","name":"==","abstract":false,"args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"args_string":"(some_nil : Nil) : Node","args_html":"(some_nil : Nil) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L50"},"def":{"name":"==","args":[{"name":"some_nil","external_name":"some_nil","restriction":"Nil"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Null.new, \"IS\")"}},{"html_id":"==(any:T):NodeforallT-instance-method","name":"==","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L50"},"def":{"name":"==","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"=\")"}},{"html_id":"=~(any:Node):Node-instance-method","name":"=~","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L25"},"def":{"name":"=~","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"~\")"}},{"html_id":"=~(regexp:Regex):Node-instance-method","name":"=~","abstract":false,"args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"args_string":"(regexp : Regex) : Node","args_html":"(regexp : Regex) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L33"},"def":{"name":"=~","args":[{"name":"regexp","external_name":"regexp","restriction":"Regex"}],"return_type":"Node","visibility":"Public","body":"if regexp.options.ignore_case?\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"~*\")\nelse\n Node::DoubleOperator.new(self, Literal.new(regexp.source), \"~\")\nend"}},{"html_id":">(any:Node):Node-instance-method","name":">","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":">","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \">\")"}},{"html_id":">(any:T):NodeforallT-instance-method","name":">","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":">","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \">\")"}},{"html_id":">=(any:Node):Node-instance-method","name":">=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","def":{"name":">=","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \">=\")"}},{"html_id":">=(any:T):NodeforallT-instance-method","name":">=","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","def":{"name":">=","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \">=\")"}},{"html_id":"|(any:Node):Node-instance-method","name":"|","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L54"},"def":{"name":"|","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"OR\")"}},{"html_id":"|(any:T):NodeforallT-instance-method","name":"|","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L54"},"def":{"name":"|","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"OR\")"}},{"html_id":"~-instance-method","name":"~","abstract":false,"location":{"filename":"src/clear/expression/nodes/node.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L82"},"def":{"name":"~","visibility":"Public","body":"Node::Not.new(self)"}},{"html_id":"between(a,b)-instance-method","name":"between","abstract":false,"args":[{"name":"a","external_name":"a","restriction":""},{"name":"b","external_name":"b","restriction":""}],"args_string":"(a, b)","args_html":"(a, b)","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":74,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L74"},"def":{"name":"between","args":[{"name":"a","external_name":"a","restriction":""},{"name":"b","external_name":"b","restriction":""}],"visibility":"Public","body":"Node::Between.new(self, a, b)"}},{"html_id":"ilike(any:Node):Node-instance-method","name":"ilike","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L52"},"def":{"name":"ilike","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"ILIKE\")"}},{"html_id":"ilike(any:T):NodeforallT-instance-method","name":"ilike","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L52"},"def":{"name":"ilike","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"ILIKE\")"}},{"html_id":"in?(range:Range(B,E))forallB,E-instance-method","name":"in?","abstract":false,"args":[{"name":"range","external_name":"range","restriction":"Range(B, E)"}],"args_string":"(range : Range(B, E)) forall B, E","args_html":"(range : Range(B, E)) forall B, E","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L56"},"def":{"name":"in?","args":[{"name":"range","external_name":"range","restriction":"Range(B, E)"}],"visibility":"Public","body":"Node::InRange.new(self, Clear::Expression[range.begin]..Clear::Expression[range.end], range.exclusive?)"}},{"html_id":"in?(arr:Array(T))forallT-instance-method","name":"in?","abstract":false,"args":[{"name":"arr","external_name":"arr","restriction":"Array(T)"}],"args_string":"(arr : Array(T)) forall T","args_html":"(arr : Array(T)) forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L62"},"def":{"name":"in?","args":[{"name":"arr","external_name":"arr","restriction":"Array(T)"}],"visibility":"Public","body":"Node::InArray.new(self, arr.map do |x|\n Clear::Expression[x]\nend)"}},{"html_id":"in?(tuple:Tuple(*T))forallT-instance-method","name":"in?","abstract":false,"args":[{"name":"tuple","external_name":"tuple","restriction":"Tuple(*T)"}],"args_string":"(tuple : Tuple(*T)) forall T","args_html":"(tuple : Tuple(*T)) forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":66,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L66"},"def":{"name":"in?","args":[{"name":"tuple","external_name":"tuple","restriction":"Tuple(*T)"}],"visibility":"Public","body":"in?(tuple.to_a)"}},{"html_id":"in?(request:Clear::SQL::SelectBuilder)-instance-method","name":"in?","abstract":false,"args":[{"name":"request","external_name":"request","restriction":"::Clear::SQL::SelectBuilder"}],"args_string":"(request : Clear::SQL::SelectBuilder)","args_html":"(request : Clear::SQL::SelectBuilder)","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L70"},"def":{"name":"in?","args":[{"name":"request","external_name":"request","restriction":"::Clear::SQL::SelectBuilder"}],"visibility":"Public","body":"Node::InSelect.new(self, request)"}},{"html_id":"like(any:Node):Node-instance-method","name":"like","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"Node"}],"args_string":"(any : Node) : Node","args_html":"(any : Node) : Node","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L51"},"def":{"name":"like","args":[{"name":"any","external_name":"any","restriction":"Node"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, any, \"LIKE\")"}},{"html_id":"like(any:T):NodeforallT-instance-method","name":"like","abstract":false,"args":[{"name":"any","external_name":"any","restriction":"T"}],"args_string":"(any : T) : Node forall T","args_html":"(any : T) : Node forall T","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L51"},"def":{"name":"like","args":[{"name":"any","external_name":"any","restriction":"T"}],"return_type":"Node","visibility":"Public","body":"Node::DoubleOperator.new(self, Literal.new(any), \"LIKE\")"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":true,"location":{"filename":"src/clear/expression/nodes/node.cr","line_number":86,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L86"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":""}}],"macros":[{"html_id":"define_operator(op_name,sql_name,null=false)-macro","name":"define_operator","abstract":false,"args":[{"name":"op_name","external_name":"op_name","restriction":""},{"name":"sql_name","external_name":"sql_name","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""}],"args_string":"(op_name, sql_name, null = false)","args_html":"(op_name, sql_name, null = false)","location":{"filename":"src/clear/expression/nodes/node.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node.cr#L5"},"def":{"name":"define_operator","args":[{"name":"op_name","external_name":"op_name","restriction":""},{"name":"sql_name","external_name":"sql_name","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""}],"visibility":"Public","body":" def \n{{ op_name.id }}\n(any : Node) : Node\n Node::DoubleOperator.new(self, any, \"\n{{ sql_name.id }}\n\")\n \nend\n\n \n{% if null %}\n def {{ op_name.id }}(some_nil : Nil) : Node\n Node::DoubleOperator.new(self, Null.new, {{ null }} )\n end\n {% end %}\n\n\n def \n{{ op_name.id }}\n(any : T) : Node forall T\n Node::DoubleOperator.new(self, Literal.new(any), \"\n{{ sql_name.id }}\n\")\n \nend\n \n"}}],"types":[{"html_id":"clear/Clear/Expression/Node/Between","path":"Clear/Expression/Node/Between.html","kind":"class","full_name":"Clear::Expression::Node::Between","name":"Between","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/between.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/between.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the rendering of `(var BETWEEN a AND b)`\nexpressions.","summary":"A node managing the rendering of (var BETWEEN a AND b)
expressions.
A node managing the rendering of combination operations like <val1> <op> <val2>
A node managing the rendering of functions in Postgres.
","constructors":[{"html_id":"new(name:String,args:Array(String))-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"args","external_name":"args","restriction":"Array(String)"}],"args_string":"(name : String, args : Array(String))","args_html":"(name : String, args : Array(String))","location":{"filename":"src/clear/expression/nodes/function.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/function.cr#L5"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"args","external_name":"args","restriction":"Array(String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, args)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/function.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/function.cr#L7"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"{@name, \"(\", @args.join(\", \"), \")\"}.join"}}]},{"html_id":"clear/Clear/Expression/Node/InArray","path":"Clear/Expression/Node/InArray.html","kind":"class","full_name":"Clear::Expression::Node::InArray","name":"InArray","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/in_array.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_array.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the rendering of array in Postgres.\n- It renders `val IN (...)`.\n- If the array passed as argument is empty, it renders `FALSE` instead.","summary":"A node managing the rendering of array in Postgres.
","constructors":[{"html_id":"new(target:Node,array:Array(String))-class-method","name":"new","abstract":false,"args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"array","external_name":"array","restriction":"Array(String)"}],"args_string":"(target : Node, array : Array(String))","args_html":"(target : Node, array : Array(String))","location":{"filename":"src/clear/expression/nodes/in_array.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_array.cr#L7"},"def":{"name":"new","args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"array","external_name":"array","restriction":"Array(String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(target, array)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/in_array.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_array.cr#L9"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"if @array.size == 0\n \"FALSE\"\nelse\n {@target.resolve, \" IN (\", @array.join(\", \"), \")\"}.join\nend"}}]},{"html_id":"clear/Clear/Expression/Node/InRange","path":"Clear/Expression/Node/InRange.html","kind":"class","full_name":"Clear::Expression::Node::InRange","name":"InRange","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/in_range.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_range.cr#L19"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the rendering a range in Postgres.\n\nExample:\n\n```\nvalue.in?(1..5)\n```\n\nwill render:\n\n```\nvalue >= 1 AND value < 5\n```\n\nInclusion and exclusion of the last number of the range is featured\n","summary":"A node managing the rendering a range in Postgres.
","constructors":[{"html_id":"new(target:Node,range:Range(String,String),exclusive:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"range","external_name":"range","restriction":"Range(String, String)"},{"name":"exclusive","default_value":"false","external_name":"exclusive","restriction":"::Bool"}],"args_string":"(target : Node, range : Range(String, String), exclusive : Bool = false)","args_html":"(target : Node, range : Range(String, String), exclusive : Bool = false)","location":{"filename":"src/clear/expression/nodes/in_range.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_range.cr#L20"},"def":{"name":"new","args":[{"name":"target","external_name":"target","restriction":"Node"},{"name":"range","external_name":"range","restriction":"Range(String, String)"},{"name":"exclusive","default_value":"false","external_name":"exclusive","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(target, range, exclusive)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/in_range.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_range.cr#L22"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"rt = @target.resolve\nfinal_op = @exclusive ? \" < \" : \" <= \"\n{\"(\", rt, \" >= \", @range.begin, \" AND \", rt, final_op, @range.end, \")\"}.join\n"}}]},{"html_id":"clear/Clear/Expression/Node/InSelect","path":"Clear/Expression/Node/InSelect.html","kind":"class","full_name":"Clear::Expression::Node::InSelect","name":"InSelect","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/in_select.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/in_select.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":" A node managing the rendering of `value IN (A node managing the rendering of value IN ( <SUBQUERY> )
Define a array contains? (?) operation between a jsonb column and a json hash
","constructors":[{"html_id":"new(jsonb_field:String,value:String)-class-method","name":"new","abstract":false,"args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::String"}],"args_string":"(jsonb_field : String, value : String)","args_html":"(jsonb_field : String, value : String)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L62"},"def":{"name":"new","args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(jsonb_field, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"jsonb_field:String-instance-method","name":"jsonb_field","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":59,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L59"},"def":{"name":"jsonb_field","return_type":"String","visibility":"Public","body":"@jsonb_field"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L65"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"{@jsonb_field, @value}.join(\" ? \")"}},{"html_id":"value:String-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":60,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L60"},"def":{"name":"value","return_type":"String","visibility":"Public","body":"@value"}}]},{"html_id":"clear/Clear/Expression/Node/JSONB/Equality","path":"Clear/Expression/Node/JSONB/Equality.html","kind":"class","full_name":"Clear::Expression::Node::JSONB::Equality","name":"Equality","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"},{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L43"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}],"namespace":{"html_id":"clear/Clear/Expression/Node/JSONB","kind":"module","full_name":"Clear::Expression::Node::JSONB","name":"JSONB"},"doc":"Define a __value match? (@>)__ operation between a jsonb column and a json hash","summary":"Define a value match? (@>) operation between a jsonb column and a json hash
","constructors":[{"html_id":"new(jsonb_field:String,value:Hash(String,Clear::SQL::JSONB::JSONBKey))-class-method","name":"new","abstract":false,"args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::Hash(::String, ::Clear::SQL::JSONB::JSONBKey)"}],"args_string":"(jsonb_field : String, value : Hash(String, Clear::SQL::JSONB::JSONBKey))","args_html":"(jsonb_field : String, value : Hash(String, Clear::SQL::JSONB::JSONBKey))","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L49"},"def":{"name":"new","args":[{"name":"jsonb_field","external_name":"jsonb_field","restriction":"::String"},{"name":"value","external_name":"value","restriction":"::Hash(::String, ::Clear::SQL::JSONB::JSONBKey)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(jsonb_field, value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"jsonb_field:String-instance-method","name":"jsonb_field","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":46,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L46"},"def":{"name":"jsonb_field","return_type":"String","visibility":"Public","body":"@jsonb_field"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L52"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"{@jsonb_field, Clear::Expression[@value.to_json]}.join(\" @> \")"}},{"html_id":"value:JSONBHash-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L47"},"def":{"name":"value","return_type":"JSONBHash","visibility":"Public","body":"@value"}}]},{"html_id":"clear/Clear/Expression/Node/JSONB/Field","path":"Clear/Expression/Node/JSONB/Field.html","kind":"class","full_name":"Clear::Expression::Node::JSONB::Field","name":"Field","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"},{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}],"namespace":{"html_id":"clear/Clear/Expression/Node/JSONB","kind":"module","full_name":"Clear::Expression::Node::JSONB","name":"JSONB"},"constructors":[{"html_id":"new(field:Clear::Expression::Node,key:String,cast:Nil|String=nil)-class-method","name":"new","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"::Clear::Expression::Node"},{"name":"key","external_name":"key","restriction":"::String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":"::Nil | ::String"}],"args_string":"(field : Clear::Expression::Node, key : String, cast : Nil | String = nil)","args_html":"(field : Clear::Expression::Node, key : String, cast : Nil | String = nil)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L10"},"def":{"name":"new","args":[{"name":"field","external_name":"field","restriction":"::Clear::Expression::Node"},{"name":"key","external_name":"key","restriction":"::String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":"::Nil | ::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(field, key, cast)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"==(value:Clear::Expression::Node)-instance-method","name":"==","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Clear::Expression::Node"}],"args_string":"(value : Clear::Expression::Node)","args_html":"(value : Clear::Expression::Node)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L21"},"def":{"name":"==","args":[{"name":"value","external_name":"value","restriction":"Clear::Expression::Node"}],"visibility":"Public","body":"super(value)"}},{"html_id":"==(value:_)-instance-method","name":"==","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"_"}],"args_string":"(value : _)","args_html":"(value : _)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L25"},"def":{"name":"==","args":[{"name":"value","external_name":"value","restriction":"_"}],"visibility":"Public","body":"if @cast\n super(value)\nelse\n Clear::Expression::Node::JSONB::Equality.new(field.resolve, jsonb_k2h(key, value))\nend"}},{"html_id":"cast(cast:Nil|String)-instance-method","name":"cast","abstract":false,"args":[{"name":"cast","external_name":"cast","restriction":"::Nil | ::String"}],"args_string":"(cast : Nil | String)","args_html":"(cast : Nil | String)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L17"},"def":{"name":"cast","args":[{"name":"cast","external_name":"cast","restriction":"::Nil | ::String"}],"visibility":"Public","body":"@cast = cast\nself\n"}},{"html_id":"cast:String|Nil-instance-method","name":"cast","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L8"},"def":{"name":"cast","return_type":"String | ::Nil","visibility":"Public","body":"@cast"}},{"html_id":"contains?(expression:Clear::Expression::Node)-instance-method","name":"contains?","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Clear::Expression::Node"}],"args_string":"(expression : Clear::Expression::Node)","args_html":"(expression : Clear::Expression::Node)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L33"},"def":{"name":"contains?","args":[{"name":"expression","external_name":"expression","restriction":"Clear::Expression::Node"}],"visibility":"Public","body":"Clear::Expression::Node::JSONB::ArrayContains.new(resolve, expression.resolve)"}},{"html_id":"contains?(expression)-instance-method","name":"contains?","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":""}],"args_string":"(expression)","args_html":"(expression)","location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L37"},"def":{"name":"contains?","args":[{"name":"expression","external_name":"expression","restriction":""}],"visibility":"Public","body":"Clear::Expression::Node::JSONB::ArrayContains.new(resolve, Clear::Expression[expression])"}},{"html_id":"field:Node-instance-method","name":"field","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L6"},"def":{"name":"field","return_type":"Node","visibility":"Public","body":"@field"}},{"html_id":"key:String-instance-method","name":"key","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L7"},"def":{"name":"key","return_type":"String","visibility":"Public","body":"@key"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/extensions/jsonb/expression.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/expression.cr#L13"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"jsonb_resolve(@field.resolve, jsonb_k2a(key), @cast)"}}]}]},{"html_id":"clear/Clear/Expression/Node/Literal","path":"Clear/Expression/Node/Literal.html","kind":"class","full_name":"Clear::Expression::Node::Literal","name":"Literal","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/literal.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"Management of rendering of literal values.","summary":"Management of rendering of literal values.
","constructors":[{"html_id":"new(value)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":""}],"args_string":"(value)","args_html":"(value)","location":{"filename":"src/clear/expression/nodes/literal.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L7"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/literal.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L17"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"Clear::Expression[@value]"}},{"html_id":"value:AvailableLiteral-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/expression/nodes/literal.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/literal.cr#L5"},"def":{"name":"value","return_type":"AvailableLiteral","visibility":"Public","body":"@value"}}]},{"html_id":"clear/Clear/Expression/Node/Minus","path":"Clear/Expression/Node/Minus.html","kind":"class","full_name":"Clear::Expression::Node::Minus","name":"Minus","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/minus.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/minus.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the unary `-` operator.","summary":"A node managing the unary -
operator.
This node is used to generate expression like `( a AND b AND ...
","constructors":[{"html_id":"new(expression:Array(Node),link:String)-class-method","name":"new","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"},{"name":"link","external_name":"link","restriction":"::String"}],"args_string":"(expression : Array(Node), link : String)","args_html":"(expression : Array(Node), link : String)","location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L8"},"def":{"name":"new","args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"},{"name":"link","external_name":"link","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(expression, link)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"expression:Array(Node)-instance-method","name":"expression","abstract":false,"location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L5"},"def":{"name":"expression","return_type":"Array(Node)","visibility":"Public","body":"@expression"}},{"html_id":"expression=(expression:Array(Node))-instance-method","name":"expression=","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"}],"args_string":"(expression : Array(Node))","args_html":"(expression : Array(Node))","location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L5"},"def":{"name":"expression=","args":[{"name":"expression","external_name":"expression","restriction":"Array(Node)"}],"visibility":"Public","body":"@expression = expression"}},{"html_id":"link:String-instance-method","name":"link","abstract":false,"location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L6"},"def":{"name":"link","return_type":"String","visibility":"Public","body":"@link"}},{"html_id":"link=(link:String)-instance-method","name":"link=","abstract":false,"args":[{"name":"link","external_name":"link","restriction":"String"}],"args_string":"(link : String)","args_html":"(link : String)","location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L6"},"def":{"name":"link=","args":[{"name":"link","external_name":"link","restriction":"String"}],"visibility":"Public","body":"@link = link"}},{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/node_array.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/node_array.cr#L12"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"if !@expression.empty?\n {\"(\", @expression.join(\" #{@link} \", &.resolve), \")\"}.join\nelse\n \"\"\nend"}}]},{"html_id":"clear/Clear/Expression/Node/Not","path":"Clear/Expression/Node/Not.html","kind":"class","full_name":"Clear::Expression::Node::Not","name":"Not","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/not.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/not.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing the unary `NOT` operator.","summary":"A node managing the unary NOT
operator.
A node managing the rendering of (var NOT BETWEEN a AND b)
expressions.
Render NULL !
","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/expression/nodes/null.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/null.cr#L5"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/null.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/null.cr#L8"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"\"NULL\""}}]},{"html_id":"clear/Clear/Expression/Node/PGArray","path":"Clear/Expression/Node/PGArray.html","kind":"class","full_name":"Clear::Expression::Node::PGArray(T)","name":"PGArray","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/pg_array.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/pg_array.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A node managing PG structure `array[args...]`\nNamed PGArray instead of Array to avoid issue with naming","summary":"A node managing PG structure array[args...]
Named PGArray instead of Array to avoid issue with naming
This node manage the rendering of a raw SQL fragment.
","constructors":[{"html_id":"new(raw:String)-class-method","name":"new","abstract":false,"args":[{"name":"raw","external_name":"raw","restriction":"String"}],"args_string":"(raw : String)","args_html":"(raw : String)","location":{"filename":"src/clear/expression/nodes/raw.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/raw.cr#L5"},"def":{"name":"new","args":[{"name":"raw","external_name":"raw","restriction":"String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(raw)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/raw.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/raw.cr#L7"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"@raw"}}]},{"html_id":"clear/Clear/Expression/Node/Variable","path":"Clear/Expression/Node/Variable.html","kind":"class","full_name":"Clear::Expression::Node::Variable","name":"Variable","abstract":false,"superclass":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"ancestors":[{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},{"html_id":"clear/Clear/Expression/JSONB/Node","kind":"module","full_name":"Clear::Expression::JSONB::Node","name":"Node"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/nodes/variable.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L16"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Expression/Node","kind":"class","full_name":"Clear::Expression::Node","name":"Node"},"doc":"A variable AST node.\nIt's what's created under the hood when you use a non-existent variable:\n\n```\nwhere { users.id != nil }\n\nwill produce this tree:\n\n# => double_operator('<>')\n# # => variable('id', parent: 'users')\n# # => null\n\n```","summary":"A variable AST node.
","constructors":[{"html_id":"new(name:String,parent:Variable|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"parent","default_value":"nil","external_name":"parent","restriction":"Variable | ::Nil"}],"args_string":"(name : String, parent : Variable | Nil = nil)","args_html":"(name : String, parent : Variable | Nil = nil)","location":{"filename":"src/clear/expression/nodes/variable.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L17"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"parent","default_value":"nil","external_name":"parent","restriction":"Variable | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, parent)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"resolve:String-instance-method","name":"resolve","abstract":false,"location":{"filename":"src/clear/expression/nodes/variable.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L28"},"def":{"name":"resolve","return_type":"String","visibility":"Public","body":"parent = @parent\nif parent\n {parent.resolve, \".\", Clear::SQL.escape(@name)}.join\nelse\n Clear::SQL.escape(@name)\nend\n"}}],"macros":[{"html_id":"method_missing(call)-macro","name":"method_missing","abstract":false,"args":[{"name":"call","external_name":"call","restriction":""}],"args_string":"(call)","args_html":"(call)","location":{"filename":"src/clear/expression/nodes/variable.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/nodes/variable.cr#L19"},"def":{"name":"method_missing","args":[{"name":"call","external_name":"call","restriction":""}],"visibility":"Public","body":" \n{% if call.args.size > 0 %}\n args = Clear::Expression[{{ call.args }}].join(\", \")\n return Node::Variable.new(\"{{ call.name.id }}(#{args})\", self)\n {% else %}\n return Node::Variable.new({{ call.name.id.stringify }}, self)\n {% end %}\n\n \n"}}]}]},{"html_id":"clear/Clear/Expression/UnsafeSql","path":"Clear/Expression/UnsafeSql.html","kind":"class","full_name":"Clear::Expression::UnsafeSql","name":"UnsafeSql","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/expression/expression.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L70"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Expression/Literal","kind":"module","full_name":"Clear::Expression::Literal","name":"Literal"}],"namespace":{"html_id":"clear/Clear/Expression","kind":"class","full_name":"Clear::Expression","name":"Expression"},"doc":"Wrap an unsafe string. Useful to cancel-out the\nsafe_literal function used internally.\nObviously, this can lead to SQL injection, so beware!","summary":"Wrap an unsafe string.
","constructors":[{"html_id":"new(value:String)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::String"}],"args_string":"(value : String)","args_html":"(value : String)","location":{"filename":"src/clear/expression/expression.cr","line_number":75,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L75"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"to_json(json=nil):String-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","default_value":"nil","external_name":"json","restriction":""}],"args_string":"(json = nil) : String","args_html":"(json = nil) : String","location":{"filename":"src/clear/expression/expression.cr","line_number":86,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L86"},"def":{"name":"to_json","args":[{"name":"json","default_value":"nil","external_name":"json","restriction":""}],"visibility":"Public","body":"@value"}},{"html_id":"to_s:String-instance-method","name":"to_s","doc":"Returns a nicely readable and concise string representation of this object,\ntypically intended for users.\n\nThis method should usually **not** be overridden. It delegates to\n`#to_s(IO)` which can be overridden for custom implementations.\n\nAlso see `#inspect`.","summary":"Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"location":{"filename":"src/clear/expression/expression.cr","line_number":78,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L78"},"def":{"name":"to_s","visibility":"Public","body":"@value"}},{"html_id":"to_sql:String-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/expression/expression.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/expression/expression.cr#L82"},"def":{"name":"to_sql","visibility":"Public","body":"@value"}}]}]},{"html_id":"clear/Clear/IllegalEnumValueError","path":"Clear/IllegalEnumValueError.html","kind":"class","full_name":"Clear::IllegalEnumValueError","name":"IllegalEnumValueError","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/enum/enum.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/enum.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"}},{"html_id":"clear/Clear/Interval","path":"Clear/Interval.html","kind":"struct","full_name":"Clear::Interval","name":"Interval","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/interval/interval.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/interval/interval.cr#L17"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"It can be converted automatically from/to a `interval` column.\n\n## Usage example\n\n```\nclass MyModel\n include Clear::Model\n\n column interval : Clear::TimeInDay\nend\n\ninterval = Clear::Interval.new(60.days)\nrecord = MyModel.create!(interval: interval)\n```","summary":"It can be converted automatically from/to a interval
column.
For PG::Interval
Run the block given in parameter if the direction is a rollback
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L38"},"def":{"name":"down","yields":0,"block_arity":0,"visibility":"Public","body":"if down?\n yield\nend"}},{"html_id":"down?-instance-method","name":"down?","doc":"Return true whether the migration is a rollback","summary":"Return true whether the migration is a rollback
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L43"},"def":{"name":"down?","visibility":"Public","body":"self == Down"}},{"html_id":"up(&)-instance-method","name":"up","doc":"Run the block given in parameter if the direction is a upstream","summary":"Run the block given in parameter if the direction is a upstream
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L28"},"def":{"name":"up","yields":0,"block_arity":0,"visibility":"Public","body":"if self == Up\n yield\nend"}},{"html_id":"up?-instance-method","name":"up?","doc":"Return true whether the migration is a upstream","summary":"Return true whether the migration is a upstream
","abstract":false,"location":{"filename":"src/clear/migration/direction.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/direction.cr#L33"},"def":{"name":"up?","visibility":"Public","body":"self == Up"}}]},{"html_id":"clear/Clear/Migration/DropEnum","path":"Clear/Migration/DropEnum.html","kind":"class","full_name":"Clear::Migration::DropEnum","name":"DropEnum","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/enum/migration.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L18"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(name:String,values:Nil|Array(String))-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"values","external_name":"values","restriction":"::Nil | ::Array(::String)"}],"args_string":"(name : String, values : Nil | Array(String))","args_html":"(name : String, values : Nil | Array(String))","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L22"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"values","external_name":"values","restriction":"::Nil | ::Array(::String)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, values)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L29"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"if values = @values\n [\"CREATE TYPE #{@name} AS ENUM (#{Clear::Expression[values].join(\", \")})\"]\nelse\n irreversible!\nend"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L25"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"DROP TYPE #{@name}\"]"}}]},{"html_id":"clear/Clear/Migration/DropTable","path":"Clear/Migration/DropTable.html","kind":"class","full_name":"Clear::Migration::DropTable","name":"DropTable","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":209,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L209"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(table:String,schema:String)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"}],"args_string":"(table : String, schema : String)","args_html":"(table : String, schema : String)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":213,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L213"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, schema)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":224,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L224"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[\"CREATE TABLE #{@table}\"]"}},{"html_id":"full_name-instance-method","name":"full_name","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":216,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L216"},"def":{"name":"full_name","visibility":"Public","body":"{Clear::SQL.escape(@schema), Clear::SQL.escape(@name)}.join(\".\")"}},{"html_id":"schema:String-instance-method","name":"schema","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":211,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L211"},"def":{"name":"schema","return_type":"String","visibility":"Public","body":"@schema"}},{"html_id":"table:String-instance-method","name":"table","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":210,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L210"},"def":{"name":"table","return_type":"String","visibility":"Public","body":"@table"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":220,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L220"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"DROP TABLE #{@table}\"]"}}]},{"html_id":"clear/Clear/Migration/Execute","path":"Clear/Migration/Execute.html","kind":"class","full_name":"Clear::Migration::Execute","name":"Execute","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/execute.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(sql:String,irreversible:Bool|Nil=false)-class-method","name":"new","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":"String"},{"name":"irreversible","default_value":"false","external_name":"irreversible","restriction":"Bool | ::Nil"}],"args_string":"(sql : String, irreversible : Bool | Nil = false)","args_html":"(sql : String, irreversible : Bool | Nil = false)","location":{"filename":"src/clear/migration/operation/execute.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L5"},"def":{"name":"new","args":[{"name":"sql","external_name":"sql","restriction":"String"},{"name":"irreversible","default_value":"false","external_name":"irreversible","restriction":"Bool | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(sql, irreversible)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/execute.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L12"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"if @irreversible\n irreversible!\nend\n[@sql].compact\n"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/execute.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/execute.cr#L8"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[@sql].compact"}}]},{"html_id":"clear/Clear/Migration/FullTextSearchableHelpers","path":"Clear/Migration/FullTextSearchableHelpers.html","kind":"module","full_name":"Clear::Migration::FullTextSearchableHelpers","name":"FullTextSearchableHelpers","abstract":false,"locations":[{"filename":"src/clear/extensions/full_text_searchable/migration.cr","line_number":83,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/migration.cr#L83"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Migration/Helper","kind":"module","full_name":"Clear::Migration::Helper","name":"Helper"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"instance_methods":[{"html_id":"add_full_text_searchable(table,on:Array(Tuple(String,Char)),column_name=\"full_text_vector\",catalog=\"pg_catalog.english\",trigger_name=nil,function_name=nil)-instance-method","name":"add_full_text_searchable","doc":"Add a `tsvector` field to a table.\nCreate column, index and trigger.","summary":"Add a tsvector
field to a table.
Replace some common type to their equivalent in postgresql if the type is not found in the correspondance table, then return itself
","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"}],"args_string":"(type : String)","args_html":"(type : String)","location":{"filename":"src/clear/migration/migration.cr","line_number":82,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L82"},"def":{"name":"datatype","args":[{"name":"type","external_name":"type","restriction":"String"}],"visibility":"Public","body":"ts = type\nTYPE_MAPPING[type]? || ts\n"}}],"instance_methods":[{"html_id":"add_column(table,column,datatype,nullable=false,constraint=nil,default=nil,with_values=false)-instance-method","name":"add_column","doc":"Add a column to a specific table","summary":"Add a column to a specific table
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"datatype","external_name":"datatype","restriction":""},{"name":"nullable","default_value":"false","external_name":"nullable","restriction":""},{"name":"constraint","default_value":"nil","external_name":"constraint","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"with_values","default_value":"false","external_name":"with_values","restriction":""}],"args_string":"(table, column, datatype, nullable = false, constraint = nil, default = nil, with_values = false)","args_html":"(table, column, datatype, nullable = false, constraint = nil, default = nil, with_values = false)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":97,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L97"},"def":{"name":"add_column","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"datatype","external_name":"datatype","restriction":""},{"name":"nullable","default_value":"false","external_name":"nullable","restriction":""},{"name":"constraint","default_value":"nil","external_name":"constraint","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"with_values","default_value":"false","external_name":"with_values","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::AddColumn.new(table, column, datatype, nullable, constraint, default, with_values))"}},{"html_id":"add_operation(op:Operation)-instance-method","name":"add_operation","abstract":false,"args":[{"name":"op","external_name":"op","restriction":"Operation"}],"args_string":"(op : Operation)","args_html":"(op : Operation)","location":{"filename":"src/clear/migration/migration.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L95"},"def":{"name":"add_operation","args":[{"name":"op","external_name":"op","restriction":"Operation"}],"visibility":"Public","body":"op.migration = self\n@operations << op\n"}},{"html_id":"apply(dir:Direction=Clear::Migration::Direction::Up)-instance-method","name":"apply","doc":"This will apply the migration in a given direction (up or down)","summary":"This will apply the migration in a given direction (up or down)
","abstract":false,"args":[{"name":"dir","default_value":"Clear::Migration::Direction::Up","external_name":"dir","restriction":"Direction"}],"args_string":"(dir : Direction = Clear::Migration::Direction::Up)","args_html":"(dir : Direction = Clear::Migration::Direction::Up)","location":{"filename":"src/clear/migration/migration.cr","line_number":103,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L103"},"def":{"name":"apply","args":[{"name":"dir","default_value":"Clear::Migration::Direction::Up","external_name":"dir","restriction":"Direction"}],"visibility":"Public","body":"Clear::Migration::Manager.instance.ensure_ready\nClear::SQL.transaction do\n Log.info do\n \"[#{dir}] #{self.class.name}\"\n end\n @operations.clear\n change(dir)\n dir.up do\n @operations.each do |op|\n op.up.each do |x|\n Clear::SQL.execute(x.as(String))\n end\n end\n (SQL.insert(\"__clear_metadatas\", {metatype: \"migration\", value: uid.to_s})).execute\n end\n dir.down do\n @operations.reverse_each do |op|\n op.down.each do |x|\n Clear::SQL.execute(x.as(String))\n end\n end\n ((SQL.delete(\"__clear_metadatas\")).where({metatype: \"migration\", value: uid.to_s})).execute\n end\n self\nend\n"}},{"html_id":"change(dir)-instance-method","name":"change","abstract":true,"args":[{"name":"dir","external_name":"dir","restriction":""}],"args_string":"(dir)","args_html":"(dir)","location":{"filename":"src/clear/migration/migration.cr","line_number":100,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L100"},"def":{"name":"change","args":[{"name":"dir","external_name":"dir","restriction":""}],"visibility":"Public","body":""}},{"html_id":"change_column_type(table,column,from,to)-instance-method","name":"change_column_type","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"args_string":"(table, column, from, to)","args_html":"(table, column, from, to)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":110,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L110"},"def":{"name":"change_column_type","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::ChangeColumnType.new(table, column, from, to))"}},{"html_id":"create_enum(name,arr:Enumerable(T))forallT-instance-method","name":"create_enum","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","external_name":"arr","restriction":"Enumerable(T)"}],"args_string":"(name, arr : Enumerable(T)) forall T","args_html":"(name, arr : Enumerable(T)) forall T","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L39"},"def":{"name":"create_enum","args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","external_name":"arr","restriction":"Enumerable(T)"}],"visibility":"Public","body":"add_operation(CreateEnum.new(name.to_s, arr.map(&.to_s)))"}},{"html_id":"create_enum(name,e)-instance-method","name":"create_enum","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"e","external_name":"e","restriction":""}],"args_string":"(name, e)","args_html":"(name, e)","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L47"},"def":{"name":"create_enum","args":[{"name":"name","external_name":"name","restriction":""},{"name":"e","external_name":"e","restriction":""}],"visibility":"Public","body":"add_operation(CreateEnum.new(name.to_s, e.authorized_values))"}},{"html_id":"create_index(table,columns:Array(String),name=nil,using=nil,unique=false)-instance-method","name":"create_index","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"columns","external_name":"columns","restriction":"Array(String)"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(table, columns : Array(String), name = nil, using = nil, unique = false)","args_html":"(table, columns : Array(String), name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/indexes.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/indexes.cr#L56"},"def":{"name":"create_index","args":[{"name":"table","external_name":"table","restriction":""},{"name":"columns","external_name":"columns","restriction":"Array(String)"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::CreateIndex.new(table, fields: columns, name: name, using: using, unique: unique))"}},{"html_id":"create_index(table,column,name=nil,using=nil,unique=false)-instance-method","name":"create_index","doc":"Add a column to a specific table","summary":"Add a column to a specific table
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(table, column, name = nil, using = nil, unique = false)","args_html":"(table, column, name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/indexes.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/indexes.cr#L50"},"def":{"name":"create_index","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::CreateIndex.new(table, fields: [column], name: name, using: using, unique: unique))"}},{"html_id":"create_table(name,id:Symbol|Bool=true,schema=\"public\",&)-instance-method","name":"create_table","doc":"\nHelper used in migration to create a new table.\n\nUsage:\n\n```\ncreate_table(:users) do |t|\n t.column :first_name, :string\n t.column :last_name, :string\n t.column :email, :string, unique: true\n t.timestamps\nend\n```\n\nBy default, a column `id` of type `integer` will be created as primary key of the table.\nThis can be prevented using `primary: false`\n\n```\ncreate_table(:users, id: false) do |t|\n t.column :user_id, :integer, primary: true # Use custom name for the primary key\n t.column :first_name, :string\n t.column :last_name, :string\n t.column :email, :string, unique: true\n t.timestamps\nend\n```\n","summary":"Helper used in migration to create a new table.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"id","default_value":"true","external_name":"id","restriction":"Symbol | Bool"},{"name":"schema","default_value":"\"public\"","external_name":"schema","restriction":""}],"args_string":"(name, id : Symbol | Bool = true, schema = \"public\", &)","args_html":"(name, id : Symbol | Bool = true, schema = "public", &)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":257,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L257"},"def":{"name":"create_table","args":[{"name":"name","external_name":"name","restriction":""},{"name":"id","default_value":"true","external_name":"id","restriction":"Symbol | Bool"},{"name":"schema","default_value":"\"public\"","external_name":"schema","restriction":""}],"yields":1,"block_arity":1,"visibility":"Public","body":"table = Table.new(name.to_s, schema.to_s, is_create: true)\nadd_operation(table)\ncase id\nwhen true, :bigserial\n table.column(\"id\", \"bigserial\", primary: true, null: false)\nwhen :serial\n table.column(\"id\", \"serial\", primary: true, null: false)\nwhen :uuid\n table.column(\"id\", \"uuid\", primary: true, null: false)\nwhen false\nelse\n raise(\"Unknown key type while try to create new table: `#{id}`. Candidates are :bigserial, :serial and :uuid\" + \"Please proceed with `id: false` and add the column manually\")\nend\nyield(table)\n"}},{"html_id":"drop_column(table,column,type)-instance-method","name":"drop_column","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""}],"args_string":"(table, column, type)","args_html":"(table, column, type)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":102,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L102"},"def":{"name":"drop_column","args":[{"name":"table","external_name":"table","restriction":""},{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::RemoveColumn.new(table, column, type))"}},{"html_id":"drop_enum(name,arr:Enumerable(T)|Nil=nil)forallT-instance-method","name":"drop_enum","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","default_value":"nil","external_name":"arr","restriction":"Enumerable(T) | ::Nil"}],"args_string":"(name, arr : Enumerable(T) | Nil = nil) forall T","args_html":"(name, arr : Enumerable(T) | Nil = nil) forall T","location":{"filename":"src/clear/extensions/enum/migration.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/enum/migration.cr#L43"},"def":{"name":"drop_enum","args":[{"name":"name","external_name":"name","restriction":""},{"name":"arr","default_value":"nil","external_name":"arr","restriction":"Enumerable(T) | ::Nil"}],"visibility":"Public","body":"add_operation(DropEnum.new(name.to_s, arr.try(&.map(&.to_s))))"}},{"html_id":"execute(sql:String)-instance-method","name":"execute","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":"String"}],"args_string":"(sql : String)","args_html":"(sql : String)","location":{"filename":"src/clear/migration/migration.cr","line_number":91,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L91"},"def":{"name":"execute","args":[{"name":"sql","external_name":"sql","restriction":"String"}],"visibility":"Public","body":"@operations << (Clear::Migration::Execute.new(sql))"}},{"html_id":"irreversible!-instance-method","name":"irreversible!","abstract":false,"location":{"filename":"src/clear/migration/migration.cr","line_number":87,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L87"},"def":{"name":"irreversible!","visibility":"Public","body":"raise(IrreversibleMigration.new(migration_irreversible(self.class.name)))"}},{"html_id":"rename_column(table,from,to)-instance-method","name":"rename_column","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"args_string":"(table, from, to)","args_html":"(table, from, to)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":106,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L106"},"def":{"name":"rename_column","args":[{"name":"table","external_name":"table","restriction":""},{"name":"from","external_name":"from","restriction":""},{"name":"to","external_name":"to","restriction":""}],"visibility":"Public","body":"add_operation(Clear::Migration::RenameColumn.new(table, from, to))"}}]},{"html_id":"clear/Clear/Migration/IrreversibleMigration","path":"Clear/Migration/IrreversibleMigration.html","kind":"class","full_name":"Clear::Migration::IrreversibleMigration","name":"IrreversibleMigration","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/migration.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/migration.cr#L65"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"doc":"This error is throw when you try to revert a migration which is irreversible.","summary":"This error is throw when you try to revert a migration which is irreversible.
"},{"html_id":"clear/Clear/Migration/Manager","path":"Clear/Migration/Manager.html","kind":"class","full_name":"Clear::Migration::Manager","name":"Manager","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/manager.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"METADATA_VERSION","name":"METADATA_VERSION","value":"\"1\"","doc":"Used to migrate between metadata version, in case we need it in the future.","summary":"Used to migrate between metadata version, in case we need it in the future.
"}],"included_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"doc":"The migration manager is a singleton, it load all the migrations,\ncheck which one are `up` and `down`, and can trigger one or multiple\ndowngrade / upgrade of the database.\n\nThe migration system needs the creation of a table named `__clear_metadatas`\nin your database. This table will be created automatically on the first\ninitialization of the Migration Manager.\n","summary":"The migration manager is a singleton, it load all the migrations, check which one are #up
and #down
, and can trigger one or multiple downgrade / upgrade of the database.
To access to the manager
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L22"},"def":{"name":"instance","visibility":"Public","body":"@@instance || (@@instance = Manager.new)"}}],"instance_methods":[{"html_id":"apply_all-instance-method","name":"apply_all","doc":"Apply all the migrations not yet applied.","summary":"Apply all the migrations not yet applied.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":141,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L141"},"def":{"name":"apply_all","visibility":"Public","body":"ensure_ready\nClear::View.apply(:drop)\nlist_of_migrations = @migrations.sort do |a, b|\n a.uid <=> b.uid\nend\nlist_of_migrations.reject! do |x|\n @migrations_up.includes?(x.uid)\nend\nlist_of_migrations.each do |migration|\n migration.apply\n @migrations_up.add(migration.uid)\nend\nClear::View.apply(:create)\n"}},{"html_id":"apply_to(version,direction=:both)-instance-method","name":"apply_to","abstract":false,"args":[{"name":"version","external_name":"version","restriction":""},{"name":"direction","default_value":":both","external_name":"direction","restriction":""}],"args_string":"(version, direction = :both)","args_html":"(version, direction = :both)","location":{"filename":"src/clear/migration/manager.cr","line_number":73,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L73"},"def":{"name":"apply_to","args":[{"name":"version","external_name":"version","restriction":""},{"name":"direction","default_value":":both","external_name":"direction","restriction":""}],"visibility":"Public","body":"ensure_ready\nlist_of_migrations = @migrations.sort do |a, b|\n a.uid <=> b.uid\nend\nversion = compute_version(version, list_of_migrations)\noperations = [] of ::Tuple(Int64, Migration::Direction)\nuid_to_apply = list_of_migrations.map(&.uid).reject(&.>(version)) - @migrations_up.to_a\nuid_to_apply.each do |uid|\n operations << {uid, Migration::Direction::Up}\nend\nuid_to_apply = list_of_migrations.map(&.uid).select(&.>(version)) & @migrations_up.to_a\nuid_to_apply.each do |uid|\n operations << {uid, Migration::Direction::Down}\nend\noperations.sort! do |a, b|\n if a[1].up?\n if b[1].down?\n 1\n else\n a[0] <=> b[0]\n end\n else\n if b[1].down?\n b[0] <=> a[0]\n else\n 0\n end\n end\nend\nif operations.empty?\n Log.info do\n \"Nothing to do.\"\n end\n return\nend\nLog.info do\n \"Migrations will be applied (in this order):\"\nend\noperations.each do |__temp_94|\n uid, d = __temp_94\n Log.info do\n \"#{d.up? ? \"[ UP ]\" : \"[DOWN]\"} #{uid} - #{(find(uid)).class.name}\"\n end\nend\noperations.each do |__temp_95|\n uid, d = __temp_95\n if (direction == (:both)) || (direction == (:up))\n d.up do\n up(uid)\n end\n end\n if (direction == (:both)) || (direction == (:down))\n d.down do\n down(uid)\n end\n end\nend\n"}},{"html_id":"commited?(m:Clear::Migration)-instance-method","name":"commited?","doc":"Return `true` if the migration has been commited (already applied into the database)\nor `false` otherwise","summary":"Return true
if the migration has been commited (already applied into the database) or false
otherwise
Force down a migration; throw error if the mgiration is already down
","abstract":false,"args":[{"name":"number","external_name":"number","restriction":"Int64"}],"args_string":"(number : Int64) : Nil","args_html":"(number : Int64) : Nil","location":{"filename":"src/clear/migration/manager.cr","line_number":232,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L232"},"def":{"name":"down","args":[{"name":"number","external_name":"number","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"m = find(number)\nif migrations_up.includes?(number)\nelse\n raise(migration_already_down(number))\nend\nm.apply(Clear::Migration::Direction::Down)\n@migrations_up.delete(m.uid)\n"}},{"html_id":"ensure_ready-instance-method","name":"ensure_ready","doc":"Create if needed the metadata table\nto save the migrations.","summary":"Create if needed the metadata table to save the migrations.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":165,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L165"},"def":{"name":"ensure_ready","visibility":"Public","body":"if @loaded\nelse\n Clear::SQL.execute(\" CREATE TABLE IF NOT EXISTS __clear_metadatas ( metatype text NOT NULL, value text NOT NULL );\")\n Clear::SQL.execute(\" CREATE UNIQUE INDEX IF NOT EXISTS __clear_metadatas_idx ON __clear_metadatas (metatype, value);\")\n load_existing_migrations\n ensure_unicity!\n @loaded = true\nend"}},{"html_id":"find(number)-instance-method","name":"find","doc":"Fetch the migration instance with the selected number","summary":"Fetch the migration instance with the selected number
","abstract":false,"args":[{"name":"number","external_name":"number","restriction":""}],"args_string":"(number)","args_html":"(number)","location":{"filename":"src/clear/migration/manager.cr","line_number":216,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L216"},"def":{"name":"find","args":[{"name":"number","external_name":"number","restriction":""}],"visibility":"Public","body":"number = Int64.new(number)\n@migrations.find() do |__arg6|\n __arg6.uid == number\nend || (raise(migration_not_found(number)))\n"}},{"html_id":"load_existing_migrations-instance-method","name":"load_existing_migrations","doc":"Fetch all the migrations already activated on the database.","summary":"Fetch all the migrations already activated on the database.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":203,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L203"},"def":{"name":"load_existing_migrations","visibility":"Public","body":"@migrations_up.clear\n((Clear::SQL.select(\"*\")).from(\"__clear_metadatas\")).where(metatype: \"migration\").map do |m|\n @migrations_up.add(Int64.new(m[\"value\"].as(String)))\nend\n"}},{"html_id":"max_version-instance-method","name":"max_version","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L54"},"def":{"name":"max_version","visibility":"Public","body":"if @migrations.size > 0\n @migrations.max_of(&.uid)\nelse\n nil\nend"}},{"html_id":"migrations_up-instance-method","name":"migrations_up","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L33"},"def":{"name":"migrations_up","visibility":"Public","body":"ensure_ready\n@migrations_up\n"}},{"html_id":"print_status:String-instance-method","name":"print_status","doc":"Print out the status ( up | down ) of all migrations found by the manager.","summary":"Print out the status ( up | down ) of all migrations found by the manager.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":242,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L242"},"def":{"name":"print_status","return_type":"String","visibility":"Public","body":"ensure_ready\n@migrations.sort do |a, b|\n (a.as(Clear::Migration)).uid <=> (b.as(Clear::Migration)).uid\nend.join(\"\\n\") do |m|\n active = @migrations_up.includes?(m.uid)\n \"[#{active ? \"✓\".colorize.green : \"✗\".colorize.red}] #{m.uid} - #{m.class.name}\"\nend\n"}},{"html_id":"refresh-instance-method","name":"refresh","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":211,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L211"},"def":{"name":"refresh","visibility":"Public","body":"load_existing_migrations"}},{"html_id":"reinit!-instance-method","name":"reinit!","doc":"Force reloading the migration system\nRecheck all the current up migrations\nand the metadata table.\nThis is useful if you access to the migration process\nthrough another program, or during specs","summary":"Force reloading the migration system Recheck all the current up migrations and the metadata table.
","abstract":false,"location":{"filename":"src/clear/migration/manager.cr","line_number":187,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L187"},"def":{"name":"reinit!","visibility":"Public","body":"@loaded = false\nensure_ready\nself\n"}},{"html_id":"up(number:Int64):Nil-instance-method","name":"up","doc":"Force up a migration; throw error if the migration is already up","summary":"Force up a migration; throw error if the migration is already up
","abstract":false,"args":[{"name":"number","external_name":"number","restriction":"Int64"}],"args_string":"(number : Int64) : Nil","args_html":"(number : Int64) : Nil","location":{"filename":"src/clear/migration/manager.cr","line_number":222,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/manager.cr#L222"},"def":{"name":"up","args":[{"name":"number","external_name":"number","restriction":"Int64"}],"return_type":"Nil","visibility":"Public","body":"m = find(number)\nif migrations_up.includes?(number)\n raise(migration_already_up(number))\nend\nm.apply\n@migrations_up.add(m.uid)\n"}}]},{"html_id":"clear/Clear/Migration/Operation","path":"Clear/Migration/Operation.html","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation","abstract":true,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/operation.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"subclasses":[{"html_id":"clear/Clear/Migration/AddColumn","kind":"class","full_name":"Clear::Migration::AddColumn","name":"AddColumn"},{"html_id":"clear/Clear/Migration/AddTable","kind":"class","full_name":"Clear::Migration::AddTable","name":"AddTable"},{"html_id":"clear/Clear/Migration/ChangeColumnType","kind":"class","full_name":"Clear::Migration::ChangeColumnType","name":"ChangeColumnType"},{"html_id":"clear/Clear/Migration/CreateEnum","kind":"class","full_name":"Clear::Migration::CreateEnum","name":"CreateEnum"},{"html_id":"clear/Clear/Migration/CreateIndex","kind":"class","full_name":"Clear::Migration::CreateIndex","name":"CreateIndex"},{"html_id":"clear/Clear/Migration/DropEnum","kind":"class","full_name":"Clear::Migration::DropEnum","name":"DropEnum"},{"html_id":"clear/Clear/Migration/DropTable","kind":"class","full_name":"Clear::Migration::DropTable","name":"DropTable"},{"html_id":"clear/Clear/Migration/Execute","kind":"class","full_name":"Clear::Migration::Execute","name":"Execute"},{"html_id":"clear/Clear/Migration/FullTextSearchableOperation","kind":"class","full_name":"Clear::Migration::FullTextSearchableOperation","name":"FullTextSearchableOperation"},{"html_id":"clear/Clear/Migration/RemoveColumn","kind":"class","full_name":"Clear::Migration::RemoveColumn","name":"RemoveColumn"},{"html_id":"clear/Clear/Migration/RenameColumn","kind":"class","full_name":"Clear::Migration::RenameColumn","name":"RenameColumn"},{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":true,"location":{"filename":"src/clear/migration/operation/operation.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L8"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":""}},{"html_id":"irreversible!(operation_name:String|Nil=nil)-instance-method","name":"irreversible!","abstract":false,"args":[{"name":"operation_name","default_value":"nil","external_name":"operation_name","restriction":"String | ::Nil"}],"args_string":"(operation_name : String | Nil = nil)","args_html":"(operation_name : String | Nil = nil)","location":{"filename":"src/clear/migration/operation/operation.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L10"},"def":{"name":"irreversible!","args":[{"name":"operation_name","default_value":"nil","external_name":"operation_name","restriction":"String | ::Nil"}],"visibility":"Public","body":"operation_name || (operation_name = self.class.name)\nmigration_name = migration ? migration.class.name : nil\nraise(IrreversibleMigration.new(migration_irreversible(migration_name, operation_name)))\n"}},{"html_id":"migration:Clear::Migration|Nil-instance-method","name":"migration","abstract":false,"location":{"filename":"src/clear/migration/operation/operation.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L5"},"def":{"name":"migration","return_type":"Clear::Migration | ::Nil","visibility":"Public","body":"@migration"}},{"html_id":"migration=(migration:Clear::Migration|Nil)-instance-method","name":"migration=","abstract":false,"args":[{"name":"migration","external_name":"migration","restriction":"Clear::Migration | ::Nil"}],"args_string":"(migration : Clear::Migration | Nil)","args_html":"(migration : Clear::Migration | Nil)","location":{"filename":"src/clear/migration/operation/operation.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L5"},"def":{"name":"migration=","args":[{"name":"migration","external_name":"migration","restriction":"Clear::Migration | ::Nil"}],"visibility":"Public","body":"@migration = migration"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":true,"location":{"filename":"src/clear/migration/operation/operation.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/operation.cr#L7"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":""}}]},{"html_id":"clear/Clear/Migration/RemoveColumn","path":"Clear/Migration/RemoveColumn.html","kind":"class","full_name":"Clear::Migration::RemoveColumn","name":"RemoveColumn","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/columns.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L39"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(table:String,column:String,datatype)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"column","external_name":"column","restriction":"::String"},{"name":"datatype","external_name":"datatype","restriction":""}],"args_string":"(table : String, column : String, datatype)","args_html":"(table : String, column : String, datatype)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L44"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"column","external_name":"column","restriction":"::String"},{"name":"datatype","external_name":"datatype","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, column, datatype)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L52"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} ADD #{@column} #{@datatype}\"]"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L48"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} DROP #{@column}\"]"}}]},{"html_id":"clear/Clear/Migration/RenameColumn","path":"Clear/Migration/RenameColumn.html","kind":"class","full_name":"Clear::Migration::RenameColumn","name":"RenameColumn","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/columns.cr","line_number":57,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L57"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"constructors":[{"html_id":"new(table:String,old_column_name:String,new_column_name:String)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"old_column_name","external_name":"old_column_name","restriction":"::String"},{"name":"new_column_name","external_name":"new_column_name","restriction":"::String"}],"args_string":"(table : String, old_column_name : String, new_column_name : String)","args_html":"(table : String, old_column_name : String, new_column_name : String)","location":{"filename":"src/clear/migration/operation/columns.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L62"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String"},{"name":"old_column_name","external_name":"old_column_name","restriction":"::String"},{"name":"new_column_name","external_name":"new_column_name","restriction":"::String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, old_column_name, new_column_name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":69,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L69"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} RENAME COLUMN #{@new_column_name} TO #{@old_column_name};\"]"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/columns.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/columns.cr#L65"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"[\"ALTER TABLE #{@table} RENAME COLUMN #{@old_column_name} TO #{@new_column_name};\"]"}}]},{"html_id":"clear/Clear/Migration/Table","path":"Clear/Migration/Table.html","kind":"class","full_name":"Clear::Migration::Table","name":"Table","abstract":false,"superclass":{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},"ancestors":[{"html_id":"clear/Clear/Migration/FullTextSearchableTableHelpers","kind":"module","full_name":"Clear::Migration::FullTextSearchableTableHelpers","name":"FullTextSearchableTableHelpers"},{"html_id":"clear/Clear/Migration/Operation","kind":"class","full_name":"Clear::Migration::Operation","name":"Operation"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/full_text_searchable.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/full_text_searchable.cr#L8"},{"filename":"src/clear/migration/operation/table.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Migration/FullTextSearchableTableHelpers","kind":"module","full_name":"Clear::Migration::FullTextSearchableTableHelpers","name":"FullTextSearchableTableHelpers"}],"namespace":{"html_id":"clear/Clear/Migration","kind":"module","full_name":"Clear::Migration","name":"Migration"},"doc":"Reopen Table to add the helpers","summary":"Reopen Table to add the helpers
","constructors":[{"html_id":"new(name:String,schema:String,is_create:Bool)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"},{"name":"is_create","external_name":"is_create","restriction":"::Bool"}],"args_string":"(name : String, schema : String, is_create : Bool)","args_html":"(name : String, schema : String, is_create : Bool)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L23"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"::String"},{"name":"schema","external_name":"schema","restriction":"::String"},{"name":"is_create","external_name":"is_create","restriction":"::Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(name, schema, is_create)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"add_column(column,type,default=nil,null=true,primary=false,index=false,unique=false,array=false)-instance-method","name":"add_column","doc":"Add/alter a column for this table.","summary":"Add/alter a column for this table.
","abstract":false,"args":[{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"args_string":"(column, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","args_html":"(column, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":52,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L52"},"def":{"name":"add_column","args":[{"name":"column","external_name":"column","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"visibility":"Public","body":"self.column_operations << ColumnOperation.new(column: column.to_s, type: type.to_s, default: default, null: null, primary: primary, array: array)\nif unique\n add_index(fields: [column.to_s], unique: true)\nelse\n if index\n if index.is_a?(Bool)\n add_index(fields: [column.to_s], unique: false)\n else\n add_index(fields: [column.to_s], unique: false, using: index)\n end\n end\nend\n"}},{"html_id":"add_fkey(fields:Array(String),table:String,foreign_fields:Array(String),on_delete:String,primary:Bool)-instance-method","name":"add_fkey","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"args_string":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","args_html":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":45,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L45"},"def":{"name":"add_fkey","args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"visibility":"Public","body":"self.fkey_operations << FkeyOperation.new(fields: fields, table: table, foreign_fields: foreign_fields, on_delete: on_delete, primary: primary)"}},{"html_id":"column(name,type,default=nil,null=true,primary=false,index=false,unique=false,array=false)-instance-method","name":"column","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"args_string":"(name, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","args_html":"(name, type, default = nil, null = true, primary = false, index = false, unique = false, array = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":167,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L167"},"def":{"name":"column","args":[{"name":"name","external_name":"name","restriction":""},{"name":"type","external_name":"type","restriction":""},{"name":"default","default_value":"nil","external_name":"default","restriction":""},{"name":"null","default_value":"true","external_name":"null","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"index","default_value":"false","external_name":"index","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""},{"name":"array","default_value":"false","external_name":"array","restriction":""}],"visibility":"Public","body":"type = case type.to_s\nwhen \"string\"\n \"text\"\nwhen \"int32\", \"integer\"\n \"integer\"\nwhen \"int64\", \"long\"\n \"bigint\"\nwhen \"bigdecimal\", \"numeric\"\n \"numeric\"\nwhen \"datetime\"\n \"timestamp without time zone\"\nelse\n type.to_s\nend\nadd_column(name.to_s, type: type, default: default, null: null, primary: primary, index: index, unique: unique, array: array)\n"}},{"html_id":"column_operations:Array(ColumnOperation)-instance-method","name":"column_operations","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L19"},"def":{"name":"column_operations","return_type":"Array(ColumnOperation)","visibility":"Public","body":"@column_operations"}},{"html_id":"down:Array(String)-instance-method","name":"down","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":113,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L113"},"def":{"name":"down","return_type":"Array(String)","visibility":"Public","body":"[(if is_create?\n [\"DROP TABLE\", full_name].join(\" \")\nend)].compact"}},{"html_id":"fkey_operations:Array(FkeyOperation)-instance-method","name":"fkey_operations","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L21"},"def":{"name":"fkey_operations","return_type":"Array(FkeyOperation)","visibility":"Public","body":"@fkey_operations"}},{"html_id":"full_name-instance-method","name":"full_name","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":68,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L68"},"def":{"name":"full_name","visibility":"Public","body":"{Clear::SQL.escape(@schema), Clear::SQL.escape(@name)}.join(\".\")"}},{"html_id":"index(field:String|Symbol,name=nil,using=nil,unique=false)-instance-method","name":"index","doc":"Add or replace an index for this table.\nAlias for `add_index`","summary":"Add or replace an index for this table.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"String | Symbol"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(field : String | Symbol, name = nil, using = nil, unique = false)","args_html":"(field : String | Symbol, name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":74,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L74"},"def":{"name":"index","args":[{"name":"field","external_name":"field","restriction":"String | Symbol"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_index(fields: [field.to_s], name: name, using: using, unique: unique)"}},{"html_id":"index(fields:Array,name=nil,using=nil,unique=false)-instance-method","name":"index","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"args_string":"(fields : Array, name = nil, using = nil, unique = false)","args_html":"(fields : Array, name = nil, using = nil, unique = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":78,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L78"},"def":{"name":"index","args":[{"name":"fields","external_name":"fields","restriction":"Array"},{"name":"name","default_value":"nil","external_name":"name","restriction":""},{"name":"using","default_value":"nil","external_name":"using","restriction":""},{"name":"unique","default_value":"false","external_name":"unique","restriction":""}],"visibility":"Public","body":"add_index(fields: fields.map(&.to_s), name: name, using: using, unique: unique)"}},{"html_id":"index_operations:Array(IndexOperation)-instance-method","name":"index_operations","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L20"},"def":{"name":"index_operations","return_type":"Array(IndexOperation)","visibility":"Public","body":"@index_operations"}},{"html_id":"is_create?:Bool-instance-method","name":"is_create?","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L17"},"def":{"name":"is_create?","return_type":"Bool","visibility":"Public","body":"@is_create"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L14"},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"references(to,name:String|Nil=nil,on_delete=\"restrict\",type=\"bigint\",null=false,foreign_key=\"id\",primary=false)-instance-method","name":"references","abstract":false,"args":[{"name":"to","external_name":"to","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":"String | ::Nil"},{"name":"on_delete","default_value":"\"restrict\"","external_name":"on_delete","restriction":""},{"name":"type","default_value":"\"bigint\"","external_name":"type","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""},{"name":"foreign_key","default_value":"\"id\"","external_name":"foreign_key","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""}],"args_string":"(to, name : String | Nil = nil, on_delete = \"restrict\", type = \"bigint\", null = false, foreign_key = \"id\", primary = false)","args_html":"(to, name : String | Nil = nil, on_delete = "restrict", type = "bigint", null = false, foreign_key = "id", primary = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L35"},"def":{"name":"references","args":[{"name":"to","external_name":"to","restriction":""},{"name":"name","default_value":"nil","external_name":"name","restriction":"String | ::Nil"},{"name":"on_delete","default_value":"\"restrict\"","external_name":"on_delete","restriction":""},{"name":"type","default_value":"\"bigint\"","external_name":"type","restriction":""},{"name":"null","default_value":"false","external_name":"null","restriction":""},{"name":"foreign_key","default_value":"\"id\"","external_name":"foreign_key","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""}],"visibility":"Public","body":"name || (name = to.singularize.underscore + \"_id\")\nadd_column(name, type, null: null, index: true)\nadd_fkey(fields: [name.to_s], table: to.to_s, foreign_fields: [foreign_key.to_s], on_delete: on_delete.to_s, primary: primary)\n"}},{"html_id":"schema:String-instance-method","name":"schema","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L15"},"def":{"name":"schema","return_type":"String","visibility":"Public","body":"@schema"}},{"html_id":"timestamps(null=false)-instance-method","name":"timestamps","doc":"Add the timestamps to the field.","summary":"Add the timestamps to the field.
","abstract":false,"args":[{"name":"null","default_value":"false","external_name":"null","restriction":""}],"args_string":"(null = false)","args_html":"(null = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L28"},"def":{"name":"timestamps","args":[{"name":"null","default_value":"false","external_name":"null","restriction":""}],"visibility":"Public","body":"add_column(:created_at, \"timestamp without time zone\", null: null, default: \"NOW()\")\nadd_column(:updated_at, \"timestamp without time zone\", null: null, default: \"NOW()\")\nadd_index([\"created_at\"])\nadd_index([\"updated_at\"])\n"}},{"html_id":"up:Array(String)-instance-method","name":"up","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":97,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L97"},"def":{"name":"up","return_type":"Array(String)","visibility":"Public","body":"columns_and_fkeys = print_columns + print_fkeys\nif columns_and_fkeys.empty?\nelse\n content = \"(#{columns_and_fkeys.join(\", \")})\"\nend\narr = if is_create?\n [[\"CREATE TABLE\", full_name, content].compact.join(\" \")]\nelse\n [] of String\nend\narr + print_indexes\n"}}],"macros":[{"html_id":"method_missing(caller)-macro","name":"method_missing","doc":"DEPRECATED\nMethod missing is used to generate add_column using the method name as\ncolumn type (ActiveRecord's style)","summary":"DEPRECATED Method missing is used to generate add_column using the method name as column type (ActiveRecord's style)
","abstract":false,"args":[{"name":"caller","external_name":"caller","restriction":""}],"args_string":"(caller)","args_html":"(caller)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":162,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L162"},"def":{"name":"method_missing","args":[{"name":"caller","external_name":"caller","restriction":""}],"visibility":"Public","body":" \n{% raise(\"Migration: usage of Table##{caller.name} is deprecated.\\n\" + \"Tip: use instead `self.column(NAME, \\\"#{caller.name}\\\", ...)`\") %}\n\n \n"}}],"types":[{"html_id":"clear/Clear/Migration/Table/ColumnOperation","path":"Clear/Migration/Table/ColumnOperation.html","kind":"struct","full_name":"Clear::Migration::Table::ColumnOperation","name":"ColumnOperation","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"},"constructors":[{"html_id":"new(column:String,type:String,null:Bool=false,default:SQL::Any=nil,primary:Bool=false,array:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"column","external_name":"column","restriction":"String"},{"name":"type","external_name":"type","restriction":"String"},{"name":"null","default_value":"false","external_name":"null","restriction":"Bool"},{"name":"default","default_value":"nil","external_name":"default","restriction":"SQL::Any"},{"name":"primary","default_value":"false","external_name":"primary","restriction":"Bool"},{"name":"array","default_value":"false","external_name":"array","restriction":"Bool"}],"args_string":"(column : String, type : String, null : Bool = false, default : SQL::Any = nil, primary : Bool = false, array : Bool = false)","args_html":"(column : String, type : String, null : Bool = false, default : SQL::Any = nil, primary : Bool = false, array : Bool = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"},"def":{"name":"new","args":[{"name":"column","external_name":"column","restriction":"String"},{"name":"type","external_name":"type","restriction":"String"},{"name":"null","default_value":"false","external_name":"null","restriction":"Bool"},{"name":"default","default_value":"nil","external_name":"default","restriction":"SQL::Any"},{"name":"primary","default_value":"false","external_name":"primary","restriction":"Bool"},{"name":"array","default_value":"false","external_name":"array","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(column, type, null, default, primary, array)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"array:Bool-instance-method","name":"array","abstract":false,"def":{"name":"array","return_type":"Bool","visibility":"Public","body":"@array"}},{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@column.clone, @type.clone, @null.clone, @default.clone, @primary.clone, @array.clone)"}},{"html_id":"column:String-instance-method","name":"column","abstract":false,"def":{"name":"column","return_type":"String","visibility":"Public","body":"@column"}},{"html_id":"copy_with(column_column=@column,type_type=@type,null_null=@null,default_default=@default,primary_primary=@primary,array_array=@array)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_column","default_value":"@column","external_name":"column","restriction":""},{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_null","default_value":"@null","external_name":"null","restriction":""},{"name":"_default","default_value":"@default","external_name":"default","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""},{"name":"_array","default_value":"@array","external_name":"array","restriction":""}],"args_string":"(column _column = @column, type _type = @type, null _null = @null, default _default = @default, primary _primary = @primary, array _array = @array)","args_html":"(column _column = @column, type _type = @type, null _null = @null, default _default = @default, primary _primary = @primary, array _array = @array)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L4"},"def":{"name":"copy_with","args":[{"name":"_column","default_value":"@column","external_name":"column","restriction":""},{"name":"_type","default_value":"@type","external_name":"type","restriction":""},{"name":"_null","default_value":"@null","external_name":"null","restriction":""},{"name":"_default","default_value":"@default","external_name":"default","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""},{"name":"_array","default_value":"@array","external_name":"array","restriction":""}],"visibility":"Public","body":"self.class.new(_column, _type, _null, _default, _primary, _array)"}},{"html_id":"default:SQL::Any-instance-method","name":"default","abstract":false,"def":{"name":"default","return_type":"SQL::Any","visibility":"Public","body":"@default"}},{"html_id":"null:Bool-instance-method","name":"null","abstract":false,"def":{"name":"null","return_type":"Bool","visibility":"Public","body":"@null"}},{"html_id":"primary:Bool-instance-method","name":"primary","abstract":false,"def":{"name":"primary","return_type":"Bool","visibility":"Public","body":"@primary"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"clear/Clear/Migration/Table/FkeyOperation","path":"Clear/Migration/Table/FkeyOperation.html","kind":"struct","full_name":"Clear::Migration::Table::FkeyOperation","name":"FkeyOperation","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"},"constructors":[{"html_id":"new(fields:Array(String),table:String,foreign_fields:Array(String),on_delete:String,primary:Bool)-class-method","name":"new","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"args_string":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","args_html":"(fields : Array(String), table : String, foreign_fields : Array(String), on_delete : String, primary : Bool)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"},"def":{"name":"new","args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"table","external_name":"table","restriction":"String"},{"name":"foreign_fields","external_name":"foreign_fields","restriction":"Array(String)"},{"name":"on_delete","external_name":"on_delete","restriction":"String"},{"name":"primary","external_name":"primary","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(fields, table, foreign_fields, on_delete, primary)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@fields.clone, @table.clone, @foreign_fields.clone, @on_delete.clone, @primary.clone)"}},{"html_id":"copy_with(fields_fields=@fields,table_table=@table,foreign_fields_foreign_fields=@foreign_fields,on_delete_on_delete=@on_delete,primary_primary=@primary)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_table","default_value":"@table","external_name":"table","restriction":""},{"name":"_foreign_fields","default_value":"@foreign_fields","external_name":"foreign_fields","restriction":""},{"name":"_on_delete","default_value":"@on_delete","external_name":"on_delete","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""}],"args_string":"(fields _fields = @fields, table _table = @table, foreign_fields _foreign_fields = @foreign_fields, on_delete _on_delete = @on_delete, primary _primary = @primary)","args_html":"(fields _fields = @fields, table _table = @table, foreign_fields _foreign_fields = @foreign_fields, on_delete _on_delete = @on_delete, primary _primary = @primary)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L11"},"def":{"name":"copy_with","args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_table","default_value":"@table","external_name":"table","restriction":""},{"name":"_foreign_fields","default_value":"@foreign_fields","external_name":"foreign_fields","restriction":""},{"name":"_on_delete","default_value":"@on_delete","external_name":"on_delete","restriction":""},{"name":"_primary","default_value":"@primary","external_name":"primary","restriction":""}],"visibility":"Public","body":"self.class.new(_fields, _table, _foreign_fields, _on_delete, _primary)"}},{"html_id":"fields:Array(String)-instance-method","name":"fields","abstract":false,"def":{"name":"fields","return_type":"Array(String)","visibility":"Public","body":"@fields"}},{"html_id":"foreign_fields:Array(String)-instance-method","name":"foreign_fields","abstract":false,"def":{"name":"foreign_fields","return_type":"Array(String)","visibility":"Public","body":"@foreign_fields"}},{"html_id":"on_delete:String-instance-method","name":"on_delete","abstract":false,"def":{"name":"on_delete","return_type":"String","visibility":"Public","body":"@on_delete"}},{"html_id":"primary:Bool-instance-method","name":"primary","abstract":false,"def":{"name":"primary","return_type":"Bool","visibility":"Public","body":"@primary"}},{"html_id":"table:String-instance-method","name":"table","abstract":false,"def":{"name":"table","return_type":"String","visibility":"Public","body":"@table"}}]},{"html_id":"clear/Clear/Migration/Table/IndexOperation","path":"Clear/Migration/Table/IndexOperation.html","kind":"struct","full_name":"Clear::Migration::Table::IndexOperation","name":"IndexOperation","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Migration/Table","kind":"class","full_name":"Clear::Migration::Table","name":"Table"},"constructors":[{"html_id":"new(fields:Array(String),name:String,using:String|Nil=nil,unique:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"name","external_name":"name","restriction":"String"},{"name":"using","default_value":"nil","external_name":"using","restriction":"String | ::Nil"},{"name":"unique","default_value":"false","external_name":"unique","restriction":"Bool"}],"args_string":"(fields : Array(String), name : String, using : String | Nil = nil, unique : Bool = false)","args_html":"(fields : Array(String), name : String, using : String | Nil = nil, unique : Bool = false)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"},"def":{"name":"new","args":[{"name":"fields","external_name":"fields","restriction":"Array(String)"},{"name":"name","external_name":"name","restriction":"String"},{"name":"using","default_value":"nil","external_name":"using","restriction":"String | ::Nil"},{"name":"unique","default_value":"false","external_name":"unique","restriction":"Bool"}],"visibility":"Public","body":"_ = allocate\n_.initialize(fields, name, using, unique)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@fields.clone, @name.clone, @using.clone, @unique.clone)"}},{"html_id":"copy_with(fields_fields=@fields,name_name=@name,using_using=@using,unique_unique=@unique)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_using","default_value":"@using","external_name":"using","restriction":""},{"name":"_unique","default_value":"@unique","external_name":"unique","restriction":""}],"args_string":"(fields _fields = @fields, name _name = @name, using _using = @using, unique _unique = @unique)","args_html":"(fields _fields = @fields, name _name = @name, using _using = @using, unique _unique = @unique)","location":{"filename":"src/clear/migration/operation/table.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/migration/operation/table.cr#L8"},"def":{"name":"copy_with","args":[{"name":"_fields","default_value":"@fields","external_name":"fields","restriction":""},{"name":"_name","default_value":"@name","external_name":"name","restriction":""},{"name":"_using","default_value":"@using","external_name":"using","restriction":""},{"name":"_unique","default_value":"@unique","external_name":"unique","restriction":""}],"visibility":"Public","body":"self.class.new(_fields, _name, _using, _unique)"}},{"html_id":"fields:Array(String)-instance-method","name":"fields","abstract":false,"def":{"name":"fields","return_type":"Array(String)","visibility":"Public","body":"@fields"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"unique:Bool-instance-method","name":"unique","abstract":false,"def":{"name":"unique","return_type":"Bool","visibility":"Public","body":"@unique"}},{"html_id":"using:String|Nil-instance-method","name":"using","abstract":false,"def":{"name":"using","return_type":"String | ::Nil","visibility":"Public","body":"@using"}}]}]}]},{"html_id":"clear/Clear/Model","path":"Clear/Model.html","kind":"module","full_name":"Clear::Model","name":"Model","abstract":false,"ancestors":[{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Validation/Helper","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/full_text_searchable.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/full_text_searchable.cr#L3"},{"filename":"src/clear/model/collection.cr","line_number":158,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L158"},{"filename":"src/clear/model/errors.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L1"},{"filename":"src/clear/model/model.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L9"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"}],"including_types":[{"html_id":"clear/Clear/Reflection/Column","kind":"class","full_name":"Clear::Reflection::Column","name":"Column"},{"html_id":"clear/Clear/Reflection/Table","kind":"class","full_name":"Clear::Reflection::Table","name":"Table"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"Model definition is made by adding the `Clear::Model` mixin in your class.\n## Simple Model\n\n```\nclass MyModel\n include Clear::Model\n\n column my_column : String\nend\n```\n\nWe just created a new model, linked to your database, mapping the column `my_column` of type String (`text` in postgres).\n\nNow, you can play with your model:\n\n```\nrow = MyModel.new # create an empty row\nrow.my_column = \"This is a content\"\nrow.save! # insert the new row in the database !\n```\n\nBy convention, the table name will follow an underscore, plural version of your model: `my_models`.\nA model into a module will prepend the module name before, so `Logistic::MyModel` will check for `logistic_my_models` in your database.\nYou can force a specific table name using:\n\n```\nclass MyModel\n include Clear::Model\n self.table = \"another_table_name\"\nend\n```\n\n## Presence validation\n\nUnlike many ORM around, Clear carry about non-nullable pattern in crystal. Meaning `column my_column : String` assume than a call to `row.my_column` will return a String.\n\nBut it exists cases where the column is not yet initialized:\n- When the object is built with constructor without providing the value (See above).\n- When an object is semi-fetched through the database query. This is useful to ignore some large fields non-interesting in the body of the current operation.\n\nFor example, this code will compile:\n\n```\nrow = MyModel.new # create an empty row\nputs row.my_column\n```\n\nHowever, it will throw a runtime exception `You cannot access to the field 'my_column' because it never has been initialized`\n\nSame way, trying to save the object will raise an error:\n\n```\nrow.save # Will return false\npp row.errors # Will tell you than `my_column` presence is mandatory.\n```\n\nThanks to expressiveness of the Crystal language, we can handle presence validation by simply using the `Nilable` type in crystal:\n\n```\nclass MyModel\n include Clear::Model\n\n column my_column : String? # Now, the column can be NULL or text in postgres.\nend\n```\n\nThis time, the code above will works; in case of no value, my_column will be `nil` by default.\n\n## Querying your code\n\nWhenever you want to fetch data from your database, you must create a new collection query:\n\n`MyModel.query #Will setup a vanilla 'SELECT * FROM my_models'`\n\nQueries are fetchable using `each`:\n\n```\nMyModel.query.each do |model|\n # Do something with your model here.\nend\n```\n\n## Refining your query\n\nA collection query offers a lot of functionalities. You can read the [API](https://anykeyh.github.io/clear/Clear/Model/CollectionBase.html) for more informations.\n\n## Column type\n\nBy default, Clear map theses columns types:\n\n- `String` => `text`\n- `Numbers` (any from 8 to 64 bits, float, double, big number, big float) => `int, large int etc... (depends of your choice)`\n- `Bool` => `text or bool`\n- `Time` => `timestamp without timezone or text`\n- `JSON::Any` => `json and jsonb`\n- `Nilable` => `NULL` (treated as special !)\n\n_NOTE_: The `crystal-pg` gems map also some structures like GIS coordinates, but their implementation is not tested in Clear. Use them at your own risk. Tell me if it's working 😉\n\nIf you need to map special structure, see [Mapping Your Data](Mapping) guides for more informations.\n\n## Primary key\n\nPrimary key is essential for relational mapping. Currently Clear support only one column primary key.\n\nA model without primary key can work in sort of degraded mode, throwing error in case of using some methods on them:\n- `collection#first` will be throwing error if no `order_by` has been setup\n\nTo setup a primary key, you can add the modifier `primary: true` to the column:\n\n```\nclass MyModel\n include Clear::Model\n\n column id : Int32, primary: true, presence: false\n column my_column : String?\nend\n```\n\nNote the flag `presence: false` added to the column. This tells Clear than presence checking on save is not mandatory. Usually this happens if you setup a default value in postgres. In the case of our primary key `id`, we use a serial auto-increment default value.\nTherefore, saving the model without primary key will works. The id will be fetched after insertion:\n\n```\nm = MyModel\nm.save!\nm.id # Now the id value is setup.\n```\n\n## Helpers\n\nClear provides various built-in helpers to facilitate your life:\n\n### Timestamps\n\n```\nclass MyModel\n include Clear::Model\n timestamps # Will map the two columns 'created_at' and 'updated_at', and map some hooks to update their values.\nend\n```\n\nTheses fields are automatically updated whenever you call `save` methods, and works as Rails ActiveRecord.\n\n### With Serial Pkey\n\n```\nclass MyModel\n include Clear::Model\n primary_key \"my_primary_key\"\nend\n```\n\nBasically rewrite `column id : UInt64, primary: true, presence: false`\n\nArgument is optional (default = id)","summary":"Model definition is made by adding the Clear::Model
mixin in your class.
Alias method for primary key.
","abstract":false,"location":{"filename":"src/clear/model/model.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L33"},"def":{"name":"__pkey__","visibility":"Public","body":"raise(lack_of_primary_key(self.class.name))"}},{"html_id":"cache:Clear::Model::QueryCache|Nil-instance-method","name":"cache","abstract":false,"location":{"filename":"src/clear/model/model.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L25"},"def":{"name":"cache","return_type":"Clear::Model::QueryCache | ::Nil","visibility":"Public","body":"@cache"}}],"macros":[{"html_id":"scope(name,&block)-macro","name":"scope","doc":"A scope allow you to filter in a very human way a set of data.\n\nUsage:\n\n```\nscope(\"admin\") { where({role: \"admin\"}) }\n```\n\nfor example, instead of writing:\n\n```\nUser.query.where { (role == \"admin\") & (active == true) }\n```\n\nYou can write:\n\n```\nUser.admin.active\n```\n\nScope can be used for other purpose than just filter (e.g. ordering),\nbut I would not recommend it.","summary":"A scope allow you to filter in a very human way a set of data.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""}],"args_string":"(name, &block)","args_html":"(name, &block)","location":{"filename":"src/clear/model/model.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/model.cr#L19"},"def":{"name":"scope","args":[{"name":"name","external_name":"name","restriction":""}],"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" \n{% parameters = \"\" %}\n\n \n{% for arg, idx in block.args %}\n {% if (block.splat_index && (idx == block.splat_index))\n parameters = parameters + \"*\"\nend %}\n {% parameters = parameters + \"#{arg}\" %}\n {% unless (idx == (block.args.size - 1))\n parameters = parameters + \", \"\nend %}\n {% end %}\n\n \n{% parameters = parameters.id %}\n\n\n def self.\n{{ name.id }}\n(\n{{ parameters }}\n)\n query.\n{{ name.id }}\n(\n{{ parameters }}\n)\n \nend\n\n class Collection < Clear::Model::CollectionBase(\n{{ @type }}\n);\n def \n{{ name.id }}\n(\n{{ parameters }}\n)\n \n{{ yield }}\n\n\n return self\n \nend\n \nend\n \n"}}],"types":[{"html_id":"clear/Clear/Model/ClassMethods","path":"Clear/Model/ClassMethods.html","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/clear/model/modules/class_methods.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/class_methods.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}},{"html_id":"clear/Clear/Model/CollectionBase","path":"Clear/Model/CollectionBase.html","kind":"class","full_name":"Clear::Model::CollectionBase(T)","name":"CollectionBase","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/collection.cr","line_number":168,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L168"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"}],"subclasses":[{"html_id":"clear/Clear/Reflection/Column/Collection","kind":"class","full_name":"Clear::Reflection::Column::Collection","name":"Collection"},{"html_id":"clear/Clear/Reflection/Table/Collection","kind":"class","full_name":"Clear::Reflection::Table::Collection","name":"Collection"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"`CollectionBase(T)` is the base class for collection of model.\nCollection of model are a SQL `SELECT` query mapping & building system. They are Enumerable and are\n`Clear::SQL::SelectBuilder` behavior; therefore, they can be used array-like and are working with low-level SQL\nBuilding.\n\nThe `CollectionBase(T)` is extended by each model. For example, generating the model `MyModel` will generate the\nclass `MyModel::Collection` which inherits from `CollectionBase(MyModel)`\n\nCollection are instantiated using `Model.query` method.","summary":"CollectionBase(T)
is the base class for collection of model.
Add an item to the current collection.
","abstract":false,"args":[{"name":"item","external_name":"item","restriction":"T"}],"args_string":"(item : T)","args_html":"(item : T)","location":{"filename":"src/clear/model/collection.cr","line_number":494,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L494"},"def":{"name":"<<","args":[{"name":"item","external_name":"item","restriction":"T"}],"visibility":"Public","body":"append_operation = self.append_operation\nif append_operation\nelse\n raise(\"Operation not permitted on this collection.\")\nend\nappend_operation.call(item)\n@cached_result.try(&.<<(item))\nself\n"}},{"html_id":"[](range:Range(Number,Number),fetch_columns=false):Array(T)-instance-method","name":"[]","doc":"Get a range of models","summary":"Get a range of models
","abstract":false,"args":[{"name":"range","external_name":"range","restriction":"Range(Number, Number)"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(range : Range(Number, Number), fetch_columns = false) : Array(T)","args_html":"(range : Range(Number, Number), fetch_columns = false) : Array(T)","location":{"filename":"src/clear/model/collection.cr","line_number":550,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L550"},"def":{"name":"[]","args":[{"name":"range","external_name":"range","restriction":"Range(Number, Number)"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"Array(T)","visibility":"Public","body":"((offset(range.begin)).limit(range.end - range.begin)).to_a(fetch_columns)"}},{"html_id":"[](off,fetch_columns=false):T-instance-method","name":"[]","doc":"Basically a fancy way to write `OFFSET x LIMIT 1`","summary":"Basically a fancy way to write OFFSET x LIMIT 1
Basically a fancy way to write OFFSET x LIMIT 1
Alias for Collection#<<
Check whether the query return any row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":464,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L464"},"def":{"name":"any?","visibility":"Public","body":"cr = @cached_result\nif cr\n return !cr.empty?\nend\n((clear_select.select(\"1\")).limit(1)).fetch do |_|\n return true\nend\nfalse\n"}},{"html_id":"build(x:NamedTuple,&block:T->Nil):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":405,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L405"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"build(**x, &block)"}},{"html_id":"build(**tuple,&:T->Nil):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":383,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L383"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"str_hash = @tags.dup\ntuple.map do |k, v|\n str_hash[k.to_s] = v\nend\nr = Clear::Model::Factory.build(T, str_hash, persisted: false)\nyield(r)\nr\n"}},{"html_id":"build(x:NamedTuple):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":400,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L400"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"build(**x) do\nend"}},{"html_id":"build(**tuple):T-instance-method","name":"build","doc":"Build a new collection; if the collection comes from a has_many relation\n(e.g. `my_model.associations.build`), the foreign column which store\nthe primary key of `my_model` will be setup by default, preventing you\nto forget it.\nYou can pass extra parameters using a named tuple:\n`my_model.associations.build({a_column: \"value\"}) `","summary":"Build a new collection; if the collection comes from a has_many relation (e.g.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":395,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L395"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"build(**tuple) do\nend"}},{"html_id":"count(type:X.class=Int64)forallX-instance-method","name":"count","doc":"Use SQL `COUNT` over your query, and return this number as a Int64","summary":"Use SQL COUNT
over your query, and return this number as a Int64
Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":431,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L431"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create(**tuple,&:T->Nil):T-instance-method","name":"create","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":412,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L412"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save\nr\n"}},{"html_id":"create(x:NamedTuple):T-instance-method","name":"create","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":426,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L426"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"create(**x)"}},{"html_id":"create(**tuple):T-instance-method","name":"create","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":421,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L421"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"create(**tuple) do\nend"}},{"html_id":"create!(x:NamedTuple,&block:T->Nil):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":459,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L459"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create!(**tuple,&:T->Nil):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":440,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L440"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"create!(x:NamedTuple):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":454,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L454"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"create(**x)"}},{"html_id":"create!(**tuple):T-instance-method","name":"create!","doc":"Build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.\nBut instead of returning self if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Build a new object and setup the fields like setup in the condition tuple.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":449,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L449"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"create!(**tuple) do\nend"}},{"html_id":"delete_all:self-instance-method","name":"delete_all","doc":"Delete all the rows which would have been returned by this collection.\nIs equivalent to `collection.to_delete.execute`","summary":"Delete all the rows which would have been returned by this collection.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":704,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L704"},"def":{"name":"delete_all","return_type":"self","visibility":"Public","body":"to_delete.execute\nchange!\n"}},{"html_id":"dup-instance-method","name":"dup","doc":"Duplicate the query","summary":"Duplicate the query
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":220,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L220"},"def":{"name":"dup","visibility":"Public","body":"if (@polymorphic && (polymorphic_key = @polymorphic_key)) && (polymorphic_scope = @polymorphic_scope)\n super().flag_as_polymorphic!(polymorphic_key, polymorphic_scope)\nelse\n super()\nend"}},{"html_id":"each(fetch_columns=false,&:T->):Nil-instance-method","name":"each","doc":"Build the SQL, send the query then iterate through each models\ngathered by the request.","summary":"Build the SQL, send the query then iterate through each models gathered by the request.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, & : T -> ) : Nil","args_html":"(fetch_columns = false, & : T -> ) : Nil","location":{"filename":"src/clear/model/collection.cr","line_number":322,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L322"},"def":{"name":"each","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T ->)"},"return_type":"Nil","visibility":"Public","body":"result = @cached_result\nif result\nelse\n result = [] of T\n if @polymorphic\n fetch(fetch_all: false) do |hash|\n type = hash[@polymorphic_key].as(String)\n result << ((Clear::Model::Factory.build(type, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache)).as(T))\n end\n else\n fetch(fetch_all: false) do |hash|\n result << (Clear::Model::Factory.build(T, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache))\n end\n end\nend\nresult.each do |value|\n yield value\nend\n"}},{"html_id":"each_with_cursor(batch=1000,fetch_columns=false,&block:T->)-instance-method","name":"each_with_cursor","doc":"Build the SQL, send the query then iterate through each models\ngathered by the request.\nUse a postgres cursor to avoid memory bloating.\nUseful to fetch millions of rows at once.","summary":"Build the SQL, send the query then iterate through each models gathered by the request.
","abstract":false,"args":[{"name":"batch","default_value":"1000","external_name":"batch","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(batch = 1000, fetch_columns = false, &block : T -> )","args_html":"(batch = 1000, fetch_columns = false, &block : T -> )","location":{"filename":"src/clear/model/collection.cr","line_number":358,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L358"},"def":{"name":"each_with_cursor","args":[{"name":"batch","default_value":"1000","external_name":"batch","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T ->)"},"visibility":"Public","body":"cr = @cached_result\nif cr\n cr.each(&block)\nelse\n if @polymorphic\n fetch_with_cursor(count: batch) do |hash|\n type = hash[@polymorphic_key].as(String)\n yield((Clear::Model::Factory.build(type, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache)).as(T))\n end\n else\n fetch_with_cursor(count: batch) do |hash|\n yield(Clear::Model::Factory.build(T, hash, persisted: true, fetch_columns: fetch_columns, cache: @cache))\n end\n end\nend\n"}},{"html_id":"empty?-instance-method","name":"empty?","doc":"Inverse of `any?`, return true if the request return no rows.","summary":"Inverse of #any?
, return true if the request return no rows.
A convenient way to write where { condition }.first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first
A convenient way to write where { condition }.first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!(fetch_columns)
A convenient way to write where({any_column: "any_value"}).first!
Try to fetch a row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":590,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L590"},"def":{"name":"find_or_build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"if tuple.size == 0\nelse\n where(tuple)\nend\nr = first\nif r\n return r\nend\nstr_hash = @tags.dup\ntuple.map do |k, v|\n str_hash[k.to_s] = v\nend\nr = Clear::Model::Factory.build(T, str_hash)\nyield(r)\nr\n"}},{"html_id":"find_or_build(x:NamedTuple):T-instance-method","name":"find_or_build","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":610,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L610"},"def":{"name":"find_or_build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"find_or_build(**x)"}},{"html_id":"find_or_build(**tuple):T-instance-method","name":"find_or_build","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":605,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L605"},"def":{"name":"find_or_build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"find_or_build(**tuple) do\nend"}},{"html_id":"find_or_create(x:NamedTuple,&block:T->Nil):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : T -> Nil) : T","args_html":"(x : NamedTuple, &block : T -> Nil) : T","location":{"filename":"src/clear/model/collection.cr","line_number":641,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L641"},"def":{"name":"find_or_create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"find_or_create(**x, &block)"}},{"html_id":"find_or_create(**tuple,&:T->Nil):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":622,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L622"},"def":{"name":"find_or_create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(T -> Nil)"},"return_type":"T","visibility":"Public","body":"r = find_or_build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"find_or_create(x:NamedTuple):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : T","args_html":"(x : NamedTuple) : T","location":{"filename":"src/clear/model/collection.cr","line_number":636,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L636"},"def":{"name":"find_or_create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"T","visibility":"Public","body":"find_or_create(**x)"}},{"html_id":"find_or_create(**tuple):T-instance-method","name":"find_or_create","doc":"Try to fetch a row. If not found, build a new object and setup\nthe fields like setup in the condition tuple.\nJust after building, save the object.","summary":"Try to fetch a row.
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":631,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L631"},"def":{"name":"find_or_create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"T","visibility":"Public","body":"find_or_create(**tuple) do\nend"}},{"html_id":"first(fetch_columns=false):T|Nil-instance-method","name":"first","doc":"Get the first row from the collection query.\nif not found, return `nil`","summary":"Get the first row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T | Nil","args_html":"(fetch_columns = false) : T | Nil","location":{"filename":"src/clear/model/collection.cr","line_number":647,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L647"},"def":{"name":"first","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T | ::Nil","visibility":"Public","body":"if T.__pkey__ || order_bys.empty?\n order_by(Clear::SQL.escape(\"#{T.__pkey__}\"), :asc)\nend\n(limit(1)).fetch do |hash|\n return Clear::Model::Factory.build(T, hash, persisted: true, cache: @cache, fetch_columns: fetch_columns)\nend\nnil\n"}},{"html_id":"first!(fetch_columns=false):T-instance-method","name":"first!","doc":"Get the first row from the collection query.\nif not found, throw an error","summary":"Get the first row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T","args_html":"(fetch_columns = false) : T","location":{"filename":"src/clear/model/collection.cr","line_number":659,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L659"},"def":{"name":"first!","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T","visibility":"Public","body":"(first(fetch_columns)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"item_class-instance-method","name":"item_class","doc":"Return the model class for this collection","summary":"Return the model class for this collection
","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":235,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L235"},"def":{"name":"item_class","visibility":"Public","body":"T"}},{"html_id":"last(fetch_columns=false):T|Nil-instance-method","name":"last","doc":"Get the last row from the collection query.\nif not found, return `nil`","summary":"Get the last row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T | Nil","args_html":"(fetch_columns = false) : T | Nil","location":{"filename":"src/clear/model/collection.cr","line_number":665,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L665"},"def":{"name":"last","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T | ::Nil","visibility":"Public","body":"if T.__pkey__ || order_bys.empty?\n order_by(\"#{T.__pkey__}\", :asc)\nend\narr = order_bys.dup\nbegin\n new_order = arr.map do |x|\n Clear::SQL::Query::OrderBy::Record.new(x.op, (x.dir == (:asc) ? :desc : :asc), nil)\n end\n clear_order_bys.order_by(new_order)\n (limit(1)).fetch do |hash|\n return Clear::Model::Factory.build(T, hash, persisted: true, cache: @cache, fetch_columns: fetch_columns)\n end\n nil\nensure\n clear_order_bys.order_by(order_bys)\nend\n"}},{"html_id":"last!(fetch_columns=false):T-instance-method","name":"last!","doc":"Get the last row from the collection query.\nif not found, throw an error","summary":"Get the last row from the collection query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : T","args_html":"(fetch_columns = false) : T","location":{"filename":"src/clear/model/collection.cr","line_number":690,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L690"},"def":{"name":"last!","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T","visibility":"Public","body":"(last(fetch_columns)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"map(fetch_columns=false,&block:T->X):Array(X)forallX-instance-method","name":"map","doc":"Build the SQL, send the query then build and array by applying the\nblock transformation over it.","summary":"Build the SQL, send the query then build and array by applying the block transformation over it.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, &block : T -> X) : Array(X) forall X","args_html":"(fetch_columns = false, &block : T -> X) : Array(X) forall X","location":{"filename":"src/clear/model/collection.cr","line_number":347,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L347"},"def":{"name":"map","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(T -> X)"},"return_type":"Array(X)","visibility":"Public","body":"o = [] of X\neach(fetch_columns) do |mdl|\n o << (block.call(mdl))\nend\no\n"}},{"html_id":"tags-instance-method","name":"tags","abstract":false,"location":{"filename":"src/clear/model/collection.cr","line_number":292,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L292"},"def":{"name":"tags","visibility":"Public","body":"@tags"}},{"html_id":"to_a(fetch_columns=false):Array(T)-instance-method","name":"to_a","doc":"Create an array from the query.","summary":"Create an array from the query.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : Array(T)","args_html":"(fetch_columns = false) : Array(T)","location":{"filename":"src/clear/model/collection.cr","line_number":528,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/collection.cr#L528"},"def":{"name":"to_a","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"Array(T)","visibility":"Public","body":"cr = @cached_result\nif cr\n return cr\nend\no = [] of T\neach(fetch_columns: fetch_columns) do |m|\n o << m\nend\no\n"}},{"html_id":"unlink(item:T)-instance-method","name":"unlink","doc":"Unlink the model currently referenced through a relation `has_many through`\n\nIf the current colleciton doesn't come from a `has_many through` relation,\nthis method will throw `Clear::SQL::OperationNotPermittedError`\n\nReturns `true` if unlinking is successful (e.g. one or more rows have been updated), or `false` otherwise","summary":"Unlink the model currently referenced through a relation has_many through
A column of a Model Provide some methods like: - Informations persistance (value before, value changed?) - Raise error if we try to access the value of a field which is not gathered through the query system (uninitialized column).
","constructors":[{"html_id":"new(name:String,value:T|UnknownClass=UNKNOWN,has_db_default:Bool=false)-class-method","name":"new","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"value","default_value":"UNKNOWN","external_name":"value","restriction":"T | UnknownClass"},{"name":"has_db_default","default_value":"false","external_name":"has_db_default","restriction":"::Bool"}],"args_string":"(name : String, value : T | UnknownClass = UNKNOWN, has_db_default : Bool = false)","args_html":"(name : String, value : T | UnknownClass = UNKNOWN, has_db_default : Bool = false)","location":{"filename":"src/clear/model/column.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L24"},"def":{"name":"new","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"value","default_value":"UNKNOWN","external_name":"value","restriction":"T | UnknownClass"},{"name":"has_db_default","default_value":"false","external_name":"has_db_default","restriction":"::Bool"}],"visibility":"Public","body":"_ = Column(T, C).allocate\n_.initialize(name, value, has_db_default)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"changed?:Bool-instance-method","name":"changed?","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L21"},"def":{"name":"changed?","return_type":"Bool","visibility":"Public","body":"@changed"}},{"html_id":"clear-instance-method","name":"clear","doc":"Completely clear the column, remove both `value` and `old_value` and turning the column in a non-defined state.","summary":"Completely clear the column, remove both #value
and #old_value
and turning the column in a non-defined state.
Reset #changed?
flag to false
.
Check whether the column is defined or not.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":128,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L128"},"def":{"name":"defined?","visibility":"Public","body":"UNKNOWN != @value"}},{"html_id":"dirty!-instance-method","name":"dirty!","doc":"Reset `changed?` flag to `true`. See `Column(T)#clear_change_flag` for the counter part.","summary":"Reset #changed?
flag to true
.
Inspect this column.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":114,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L114"},"def":{"name":"inspect","visibility":"Public","body":"if defined?\n @value.inspect + (changed? ? \"*\" : \"\")\nelse\n \"#undef\"\nend"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L20"},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"nilable?-instance-method","name":"nilable?","doc":"Return `true` if the value is an union of a Type with Nilable, `false` otherwise.","summary":"Return true
if the value is an union of a Type with Nilable, false
otherwise.
Reset the current field.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"args_string":"(x : T | Nil)","args_html":"(x : T | Nil)","location":{"filename":"src/clear/model/column.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L79"},"def":{"name":"reset","args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"visibility":"Public","body":"{% if T.nilable? %}\n @value = x.as(T)\n {% else %}\n raise null_column_mapping_error(@name, T) if x.nil?\n @value = x.not_nil!\n {% end %}\n@changed = false\n@old_value = @value\n"}},{"html_id":"reset_convert(x)-instance-method","name":"reset_convert","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/column.cr","line_number":55,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L55"},"def":{"name":"reset_convert","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"reset(C.to_column(x))"}},{"html_id":"revert-instance-method","name":"revert","doc":"If the column is dirty (e.g the value has been changed), return to the previous state.","summary":"If the column is dirty (e.g the value has been changed), return to the previous state.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":46,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L46"},"def":{"name":"revert","visibility":"Public","body":"if (@value != @old_value) && (@old_value != UNKNOWN)\n @changed = true\n @value = @old_value\nend\n@value\n"}},{"html_id":"set(x:T|Nil)-instance-method","name":"set","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"args_string":"(x : T | Nil)","args_html":"(x : T | Nil)","location":{"filename":"src/clear/model/column.cr","line_number":63,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L63"},"def":{"name":"set","args":[{"name":"x","external_name":"x","restriction":"T | ::Nil"}],"visibility":"Public","body":"old_value = @value\n{% if T.nilable? %}\n @value = x.as(T)\n {% else %}\n raise null_column_mapping_error(@name, T) if x.nil?\n @value = x.not_nil!\n {% end %}\n@old_value = old_value\n@changed = true\n"}},{"html_id":"set_convert(x)-instance-method","name":"set_convert","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/column.cr","line_number":59,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L59"},"def":{"name":"set_convert","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"set(C.to_column(x))"}},{"html_id":"to_sql_value(default=nil):Clear::SQL::Any-instance-method","name":"to_sql_value","doc":"Return the database converted value using the converter","summary":"Return the database converted value using the converter
","abstract":false,"args":[{"name":"default","default_value":"nil","external_name":"default","restriction":""}],"args_string":"(default = nil) : Clear::SQL::Any","args_html":"(default = nil) : Clear::SQL::Any","location":{"filename":"src/clear/model/column.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L36"},"def":{"name":"to_sql_value","args":[{"name":"default","default_value":"nil","external_name":"default","restriction":""}],"return_type":"Clear::SQL::Any","visibility":"Public","body":"C.to_db(value(default))"}},{"html_id":"value(default:X):T|XforallX-instance-method","name":"value","doc":"Returns the current value of this column or `default` if the value is undefined.","summary":"Returns the current value of this column or default
if the value is undefined.
Returns the current value of this column.
","abstract":false,"location":{"filename":"src/clear/model/column.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/column.cr#L30"},"def":{"name":"value","return_type":"T","visibility":"Public","body":"if defined?\nelse\n raise(illegal_setter_access_to_undefined_column(@name))\nend\n@value.as(T)\n"}},{"html_id":"value=(x:T)-instance-method","name":"value=","doc":"Set the value of the column to the value `x`. If `x` is not equal to the old value, then the column `changed?`\nflag is set to `true`.","summary":"Set the value of the column to the value x
.
Convert from and to BigDecimal
","class_methods":[{"html_id":"to_column(x):BigDecimal|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : BigDecimal | Nil","args_html":"(x) : BigDecimal | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L43"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"BigDecimal | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n BigDecimal.new(x)\nelse\n BigDecimal.new(x.to_s)\nend"}},{"html_id":"to_db(x:BigDecimal|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"BigDecimal | ::Nil"}],"args_string":"(x : BigDecimal | Nil)","args_html":"(x : BigDecimal | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L43"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"BigDecimal | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/BigFloatConverter","path":"Clear/Model/Converter/BigFloatConverter.html","kind":"class","full_name":"Clear::Model::Converter::BigFloatConverter","name":"BigFloatConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L42"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to BigFloat","summary":"Convert from and to BigFloat
","class_methods":[{"html_id":"to_column(x):BigFloat|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : BigFloat | Nil","args_html":"(x) : BigFloat | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L42"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"BigFloat | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n BigFloat.new(x)\nelse\n BigFloat.new(x.to_s)\nend"}},{"html_id":"to_db(x:BigFloat|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"BigFloat | ::Nil"}],"args_string":"(x : BigFloat | Nil)","args_html":"(x : BigFloat | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L42"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"BigFloat | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/BigIntConverter","path":"Clear/Model/Converter/BigIntConverter.html","kind":"class","full_name":"Clear::Model::Converter::BigIntConverter","name":"BigIntConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L41"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to BigInt","summary":"Convert from and to BigInt
","class_methods":[{"html_id":"to_column(x):BigInt|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : BigInt | Nil","args_html":"(x) : BigInt | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L41"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"BigInt | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n BigInt.new(x)\nelse\n BigInt.new(x.to_s)\nend"}},{"html_id":"to_db(x:BigInt|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"BigInt | ::Nil"}],"args_string":"(x : BigInt | Nil)","args_html":"(x : BigInt | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":41,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L41"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"BigInt | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/BoolConverter","path":"Clear/Model/Converter/BoolConverter.html","kind":"module","full_name":"Clear::Model::Converter::BoolConverter","name":"BoolConverter","abstract":false,"locations":[{"filename":"src/clear/model/converters/bool_converter.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/bool_converter.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert the column to a boolean\nIf value is not boolean (e.g. string or number), rules of `falsey`\nvalue is used:\n\nfalsey's values are:\n`false`, `nil`, `0`, `\"0\"`, `\"\"` (empty string), `\"false\"`, `\"f\"`\n\nAnything else is considered `true`","summary":"Convert the column to a boolean If value is not boolean (e.g.
","class_methods":[{"html_id":"to_column(x):Bool|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Bool | Nil","args_html":"(x) : Bool | Nil","location":{"filename":"src/clear/model/converters/bool_converter.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/bool_converter.cr#L12"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Bool | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Bool\n x\nwhen Number\n x != 0\nwhen String\n x = x.downcase\n (((x != \"f\") && (x != \"false\")) && (x != \"\")) && (x != \"0\")\nelse\n true\nend"}},{"html_id":"to_db(x:Bool|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Bool | ::Nil"}],"args_string":"(x : Bool | Nil)","args_html":"(x : Bool | Nil)","location":{"filename":"src/clear/model/converters/bool_converter.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/bool_converter.cr#L28"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Bool | ::Nil"}],"visibility":"Public","body":"x.nil? ? nil : (x ? \"t\" : \"f\")"}}]},{"html_id":"clear/Clear/Model/Converter/Float32Converter","path":"Clear/Model/Converter/Float32Converter.html","kind":"class","full_name":"Clear::Model::Converter::Float32Converter","name":"Float32Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L38"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Float32","summary":"Convert from and to Float32
","class_methods":[{"html_id":"to_column(x):Float32|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Float32 | Nil","args_html":"(x) : Float32 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L38"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Float32 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Float32.new(x)\nelse\n Float32.new(x.to_s)\nend"}},{"html_id":"to_db(x:Float32|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Float32 | ::Nil"}],"args_string":"(x : Float32 | Nil)","args_html":"(x : Float32 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L38"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Float32 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Float64Converter","path":"Clear/Model/Converter/Float64Converter.html","kind":"class","full_name":"Clear::Model::Converter::Float64Converter","name":"Float64Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L39"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Float64","summary":"Convert from and to Float64
","class_methods":[{"html_id":"to_column(x):Float64|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Float64 | Nil","args_html":"(x) : Float64 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L39"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Float64 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Float64.new(x)\nelse\n Float64.new(x.to_s)\nend"}},{"html_id":"to_db(x:Float64|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Float64 | ::Nil"}],"args_string":"(x : Float64 | Nil)","args_html":"(x : Float64 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L39"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Float64 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int16Converter","path":"Clear/Model/Converter/Int16Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int16Converter","name":"Int16Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L29"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int16","summary":"Convert from and to Int16
","class_methods":[{"html_id":"to_column(x):Int16|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int16 | Nil","args_html":"(x) : Int16 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L29"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int16 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int16.new(x)\nelse\n Int16.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int16|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int16 | ::Nil"}],"args_string":"(x : Int16 | Nil)","args_html":"(x : Int16 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L29"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int16 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int32Converter","path":"Clear/Model/Converter/Int32Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int32Converter","name":"Int32Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L30"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int32","summary":"Convert from and to Int32
","class_methods":[{"html_id":"to_column(x):Int32|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int32 | Nil","args_html":"(x) : Int32 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L30"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int32 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int32.new(x)\nelse\n Int32.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int32|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int32 | ::Nil"}],"args_string":"(x : Int32 | Nil)","args_html":"(x : Int32 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L30"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int32 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int64Converter","path":"Clear/Model/Converter/Int64Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int64Converter","name":"Int64Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L31"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int64","summary":"Convert from and to Int64
","class_methods":[{"html_id":"to_column(x):Int64|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int64 | Nil","args_html":"(x) : Int64 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L31"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int64 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int64.new(x)\nelse\n Int64.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int64|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int64 | ::Nil"}],"args_string":"(x : Int64 | Nil)","args_html":"(x : Int64 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":31,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L31"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/Int8Converter","path":"Clear/Model/Converter/Int8Converter.html","kind":"class","full_name":"Clear::Model::Converter::Int8Converter","name":"Int8Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L28"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to Int8","summary":"Convert from and to Int8
","class_methods":[{"html_id":"to_column(x):Int8|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Int8 | Nil","args_html":"(x) : Int8 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L28"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Int8 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n Int8.new(x)\nelse\n Int8.new(x.to_s)\nend"}},{"html_id":"to_db(x:Int8|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int8 | ::Nil"}],"args_string":"(x : Int8 | Nil)","args_html":"(x : Int8 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L28"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Int8 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/JSON","path":"Clear/Model/Converter/JSON.html","kind":"module","full_name":"Clear::Model::Converter::JSON","name":"JSON","abstract":false,"locations":[{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"types":[{"html_id":"clear/Clear/Model/Converter/JSON/AnyConverter","path":"Clear/Model/Converter/JSON/AnyConverter.html","kind":"module","full_name":"Clear::Model::Converter::JSON::AnyConverter","name":"AnyConverter","abstract":false,"locations":[{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter/JSON","kind":"module","full_name":"Clear::Model::Converter::JSON","name":"JSON"},"class_methods":[{"html_id":"to_column(x):::JSON::Any|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : ::JSON::Any | Nil","args_html":"(x) : ::JSON::Any | Nil","location":{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L4"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"::JSON::Any | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen ::JSON::Any\n x\nwhen ::JSON::PullParser\n ::JSON::Any.new(x)\nelse\n ::JSON.parse(x.to_s)\nend"}},{"html_id":"to_db(x:::JSON::Any|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"::JSON::Any | ::Nil"}],"args_string":"(x : ::JSON::Any | Nil)","args_html":"(x : ::JSON::Any | Nil)","location":{"filename":"src/clear/model/converters/json_any_converter.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/json_any_converter.cr#L17"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"::JSON::Any | ::Nil"}],"visibility":"Public","body":"x.to_json"}}]}]},{"html_id":"clear/Clear/Model/Converter/StringConverter","path":"Clear/Model/Converter/StringConverter.html","kind":"class","full_name":"Clear::Model::Converter::StringConverter","name":"StringConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/string_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/string_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"class_methods":[{"html_id":"to_column(x):String|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : String | Nil","args_html":"(x) : String | Nil","location":{"filename":"src/clear/model/converters/string_converter.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/string_converter.cr#L4"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"String | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Slice(UInt8)\n String.new(x)\nelse\n x.to_s\nend"}},{"html_id":"to_db(x:String|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | ::Nil"}],"args_string":"(x : String | Nil)","args_html":"(x : String | Nil)","location":{"filename":"src/clear/model/converters/string_converter.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/string_converter.cr#L15"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"String | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/TimeConverter","path":"Clear/Model/Converter/TimeConverter.html","kind":"class","full_name":"Clear::Model::Converter::TimeConverter","name":"TimeConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/time_converter.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/time_converter.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"class_methods":[{"html_id":"to_column(x):Time|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Time | Nil","args_html":"(x) : Time | Nil","location":{"filename":"src/clear/model/converters/time_converter.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/time_converter.cr#L4"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Time | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Time\n x.to_local\nelse\n time = x.to_s\n case time\n when /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]+/\n Time.parse_local(x.to_s, \"%F %X.%L\")\n else\n Time::Format::RFC_3339.parse(time)\n end\nend"}},{"html_id":"to_db(x:Time|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Time | ::Nil"}],"args_string":"(x : Time | Nil)","args_html":"(x : Time | Nil)","location":{"filename":"src/clear/model/converters/time_converter.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/time_converter.cr#L21"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"Time | ::Nil"}],"visibility":"Public","body":"case x\nwhen Nil\n nil\nelse\n x.to_utc.to_s(Clear::Expression::DATABASE_DATE_TIME_FORMAT)\nend"}}]},{"html_id":"clear/Clear/Model/Converter/UInt16Converter","path":"Clear/Model/Converter/UInt16Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt16Converter","name":"UInt16Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L34"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt16","summary":"Convert from and to UInt16
","class_methods":[{"html_id":"to_column(x):UInt16|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt16 | Nil","args_html":"(x) : UInt16 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L34"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt16 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt16.new(x)\nelse\n UInt16.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt16|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt16 | ::Nil"}],"args_string":"(x : UInt16 | Nil)","args_html":"(x : UInt16 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L34"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt16 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UInt32Converter","path":"Clear/Model/Converter/UInt32Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt32Converter","name":"UInt32Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L35"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt32","summary":"Convert from and to UInt32
","class_methods":[{"html_id":"to_column(x):UInt32|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt32 | Nil","args_html":"(x) : UInt32 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L35"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt32 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt32.new(x)\nelse\n UInt32.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt32|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt32 | ::Nil"}],"args_string":"(x : UInt32 | Nil)","args_html":"(x : UInt32 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L35"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt32 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UInt64Converter","path":"Clear/Model/Converter/UInt64Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt64Converter","name":"UInt64Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L36"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt64","summary":"Convert from and to UInt64
","class_methods":[{"html_id":"to_column(x):UInt64|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt64 | Nil","args_html":"(x) : UInt64 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L36"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt64 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt64.new(x)\nelse\n UInt64.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt64|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt64 | ::Nil"}],"args_string":"(x : UInt64 | Nil)","args_html":"(x : UInt64 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L36"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt64 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UInt8Converter","path":"Clear/Model/Converter/UInt8Converter.html","kind":"class","full_name":"Clear::Model::Converter::UInt8Converter","name":"UInt8Converter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/converters/number_converters.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L33"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from and to UInt8","summary":"Convert from and to UInt8
","class_methods":[{"html_id":"to_column(x):UInt8|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UInt8 | Nil","args_html":"(x) : UInt8 | Nil","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L33"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UInt8 | ::Nil","visibility":"Public","body":"case x\nwhen Nil\n nil\nwhen Number\n UInt8.new(x)\nelse\n UInt8.new(x.to_s)\nend"}},{"html_id":"to_db(x:UInt8|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UInt8 | ::Nil"}],"args_string":"(x : UInt8 | Nil)","args_html":"(x : UInt8 | Nil)","location":{"filename":"src/clear/model/converters/number_converters.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/converters/number_converters.cr#L33"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UInt8 | ::Nil"}],"visibility":"Public","body":"x"}}]},{"html_id":"clear/Clear/Model/Converter/UUIDConverter","path":"Clear/Model/Converter/UUIDConverter.html","kind":"class","full_name":"Clear::Model::Converter::UUIDConverter","name":"UUIDConverter","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/Converter","kind":"module","full_name":"Clear::Model::Converter","name":"Converter"},"doc":"Convert from UUID column to Crystal's UUID","summary":"Convert from UUID column to Crystal's UUID
","class_methods":[{"html_id":"to_column(x):UUID|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : UUID | Nil","args_html":"(x) : UUID | Nil","location":{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L9"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"UUID | ::Nil","visibility":"Public","body":"case x\nwhen String\n UUID.new(x)\nwhen Slice(UInt8)\n UUID.new(x)\nwhen UUID\n x\nwhen Nil\n nil\nelse\n raise(Clear::ErrorMessages.converter_error(x.class.name, \"UUID\"))\nend"}},{"html_id":"to_db(x:UUID|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"UUID | ::Nil"}],"args_string":"(x : UUID | Nil)","args_html":"(x : UUID | Nil)","location":{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L24"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"UUID | ::Nil"}],"visibility":"Public","body":"if x.nil?\n nil\nelse\n x.to_s\nend"}}]}]},{"html_id":"clear/Clear/Model/Error","path":"Clear/Model/Error.html","kind":"class","full_name":"Clear::Model::Error","name":"Error","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/errors.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"clear/Clear/Model/InvalidError","kind":"class","full_name":"Clear::Model::InvalidError","name":"InvalidError"},{"html_id":"clear/Clear/Model/ReadOnlyError","kind":"class","full_name":"Clear::Model::ReadOnlyError","name":"ReadOnlyError"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}},{"html_id":"clear/Clear/Model/EventManager","path":"Clear/Model/EventManager.html","kind":"class","full_name":"Clear::Model::EventManager","name":"EventManager","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/event_manager.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"EVENT_CALLBACKS","name":"EVENT_CALLBACKS","value":"{} of EventKey => Array(HookFunction)"},{"id":"INHERITANCE_MAP","name":"INHERITANCE_MAP","value":"{} of String => String"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"Global storage for model lifecycle event management\n\nThis class acts as a storage and can trigger events\nThis class a singleton.","summary":"Global storage for model lifecycle event management
","class_methods":[{"html_id":"add_inheritance(parent,child)-class-method","name":"add_inheritance","doc":"Map the inheritance between models. Events which belongs to parent model are triggered when child model lifecycle\nactions occurs","summary":"Map the inheritance between models.
","abstract":false,"args":[{"name":"parent","external_name":"parent","restriction":""},{"name":"child","external_name":"child","restriction":""}],"args_string":"(parent, child)","args_html":"(parent, child)","location":{"filename":"src/clear/model/event_manager.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L43"},"def":{"name":"add_inheritance","args":[{"name":"parent","external_name":"parent","restriction":""},{"name":"child","external_name":"child","restriction":""}],"visibility":"Public","body":"INHERITANCE_MAP[child.to_s] = parent.to_s"}},{"html_id":"attach(klazz,direction:Symbol,event:Symbol,block:HookFunction)-class-method","name":"attach","doc":"Add an event for a specific class, to a specific direction (after or before), a specific event Symbol (validate, save, commit...)","summary":"Add an event for a specific class, to a specific direction (after or before), a specific event Symbol (validate, save, commit...)
","abstract":false,"args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"block","external_name":"block","restriction":"HookFunction"}],"args_string":"(klazz, direction : Symbol, event : Symbol, block : HookFunction)","args_html":"(klazz, direction : Symbol, event : Symbol, block : HookFunction)","location":{"filename":"src/clear/model/event_manager.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L48"},"def":{"name":"attach","args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"block","external_name":"block","restriction":"HookFunction"}],"visibility":"Public","body":"tuple = {klazz.to_s, direction, event}\narr = EVENT_CALLBACKS.fetch(tuple) do\n [] of HookFunction\nend\narr.push(block)\nEVENT_CALLBACKS[tuple] = arr\n"}},{"html_id":"trigger(klazz,direction:Symbol,event:Symbol,mdl:Clear::Model)-class-method","name":"trigger","doc":"Trigger events callback for a specific model.\nDirection can be `:before` and `:after`\nIn case of `:before` direction, the events are called in reverse order:\n\n```\nbefore:\n- Last defined event\n- First defined event\naction\nafter:\n- First defined events\n- Last defined events\n```","summary":"Trigger events callback for a specific model.
","abstract":false,"args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"mdl","external_name":"mdl","restriction":"Clear::Model"}],"args_string":"(klazz, direction : Symbol, event : Symbol, mdl : Clear::Model)","args_html":"(klazz, direction : Symbol, event : Symbol, mdl : Clear::Model)","location":{"filename":"src/clear/model/event_manager.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L25"},"def":{"name":"trigger","args":[{"name":"klazz","external_name":"klazz","restriction":""},{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"event","external_name":"event","restriction":"Symbol"},{"name":"mdl","external_name":"mdl","restriction":"Clear::Model"}],"visibility":"Public","body":"arr = EVENT_CALLBACKS.fetch({klazz.to_s, direction, event}) do\n [] of HookFunction\nend\nparent = INHERITANCE_MAP[klazz.to_s]?\nif direction == (:after)\n arr = arr.reverse\n arr.each(&.call(mdl))\n if parent.nil?\n else\n trigger(parent, direction, event, mdl)\n end\nelse\n if parent.nil?\n else\n trigger(parent, direction, event, mdl)\n end\n arr.each(&.call(mdl))\nend\n"}}],"types":[{"html_id":"clear/Clear/Model/EventManager/EventKey","path":"Clear/Model/EventManager/EventKey.html","kind":"alias","full_name":"Clear::Model::EventManager::EventKey","name":"EventKey","abstract":false,"locations":[{"filename":"src/clear/model/event_manager.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Tuple(String, Symbol, Symbol)","aliased_html":"{String, Symbol, Symbol}","const":false,"namespace":{"html_id":"clear/Clear/Model/EventManager","kind":"class","full_name":"Clear::Model::EventManager","name":"EventManager"}},{"html_id":"clear/Clear/Model/EventManager/HookFunction","path":"Clear/Model/EventManager/HookFunction.html","kind":"alias","full_name":"Clear::Model::EventManager::HookFunction","name":"HookFunction","abstract":false,"locations":[{"filename":"src/clear/model/event_manager.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/event_manager.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Proc(Clear::Model, Nil)","aliased_html":"Clear::Model -> Nil","const":false,"namespace":{"html_id":"clear/Clear/Model/EventManager","kind":"class","full_name":"Clear::Model::EventManager","name":"EventManager"}}]},{"html_id":"clear/Clear/Model/Factory","path":"Clear/Model/Factory.html","kind":"module","full_name":"Clear::Model::Factory","name":"Factory","abstract":false,"locations":[{"filename":"src/clear/model/factories/base.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/base.cr#L1"},{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L3"},{"filename":"src/clear/model/factories/simple_factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/simple_factory.cr#L3"},{"filename":"src/clear/model/factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"FACTORIES","name":"FACTORIES","value":"{\"Clear::Reflection::Column\" => ::Clear::Model::Factory::SimpleFactory(Clear::Reflection::Column).new, \"Clear::Reflection::Table\" => ::Clear::Model::Factory::SimpleFactory(Clear::Reflection::Table).new} of String => Clear::Model::Factory::Base"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"class_methods":[{"html_id":"build(type:String,h:Hash,cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false):Clear::Model-class-method","name":"build","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(type : String, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : Clear::Model","args_html":"(type : String, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : Clear::Model","location":{"filename":"src/clear/model/factory.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L10"},"def":{"name":"build","args":[{"name":"type","external_name":"type","restriction":"String"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"Clear::Model","visibility":"Public","body":"factory = FACTORIES[type].as(Base)\nfactory.build(h, cache, persisted, fetch_columns)\n"}},{"html_id":"build(type:T.class,h:Hash,cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false):TforallT-class-method","name":"build","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"T.class"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(type : T.class, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : T forall T","args_html":"(type : T.class, h : Hash, cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false) : T forall T","location":{"filename":"src/clear/model/factory.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L22"},"def":{"name":"build","args":[{"name":"type","external_name":"type","restriction":"T.class"},{"name":"h","external_name":"h","restriction":"Hash"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"T","visibility":"Public","body":"(build(T.name, h, cache, persisted, fetch_columns)).as(T)"}}],"macros":[{"html_id":"add(type,factory)-macro","name":"add","abstract":false,"args":[{"name":"type","external_name":"type","restriction":""},{"name":"factory","external_name":"factory","restriction":""}],"args_string":"(type, factory)","args_html":"(type, factory)","location":{"filename":"src/clear/model/factory.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factory.cr#L6"},"def":{"name":"add","args":[{"name":"type","external_name":"type","restriction":""},{"name":"factory","external_name":"factory","restriction":""}],"visibility":"Public","body":" \n{% Clear::Model::Factory::FACTORIES[type] = factory %}\n\n \n"}}],"types":[{"html_id":"clear/Clear/Model/Factory/Base","path":"Clear/Model/Factory/Base.html","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base","abstract":false,"locations":[{"filename":"src/clear/model/factories/base.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/base.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model/Factory/PolymorphicFactory","kind":"class","full_name":"Clear::Model::Factory::PolymorphicFactory(T)","name":"PolymorphicFactory"},{"html_id":"clear/Clear/Model/Factory/SimpleFactory","kind":"class","full_name":"Clear::Model::Factory::SimpleFactory(T)","name":"SimpleFactory"}],"namespace":{"html_id":"clear/Clear/Model/Factory","kind":"module","full_name":"Clear::Model::Factory","name":"Factory"},"instance_methods":[{"html_id":"build(h:Hash(String,Clear::SQL::Any),cache:Clear::Model::QueryCache|Nil=nil,persisted:Bool=false,fetch_columns:Bool=false):Clear::Model-instance-method","name":"build","abstract":true,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"args_string":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","args_html":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","location":{"filename":"src/clear/model/factories/base.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/base.cr#L3"},"def":{"name":"build","args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"return_type":"Clear::Model","visibility":"Public","body":""}}]},{"html_id":"clear/Clear/Model/Factory/PolymorphicFactory","path":"Clear/Model/Factory/PolymorphicFactory.html","kind":"class","full_name":"Clear::Model::Factory::PolymorphicFactory(T)","name":"PolymorphicFactory","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"}],"namespace":{"html_id":"clear/Clear/Model/Factory","kind":"module","full_name":"Clear::Model::Factory","name":"Factory"},"constructors":[{"html_id":"new(type_field:String,self_class:String)-class-method","name":"new","abstract":false,"args":[{"name":"type_field","external_name":"type_field","restriction":"::String"},{"name":"self_class","external_name":"self_class","restriction":"::String"}],"args_string":"(type_field : String, self_class : String)","args_html":"(type_field : String, self_class : String)","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L9"},"def":{"name":"new","args":[{"name":"type_field","external_name":"type_field","restriction":"::String"},{"name":"self_class","external_name":"self_class","restriction":"::String"}],"visibility":"Public","body":"_ = PolymorphicFactory(T).allocate\n_.initialize(type_field, self_class)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"build(h:Hash(String,Clear::SQL::Any),cache:Clear::Model::QueryCache|Nil=nil,persisted:Bool=false,fetch_columns:Bool=false):Clear::Model-instance-method","name":"build","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"args_string":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","args_html":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L12"},"def":{"name":"build","args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"return_type":"Clear::Model","visibility":"Public","body":"v = h[@type_field]\ncase v\nwhen String\n if v == T.name\n {% if T.abstract? %}\n raise \"Cannot instantiate #{@type_field} because it is abstract class\"\n {% else %}\n T.new(v, h, cache, persisted, fetch_columns).as(Clear::Model)\n {% end %}\n else\n (Clear::Model::Factory.build(v, h, cache, persisted, fetch_columns)).as(Clear::Model)\n end\nwhen Nil\n raise(Clear::ErrorMessages.polymorphic_nil(@type_field))\nelse\n raise(Clear::ErrorMessages.polymorphic_nil(@type_field))\nend\n"}},{"html_id":"self_class:String-instance-method","name":"self_class","abstract":false,"location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L7"},"def":{"name":"self_class","return_type":"String","visibility":"Public","body":"@self_class"}},{"html_id":"self_class=(self_class:String)-instance-method","name":"self_class=","abstract":false,"args":[{"name":"self_class","external_name":"self_class","restriction":"String"}],"args_string":"(self_class : String)","args_html":"(self_class : String)","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L7"},"def":{"name":"self_class=","args":[{"name":"self_class","external_name":"self_class","restriction":"String"}],"visibility":"Public","body":"@self_class = self_class"}},{"html_id":"type_field:String-instance-method","name":"type_field","abstract":false,"location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L6"},"def":{"name":"type_field","return_type":"String","visibility":"Public","body":"@type_field"}},{"html_id":"type_field=(type_field:String)-instance-method","name":"type_field=","abstract":false,"args":[{"name":"type_field","external_name":"type_field","restriction":"String"}],"args_string":"(type_field : String)","args_html":"(type_field : String)","location":{"filename":"src/clear/model/factories/polymorphic_factory.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/polymorphic_factory.cr#L6"},"def":{"name":"type_field=","args":[{"name":"type_field","external_name":"type_field","restriction":"String"}],"visibility":"Public","body":"@type_field = type_field"}}]},{"html_id":"clear/Clear/Model/Factory/SimpleFactory","path":"Clear/Model/Factory/SimpleFactory.html","kind":"class","full_name":"Clear::Model::Factory::SimpleFactory(T)","name":"SimpleFactory","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/factories/simple_factory.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/simple_factory.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/Model/Factory/Base","kind":"module","full_name":"Clear::Model::Factory::Base","name":"Base"}],"namespace":{"html_id":"clear/Clear/Model/Factory","kind":"module","full_name":"Clear::Model::Factory","name":"Factory"},"instance_methods":[{"html_id":"build(h:Hash(String,Clear::SQL::Any),cache:Clear::Model::QueryCache|Nil=nil,persisted:Bool=false,fetch_columns:Bool=false):Clear::Model-instance-method","name":"build","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"args_string":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","args_html":"(h : Hash(String, Clear::SQL::Any), cache : Clear::Model::QueryCache | Nil = nil, persisted : Bool = false, fetch_columns : Bool = false) : Clear::Model","location":{"filename":"src/clear/model/factories/simple_factory.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/factories/simple_factory.cr#L7"},"def":{"name":"build","args":[{"name":"h","external_name":"h","restriction":"Hash(String, ::Clear::SQL::Any)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":"Bool"},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":"Bool"}],"return_type":"Clear::Model","visibility":"Public","body":"(T.new(h, cache, persisted, fetch_columns)).as(Clear::Model)"}}]}]},{"html_id":"clear/Clear/Model/FullTextSearchable","path":"Clear/Model/FullTextSearchable.html","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable","abstract":false,"locations":[{"filename":"src/clear/extensions/full_text_searchable/model.cr","line_number":87,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/model.cr#L87"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"Full text search plugin offers full integration with `tsvector` capabilities of\nPostgresql.\n\nIt allows you to query models through the text content of one or multiple fields.\n\n### The blog example\n\nLet's assume we have a blog and want to implement full text search over title and content:\n\n```\ncreate_table \"posts\" do |t|\n t.column :title, :string, null: false\n t.column :content, :string, null: false\n\n t.full_text_searchable on: [{\"title\", 'A'}, {\"content\", 'C'}]\nend\n```\n\nThis migration will create a 3rd column named `full_text_vector` of type `tsvector`,\na gin index, a trigger and a function to update automatically this column.\n\nOver the `on` keyword, `'{\"title\", 'A'}'` means it allows search of the content of \"title\", with level of priority (weight) \"A\", which tells postgres than title content is more meaningful than the article content itself.\n\nNow, let's build some models:\n\n```\n\n model Post\n include Clear::Model\n #...\n\n full_text_searchable\n end\n\n Post.create!({title: \"About poney\", content: \"Poney are cool\"})\n Post.create!({title: \"About dog and cat\", content: \"Cat and dog are cool. But not as much as poney\"})\n Post.create!({title: \"You won't believe: She raises her poney like as star!\", content: \"She's cool because poney are cool\"})\n```\n\nSearch is now easily done\n\n```\nPost.query.search(\"poney\") # Return all the articles !\n```\n\nObviously, search call can be chained:\n\n```\nuser = User.find! { email == \"some_email@example.com\" }\nPost.query.from_user(user).search(\"orm\")\n```\n\n### Additional parameters\n\n#### `catalog`\n\nSelect the catalog to use to build the tsquery. By default, `pg_catalog.english` is used.\n\n```\n# in your migration:\nt.full_text_searchable on: [{\"title\", 'A'}, {\"content\", 'C'}], catalog: \"pg_catalog.french\"\n\n# in your model\nfull_text_searchable catalog: \"pg_catalog.french\"\n```\n\nNote: For now, Clear doesn't offers dynamic selection of catalog (for let's say multi-lang service).\nIf your app need this feature, do not hesitate to open an issue.\n\n#### `trigger_name`, `function_name`\n\nIn migration, you can change the name generated for the trigger and the function, using theses two keys.\n\n#### `dest_field`\n\nThe field created in the database, which will contains your ts vector. Default is `full_text_vector`.\n\n```\n# in your migration\nt.full_text_searchable on: [{\"title\", 'A'}, {\"content\", 'C'}], dest_field: \"tsv\"\n\n# in your model\nfull_text_searchable \"tsv\"\n```","summary":"Full text search plugin offers full integration with tsvector
capabilities of Postgresql.
Parse client side text and generate string ready to be ingested by PG's to_tsquery
.
Set this model as searchable using tsvector
","abstract":false,"args":[{"name":"through","default_value":"\"full_text_vector\"","external_name":"through","restriction":""},{"name":"catalog","default_value":"\"pg_catalog.english\"","external_name":"catalog","restriction":""},{"name":"scope_name","default_value":"\"search\"","external_name":"scope_name","restriction":""}],"args_string":"(through = \"full_text_vector\", catalog = \"pg_catalog.english\", scope_name = \"search\")","args_html":"(through = "full_text_vector", catalog = "pg_catalog.english", scope_name = "search")","location":{"filename":"src/clear/extensions/full_text_searchable/model.cr","line_number":89,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/model.cr#L89"},"def":{"name":"full_text_searchable","args":[{"name":"through","default_value":"\"full_text_vector\"","external_name":"through","restriction":""},{"name":"catalog","default_value":"\"pg_catalog.english\"","external_name":"catalog","restriction":""},{"name":"scope_name","default_value":"\"search\"","external_name":"scope_name","restriction":""}],"visibility":"Public","body":" column( \n{{ through.id }}\n : Clear::TSVector, presence: false)\n\n scope \"\n{{ scope_name.id }}\n\" do |str|\n table = self.item_class.table\n where \n{\n op(\n var(table, \"\n{{ through.id }}\n\"),\n to_tsquery(\n{{ catalog }}\n, Clear::Model::FullTextSearchable.to_tsq(str)),\n \"@@\"\n )\n }\n \nend\n \n"}}]},{"html_id":"clear/Clear/Model/HasColumns","path":"Clear/Model/HasColumns.html","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_columns.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L5"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"This module declare all the methods and macro related to columns in `Clear::Model`","summary":"This module declare all the methods and macro related to columns in Clear::Model
Access to direct SQL attributes given by the request used to build the model.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Clear::SQL::Any","args_html":"(x) : Clear::SQL::Any","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L72"},"def":{"name":"[]","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"::Clear::SQL::Any","visibility":"Public","body":"attributes[x]"}},{"html_id":"[]?(x):Clear::SQL::Any-instance-method","name":"[]?","doc":"Access to direct SQL attributes given by the request and used to build the model\nor Nil if not found.\n\nAccess is read only and updating the model columns will not apply change to theses columns.\nYou must set `fetch_column: true` in your model to access the attributes.","summary":"Access to direct SQL attributes given by the request and used to build the model or Nil if not found.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Clear::SQL::Any","args_html":"(x) : Clear::SQL::Any","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":81,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L81"},"def":{"name":"[]?","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"::Clear::SQL::Any","visibility":"Public","body":"attributes[x]?"}},{"html_id":"reset(h:Hash(String,_))-instance-method","name":"reset","doc":"See `reset(**t : **T)`","summary":"","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L35"},"def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":""}},{"html_id":"reset(h:Hash(Symbol,_))-instance-method","name":"reset","doc":"See `reset(**t : **T)`","summary":"","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L39"},"def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":""}},{"html_id":"reset(**t:**T)forallT-instance-method","name":"reset","doc":"Reset one or multiple columns; Reseting set the current value of the column\nto the given value, while the `changed?` flag remains false.\nIf you call save on a persisted model, the reset columns won't be\ncommited in the UPDATE query.","summary":"Reset one or multiple columns; Reseting set the current value of the column to the given value, while the changed?
flag remains false.
See #set(**t : **T)
See #set(**t : **T)
Set one or multiple columns to a specific value This two are equivalents:
","abstract":false,"location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":49,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L49"},"def":{"name":"set","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":""}},{"html_id":"to_h(full=false)-instance-method","name":"to_h","doc":"Returns the model columns as Hash.\nCalling `to_h` will returns only the defined columns, while settings the optional parameter `full` to `true`\n will return all the column and fill the undefined columns by `nil` values.\nExample:\n\n```\n# Assuming our model has a primary key, a first name and last name and two timestamp columns:\nmodel = Model.query.select(\"first_name, last_name\").first!\nmodel.to_h # => { \"first_name\" => \"Johnny\", \"last_name\" => \"Walker\" }\nmodel.to_h(full: true) # => {\"id\" => nil, \"first_name\" => \"Johnny\", \"last_name\" => \"Walker\", \"created_at\" => nil, \"updated_at\" => nil}\n```","summary":"Returns the model columns as Hash.
","abstract":false,"args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"args_string":"(full = false)","args_html":"(full = false)","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":110,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L110"},"def":{"name":"to_h","args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"visibility":"Public","body":"{} of String => ::Clear::SQL::Any"}},{"html_id":"update_h-instance-method","name":"update_h","doc":"Returns the current hash of the modified values:\n\n```\nmodel = Model.query.first!\nmodel.update_h # => {}\nmodel.first_name = \"hello\"\nmodel.update_h # => { \"first_name\" => \"hello\" }\nmodel.save!\nmodel.update_h # => {}\n```","summary":"Returns the current hash of the modified values:
","abstract":false,"location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L95"},"def":{"name":"update_h","visibility":"Public","body":"{} of String => ::Clear::SQL::Any"}}],"macros":[{"html_id":"column(name,primary=false,converter=nil,column_name=nil,presence=true,mass_assign=true)-macro","name":"column","doc":"Bind a column to the model.\n\nSimple example:\n\n```\nclass MyModel\n include Clear::Model\n\n column some_id : Int32, primary: true\n column nullable_column : String?\nend\n```\noptions:\n\n* `primary : Bool`: Let Clear ORM know which column is the primary key.\nCurrently compound primary key are not compatible with Clear ORM.\n\n* `converter : Class | Module`: Use this class to convert the data from the\nSQL. This class must possess the class methods\n`to_column(::Clear::SQL::Any) : T` and `to_db(T) : ::Clear::SQL::Any`\nwith `T` the type of the column.\n\n* `column_name : String`: If the name of the column in the model doesn't fit the name of the\n column in the SQL, you can use the parameter `column_name` to tell Clear about\n which db column is linked to current field.\n\n* `presence : Bool (default = true)`: Use this option to let know Clear that\n your column is not nullable but with default value generated by the database\n on insert (e.g. serial)\nDuring validation before saving, the presence will not be checked on this field\n and Clear will try to insert without the field value.\n\n* `mass_assign : Bool (default = true)`: Use this option to turn on/ off mass assignment\n when instantiating or updating a new model from json through `.from_json` methods from\n the `Clear::Model::JSONDeserialize` module.\n","summary":"Bind a column to the model.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"converter","default_value":"nil","external_name":"converter","restriction":""},{"name":"column_name","default_value":"nil","external_name":"column_name","restriction":""},{"name":"presence","default_value":"true","external_name":"presence","restriction":""},{"name":"mass_assign","default_value":"true","external_name":"mass_assign","restriction":""}],"args_string":"(name, primary = false, converter = nil, column_name = nil, presence = true, mass_assign = true)","args_html":"(name, primary = false, converter = nil, column_name = nil, presence = true, mass_assign = true)","location":{"filename":"src/clear/model/modules/has_columns.cr","line_number":150,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_columns.cr#L150"},"def":{"name":"column","args":[{"name":"name","external_name":"name","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"converter","default_value":"nil","external_name":"converter","restriction":""},{"name":"column_name","default_value":"nil","external_name":"column_name","restriction":""},{"name":"presence","default_value":"true","external_name":"presence","restriction":""},{"name":"mass_assign","default_value":"true","external_name":"mass_assign","restriction":""}],"visibility":"Public","body":" \n{% _type = name.type %}\n\n \n{% unless converter\n if _type.is_a?(Path)\n if _type.resolve.stringify =~ (/\\(/)\n converter = _type.stringify\n else\n converter = _type.resolve.stringify\n end\n else\n if _type.is_a?(Generic)\n if _type.name.stringify == \"::Union\"\n converter = (_type.type_vars.map(&.resolve).map(&.stringify).sort.reject do |x|\n (x == \"Nil\") || (x == \"::Nil\")\n end.join(\"\")).id.stringify\n else\n converter = _type.resolve.stringify\n end\n else\n if _type.is_a?(Union)\n converter = (_type.types.map(&.resolve).map(&.stringify).sort.reject do |x|\n (x == \"Nil\") || (x == \"::Nil\")\n end.join(\"\")).id.stringify\n else\n raise(\"Unknown: #{_type}, #{_type.class}\")\n end\n end\n end\nend %}\n\n\n \n{% db_column_name = column_name == nil ? name.var : column_name.id\nCOLUMNS[\"#{db_column_name.id}\"] = {type: _type, primary: primary, converter: converter, db_column_name: \"#{db_column_name.id}\", crystal_variable_name: name.var, presence: presence, mass_assign: mass_assign}\n %}\n\n \n"}}]},{"html_id":"clear/Clear/Model/HasFactory","path":"Clear/Model/HasFactory.html","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_factory.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_factory.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"macros":[{"html_id":"polymorphic(through=\"type\")-macro","name":"polymorphic","doc":"Define a polymorphic factory, if the model is tagged as polymorphic","summary":"Define a polymorphic factory, if the model is tagged as polymorphic
","abstract":false,"args":[{"name":"through","default_value":"\"type\"","external_name":"through","restriction":""}],"args_string":"(through = \"type\")","args_html":"(through = "type")","location":{"filename":"src/clear/model/modules/has_factory.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_factory.cr#L36"},"def":{"name":"polymorphic","args":[{"name":"through","default_value":"\"type\"","external_name":"through","restriction":""}],"visibility":"Public","body":" \n{% POLYMORPHISM_SETTINGS[:has_factory] = true %}\n\n\n column \n{{ through.id }}\n : String\n\n before(:validate) do |model|\n model = model.as(self)\n model.\n{{ through.id }}\n = model.class.name\n \nend\n\n \n# Subclasses are refined using a default scope\n\n \n# to filter by type.\n\n macro inherited\n class Collection < Clear::Model::CollectionBase(\n\\{\n{@type}}); \nend\n\n def self.query\n Collection.new.from(table).where \n{ \n{{ through.id }}\n == self.name }\n \nend\n \nend\n\n \n# Base class can be refined too, only if the baseclass is not abstract.\n\n \n{% if @type.abstract? %}{% else %}\n def self.query\n Collection.new.from(table).where { {{ through.id }} == self.name }\n end\n {% end %}\n\n\n def self.polymorphic?\n true\n \nend\n\n Clear::Model::Factory.add(\n \"\n{{ @type }}\n\",\n Clear::Model::Factory::PolymorphicFactory(\n{{ @type }}\n).new(\n{{ through.id.stringify }}\n, \"\n{{ @type }}\n\")\n )\n\n macro inherited\n Clear::Model::Factory.add(\n \"\n\\{\n{@type}}\",\n Clear::Model::Factory::SimpleFactory(\n\\{\n{@type}}).new\n )\n \nend\n \n"}}]},{"html_id":"clear/Clear/Model/HasHooks","path":"Clear/Model/HasHooks.html","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_hooks.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"instance_methods":[{"html_id":"trigger_after_events(event_name)-instance-method","name":"trigger_after_events","doc":"Triggers the events hooked after `event_name`","summary":"Triggers the events hooked after event_name
Triggers the events hooked before event_name
This performs theses operations:
","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":""}],"args_string":"(event_name, &)","args_html":"(event_name, &)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L15"},"def":{"name":"with_triggers","args":[{"name":"event_name","external_name":"event_name","restriction":""}],"yields":1,"block_arity":1,"visibility":"Public","body":"Clear::SQL.transaction do |cnx|\n trigger_before_events(event_name)\n yield(cnx)\n trigger_after_events(event_name)\nend\nself\n"}}],"macros":[{"html_id":"after(event_name,method_name)-macro","name":"after","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"args_string":"(event_name, method_name)","args_html":"(event_name, method_name)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L50"},"def":{"name":"after","args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"visibility":"Public","body":" after(\n{{ event_name }}\n) \n{ |mdl|\n mdl.as(\n{{ @type }}\n).\n{{ method_name.id }}\n\n }\n \n"}},{"html_id":"before(event_name,method_name)-macro","name":"before","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"args_string":"(event_name, method_name)","args_html":"(event_name, method_name)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L44"},"def":{"name":"before","args":[{"name":"event_name","external_name":"event_name","restriction":""},{"name":"method_name","external_name":"method_name","restriction":""}],"visibility":"Public","body":" before(\n{{ event_name }}\n) \n{ |mdl|\n mdl.as(\n{{ @type }}\n).\n{{ method_name.id }}\n\n }\n \n"}}],"types":[{"html_id":"clear/Clear/Model/HasHooks/ClassMethods","path":"Clear/Model/HasHooks/ClassMethods.html","kind":"module","full_name":"Clear::Model::HasHooks::ClassMethods","name":"ClassMethods","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_hooks.cr","line_number":34,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L34"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},"instance_methods":[{"html_id":"after(event_name:Symbol,&block:Clear::Model->Nil)-instance-method","name":"after","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"args_string":"(event_name : Symbol, &block : Clear::Model -> Nil)","args_html":"(event_name : Symbol, &block : Clear::Model -> Nil)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L39"},"def":{"name":"after","args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Model -> Nil)"},"visibility":"Public","body":"Clear::Model::EventManager.attach(self, :after, event_name, block)"}},{"html_id":"before(event_name:Symbol,&block:Clear::Model->Nil)-instance-method","name":"before","abstract":false,"args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"args_string":"(event_name : Symbol, &block : Clear::Model -> Nil)","args_html":"(event_name : Symbol, &block : Clear::Model -> Nil)","location":{"filename":"src/clear/model/modules/has_hooks.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_hooks.cr#L35"},"def":{"name":"before","args":[{"name":"event_name","external_name":"event_name","restriction":"Symbol"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Model -> Nil)"},"visibility":"Public","body":"Clear::Model::EventManager.attach(self, :before, event_name, block)"}}]}]},{"html_id":"clear/Clear/Model/HasRelations","path":"Clear/Model/HasRelations.html","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_relations.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_relations.cr#L13"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"doc":"```\nclass Model\n include Clear::Model\n\n has_many posts : Post, foreign_key: Model.underscore_name + \"_id\", no_cache : false\n\n has_one passport : Passport\n has_many posts\nend\n```","summary":"
","macros":[{"html_id":"belongs_to(name,foreign_key=nil,no_cache=false,primary=false,foreign_key_type=Int64)-macro","name":"belongs_to","doc":"```\nclass Model\n include Clear::Model\n\n belongs_to user : User, foreign_key: \"the_user_id\"\nend\n```","summary":"
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"foreign_key_type","default_value":"Int64","external_name":"foreign_key_type","restriction":""}],"args_string":"(name, foreign_key = nil, no_cache = false, primary = false, foreign_key_type = Int64)","args_html":"(name, foreign_key = nil, no_cache = false, primary = false, foreign_key_type = Int64)","location":{"filename":"src/clear/model/modules/has_relations.cr","line_number":120,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_relations.cr#L120"},"def":{"name":"belongs_to","args":[{"name":"name","external_name":"name","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"primary","default_value":"false","external_name":"primary","restriction":""},{"name":"foreign_key_type","default_value":"Int64","external_name":"foreign_key_type","restriction":""}],"visibility":"Public","body":" \n{% if foreign_key.is_a?(SymbolLiteral) || foreign_key.is_a?(StringLiteral)\n foreign_key = foreign_key.id\nend\nnilable = false\nif name.type.is_a?(Union)\n types = name.type.types.map do |x|\n \"#{x.id}\"\n end\n nilable = types.includes?(\"Nil\")\n type = name.type.types.first\nelse\n type = name.type\nend\nif nilable\n unless foreign_key_type.resolve.nilable?\n foreign_key_type = \"#{foreign_key_type.id}?\".id\n end\nend\nRELATIONS[name.var.id] = {relation_type: :belongs_to, type: type, foreign_key: foreign_key, nilable: nilable, primary: primary, no_cache: no_cache, foreign_key_type: foreign_key_type}\n %}\n\n \n"}},{"html_id":"has_many(name,through=nil,foreign_key=nil,own_key=nil,primary_key=nil,no_cache=false,polymorphic=false,foreign_key_type=nil)-macro","name":"has_many","doc":"Has Many and Has One are the relations where the model share its primary key into a foreign table. In our example above, we can assume than a User has many Post as author.\n\nBasically, for each `belongs_to` declaration, you must have a `has_many` or `has_one` declaration on the other model.\n\nWhile `has_many` relation returns a list of models, `has_one` returns only one model when called.\n\nExample:\n\n```\nclass User\n include Clear::Model\n\n has_many posts : Post, foreign_key: \"author_id\"\nend\n```","summary":"Has Many and Has One are the relations where the model share its primary key into a foreign table.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"through","default_value":"nil","external_name":"through","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"own_key","default_value":"nil","external_name":"own_key","restriction":""},{"name":"primary_key","default_value":"nil","external_name":"primary_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"polymorphic","default_value":"false","external_name":"polymorphic","restriction":""},{"name":"foreign_key_type","default_value":"nil","external_name":"foreign_key_type","restriction":""}],"args_string":"(name, through = nil, foreign_key = nil, own_key = nil, primary_key = nil, no_cache = false, polymorphic = false, foreign_key_type = nil)","args_html":"(name, through = nil, foreign_key = nil, own_key = nil, primary_key = nil, no_cache = false, polymorphic = false, foreign_key_type = nil)","location":{"filename":"src/clear/model/modules/has_relations.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_relations.cr#L72"},"def":{"name":"has_many","args":[{"name":"name","external_name":"name","restriction":""},{"name":"through","default_value":"nil","external_name":"through","restriction":""},{"name":"foreign_key","default_value":"nil","external_name":"foreign_key","restriction":""},{"name":"own_key","default_value":"nil","external_name":"own_key","restriction":""},{"name":"primary_key","default_value":"nil","external_name":"primary_key","restriction":""},{"name":"no_cache","default_value":"false","external_name":"no_cache","restriction":""},{"name":"polymorphic","default_value":"false","external_name":"polymorphic","restriction":""},{"name":"foreign_key_type","default_value":"nil","external_name":"foreign_key_type","restriction":""}],"visibility":"Public","body":" \n{% if through != nil\n if through.is_a?(SymbolLiteral) || through.is_a?(StringLiteral)\n through = through.id\n end\n if own_key.is_a?(SymbolLiteral) || own_key.is_a?(StringLiteral)\n own_key = own_key.id\n end\n if foreign_key.is_a?(SymbolLiteral) || foreign_key.is_a?(StringLiteral)\n foreign_key = foreign_key.id\n end\n if foreign_key_type.is_a?(SymbolLiteral) || foreign_key_type.is_a?(StringLiteral)\n foreign_key_type = foreign_key_type.id\n end\n RELATIONS[name.var.id] = {relation_type: :has_many_through, type: name.type, through: through, own_key: own_key, foreign_key: foreign_key, foreign_key_type: foreign_key_type, polymorphic: polymorphic}\nelse\n if foreign_key.is_a?(SymbolLiteral) || foreign_key.is_a?(StringLiteral)\n foreign_key = foreign_key.id\n end\n if primary_key.is_a?(SymbolLiteral) || primary_key.is_a?(StringLiteral)\n primary_key = primary_key.id\n end\n if foreign_key_type.is_a?(SymbolLiteral) || foreign_key_type.is_a?(StringLiteral)\n foreign_key_type = foreign_key_type.id\n end\n RELATIONS[name.var.id] = {relation_type: :has_many, type: name.type, foreign_key: foreign_key, primary_key: primary_key, foreign_key_type: foreign_key_type, no_cache: no_cache, polymorphic: polymorphic}\nend %}\n\n \n"}},{"html_id":"has_one(name,foreign_key=nil,primary_key=nil,no_cache=false,polymorphic=false,foreign_key_type=nil)-macro","name":"has_one","doc":"The method `has_one` declare a relation 1 to [0,1]\nwhere the current model primary key is stored in the foreign table.\n`primary_key` method (default: `self#__pkey__`) and `foreign_key` method\n(default: table_name in singular, plus \"_id\" appended)\ncan be redefined\n\nExample:\n\n```\nmodel Passport\n column id : Int32, primary : true\n has_one user : User It assumes the table `users` have a column `passport_id`\nend\n\nmodel Passport\n column id : Int32, primary : true\n has_one owner : User # It assumes the table `users` have a column `passport_id`\nend\n```","summary":"The method has_one
declare a relation 1 to [0,1] where the current model primary key is stored in the foreign table.
Delete the model by building and executing a DELETE
query.
Save the model.
","abstract":false,"args":[{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"args_string":"(on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","args_html":"(on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","location":{"filename":"src/clear/model/modules/has_saving.cr","line_number":93,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_saving.cr#L93"},"def":{"name":"save","args":[{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"visibility":"Public","body":"if self.class.read_only?\n return false\nend\nwith_triggers(:save) do\n if valid?\n if persisted?\n h = update_h\n if h.empty?\n else\n with_triggers(:update) do\n ((Clear::SQL.update(self.class.full_table_name)).set(update_h)).where do\n (var(\"#{self.class.__pkey__}\")) == __pkey__\n end.execute(@@connection)\n end\n end\n else\n with_triggers(:create) do\n query = (Clear::SQL.insert_into(self.class.full_table_name, to_h)).returning(\"*\")\n if on_conflict\n on_conflict.call(query)\n end\n hash = query.execute(@@connection)\n reset(hash)\n @persisted = true\n end\n end\n clear_change_flags\n return true\n else\n return false\n end\nend\n"}},{"html_id":"save(&block)-instance-method","name":"save","abstract":false,"location":{"filename":"src/clear/model/modules/has_saving.cr","line_number":125,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_saving.cr#L125"},"def":{"name":"save","yields":0,"block_arity":0,"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":"save(on_conflict: block)"}},{"html_id":"save!(on_conflict:Clear::SQL::InsertQuery->|Nil=nil)-instance-method","name":"save!","doc":"Performs `save` call, but instead of returning `false` if validation failed,\nraise `Clear::Model::InvalidError` exception","summary":"Performs #save
call, but instead of returning false
if validation failed, raise Clear::Model::InvalidError
exception
Pass the on_conflict
optional parameter via block.
Set the fields passed as argument and call #save
on the object
Set the fields passed as argument and call #save!
on the object
Add a hook for the primary_key
In the hook, name will be replaced by the column name required by calling primary_key
Macro used to define serializable primary keys.
","abstract":false,"args":[{"name":"name","default_value":"\"id\"","external_name":"name","restriction":""},{"name":"type","default_value":":bigserial","external_name":"type","restriction":""}],"args_string":"(name = \"id\", type = :bigserial)","args_html":"(name = "id", type = :bigserial)","location":{"filename":"src/clear/model/modules/has_serial_pkey.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_serial_pkey.cr#L11"},"def":{"name":"primary_key","args":[{"name":"name","default_value":"\"id\"","external_name":"name","restriction":""},{"name":"type","default_value":":bigserial","external_name":"type","restriction":""}],"visibility":"Public","body":" \n# Transform symbols to string\n\n \n{% name = \"#{name.id}\"\ntype = \"#{type.id}\"\n %}\n\n\n \n{% cb = PKEY_TYPE[type] %}\n\n\n \n{% if cb %}\n {{ (cb.gsub(/__name__/, name)).id }}\n {% else %}\n {% raise(\"Cannot define primary key of type #{type}. Candidates are: #{PKEY_TYPE.keys.join(\", \")}\") %}\n {% end %}\n\n \n"}}]},{"html_id":"clear/Clear/Model/HasTimestamps","path":"Clear/Model/HasTimestamps.html","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps","abstract":false,"locations":[{"filename":"src/clear/model/modules/has_timestamps.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_timestamps.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"macros":[{"html_id":"timestamps-macro","name":"timestamps","doc":"Generate the columns `updated_at` and `created_at`\nThe two column values are automatically set during insertion\n or update of the model.","summary":"Generate the columns updated_at
and created_at
The two column values are automatically set during insertion or update of the model.
Add validation error related to a specific column
","abstract":false,"args":[{"name":"column","external_name":"column","restriction":""},{"name":"reason","external_name":"reason","restriction":""}],"args_string":"(column, reason)","args_html":"(column, reason)","location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L15"},"def":{"name":"add_error","args":[{"name":"column","external_name":"column","restriction":""},{"name":"reason","external_name":"reason","restriction":""}],"visibility":"Public","body":"@errors << Error.new(reason: reason, column: column.to_s)"}},{"html_id":"add_error(reason)-instance-method","name":"add_error","doc":"Add validation error not related to a specific column","summary":"Add validation error not related to a specific column
","abstract":false,"args":[{"name":"reason","external_name":"reason","restriction":""}],"args_string":"(reason)","args_html":"(reason)","location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L10"},"def":{"name":"add_error","args":[{"name":"reason","external_name":"reason","restriction":""}],"visibility":"Public","body":"@errors << Error.new(reason: reason, column: nil)"}},{"html_id":"clear_errors-instance-method","name":"clear_errors","doc":"Clear the errors log (if any) of the model and return itself","summary":"Clear the errors log (if any) of the model and return itself
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L26"},"def":{"name":"clear_errors","visibility":"Public","body":"@errors.clear\nself\n"}},{"html_id":"error?-instance-method","name":"error?","doc":"Return `true` if saving has been declined because of validation issues.\nThe error list can be found by calling `Clear::Model#errors`","summary":"Return true
if saving has been declined because of validation issues.
List of errors raised during validation, in case the model hasn't been saved properly.
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L7"},"def":{"name":"errors","return_type":"Array(Error)","visibility":"Public","body":"@errors"}},{"html_id":"print_errors-instance-method","name":"print_errors","doc":"Print the errors in string. Useful for debugging or simple error handling.","summary":"Print the errors in string.
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L33"},"def":{"name":"print_errors","visibility":"Public","body":"@errors.group_by(&.column).to_a.sort do |__temp_92, __temp_93|\n f1, _ = __temp_92\n f2, _ = __temp_93\n (f1 || \"\") <=> (f2 || \"\")\nend.join(\"\\n\") do |column, errors|\n [column, errors.join(\", \", &.reason)].compact.join(\": \")\nend"}},{"html_id":"valid!-instance-method","name":"valid!","doc":"Check whether the model is valid. If not, raise `InvalidModelError`.\nReturn the model itself","summary":"Check whether the model is valid.
","abstract":false,"location":{"filename":"src/clear/model/modules/has_validation.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/has_validation.cr#L47"},"def":{"name":"valid!","visibility":"Public","body":"if valid?\nelse\n raise(InvalidError.new(self))\nend\nself\n"}},{"html_id":"valid?-instance-method","name":"valid?","doc":"Return `true` if the model","summary":"Return true
if the model
This method is called whenever #valid?
or save
is called.
This module declare all the methods and macro related to deserializing json in Clear::Model
The Clear::Model::QueryCache is a fire-and-forget cache used when caching associations and preventing N+1 queries anti-pattern.
","instance_methods":[{"html_id":"active(relation_name)-instance-method","name":"active","doc":"Tell this cache than we active the cache over a specific relation name.\nReturns `self`","summary":"Tell this cache than we active the cache over a specific relation name.
","abstract":false,"args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"args_string":"(relation_name)","args_html":"(relation_name)","location":{"filename":"src/clear/model/query_cache.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L28"},"def":{"name":"active","args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"visibility":"Public","body":"@cache_activation.add(relation_name)\nself\n"}},{"html_id":"active?(relation_name)-instance-method","name":"active?","doc":"Check whether the cache is active on a certain association.\nReturns `true` if `relation_name` is flagged as encached, or `false` otherwise.","summary":"Check whether the cache is active on a certain association.
","abstract":false,"args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"args_string":"(relation_name)","args_html":"(relation_name)","location":{"filename":"src/clear/model/query_cache.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L36"},"def":{"name":"active?","args":[{"name":"relation_name","external_name":"relation_name","restriction":""}],"visibility":"Public","body":"@cache_activation.includes?(relation_name)"}},{"html_id":"clear-instance-method","name":"clear","doc":"Empty the cache and flag all relations has unactive","summary":"Empty the cache and flag all relations has unactive
","abstract":false,"location":{"filename":"src/clear/model/query_cache.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L70"},"def":{"name":"clear","visibility":"Public","body":"@cache.clear\n@cache_activation.clear\n"}},{"html_id":"fetch-instance-method","name":"fetch","abstract":false,"location":{"filename":"src/clear/model/query_cache.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L22"},"def":{"name":"fetch","visibility":"Public","body":"query"}},{"html_id":"hit(relation_name,relation_value,klass:T.class):Array(T)forallT-instance-method","name":"hit","doc":"Try to hit the cache. If an array is found, it will be returned.\nOtherwise, empty array is returned.\n\nThis methods do not check if a relation flagged as is actively cached or not. Therefore, hitting a non-cached\nrelation will return always an empty-array.","summary":"Try to hit the cache.
","abstract":false,"args":[{"name":"relation_name","external_name":"relation_name","restriction":""},{"name":"relation_value","external_name":"relation_value","restriction":""},{"name":"klass","external_name":"klass","restriction":"T.class"}],"args_string":"(relation_name, relation_value, klass : T.class) : Array(T) forall T","args_html":"(relation_name, relation_value, klass : T.class) : Array(T) forall T","location":{"filename":"src/clear/model/query_cache.cr","line_number":45,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L45"},"def":{"name":"hit","args":[{"name":"relation_name","external_name":"relation_name","restriction":""},{"name":"relation_value","external_name":"relation_value","restriction":""},{"name":"klass","external_name":"klass","restriction":"T.class"}],"return_type":"Array(T)","visibility":"Public","body":"(@cache.fetch(CacheKey.new(relation_name, relation_value, T.name)) do\n [] of T\nend).unsafe_as(Array(T))"}},{"html_id":"set(relation_name,relation_value,arr:Array(T))forallT-instance-method","name":"set","doc":"Set the cached array for a specific key `{relation_name,relation_value}`","summary":"Set the cached array for a specific key {relation_name,relation_value}
Perform some operations with the cache then eventually clear the cache.
","abstract":false,"location":{"filename":"src/clear/model/query_cache.cr","line_number":63,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/query_cache.cr#L63"},"def":{"name":"with_cache","yields":0,"block_arity":0,"visibility":"Public","body":"begin\n yield\nensure\n clear\nend"}}]},{"html_id":"clear/Clear/Model/ReadOnlyError","path":"Clear/Model/ReadOnlyError.html","kind":"class","full_name":"Clear::Model::ReadOnlyError","name":"ReadOnlyError","abstract":false,"superclass":{"html_id":"clear/Clear/Model/Error","kind":"class","full_name":"Clear::Model::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/Model/Error","kind":"class","full_name":"Clear::Model::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/errors.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L12"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},"constructors":[{"html_id":"new(model:Clear::Model)-class-method","name":"new","abstract":false,"args":[{"name":"model","external_name":"model","restriction":"Clear::Model"}],"args_string":"(model : Clear::Model)","args_html":"(model : Clear::Model)","location":{"filename":"src/clear/model/errors.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L15"},"def":{"name":"new","args":[{"name":"model","external_name":"model","restriction":"Clear::Model"}],"visibility":"Public","body":"_ = allocate\n_.initialize(model)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"model:Clear::Model-instance-method","name":"model","abstract":false,"location":{"filename":"src/clear/model/errors.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/errors.cr#L13"},"def":{"name":"model","return_type":"Clear::Model","visibility":"Public","body":"@model"}}]},{"html_id":"clear/Clear/Model/Relations","path":"Clear/Model/Relations.html","kind":"module","full_name":"Clear::Model::Relations","name":"Relations","abstract":false,"locations":[{"filename":"src/clear/model/modules/relations/belongs_to_macro.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/modules/relations/belongs_to_macro.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}}]},{"html_id":"clear/Clear/Reflection","path":"Clear/Reflection.html","kind":"module","full_name":"Clear::Reflection","name":"Reflection","abstract":false,"locations":[{"filename":"src/clear/model/reflection/column.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"types":[{"html_id":"clear/Clear/Reflection/Column","path":"Clear/Reflection/Column.html","kind":"class","full_name":"Clear::Reflection::Column","name":"Column","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Validation/Helper","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/column.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"COLUMNS","name":"COLUMNS","value":"{\"table_catalog\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_catalog\", crystal_variable_name: table_catalog, presence: true, mass_assign: true}, \"table_schema\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_schema\", crystal_variable_name: table_schema, presence: true, mass_assign: true}, \"table_name\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_name\", crystal_variable_name: table_name, presence: false, mass_assign: true}, \"column_name\" => {type: String, primary: true, converter: \"String\", db_column_name: \"column_name\", crystal_variable_name: column_name, presence: true, mass_assign: true}} of Nil => Nil"},{"id":"POLYMORPHISM_SETTINGS","name":"POLYMORPHISM_SETTINGS","value":"{} of Nil => Nil"}],"included_modules":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"extended_modules":[{"html_id":"clear/Clear/Model/HasHooks/ClassMethods","kind":"module","full_name":"Clear::Model::HasHooks::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"clear/Clear/Reflection","kind":"module","full_name":"Clear::Reflection","name":"Reflection"},"doc":"Reflection of the columns using information_schema in postgreSQL.\nTODO: Usage of view instead of model","summary":"Reflection of the columns using information_schema in postgreSQL.
","class_methods":[{"html_id":"build(**tuple:**T)forallT-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":"**T"},"visibility":"Public","body":"{% if T.size > 0 %}\n self.new(tuple)\n {% else %}\n self.new\n {% end %}"}},{"html_id":"build(**tuple)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"build(**tuple) do\nend"}},{"html_id":"build(**tuple,&)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"visibility":"Public","body":"r = build(**tuple)\nyield(r)\nr\n"}},{"html_id":"columns-class-method","name":"columns","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"columns","visibility":"Public","body":"@@columns"}},{"html_id":"connection:String-class-method","name":"connection","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"def":{"name":"connection","return_type":"String","visibility":"Public","body":"@@connection"}},{"html_id":"connection=(connection:String)-class-method","name":"connection=","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":"String"}],"args_string":"(connection : String)","args_html":"(connection : String)","def":{"name":"connection=","args":[{"name":"connection","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"@@connection = connection"}},{"html_id":"create_from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json","doc":"Create a new model from json and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"mdl = self.from_json(string_or_io, trusted)\nmdl.save\nmdl\n"}},{"html_id":"create_from_json!(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json!","doc":"Create a new model from json and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json!","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(self.from_json(string_or_io, trusted)).save!"}},{"html_id":"find(x)-class-method","name":"find","doc":"Returns a model using primary key equality\nReturns `nil` if not found.","summary":"Returns a model using primary key equality Returns nil
if not found.
Returns a model using primary key equality.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"find!","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"(find(x)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"from_json","doc":"Create a new empty model and fill the columns from json. Returns the new model\n\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new empty model and fill the columns from json.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).create(trusted)"}},{"html_id":"full_table_name-class-method","name":"full_table_name","doc":"returns the fully qualified and escaped name for this table.\nadd schema if schema is different from 'public' (default schema)\n\nex: \"schema\".\"table\"","summary":"returns the fully qualified and escaped name for this table.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"full_table_name","visibility":"Public","body":"if s = schema\n {schema, table}.map do |x|\n Clear::SQL.escape(x.to_s)\n end.join(\".\")\nelse\n Clear::SQL.escape(table)\nend"}},{"html_id":"import(array:Enumerable(self),on_conflict:Clear::SQL::InsertQuery->|Nil=nil)-class-method","name":"import","doc":"Import a bulk of models in one SQL insert query.\nEach model must be non-persisted.\n\n`on_conflict` callback can be optionnaly turned on\nto manage constraints of the database.\n\nNote: Old models are not modified. This method return a copy of the\nmodels as saved in the database.\n\n## Example:\n\n```\nusers = [User.new(id: 1), User.new(id: 2), User.new(id: 3)]\nusers = User.import(users)\n```","summary":"Import a bulk of models in one SQL insert query.
","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"args_string":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","args_html":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"import","args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"visibility":"Public","body":"array.each do |item|\n if item.persisted?\n raise(\"One of your model is persisted while calling import\")\n end\nend\nhashes = array.map do |item|\n item.trigger_before_events(:save)\n if item.valid?\n else\n raise(\"import: Validation failed for `#{item}`\")\n end\n item.trigger_before_events(:create)\n item.to_h\nend\nquery = (Clear::SQL.insert_into(self.table, hashes)).returning(\"*\")\nif on_conflict\n on_conflict.call(query)\nend\no = [] of self\nquery.fetch(@@connection) do |hash|\n o << ((Clear::Model::Factory.build(self.name, hash, persisted: true, fetch_columns: false, cache: nil)).as(self))\nend\no.each(&.trigger_after_events(:create))\no.each(&.trigger_after_events(:save))\no\n"}},{"html_id":"polymorphic?:Bool-class-method","name":"polymorphic?","abstract":false,"def":{"name":"polymorphic?","return_type":"Bool","visibility":"Public","body":"@@polymorphic"}},{"html_id":"query-class-method","name":"query","doc":"Return a new empty query `SELECT * FROM [my_model_table]`. Can be refined after that.","summary":"Return a new empty query SELECT * FROM [my_model_table]
.
Define the current schema used in PostgreSQL.
","abstract":false,"def":{"name":"schema","return_type":"Clear::SQL::Symbolic | ::Nil","visibility":"Public","body":"@@schema"}},{"html_id":"schema=(schema:Clear::SQL::Symbolic|Nil)-class-method","name":"schema=","doc":"Define the current schema used in PostgreSQL. The value is `nil` by default, which lead to non-specified\n schema during the querying, and usage of \"public\" by PostgreSQL.\n\nThis property can be redefined on initialization. Example:\n\n```\nclass MyModel\n include Clear::Model\n\n self.schema = \"my_schema\"\nend\nMyModel.query.to_sql # SELECT * FROM \"my_schema\".\"my_models\"\n```","summary":"Define the current schema used in PostgreSQL.
","abstract":false,"args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"args_string":"(schema : Clear::SQL::Symbolic | Nil)","args_html":"(schema : Clear::SQL::Symbolic | Nil)","def":{"name":"schema=","args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"visibility":"Public","body":"@@schema = schema"}},{"html_id":"table:Clear::SQL::Symbolic-class-method","name":"table","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"def":{"name":"table","return_type":"Clear::SQL::Symbolic","visibility":"Public","body":"@@table"}},{"html_id":"table=(table:Clear::SQL::Symbolic)-class-method","name":"table=","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"args_string":"(table : Clear::SQL::Symbolic)","args_html":"(table : Clear::SQL::Symbolic)","def":{"name":"table=","args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"visibility":"Public","body":"@@table = table"}}],"constructors":[{"html_id":"build(x:NamedTuple):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"build(**x) do\nend"}},{"html_id":"build(x:NamedTuple,&block:self->Nil):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"build(**x, &block)"}},{"html_id":"create(x:NamedTuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create(**tuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save\nr\n"}},{"html_id":"create(x:NamedTuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create(**x) do\nend"}},{"html_id":"create(**tuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create(**tuple) do\nend"}},{"html_id":"create!(x:NamedTuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create!(**x, &block)"}},{"html_id":"create!(**tuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"create!(x:NamedTuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create!(**x) do\nend"}},{"html_id":"create!(**tuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create!(**tuple) do\nend"}},{"html_id":"new(h:Hash(String,_),cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false)-class-method","name":"new","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","args_html":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(h, cache, persisted, fetch_columns)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(json:JSON::Any,cache:Clear::Model::QueryCache|Nil=nil,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","args_html":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(json, cache, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(t:NamedTuple,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(t : NamedTuple, persisted = false)","args_html":"(t : NamedTuple, persisted = false)","location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(t, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"_cached_table:Clear::Reflection::Table|Nil-instance-method","name":"_cached_table","abstract":false,"def":{"name":"_cached_table","return_type":"Clear::Reflection::Table | ::Nil","visibility":"Public","body":"@_cached_table"}},{"html_id":"attributes:Hash(String,Clear::SQL::Any)-instance-method","name":"attributes","doc":"Attributes, used when fetch_columns is true","summary":"Attributes, used when fetch_columns is true
","abstract":false,"def":{"name":"attributes","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"@attributes"}},{"html_id":"cache:Clear::Model::QueryCache|Nil-instance-method","name":"cache","abstract":false,"def":{"name":"cache","return_type":"Clear::Model::QueryCache | ::Nil","visibility":"Public","body":"@cache"}},{"html_id":"changed?-instance-method","name":"changed?","doc":"Return `true` if the model is dirty (e.g. one or more fields\n have been changed.). Return `false` otherwise.","summary":"Return true
if the model is dirty (e.g.
Reset the #changed?
flag on all columns
Returns the value of #column_name
column or throw an exception if the column is not defined.
Setter for #column_name
column.
Returns the column object used to manage #column_name
field
Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:\\{{settings[:db_column_name]}}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(h:Hash(String,_))-instance-method","name":"reset","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(t:NamedTuple)-instance-method","name":"reset","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"reset","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"reset(**t)"}},{"html_id":"reset(from_json:JSON::Any)-instance-method","name":"reset","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"reset","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"reset(from_json.as_h)"}},{"html_id":"reset(**t:**T)forallT-instance-method","name":"reset","doc":"reset flavors","summary":"reset flavors
","abstract":false,"def":{"name":"reset","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n\n {% if settings = COLUMNS[\"#{name}\"] %}\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"Cannot find the column `#{name}` of the model `#{@type}`\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(Symbol,_))-instance-method","name":"set","doc":"Set the columns from hash","summary":"Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:{{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(String,_))-instance-method","name":"set","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(t:NamedTuple)-instance-method","name":"set","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"set","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"set(**t)"}},{"html_id":"set(from_json:JSON::Any)-instance-method","name":"set","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"set","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"set(from_json.as_h)"}},{"html_id":"set(**t:**T)forallT-instance-method","name":"set","doc":"Set one or multiple columns to a specific value\nThis two are equivalents:\n\n```\nmodel.set(a: 1)\nmodel.a = 1\n```","summary":"Set one or multiple columns to a specific value This two are equivalents:
","abstract":false,"def":{"name":"set","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n {% if settings = COLUMNS[\"#{name}\".id] %}\n @{{ settings[:crystal_variable_name] }}_column.set_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"No method #{@type}##{name}= while trying to set value of #{name}\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"set_from_json","doc":"Set the fields from json passed as argument\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument Trusted flag set to true will allow mass assignment without protection, FALSE by default
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"set_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).update(self, trusted)"}},{"html_id":"table:Clear::Reflection::Table-instance-method","name":"table","doc":"The method table is a `belongs_to` relation to Clear::Reflection::Table","summary":"The method table is a belongs_to
relation to Clear::Reflection::Table
Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Setter for #table_name
column.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Setter for #table_schema
column.
Returns the column object used to manage #table_schema
field
Return a hash version of the columns of this model.
","abstract":false,"args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"args_string":"(full = false) : Hash(String, Clear::SQL::Any)","args_html":"(full = false) : Hash(String, Clear::SQL::Any)","def":{"name":"to_h","args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"out = super(full)\nif full || @table_catalog_column.defined?\n out[\"table_catalog\"] = @table_catalog_column.to_sql_value(nil)\nend\nif full || @table_schema_column.defined?\n out[\"table_schema\"] = @table_schema_column.to_sql_value(nil)\nend\nif full || @table_name_column.defined?\n out[\"table_name\"] = @table_name_column.to_sql_value(nil)\nend\nif full || @column_name_column.defined?\n out[\"column_name\"] = @column_name_column.to_sql_value(nil)\nend\nout\n"}},{"html_id":"to_json(emit_nulls:Bool=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"args_string":"(emit_nulls : Bool = false)","args_html":"(emit_nulls : Bool = false)","def":{"name":"to_json","args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"visibility":"Public","body":"JSON.build do |json|\n to_json(json, emit_nulls)\nend"}},{"html_id":"to_json(json,emit_nulls=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"args_string":"(json, emit_nulls = false)","args_html":"(json, emit_nulls = false)","def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"visibility":"Public","body":"json.object do\n if emit_nulls || @table_catalog_column.defined?\n json.field(\"table_catalog\") do\n (@table_catalog_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_schema_column.defined?\n json.field(\"table_schema\") do\n (@table_schema_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_name_column.defined?\n json.field(\"table_name\") do\n (@table_name_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @column_name_column.defined?\n json.field(\"column_name\") do\n (@column_name_column.value(nil)).to_json(json)\n end\n end\nend"}},{"html_id":"update_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"update_from_json","doc":"Set the fields from json passed as argument and call `save` on the object\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument and call save
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
","abstract":false,"def":{"name":"update_h","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"o = super()\nif @table_catalog_column.defined? && @table_catalog_column.changed?\n o[\"table_catalog\"] = @table_catalog_column.to_sql_value\nend\nif @table_schema_column.defined? && @table_schema_column.changed?\n o[\"table_schema\"] = @table_schema_column.to_sql_value\nend\nif @table_name_column.defined? && @table_name_column.changed?\n o[\"table_name\"] = @table_name_column.to_sql_value\nend\nif @column_name_column.defined? && @column_name_column.changed?\n o[\"column_name\"] = @column_name_column.to_sql_value\nend\no\n"}},{"html_id":"validate_fields_presence-instance-method","name":"validate_fields_presence","doc":"For each column, ensure than when needed the column has present\ninformation into it.\n\nThis method is called on validation.","summary":"For each column, ensure than when needed the column has present information into it.
","abstract":false,"def":{"name":"validate_fields_presence","visibility":"Public","body":"if persisted?\nelse\n if @table_catalog_column.failed_to_be_present?\n add_error(\"table_catalog\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_schema_column.failed_to_be_present?\n add_error(\"table_schema\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_name_column.failed_to_be_present?\n add_error(\"table_name\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @column_name_column.failed_to_be_present?\n add_error(\"column_name\", \"must be present\")\n end\nend\n"}}],"types":[{"html_id":"clear/Clear/Reflection/Column/Collection","path":"Clear/Reflection/Column/Collection.html","kind":"class","full_name":"Clear::Reflection::Column::Collection","name":"Collection","abstract":false,"superclass":{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},"ancestors":[{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/column.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/column.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Reflection/Column","kind":"class","full_name":"Clear::Reflection::Column","name":"Column"},"doc":":doc:\nClear::Model::Collection\n\nThis is the object managing a `SELECT` request.\nA new collection is created by calling `Clear::Model.query`\n\nCollection are mutable and refining the SQL will mutate the collection.\nYou may want to copy the collection by calling `dup`\n\nSee `Clear::Model::CollectionBase`","summary":":doc: Clear::Model::Collection
","instance_methods":[{"html_id":"with_table(fetch_columns=false,&block:Clear::Reflection::Table::Collection->):self-instance-method","name":"with_table","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self","args_html":"(fetch_columns = false, &block : Clear::Reflection::Table::Collection -> ) : self","def":{"name":"with_table","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Reflection::Table::Collection ->)"},"return_type":"self","visibility":"Public","body":"before_query do\n sub_query = self.dup.clear_select.select(\"#{Clear::Reflection::Column.table}.table_name\")\n cached_qry = Clear::Reflection::Table.query.where do\n (raw(\"#{Clear::Reflection::Table.table}.#{Clear::Reflection::Table.__pkey__}\")).in?(sub_query)\n end\n block.call(cached_qry)\n @cache.active(\"table\")\n cached_qry.each(fetch_columns: fetch_columns) do |mdl|\n @cache.set(\"table\", mdl.__pkey__, [mdl])\n end\nend\nself\n"}},{"html_id":"with_table(fetch_columns=false):self-instance-method","name":"with_table","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false) : self","args_html":"(fetch_columns = false) : self","def":{"name":"with_table","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"return_type":"self","visibility":"Public","body":"with_table(fetch_columns) do\nend\nself\n"}}]}]},{"html_id":"clear/Clear/Reflection/Table","path":"Clear/Reflection/Table.html","kind":"class","full_name":"Clear::Reflection::Table","name":"Table","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"},{"html_id":"clear/Clear/Model/FullTextSearchable","kind":"module","full_name":"Clear::Model::FullTextSearchable","name":"FullTextSearchable"},{"html_id":"clear/Clear/Model/JSONDeserialize","kind":"module","full_name":"Clear::Model::JSONDeserialize","name":"JSONDeserialize"},{"html_id":"clear/Clear/Model/Initializer","kind":"module","full_name":"Clear::Model::Initializer","name":"Initializer"},{"html_id":"clear/Clear/Model/HasFactory","kind":"module","full_name":"Clear::Model::HasFactory","name":"HasFactory"},{"html_id":"clear/Clear/Model/ClassMethods","kind":"module","full_name":"Clear::Model::ClassMethods","name":"ClassMethods"},{"html_id":"clear/Clear/Model/HasScope","kind":"module","full_name":"Clear::Model::HasScope","name":"HasScope"},{"html_id":"clear/Clear/Model/HasRelations","kind":"module","full_name":"Clear::Model::HasRelations","name":"HasRelations"},{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"},{"html_id":"clear/Clear/Validation/Helper","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper"},{"html_id":"clear/Clear/Model/HasSaving","kind":"module","full_name":"Clear::Model::HasSaving","name":"HasSaving"},{"html_id":"clear/Clear/Model/HasSerialPkey","kind":"module","full_name":"Clear::Model::HasSerialPkey","name":"HasSerialPkey"},{"html_id":"clear/Clear/Model/HasTimestamps","kind":"module","full_name":"Clear::Model::HasTimestamps","name":"HasTimestamps"},{"html_id":"clear/Clear/Model/HasColumns","kind":"module","full_name":"Clear::Model::HasColumns","name":"HasColumns"},{"html_id":"clear/Clear/Model/HasHooks","kind":"module","full_name":"Clear::Model::HasHooks","name":"HasHooks"},{"html_id":"clear/Clear/Model/Connection","kind":"module","full_name":"Clear::Model::Connection","name":"Connection"},{"html_id":"clear/Clear/ErrorMessages","kind":"module","full_name":"Clear::ErrorMessages","name":"ErrorMessages"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/table.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"COLUMNS","name":"COLUMNS","value":"{\"table_catalog\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_catalog\", crystal_variable_name: table_catalog, presence: true, mass_assign: true}, \"table_schema\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_schema\", crystal_variable_name: table_schema, presence: true, mass_assign: true}, \"table_name\" => {type: String, primary: true, converter: \"String\", db_column_name: \"table_name\", crystal_variable_name: table_name, presence: true, mass_assign: true}, \"table_type\" => {type: String, primary: false, converter: \"String\", db_column_name: \"table_type\", crystal_variable_name: table_type, presence: true, mass_assign: true}} of Nil => Nil"},{"id":"POLYMORPHISM_SETTINGS","name":"POLYMORPHISM_SETTINGS","value":"{} of Nil => Nil"}],"included_modules":[{"html_id":"clear/Clear/Model","kind":"module","full_name":"Clear::Model","name":"Model"}],"extended_modules":[{"html_id":"clear/Clear/Model/HasHooks/ClassMethods","kind":"module","full_name":"Clear::Model::HasHooks::ClassMethods","name":"ClassMethods"}],"namespace":{"html_id":"clear/Clear/Reflection","kind":"module","full_name":"Clear::Reflection","name":"Reflection"},"doc":"Reflection of the tables using information_schema in postgreSQL.\nTODO: Usage of view instead of model","summary":"Reflection of the tables using information_schema in postgreSQL.
","class_methods":[{"html_id":"build(**tuple:**T)forallT-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":"**T"},"visibility":"Public","body":"{% if T.size > 0 %}\n self.new(tuple)\n {% else %}\n self.new\n {% end %}"}},{"html_id":"build(**tuple)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"build(**tuple) do\nend"}},{"html_id":"build(**tuple,&)-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"visibility":"Public","body":"r = build(**tuple)\nyield(r)\nr\n"}},{"html_id":"columns-class-method","name":"columns","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"columns","visibility":"Public","body":"@@columns"}},{"html_id":"connection:String-class-method","name":"connection","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"def":{"name":"connection","return_type":"String","visibility":"Public","body":"@@connection"}},{"html_id":"connection=(connection:String)-class-method","name":"connection=","doc":"Define on which connection the model is living. Useful in case of models living in different databases.\n\nIs set to \"default\" by default.\n\nSee `Clear::SQL#init(URI, *opts)` for more information about multi-connections.\n\nExample:\n\n```\nClear::SQL.init(\"postgres://postgres@localhost/database_1\")\nClear::SQL.init(\"secondary\", \"postgres://postgres@localhost/database_2\")\n\nclass ModelA\n include Clear::Model\n\n # Performs all the queries on `database_1`\n # self.connection = \"default\"\n column id : Int32, primary: true, presence: false\n column title : String\nend\n\nclass ModelB\n include Clear::Model\n\n # Performs all the queries on `database_2`\n self.connection = \"secondary\"\n\n column id : Int32, primary: true, presence: false\nend\n```","summary":"Define on which connection the model is living.
","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":"String"}],"args_string":"(connection : String)","args_html":"(connection : String)","def":{"name":"connection=","args":[{"name":"connection","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"@@connection = connection"}},{"html_id":"create_from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json","doc":"Create a new model from json and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"mdl = self.from_json(string_or_io, trusted)\nmdl.save\nmdl\n"}},{"html_id":"create_from_json!(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"create_from_json!","doc":"Create a new model from json and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new model from json and save it.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"create_from_json!","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(self.from_json(string_or_io, trusted)).save!"}},{"html_id":"find(x)-class-method","name":"find","doc":"Returns a model using primary key equality\nReturns `nil` if not found.","summary":"Returns a model using primary key equality Returns nil
if not found.
Returns a model using primary key equality.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"find!","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"(find(x)) || (raise(Clear::SQL::RecordNotFoundError.new))"}},{"html_id":"from_json(string_or_io:String|IO,trusted:Bool=false)-class-method","name":"from_json","doc":"Create a new empty model and fill the columns from json. Returns the new model\n\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Create a new empty model and fill the columns from json.
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).create(trusted)"}},{"html_id":"full_table_name-class-method","name":"full_table_name","doc":"returns the fully qualified and escaped name for this table.\nadd schema if schema is different from 'public' (default schema)\n\nex: \"schema\".\"table\"","summary":"returns the fully qualified and escaped name for this table.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"full_table_name","visibility":"Public","body":"if s = schema\n {schema, table}.map do |x|\n Clear::SQL.escape(x.to_s)\n end.join(\".\")\nelse\n Clear::SQL.escape(table)\nend"}},{"html_id":"import(array:Enumerable(self),on_conflict:Clear::SQL::InsertQuery->|Nil=nil)-class-method","name":"import","doc":"Import a bulk of models in one SQL insert query.\nEach model must be non-persisted.\n\n`on_conflict` callback can be optionnaly turned on\nto manage constraints of the database.\n\nNote: Old models are not modified. This method return a copy of the\nmodels as saved in the database.\n\n## Example:\n\n```\nusers = [User.new(id: 1), User.new(id: 2), User.new(id: 3)]\nusers = User.import(users)\n```","summary":"Import a bulk of models in one SQL insert query.
","abstract":false,"args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"args_string":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","args_html":"(array : Enumerable(self), on_conflict : Clear::SQL::InsertQuery -> | Nil = nil)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"import","args":[{"name":"array","external_name":"array","restriction":"Enumerable(self)"},{"name":"on_conflict","default_value":"nil","external_name":"on_conflict","restriction":"(Clear::SQL::InsertQuery ->) | ::Nil"}],"visibility":"Public","body":"array.each do |item|\n if item.persisted?\n raise(\"One of your model is persisted while calling import\")\n end\nend\nhashes = array.map do |item|\n item.trigger_before_events(:save)\n if item.valid?\n else\n raise(\"import: Validation failed for `#{item}`\")\n end\n item.trigger_before_events(:create)\n item.to_h\nend\nquery = (Clear::SQL.insert_into(self.table, hashes)).returning(\"*\")\nif on_conflict\n on_conflict.call(query)\nend\no = [] of self\nquery.fetch(@@connection) do |hash|\n o << ((Clear::Model::Factory.build(self.name, hash, persisted: true, fetch_columns: false, cache: nil)).as(self))\nend\no.each(&.trigger_after_events(:create))\no.each(&.trigger_after_events(:save))\no\n"}},{"html_id":"polymorphic?:Bool-class-method","name":"polymorphic?","abstract":false,"def":{"name":"polymorphic?","return_type":"Bool","visibility":"Public","body":"@@polymorphic"}},{"html_id":"public-class-method","name":"public","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L16"},"def":{"name":"public","visibility":"Public","body":"query.public()"}},{"html_id":"query-class-method","name":"query","doc":"Return a new empty query `SELECT * FROM [my_model_table]`. Can be refined after that.","summary":"Return a new empty query SELECT * FROM [my_model_table]
.
Define the current schema used in PostgreSQL.
","abstract":false,"def":{"name":"schema","return_type":"Clear::SQL::Symbolic | ::Nil","visibility":"Public","body":"@@schema"}},{"html_id":"schema=(schema:Clear::SQL::Symbolic|Nil)-class-method","name":"schema=","doc":"Define the current schema used in PostgreSQL. The value is `nil` by default, which lead to non-specified\n schema during the querying, and usage of \"public\" by PostgreSQL.\n\nThis property can be redefined on initialization. Example:\n\n```\nclass MyModel\n include Clear::Model\n\n self.schema = \"my_schema\"\nend\nMyModel.query.to_sql # SELECT * FROM \"my_schema\".\"my_models\"\n```","summary":"Define the current schema used in PostgreSQL.
","abstract":false,"args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"args_string":"(schema : Clear::SQL::Symbolic | Nil)","args_html":"(schema : Clear::SQL::Symbolic | Nil)","def":{"name":"schema=","args":[{"name":"schema","external_name":"schema","restriction":"Clear::SQL::Symbolic | ::Nil"}],"visibility":"Public","body":"@@schema = schema"}},{"html_id":"table:Clear::SQL::Symbolic-class-method","name":"table","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"def":{"name":"table","return_type":"Clear::SQL::Symbolic","visibility":"Public","body":"@@table"}},{"html_id":"table=(table:Clear::SQL::Symbolic)-class-method","name":"table=","doc":"Return the table name setup for this model.\nBy convention, the class name is by default equals to the pluralized underscored string form of the model name.\nExample:\n\n```\nMyModel => \"my_models\"\nPerson => \"people\"\nProject::Info => \"project_infos\"\n```\n\nThe property can be updated at initialization to a custom table name:\n\n```\nclass MyModel\n include Clear::Model\n\n self.table = \"another_table_name\"\nend\nMyModel.query.to_sql # SELECT * FROM \"another_table_name\"\n```","summary":"Return the table name setup for this model.
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"args_string":"(table : Clear::SQL::Symbolic)","args_html":"(table : Clear::SQL::Symbolic)","def":{"name":"table=","args":[{"name":"table","external_name":"table","restriction":"Clear::SQL::Symbolic"}],"visibility":"Public","body":"@@table = table"}},{"html_id":"tables_only-class-method","name":"tables_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L18"},"def":{"name":"tables_only","visibility":"Public","body":"query.tables_only()"}},{"html_id":"views_only-class-method","name":"views_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L19"},"def":{"name":"views_only","visibility":"Public","body":"query.views_only()"}}],"constructors":[{"html_id":"build(x:NamedTuple):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"build(**x) do\nend"}},{"html_id":"build(x:NamedTuple,&block:self->Nil):self-class-method","name":"build","doc":"Build a new empty model and fill the columns using the NamedTuple in argument.\n\nReturns the new model","summary":"Build a new empty model and fill the columns using the NamedTuple in argument.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"build","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"build(**x, &block)"}},{"html_id":"create(x:NamedTuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create(**x, &block)"}},{"html_id":"create(**tuple,&block:self->Nil):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save\nr\n"}},{"html_id":"create(x:NamedTuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create(**x) do\nend"}},{"html_id":"create(**tuple):self-class-method","name":"create","doc":"Build and new model and save it. Returns the model.\n\nThe model may not be saved due to validation failure;\ncheck the returned model `errors?` and `persisted?` flags.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create(**tuple) do\nend"}},{"html_id":"create!(x:NamedTuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple, &block : self -> Nil) : self","args_html":"(x : NamedTuple, &block : self -> Nil) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"create!(**x, &block)"}},{"html_id":"create!(**tuple,&block:self->Nil):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(self -> Nil)"},"return_type":"self","visibility":"Public","body":"r = build(**tuple) do |mdl|\n yield(mdl)\nend\nr.save!\nr\n"}},{"html_id":"create!(x:NamedTuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"args_string":"(x : NamedTuple) : self","args_html":"(x : NamedTuple) : self","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","args":[{"name":"x","external_name":"x","restriction":"NamedTuple"}],"return_type":"self","visibility":"Public","body":"create!(**x) do\nend"}},{"html_id":"create!(**tuple):self-class-method","name":"create!","doc":"Build and new model and save it. Returns the model.\n\nReturns the newly inserted model\nRaises an exception if validation failed during the saving process.","summary":"Build and new model and save it.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"create!","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"return_type":"self","visibility":"Public","body":"create!(**tuple) do\nend"}},{"html_id":"new(h:Hash(String,_),cache:Clear::Model::QueryCache|Nil=nil,persisted=false,fetch_columns=false)-class-method","name":"new","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","args_html":"(h : Hash(String, _), cache : Clear::Model::QueryCache | Nil = nil, persisted = false, fetch_columns = false)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""},{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(h, cache, persisted, fetch_columns)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(json:JSON::Any,cache:Clear::Model::QueryCache|Nil=nil,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","args_html":"(json : JSON::Any, cache : Clear::Model::QueryCache | Nil = nil, persisted = false)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","args":[{"name":"json","external_name":"json","restriction":"::JSON::Any"},{"name":"cache","default_value":"nil","external_name":"cache","restriction":"Clear::Model::QueryCache | ::Nil"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(json, cache, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(t:NamedTuple,persisted=false)-class-method","name":"new","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"args_string":"(t : NamedTuple, persisted = false)","args_html":"(t : NamedTuple, persisted = false)","location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"},{"name":"persisted","default_value":"false","external_name":"persisted","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(t, persisted)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"attributes:Hash(String,Clear::SQL::Any)-instance-method","name":"attributes","doc":"Attributes, used when fetch_columns is true","summary":"Attributes, used when fetch_columns is true
","abstract":false,"def":{"name":"attributes","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"@attributes"}},{"html_id":"cache:Clear::Model::QueryCache|Nil-instance-method","name":"cache","abstract":false,"def":{"name":"cache","return_type":"Clear::Model::QueryCache | ::Nil","visibility":"Public","body":"@cache"}},{"html_id":"changed?-instance-method","name":"changed?","doc":"Return `true` if the model is dirty (e.g. one or more fields\n have been changed.). Return `false` otherwise.","summary":"Return true
if the model is dirty (e.g.
Reset the #changed?
flag on all columns
The method columns is a has_many
relation to Clear::Reflection::Column
List all the indexes related to the current table.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L27"},"def":{"name":"indexes","return_type":"Hash(String, Array(String))","visibility":"Public","body":"o = {} of String => Array(String)\n((((SQL.select({index_name: \"i.relname\", column_name: \"a.attname\"})).from({t: \"pg_class\", i: \"pg_class\", ix: \"pg_index\", a: \"pg_attribute\"})).where do\n (((((t.oid == ix.indrelid) & (i.oid == ix.indexrelid)) & (a.attrelid == t.oid)) & (a.attnum == (raw(\"ANY(ix.indkey)\")))) & (t.relkind == \"r\")) & (t.relname == self.table_name)\nend.order_by(\"t.relname\")).order_by(\"i.relname\")).fetch do |h|\n col = h[\"column_name\"].to_s\n v = h[\"index_name\"].to_s\n arr = o[col]? ? o[col] : (o[col] = [] of String)\n arr << v\nend\no\n"}},{"html_id":"invalidate_caching:self-instance-method","name":"invalidate_caching","doc":"Force to clean-up the caches for the relations\nconnected to this model.","summary":"Force to clean-up the caches for the relations connected to this model.
","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},"def":{"name":"invalidate_caching","return_type":"self","visibility":"Public","body":"@cache = nil\nself\n"}},{"html_id":"reset(h:Hash(Symbol,_))-instance-method","name":"reset","doc":"Set the columns from hash","summary":"Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:\\{{settings[:db_column_name]}}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(h:Hash(String,_))-instance-method","name":"reset","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"reset","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"reset(t:NamedTuple)-instance-method","name":"reset","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"reset","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"reset(**t)"}},{"html_id":"reset(from_json:JSON::Any)-instance-method","name":"reset","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"reset","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"reset(from_json.as_h)"}},{"html_id":"reset(**t:**T)forallT-instance-method","name":"reset","doc":"reset flavors","summary":"reset flavors
","abstract":false,"def":{"name":"reset","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n\n {% if settings = COLUMNS[\"#{name}\"] %}\n @{{ settings[:crystal_variable_name] }}_column.reset_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"Cannot find the column `#{name}` of the model `#{@type}`\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(Symbol,_))-instance-method","name":"set","doc":"Set the columns from hash","summary":"Set the columns from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"args_string":"(h : Hash(Symbol, _))","args_html":"(h : Hash(Symbol, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(Symbol, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch(:{{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(h:Hash(String,_))-instance-method","name":"set","doc":"Set the model fields from hash","summary":"Set the model fields from hash
","abstract":false,"args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"args_string":"(h : Hash(String, _))","args_html":"(h : Hash(String, _))","def":{"name":"set","args":[{"name":"h","external_name":"h","restriction":"Hash(String, _)"}],"visibility":"Public","body":"super(h)\n{% for name, settings in COLUMNS %}\n v = h.fetch({{ settings[:db_column_name] }}) { Clear::Model::Column::UNKNOWN }\n @{{ settings[:crystal_variable_name] }}_column.set_convert(v) unless v.is_a?(Clear::Model::Column::UnknownClass)\n {% end %}\nself\n"}},{"html_id":"set(t:NamedTuple)-instance-method","name":"set","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"args_string":"(t : NamedTuple)","args_html":"(t : NamedTuple)","def":{"name":"set","args":[{"name":"t","external_name":"t","restriction":"NamedTuple"}],"visibility":"Public","body":"set(**t)"}},{"html_id":"set(from_json:JSON::Any)-instance-method","name":"set","abstract":false,"args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"args_string":"(from_json : JSON::Any)","args_html":"(from_json : JSON::Any)","def":{"name":"set","args":[{"name":"from_json","external_name":"from_json","restriction":"JSON::Any"}],"visibility":"Public","body":"set(from_json.as_h)"}},{"html_id":"set(**t:**T)forallT-instance-method","name":"set","doc":"Set one or multiple columns to a specific value\nThis two are equivalents:\n\n```\nmodel.set(a: 1)\nmodel.a = 1\n```","summary":"Set one or multiple columns to a specific value This two are equivalents:
","abstract":false,"def":{"name":"set","double_splat":{"name":"t","external_name":"t","restriction":"**T"},"visibility":"Public","body":"super(**t)\n{% for name, typ in T %}\n {% if settings = COLUMNS[\"#{name}\".id] %}\n @{{ settings[:crystal_variable_name] }}_column.set_convert(t[:{{ name }}])\n {% else %}\n {% if !(@type.has_method?(\"#{name}=\")) %}\n {% raise(\"No method #{@type}##{name}= while trying to set value of #{name}\") %}\n {% end %}\n self.{{ name }} = t[:{{ name }}]\n {% end %}\n {% end %}\nself\n"}},{"html_id":"set_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"set_from_json","doc":"Set the fields from json passed as argument\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument Trusted flag set to true will allow mass assignment without protection, FALSE by default
","abstract":false,"args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"args_string":"(string_or_io : String | IO, trusted : Bool = false)","args_html":"(string_or_io : String | IO, trusted : Bool = false)","def":{"name":"set_from_json","args":[{"name":"string_or_io","external_name":"string_or_io","restriction":"String | IO"},{"name":"trusted","default_value":"false","external_name":"trusted","restriction":"Bool"}],"visibility":"Public","body":"(Assigner.from_json(string_or_io)).update(self, trusted)"}},{"html_id":"table_catalog:String-instance-method","name":"table_catalog","doc":"Returns the value of `table_catalog` column or throw an exception if the column is not defined.","summary":"Returns the value of #table_catalog
column or throw an exception if the column is not defined.
Setter for #table_catalog
column.
Returns the column object used to manage #table_catalog
field
Returns the value of #table_name
column or throw an exception if the column is not defined.
Setter for #table_name
column.
Returns the column object used to manage #table_name
field
Returns the value of #table_schema
column or throw an exception if the column is not defined.
Setter for #table_schema
column.
Returns the column object used to manage #table_schema
field
Returns the value of #table_type
column or throw an exception if the column is not defined.
Setter for #table_type
column.
Returns the column object used to manage #table_type
field
Return a hash version of the columns of this model.
","abstract":false,"args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"args_string":"(full = false) : Hash(String, Clear::SQL::Any)","args_html":"(full = false) : Hash(String, Clear::SQL::Any)","def":{"name":"to_h","args":[{"name":"full","default_value":"false","external_name":"full","restriction":""}],"return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"out = super(full)\nif full || @table_catalog_column.defined?\n out[\"table_catalog\"] = @table_catalog_column.to_sql_value(nil)\nend\nif full || @table_schema_column.defined?\n out[\"table_schema\"] = @table_schema_column.to_sql_value(nil)\nend\nif full || @table_name_column.defined?\n out[\"table_name\"] = @table_name_column.to_sql_value(nil)\nend\nif full || @table_type_column.defined?\n out[\"table_type\"] = @table_type_column.to_sql_value(nil)\nend\nout\n"}},{"html_id":"to_json(emit_nulls:Bool=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"args_string":"(emit_nulls : Bool = false)","args_html":"(emit_nulls : Bool = false)","def":{"name":"to_json","args":[{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":"Bool"}],"visibility":"Public","body":"JSON.build do |json|\n to_json(json, emit_nulls)\nend"}},{"html_id":"to_json(json,emit_nulls=false)-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"args_string":"(json, emit_nulls = false)","args_html":"(json, emit_nulls = false)","def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":""},{"name":"emit_nulls","default_value":"false","external_name":"emit_nulls","restriction":""}],"visibility":"Public","body":"json.object do\n if emit_nulls || @table_catalog_column.defined?\n json.field(\"table_catalog\") do\n (@table_catalog_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_schema_column.defined?\n json.field(\"table_schema\") do\n (@table_schema_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_name_column.defined?\n json.field(\"table_name\") do\n (@table_name_column.value(nil)).to_json(json)\n end\n end\n if emit_nulls || @table_type_column.defined?\n json.field(\"table_type\") do\n (@table_type_column.value(nil)).to_json(json)\n end\n end\nend"}},{"html_id":"update_from_json(string_or_io:String|IO,trusted:Bool=false)-instance-method","name":"update_from_json","doc":"Set the fields from json passed as argument and call `save` on the object\nTrusted flag set to true will allow mass assignment without protection, FALSE by default","summary":"Set the fields from json passed as argument and call save
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Set the fields from json passed as argument and call save!
on the object Trusted flag set to true will allow mass assignment without protection, FALSE by default
Generate the hash for update request (like during save)
","abstract":false,"def":{"name":"update_h","return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"o = super()\nif @table_catalog_column.defined? && @table_catalog_column.changed?\n o[\"table_catalog\"] = @table_catalog_column.to_sql_value\nend\nif @table_schema_column.defined? && @table_schema_column.changed?\n o[\"table_schema\"] = @table_schema_column.to_sql_value\nend\nif @table_name_column.defined? && @table_name_column.changed?\n o[\"table_name\"] = @table_name_column.to_sql_value\nend\nif @table_type_column.defined? && @table_type_column.changed?\n o[\"table_type\"] = @table_type_column.to_sql_value\nend\no\n"}},{"html_id":"validate_fields_presence-instance-method","name":"validate_fields_presence","doc":"For each column, ensure than when needed the column has present\ninformation into it.\n\nThis method is called on validation.","summary":"For each column, ensure than when needed the column has present information into it.
","abstract":false,"def":{"name":"validate_fields_presence","visibility":"Public","body":"if persisted?\nelse\n if @table_catalog_column.failed_to_be_present?\n add_error(\"table_catalog\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_schema_column.failed_to_be_present?\n add_error(\"table_schema\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_name_column.failed_to_be_present?\n add_error(\"table_name\", \"must be present\")\n end\nend\nif persisted?\nelse\n if @table_type_column.failed_to_be_present?\n add_error(\"table_type\", \"must be present\")\n end\nend\n"}}],"types":[{"html_id":"clear/Clear/Reflection/Table/Collection","path":"Clear/Reflection/Table/Collection.html","kind":"class","full_name":"Clear::Reflection::Table::Collection","name":"Collection","abstract":false,"superclass":{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},"ancestors":[{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase","name":"CollectionBase"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/model/reflection/table.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L4"},{"filename":"src/clear/model/reflection/table.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L16"},{"filename":"src/clear/model/reflection/table.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L18"},{"filename":"src/clear/model/reflection/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L19"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/Reflection/Table","kind":"class","full_name":"Clear::Reflection::Table","name":"Table"},"doc":"Addition of the method for eager loading and N+1 avoidance.","summary":"Addition of the method for eager loading and N+1 avoidance.
","instance_methods":[{"html_id":"public-instance-method","name":"public","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L16"},"def":{"name":"public","visibility":"Public","body":"where do\n table_schema == \"public\"\nend\nreturn self\n"}},{"html_id":"tables_only-instance-method","name":"tables_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L18"},"def":{"name":"tables_only","visibility":"Public","body":"where do\n table_type == \"BASE TABLE\"\nend\nreturn self\n"}},{"html_id":"views_only-instance-method","name":"views_only","abstract":false,"location":{"filename":"src/clear/model/reflection/table.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/reflection/table.cr#L19"},"def":{"name":"views_only","visibility":"Public","body":"where do\n table_type == \"VIEW\"\nend\nreturn self\n"}},{"html_id":"with_columns(fetch_columns=false,&block:Clear::Reflection::Column::Collection->):self-instance-method","name":"with_columns","doc":"Eager load the has many relation columns.\nUse it to avoid N+1 queries.","summary":"Eager load the has many relation columns.
","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false, &block : Clear::Reflection::Column::Collection -> ) : self","args_html":"(fetch_columns = false, &block : Clear::Reflection::Column::Collection -> ) : self","def":{"name":"with_columns","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(Clear::Reflection::Column::Collection ->)"},"return_type":"self","visibility":"Public","body":"before_query do\n __temp_99 = table_name\n __temp_100 = \"table_name\"\n sub_query = self.dup.clear_select.select(\"#{Clear::Reflection::Table.table}.#{__temp_99}\")\n qry = Clear::Reflection::Column.query.where do\n (raw(__temp_100)).in?(sub_query)\n end\n block.call(qry)\n @cache.active(\"columns\")\n h = {} of Clear::SQL::Any => Array(Clear::Reflection::Column)\n qry.each(fetch_columns: true) do |mdl|\n if h[mdl.attributes[__temp_100]]?\n else\n h[mdl.attributes[__temp_100]] = [] of Clear::Reflection::Column\n end\n h[mdl.attributes[__temp_100]] << mdl\n end\n h.each do |key, value|\n @cache.set(\"columns\", key, value)\n end\nend\nself\n"}},{"html_id":"with_columns(fetch_columns=false)-instance-method","name":"with_columns","abstract":false,"args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"args_string":"(fetch_columns = false)","args_html":"(fetch_columns = false)","def":{"name":"with_columns","args":[{"name":"fetch_columns","default_value":"false","external_name":"fetch_columns","restriction":""}],"visibility":"Public","body":"with_columns(fetch_columns) do\nend"}}]}]}]},{"html_id":"clear/Clear/SQL","path":"Clear/SQL.html","kind":"module","full_name":"Clear::SQL","name":"SQL","abstract":false,"ancestors":[{"html_id":"clear/Clear/SQL/Transaction","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction"},{"html_id":"clear/Clear/SQL/Logger","kind":"module","full_name":"Clear::SQL::Logger","name":"Logger"}],"locations":[{"filename":"src/clear/sql/connection_pool.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L1"},{"filename":"src/clear/sql/errors.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L1"},{"filename":"src/clear/sql/fragment/column.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L9"},{"filename":"src/clear/sql/fragment/fragment.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L1"},{"filename":"src/clear/sql/fragment/from.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L3"},{"filename":"src/clear/sql/fragment/join.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L3"},{"filename":"src/clear/sql/lock.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/lock.cr#L2"},{"filename":"src/clear/sql/query/connection.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/connection.cr#L1"},{"filename":"src/clear/sql/query/from.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L1"},{"filename":"src/clear/sql/sql.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L50"},{"filename":"src/clear/sql/truncate.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/truncate.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Logger","kind":"module","full_name":"Clear::SQL::Logger","name":"Logger"},{"html_id":"clear/Clear/SQL/Transaction","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction"}],"extended_modules":[{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"\n## Clear::SQL\n\nClear is made like an onion:\n\n```\n+------------------------------------+\n| THE ORM STACK +\n+------------------------------------+\n| Model | DB Views | Migrations | < High Level Tools\n+---------------+--------------------+\n| Columns | Validation | Converters | < Mapping system\n+---------------+--------------------+\n| Clear::SQL | Clear::Expression | < Low Level SQL Builder\n+------------------------------------+\n| Crystal DB | Crystal PG | < Low Level connection\n+------------------------------------+\n```\n\nOn the bottom stack, Clear offer SQL query building.\nTheses features are then used by top level parts of the engine.\n\nThe SQL module provide a simple API to generate `delete`, `insert`, `select`\nand `update` methods.\n\nEach requests can be duplicated then modified and executed.\n\nNote: Each request object is mutable. Therefore, to update and store a request,\nyou must use manually the `dup` method.\n","summary":"Lock completetly a table.
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"String | Symbol"},{"name":"mode","default_value":"\"ACCESS EXCLUSIVE\"","external_name":"mode","restriction":""},{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":""}],"args_string":"(table : String | Symbol, mode = \"ACCESS EXCLUSIVE\", connection = \"default\", &)","args_html":"(table : String | Symbol, mode = "ACCESS EXCLUSIVE", connection = "default", &)","location":{"filename":"src/clear/sql/lock.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/lock.cr#L23"},"def":{"name":"lock","args":[{"name":"table","external_name":"table","restriction":"String | Symbol"},{"name":"mode","default_value":"\"ACCESS EXCLUSIVE\"","external_name":"mode","restriction":""},{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":""}],"yields":1,"block_arity":1,"visibility":"Public","body":"Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|\n transaction do\n execute(\"LOCK TABLE #{table} IN #{mode} MODE\")\n return yield(cnx)\n end\nend"}},{"html_id":"truncate(tablename:Clear::Model.class|String|Symbol,restart_sequence:Bool=false,cascade:Bool=false,truncate_inherited:Bool=true,connection_name:String=\"default\")forallT-class-method","name":"truncate","doc":"Truncate a table or a model\n\n```\nUser.query.count # => 200\nClear::SQL.truncate(User) # equivalent to Clear::SQL.truncate(User.table, connection_name: User.connection)\nUser.query.count # => 0\n```\n\nSEE https://www.postgresql.org/docs/current/sql-truncate.html\nfor more information.\n\n- `restart_sequence` set to true will append `RESTART IDENTITY` to the query\n- `cascade` set to true will append `CASCADE` to the query\n- `truncate_inherited` set to false will append `ONLY` to the query\n- `connection_name` will be: `Model.connection` or `default` unless optionally defined.","summary":"Truncate a table or a model
","abstract":false,"args":[{"name":"tablename","external_name":"tablename","restriction":"Clear::Model.class | String | Symbol"},{"name":"restart_sequence","default_value":"false","external_name":"restart_sequence","restriction":"Bool"},{"name":"cascade","default_value":"false","external_name":"cascade","restriction":"Bool"},{"name":"truncate_inherited","default_value":"true","external_name":"truncate_inherited","restriction":"Bool"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(tablename : Clear::Model.class | String | Symbol, restart_sequence : Bool = false, cascade : Bool = false, truncate_inherited : Bool = true, connection_name : String = \"default\") forall T","args_html":"(tablename : Clear::Model.class | String | Symbol, restart_sequence : Bool = false, cascade : Bool = false, truncate_inherited : Bool = true, connection_name : String = "default") forall T","location":{"filename":"src/clear/sql/truncate.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/truncate.cr#L18"},"def":{"name":"truncate","args":[{"name":"tablename","external_name":"tablename","restriction":"Clear::Model.class | String | Symbol"},{"name":"restart_sequence","default_value":"false","external_name":"restart_sequence","restriction":"Bool"},{"name":"cascade","default_value":"false","external_name":"cascade","restriction":"Bool"},{"name":"truncate_inherited","default_value":"true","external_name":"truncate_inherited","restriction":"Bool"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"visibility":"Public","body":"case tablename\nwhen String\nwhen Symbol\n tablename = Clear::SQL.escape(tablename.to_s)\nelse\n connection_name = tablename.connection\n tablename = tablename.full_table_name\nend\nonly = truncate_inherited ? \"\" : \" ONLY \"\nrestart_sequence = restart_sequence ? \" RESTART IDENTITY \" : \"\"\ncascade = cascade ? \" CASCADE \" : \"\"\nexecute(connection_name, {\"TRUNCATE TABLE \", only, tablename, restart_sequence, cascade}.join)\n"}}],"instance_methods":[{"html_id":"add_connection(name:String,url:String)-instance-method","name":"add_connection","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"args_string":"(name : String, url : String)","args_html":"(name : String, url : String)","location":{"filename":"src/clear/sql/sql.cr","line_number":125,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L125"},"def":{"name":"add_connection","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.init(url, name)"}},{"html_id":"delete(table:Symbolic)-instance-method","name":"delete","doc":"Start a DELETE table query","summary":"Start a DELETE table query
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"args_string":"(table : Symbolic)","args_html":"(table : Symbolic)","location":{"filename":"src/clear/sql/sql.cr","line_number":185,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L185"},"def":{"name":"delete","args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"visibility":"Public","body":"Clear::SQL::DeleteQuery.new.from(table)"}},{"html_id":"escape(x:String|Symbol)-instance-method","name":"escape","doc":"Escape the expression, double quoting it.\n\nIt allows use of reserved keywords as table or column name\nNOTE: Escape is used for escaping postgresql keyword. For example\nif you have a column named order (which is a reserved word), you want\nto escape it by double-quoting it.\n\nFor escaping STRING value, please use Clear::SQL.sanitize","summary":"Escape the expression, double quoting it.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"String | Symbol"}],"args_string":"(x : String | Symbol)","args_html":"(x : String | Symbol)","location":{"filename":"src/clear/sql/sql.cr","line_number":103,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L103"},"def":{"name":"escape","args":[{"name":"x","external_name":"x","restriction":"String | Symbol"}],"visibility":"Public","body":"(\"\\\"\" + (x.to_s.gsub(\"\\\"\", \"\\\"\\\"\"))) + \"\\\"\""}},{"html_id":"execute(connection_name:String,sql)-instance-method","name":"execute","doc":"Execute a SQL statement on a specific connection.\n\nUsage:\nClear::SQL.execute(\"seconddatabase\", \"SELECT 1 FROM users\")","summary":"Execute a SQL statement on a specific connection.
","abstract":false,"args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"},{"name":"sql","external_name":"sql","restriction":""}],"args_string":"(connection_name : String, sql)","args_html":"(connection_name : String, sql)","location":{"filename":"src/clear/sql/sql.cr","line_number":175,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L175"},"def":{"name":"execute","args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"},{"name":"sql","external_name":"sql","restriction":""}],"visibility":"Public","body":"log_query(sql) do\n Clear::SQL::ConnectionPool.with_connection(connection_name, &.exec_all(sql))\nend"}},{"html_id":"execute(sql)-instance-method","name":"execute","doc":"Execute a SQL statement.\n\nUsage:\nClear::SQL.execute(\"SELECT 1 FROM users\")\n","summary":"Execute a SQL statement.
","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":""}],"args_string":"(sql)","args_html":"(sql)","location":{"filename":"src/clear/sql/sql.cr","line_number":167,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L167"},"def":{"name":"execute","args":[{"name":"sql","external_name":"sql","restriction":""}],"visibility":"Public","body":"execute(\"default\", sql)"}},{"html_id":"init(name:String,url:String)-instance-method","name":"init","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"args_string":"(name : String, url : String)","args_html":"(name : String, url : String)","location":{"filename":"src/clear/sql/sql.cr","line_number":115,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L115"},"def":{"name":"init","args":[{"name":"name","external_name":"name","restriction":"String"},{"name":"url","external_name":"url","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.init(url, name)"}},{"html_id":"init(url:String)-instance-method","name":"init","abstract":false,"args":[{"name":"url","external_name":"url","restriction":"String"}],"args_string":"(url : String)","args_html":"(url : String)","location":{"filename":"src/clear/sql/sql.cr","line_number":111,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L111"},"def":{"name":"init","args":[{"name":"url","external_name":"url","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.init(url, \"default\")"}},{"html_id":"init(connections:Hash(Symbolic,String))-instance-method","name":"init","abstract":false,"args":[{"name":"connections","external_name":"connections","restriction":"Hash(Symbolic, String)"}],"args_string":"(connections : Hash(Symbolic, String))","args_html":"(connections : Hash(Symbolic, String))","location":{"filename":"src/clear/sql/sql.cr","line_number":119,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L119"},"def":{"name":"init","args":[{"name":"connections","external_name":"connections","restriction":"Hash(Symbolic, String)"}],"visibility":"Public","body":"connections.each do |name, url|\n Clear::SQL::ConnectionPool.init(url, name)\nend"}},{"html_id":"insert(table,args:NamedTuple)-instance-method","name":"insert","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""},{"name":"args","external_name":"args","restriction":"NamedTuple"}],"args_string":"(table, args : NamedTuple)","args_html":"(table, args : NamedTuple)","location":{"filename":"src/clear/sql/sql.cr","line_number":214,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L214"},"def":{"name":"insert","args":[{"name":"table","external_name":"table","restriction":""},{"name":"args","external_name":"args","restriction":"NamedTuple"}],"visibility":"Public","body":"insert_into(table, args)"}},{"html_id":"insert(table,*args)-instance-method","name":"insert","doc":"Alias of `insert_into`, for hurry developers","summary":"Alias of #insert_into
, for hurry developers
Create a new INSERT query
","abstract":false,"location":{"filename":"src/clear/sql/sql.cr","line_number":205,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L205"},"def":{"name":"insert","visibility":"Public","body":"Clear::SQL::InsertQuery.new"}},{"html_id":"insert_into(table:Symbolic)-instance-method","name":"insert_into","doc":"Prepare a new INSERT INTO table query\n:ditto:","summary":"Prepare a new INSERT INTO table query :ditto:
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"args_string":"(table : Symbolic)","args_html":"(table : Symbolic)","location":{"filename":"src/clear/sql/sql.cr","line_number":200,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L200"},"def":{"name":"insert_into","args":[{"name":"table","external_name":"table","restriction":"Symbolic"}],"visibility":"Public","body":"Clear::SQL::InsertQuery.new(table)"}},{"html_id":"insert_into(table:Symbolic,*args)-instance-method","name":"insert_into","doc":"Start an INSERT INTO table query\n\n```\nClear::SQL.insert_into(\"table\", {id: 1, name: \"hello\"}, {id: 2, name: \"World\"})\n```","summary":"Start an INSERT INTO table query
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbolic"},{"name":"args","external_name":"args","restriction":""}],"args_string":"(table : Symbolic, *args)","args_html":"(table : Symbolic, *args)","location":{"filename":"src/clear/sql/sql.cr","line_number":194,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L194"},"def":{"name":"insert_into","args":[{"name":"table","external_name":"table","restriction":"Symbolic"},{"name":"args","external_name":"args","restriction":""}],"splat_index":1,"visibility":"Public","body":"(Clear::SQL::InsertQuery.new(table)).values(*args)"}},{"html_id":"raw(x,*params)-instance-method","name":"raw","doc":"This provide a fast way to create SQL fragment while escaping items, both with `?` and `:key` system:\n\n```\nquery = Mode.query.select(Clear::SQL.raw(\"CASE WHEN x=:x THEN 1 ELSE 0 END as check\", x: \"blabla\"))\nquery = Mode.query.select(Clear::SQL.raw(\"CASE WHEN x=? THEN 1 ELSE 0 END as check\", \"blabla\"))\n```","summary":"This provide a fast way to create SQL fragment while escaping items, both with ?
and :key
system:
See self.raw
Can pass an array to this version
Raise a rollback, in case of transaction
","abstract":false,"location":{"filename":"src/clear/sql/sql.cr","line_number":158,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L158"},"def":{"name":"rollback","visibility":"Public","body":"raise(RollbackError.new)"}},{"html_id":"sanitize(x)-instance-method","name":"sanitize","doc":"Sanitize string and convert some literals (e.g. `Time`)","summary":"Sanitize string and convert some literals (e.g.
","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/sql/sql.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L71"},"def":{"name":"sanitize","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"Clear::Expression[x]"}},{"html_id":"select(*args)-instance-method","name":"select","doc":"Start a SELECT FROM table query","summary":"Start a SELECT FROM table query
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/sql.cr","line_number":224,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L224"},"def":{"name":"select","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"if args.size > 0\n Clear::SQL::SelectQuery.new.select(*args)\nelse\n Clear::SQL::SelectQuery.new\nend"}},{"html_id":"unsafe(x)-instance-method","name":"unsafe","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x)","args_html":"(x)","location":{"filename":"src/clear/sql/sql.cr","line_number":107,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L107"},"def":{"name":"unsafe","args":[{"name":"x","external_name":"x","restriction":""}],"visibility":"Public","body":"Clear::Expression::UnsafeSql.new(x)"}},{"html_id":"update(table)-instance-method","name":"update","doc":"Start a UPDATE table query","summary":"Start a UPDATE table query
","abstract":false,"args":[{"name":"table","external_name":"table","restriction":""}],"args_string":"(table)","args_html":"(table)","location":{"filename":"src/clear/sql/sql.cr","line_number":219,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L219"},"def":{"name":"update","args":[{"name":"table","external_name":"table","restriction":""}],"visibility":"Public","body":"Clear::SQL::UpdateQuery.new(table)"}},{"html_id":"with_savepoint(connection_name=\"default\",&)-instance-method","name":"with_savepoint","doc":"Create a transaction, but this one is stackable\nusing savepoints.\n\nExample:\n\n```\nClear::SQL.with_savepoint do\n # do something\n Clear::SQL.with_savepoint do\n rollback # < Rollback only the last `with_savepoint` block\n end\nend\n```","summary":"Create a transaction, but this one is stackable using savepoints.
","abstract":false,"args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":""}],"args_string":"(connection_name = \"default\", &)","args_html":"(connection_name = "default", &)","location":{"filename":"src/clear/sql/sql.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L144"},"def":{"name":"with_savepoint","args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"transaction do |cnx|\n sp_name = \"sp_#{@@savepoint_uid = @@savepoint_uid + 1}\"\n begin\n execute(connection_name, \"SAVEPOINT #{sp_name}\")\n yield\n if cnx._clear_in_transaction?\n execute(connection_name, \"RELEASE SAVEPOINT #{sp_name}\")\n end\n rescue e : RollbackError\n if cnx._clear_in_transaction?\n execute(connection_name, \"ROLLBACK TO SAVEPOINT #{sp_name}\")\n end\n end\nend"}}],"types":[{"html_id":"clear/Clear/SQL/Any","path":"Clear/SQL/Any.html","kind":"alias","full_name":"Clear::SQL::Any","name":"Any","abstract":false,"locations":[{"filename":"src/clear/sql/sql.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L56"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil)","aliased_html":"Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/CancelTransactionError","path":"Clear/SQL/CancelTransactionError.html","kind":"class","full_name":"Clear::SQL::CancelTransactionError","name":"CancelTransactionError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L16"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"Like rollback, but used into savepoint, it will revert completely the transaction","summary":"Like rollback, but used into savepoint, it will revert completely the transaction
"},{"html_id":"clear/Clear/SQL/Column","path":"Clear/SQL/Column.html","kind":"struct","full_name":"Clear::SQL::Column","name":"Column","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},"ancestors":[{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/column.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L10"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(value:Clear::SQL::SelectBuilder|String|Symbol,var:String|Symbol|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"args_string":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","args_html":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","location":{"filename":"src/clear/sql/fragment/column.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L14"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value, var)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/fragment/column.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L17"},"def":{"name":"to_sql","visibility":"Public","body":"v = value\ncase v\nwhen String\n [v, @var].compact.join(\" AS \")\nwhen Symbol\n [SQL.escape(v.to_s), @var].compact.join(\" AS \")\nwhen SQL::SelectBuilder\n [\"( #{v.to_sql} )\", @var].compact.join(\" AS \")\nelse\n raise(QueryBuildingError.new(\"Only String and SelectQuery are allowed as column declaration\"))\nend\n"}},{"html_id":"value:Selectable-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/sql/fragment/column.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L11"},"def":{"name":"value","return_type":"Selectable","visibility":"Public","body":"@value"}},{"html_id":"value=(value:Selectable)-instance-method","name":"value=","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"args_string":"(value : Selectable)","args_html":"(value : Selectable)","location":{"filename":"src/clear/sql/fragment/column.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L11"},"def":{"name":"value=","args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"visibility":"Public","body":"@value = value"}},{"html_id":"var:Symbolic|Nil-instance-method","name":"var","abstract":false,"location":{"filename":"src/clear/sql/fragment/column.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L12"},"def":{"name":"var","return_type":"Symbolic | ::Nil","visibility":"Public","body":"@var"}},{"html_id":"var=(var:Symbolic|Nil)-instance-method","name":"var=","abstract":false,"args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"args_string":"(var : Symbolic | Nil)","args_html":"(var : Symbolic | Nil)","location":{"filename":"src/clear/sql/fragment/column.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/column.cr#L12"},"def":{"name":"var=","args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"visibility":"Public","body":"@var = var"}}]},{"html_id":"clear/Clear/SQL/ConnectionPool","path":"Clear/SQL/ConnectionPool.html","kind":"class","full_name":"Clear::SQL::ConnectionPool","name":"ConnectionPool","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/connection_pool.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"class_methods":[{"html_id":"init(uri,name)-class-method","name":"init","abstract":false,"args":[{"name":"uri","external_name":"uri","restriction":""},{"name":"name","external_name":"name","restriction":""}],"args_string":"(uri, name)","args_html":"(uri, name)","location":{"filename":"src/clear/sql/connection_pool.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L6"},"def":{"name":"init","args":[{"name":"uri","external_name":"uri","restriction":""},{"name":"name","external_name":"name","restriction":""}],"visibility":"Public","body":"@@databases[name] = DB.open(uri)"}},{"html_id":"with_connection(target:String,&)-class-method","name":"with_connection","doc":"Retrieve a connection from the connection pool, or wait for it.\nIf the current Fiber already has a connection, the connection is returned;\n this strategy provides easy usage of multiple statement connection (like BEGIN/ROLLBACK features).","summary":"Retrieve a connection from the connection pool, or wait for it.
","abstract":false,"args":[{"name":"target","external_name":"target","restriction":"String"}],"args_string":"(target : String, &)","args_html":"(target : String, &)","location":{"filename":"src/clear/sql/connection_pool.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/connection_pool.cr#L13"},"def":{"name":"with_connection","args":[{"name":"target","external_name":"target","restriction":"String"}],"yields":1,"block_arity":1,"visibility":"Public","body":"fiber_target = {target, Fiber.current}\ndatabase = @@databases.fetch(target) do\n raise(Clear::ErrorMessages.uninitialized_db_connection(target))\nend\ncnx = @@fiber_connections[fiber_target]?\nif cnx\n yield cnx\nelse\n database.using_connection do |new_connection|\n begin\n @@fiber_connections[fiber_target] = new_connection\n yield new_connection\n ensure\n @@fiber_connections.delete(fiber_target)\n end\n end\nend\n"}}]},{"html_id":"clear/Clear/SQL/DeleteQuery","path":"Clear/SQL/DeleteQuery.html","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/delete_query.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(table:String|Symbol|Nil=nil,wheres:Array(Clear::Expression::Node)=[]ofClear::Expression::Node)-class-method","name":"new","abstract":false,"args":[{"name":"table","default_value":"nil","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"args_string":"(table : String | Symbol | Nil = nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","args_html":"(table : String | Symbol | Nil = nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","location":{"filename":"src/clear/sql/delete_query.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L11"},"def":{"name":"new","args":[{"name":"table","default_value":"nil","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, wheres)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"from(table:String|Symbol|Nil)-instance-method","name":"from","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"}],"args_string":"(table : String | Symbol | Nil)","args_html":"(table : String | Symbol | Nil)","location":{"filename":"src/clear/sql/delete_query.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L14"},"def":{"name":"from","args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"}],"visibility":"Public","body":"@table = table\nchange!\n"}},{"html_id":"table:Symbolic|Nil-instance-method","name":"table","abstract":false,"location":{"filename":"src/clear/sql/delete_query.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L4"},"def":{"name":"table","return_type":"Symbolic | ::Nil","visibility":"Public","body":"@table"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/delete_query.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/delete_query.cr#L19"},"def":{"name":"to_sql","visibility":"Public","body":"if table = @table\nelse\n raise(Clear::ErrorMessages.query_building_error(\"Delete Query must have a `from` clause.\"))\nend\ntable = table.is_a?(Symbol) ? SQL.escape(table.to_s) : table\n[\"DELETE FROM\", table, print_wheres].compact.join(\" \")\n"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}]},{"html_id":"clear/Clear/SQL/Error","path":"Clear/SQL/Error.html","kind":"class","full_name":"Clear::SQL::Error","name":"Error","abstract":false,"superclass":{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"clear/Clear/SQL/CancelTransactionError","kind":"class","full_name":"Clear::SQL::CancelTransactionError","name":"CancelTransactionError"},{"html_id":"clear/Clear/SQL/ExecutionError","kind":"class","full_name":"Clear::SQL::ExecutionError","name":"ExecutionError"},{"html_id":"clear/Clear/SQL/OperationNotPermittedError","kind":"class","full_name":"Clear::SQL::OperationNotPermittedError","name":"OperationNotPermittedError"},{"html_id":"clear/Clear/SQL/QueryBuildingError","kind":"class","full_name":"Clear::SQL::QueryBuildingError","name":"QueryBuildingError"},{"html_id":"clear/Clear/SQL/RecordNotFoundError","kind":"class","full_name":"Clear::SQL::RecordNotFoundError","name":"RecordNotFoundError"},{"html_id":"clear/Clear/SQL/RollbackError","kind":"class","full_name":"Clear::SQL::RollbackError","name":"RollbackError"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/ExecutionError","path":"Clear/SQL/ExecutionError.html","kind":"class","full_name":"Clear::SQL::ExecutionError","name":"ExecutionError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/Fragment","path":"Clear/SQL/Fragment.html","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment","abstract":true,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/fragment.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"subclasses":[{"html_id":"clear/Clear/SQL/Column","kind":"struct","full_name":"Clear::SQL::Column","name":"Column"},{"html_id":"clear/Clear/SQL/From","kind":"struct","full_name":"Clear::SQL::From","name":"From"},{"html_id":"clear/Clear/SQL/Join","kind":"struct","full_name":"Clear::SQL::Join","name":"Join"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/sql/fragment/fragment.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L2"},"def":{"name":"new","visibility":"Public","body":"x = allocate\nif x.responds_to?(:finalize)\n ::GC.add_finalizer(x)\nend\nx\n"}}],"instance_methods":[{"html_id":"initialize-instance-method","name":"initialize","abstract":false,"location":{"filename":"src/clear/sql/fragment/fragment.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L2"},"def":{"name":"initialize","visibility":"Public","body":""}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":true,"location":{"filename":"src/clear/sql/fragment/fragment.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/fragment.cr#L3"},"def":{"name":"to_sql","visibility":"Public","body":""}}]},{"html_id":"clear/Clear/SQL/From","path":"Clear/SQL/From.html","kind":"struct","full_name":"Clear::SQL::From","name":"From","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},"ancestors":[{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/from.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(value:Clear::SQL::SelectBuilder|String|Symbol,var:String|Symbol|Nil=nil)-class-method","name":"new","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"args_string":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","args_html":"(value : Clear::SQL::SelectBuilder | String | Symbol, var : String | Symbol | Nil = nil)","location":{"filename":"src/clear/sql/fragment/from.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L8"},"def":{"name":"new","args":[{"name":"value","external_name":"value","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"var","default_value":"nil","external_name":"var","restriction":"::String | ::Symbol | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(value, var)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/fragment/from.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L11"},"def":{"name":"to_sql","visibility":"Public","body":"v = value\ncase v\nwhen Symbol\n [Clear::SQL.escape(v), @var].compact.join(\" AS \")\nwhen String\n [v, @var].compact.join(\" AS \")\nwhen SQL::SelectBuilder\n if @var.nil?\n raise(Clear::ErrorMessages.query_building_error(\"Subquery `from` clause must have variable name\"))\n end\n [\"(#{v.to_sql})\", @var].compact.join(\" \")\nelse\n raise(Clear::ErrorMessages.query_building_error(\"Only String and SelectQuery objects are allowed as `from` declaration\"))\nend\n"}},{"html_id":"value:Selectable-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/sql/fragment/from.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L5"},"def":{"name":"value","return_type":"Selectable","visibility":"Public","body":"@value"}},{"html_id":"value=(value:Selectable)-instance-method","name":"value=","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"args_string":"(value : Selectable)","args_html":"(value : Selectable)","location":{"filename":"src/clear/sql/fragment/from.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L5"},"def":{"name":"value=","args":[{"name":"value","external_name":"value","restriction":"Selectable"}],"visibility":"Public","body":"@value = value"}},{"html_id":"var:Symbolic|Nil-instance-method","name":"var","abstract":false,"location":{"filename":"src/clear/sql/fragment/from.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L6"},"def":{"name":"var","return_type":"Symbolic | ::Nil","visibility":"Public","body":"@var"}},{"html_id":"var=(var:Symbolic|Nil)-instance-method","name":"var=","abstract":false,"args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"args_string":"(var : Symbolic | Nil)","args_html":"(var : Symbolic | Nil)","location":{"filename":"src/clear/sql/fragment/from.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/from.cr#L6"},"def":{"name":"var=","args":[{"name":"var","external_name":"var","restriction":"Symbolic | ::Nil"}],"visibility":"Public","body":"@var = var"}}]},{"html_id":"clear/Clear/SQL/InsertQuery","path":"Clear/SQL/InsertQuery.html","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/OnConflict","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/insert_query.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L18"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/OnConflict","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"\nAn insert query\n\ncf. postgres documentation\n\n```\n[ WITH [ RECURSIVE ] with_query [, ...] ]\nINSERT INTO table_name [ AS alias ] [ ( column_name [, ...] ) ]\n { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) [, ...] | query }\n [ ON CONFLICT [ conflict_target ] conflict_action ]\n [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]\n```","summary":"An insert query
","constructors":[{"html_id":"new(table:Symbol|String,values)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbol | String"},{"name":"values","external_name":"values","restriction":""}],"args_string":"(table : Symbol | String, values)","args_html":"(table : Symbol | String, values)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L33"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"Symbol | String"},{"name":"values","external_name":"values","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, values)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(table:Symbol|String)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"args_string":"(table : Symbol | String)","args_html":"(table : Symbol | String)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L30"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clear_values-instance-method","name":"clear_values","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":85,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L85"},"def":{"name":"clear_values","visibility":"Public","body":"@values = [] of Array(Inserable)\nchange!\n"}},{"html_id":"columns(*args:Array(String|Symbol))-instance-method","name":"columns","doc":"Used with values","summary":"Used with values
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":"::Array(::String | ::Symbol)"}],"args_string":"(*args : Array(String | Symbol))","args_html":"(*args : Array(String | Symbol))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":138,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L138"},"def":{"name":"columns","args":[{"name":"args","external_name":"args","restriction":"::Array(::String | ::Symbol)"}],"splat_index":0,"visibility":"Public","body":"@keys = args\nchange!\n"}},{"html_id":"execute(connection_name:String=\"default\"):Hash(String,Clear::SQL::Any)-instance-method","name":"execute","abstract":false,"args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(connection_name : String = \"default\") : Hash(String, Clear::SQL::Any)","args_html":"(connection_name : String = "default") : Hash(String, Clear::SQL::Any)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L71"},"def":{"name":"execute","args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"return_type":"Hash(String, ::Clear::SQL::Any)","visibility":"Public","body":"o = {} of String => ::Clear::SQL::Any\nif @returning.nil?\n s = to_sql\n Clear::SQL.execute(connection_name, s)\nelse\n fetch(connection_name) do |x|\n o = x\n end\nend\no\n"}},{"html_id":"fetch(connection_name:String=\"default\",&:Hash(String,Clear::SQL::Any)->Nil)-instance-method","name":"fetch","abstract":false,"args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(connection_name : String = \"default\", & : Hash(String, Clear::SQL::Any) -> Nil)","args_html":"(connection_name : String = "default", & : Hash(String, Clear::SQL::Any) -> Nil)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L40"},"def":{"name":"fetch","args":[{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(Hash(String, ::Clear::SQL::Any) -> Nil)"},"visibility":"Public","body":"h = {} of String => ::Clear::SQL::Any\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n sql = to_sql\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n fetch_result_set(h, rs) do |x|\n yield(x)\n end\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"into(table:Symbol|String)-instance-method","name":"into","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"args_string":"(table : Symbol | String)","args_html":"(table : Symbol | String)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L37"},"def":{"name":"into","args":[{"name":"table","external_name":"table","restriction":"Symbol | String"}],"visibility":"Public","body":"@table = table"}},{"html_id":"keys:Array(Symbolic)-instance-method","name":"keys","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L25"},"def":{"name":"keys","return_type":"Array(Symbolic)","visibility":"Public","body":"@keys"}},{"html_id":"returning(str:String)-instance-method","name":"returning","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String)","args_html":"(str : String)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":161,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L161"},"def":{"name":"returning","args":[{"name":"str","external_name":"str","restriction":"String"}],"visibility":"Public","body":"@returning = str\nchange!\n"}},{"html_id":"returning:String|Nil-instance-method","name":"returning","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L28"},"def":{"name":"returning","return_type":"String | ::Nil","visibility":"Public","body":"@returning"}},{"html_id":"size:Int32-instance-method","name":"size","doc":"Number of rows of this insertion request","summary":"Number of rows of this insertion request
","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":168,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L168"},"def":{"name":"size","return_type":"Int32","visibility":"Public","body":"v = @values\nv.is_a?(Array) ? v.size : -1\n"}},{"html_id":"table:Symbol|String-instance-method","name":"table","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L27"},"def":{"name":"table","return_type":"Symbol | String","visibility":"Public","body":"if (__temp_1 = @table).nil?\n ::raise(::NilAssertionError.new(\"Clear::SQL::InsertQuery#table cannot be nil\"))\nelse\n __temp_1\nend"}},{"html_id":"table?:Symbol|String|Nil-instance-method","name":"table?","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":27,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L27"},"def":{"name":"table?","return_type":"Symbol | String | ::Nil","visibility":"Public","body":"@table"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":187,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L187"},"def":{"name":"to_sql","visibility":"Public","body":"if table = @table\nelse\n raise(QueryBuildingError.new(\"You must provide a `into` clause\"))\nend\ntable = table.is_a?(Symbol) ? Clear::SQL.escape(table) : table\no = [print_ctes, \"INSERT INTO\", table, print_keys]\nv = @values\ncase v\nwhen SelectBuilder\n o << ((\"(\" + v.to_sql) + \")\")\nelse\n if v.empty? || ((v.size == 1) && v[0].empty?)\n o << \"DEFAULT VALUES\"\n else\n o << \"VALUES\"\n o << print_values\n end\nend\nprint_on_conflict(o)\nif @returning\n o << \"RETURNING\"\n o << @returning\nend\no.compact.join(\" \")\n"}},{"html_id":"values(row:Hash(Symbolic,Inserable))-instance-method","name":"values","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"Hash(Symbolic, Inserable)"}],"args_string":"(row : Hash(Symbolic, Inserable))","args_html":"(row : Hash(Symbolic, Inserable))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L108"},"def":{"name":"values","args":[{"name":"row","external_name":"row","restriction":"Hash(Symbolic, Inserable)"}],"visibility":"Public","body":"@keys = row.keys.to_a.map() do |__arg3|\n __arg3.as(Symbolic)\nend\ncase v = @values\nwhen Array(Array(Inserable))\n v << row.values.to_a.map() do |__arg4|\n __arg4.as(Inserable)\n end\nelse\n raise(\"Cannot insert both from SELECT query and from data\")\nend\nchange!\n"}},{"html_id":"values(rows:Array(Hash(Symbolic,Inserable)))-instance-method","name":"values","abstract":false,"args":[{"name":"rows","external_name":"rows","restriction":"Array(Hash(Symbolic, Inserable))"}],"args_string":"(rows : Array(Hash(Symbolic, Inserable)))","args_html":"(rows : Array(Hash(Symbolic, Inserable)))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":129,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L129"},"def":{"name":"values","args":[{"name":"rows","external_name":"rows","restriction":"Array(Hash(Symbolic, Inserable))"}],"visibility":"Public","body":"rows.each do |nt|\n values(nt)\nend\nchange!\n"}},{"html_id":"values(row:NamedTuple)-instance-method","name":"values","doc":"Fast insert system\n\ninsert({field: \"value\"}).into(:table)\n","summary":"Fast insert system
","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"args_string":"(row : NamedTuple)","args_html":"(row : NamedTuple)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L95"},"def":{"name":"values","args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"visibility":"Public","body":"@keys = row.keys.to_a.map() do |__arg1|\n __arg1.as(Symbolic)\nend\ncase v = @values\nwhen Array(Array(Inserable))\n v << row.values.to_a.map() do |__arg2|\n __arg2.as(Inserable)\n end\nelse\n raise(\"Cannot insert both from SELECT query and from data\")\nend\nchange!\n"}},{"html_id":"values(rows:Array(NamedTuple))-instance-method","name":"values","abstract":false,"args":[{"name":"rows","external_name":"rows","restriction":"Array(NamedTuple)"}],"args_string":"(rows : Array(NamedTuple))","args_html":"(rows : Array(NamedTuple))","location":{"filename":"src/clear/sql/insert_query.cr","line_number":121,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L121"},"def":{"name":"values","args":[{"name":"rows","external_name":"rows","restriction":"Array(NamedTuple)"}],"visibility":"Public","body":"rows.each do |nt|\n values(nt)\nend\nchange!\n"}},{"html_id":"values(select_query:SelectBuilder)-instance-method","name":"values","doc":"Insert into ... (...) SELECT","summary":"Insert into ...
","abstract":false,"args":[{"name":"select_query","external_name":"select_query","restriction":"SelectBuilder"}],"args_string":"(select_query : SelectBuilder)","args_html":"(select_query : SelectBuilder)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":151,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L151"},"def":{"name":"values","args":[{"name":"select_query","external_name":"select_query","restriction":"SelectBuilder"}],"visibility":"Public","body":"if @values.is_a?(Array) && (@values.as(Array)).present?\n raise(QueryBuildingError.new(\"Cannot insert both from SELECT and from data\"))\nend\n@values = select_query\nchange!\n"}},{"html_id":"values:SelectBuilder|Array(Array(Inserable))-instance-method","name":"values","abstract":false,"location":{"filename":"src/clear/sql/insert_query.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L26"},"def":{"name":"values","return_type":"SelectBuilder | Array(Array(Inserable))","visibility":"Public","body":"@values"}},{"html_id":"values(*args)-instance-method","name":"values","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/insert_query.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L144"},"def":{"name":"values","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"@values << args\nchange!\n"}}],"types":[{"html_id":"clear/Clear/SQL/InsertQuery/Inserable","path":"Clear/SQL/InsertQuery/Inserable.html","kind":"alias","full_name":"Clear::SQL::InsertQuery::Inserable","name":"Inserable","abstract":false,"locations":[{"filename":"src/clear/sql/insert_query.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/insert_query.cr#L24"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil)","aliased_html":"Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"}}]},{"html_id":"clear/Clear/SQL/Join","path":"Clear/SQL/Join.html","kind":"struct","full_name":"Clear::SQL::Join","name":"Join","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},"ancestors":[{"html_id":"clear/Clear/SQL/Fragment","kind":"struct","full_name":"Clear::SQL::Fragment","name":"Fragment"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/fragment/join.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"TYPE","name":"TYPE","value":"{left: \"LEFT JOIN\", inner: \"INNER JOIN\", right: \"RIGHT JOIN\", full_outer: \"FULL OUTER JOIN\", cross: \"CROSS JOIN\"}"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(from:Clear::SQL::SelectBuilder|String|Symbol,condition:Clear::Expression::Node|Nil=nil,lateral:Bool=false,type:Symbol=:inner)-class-method","name":"new","abstract":false,"args":[{"name":"from","external_name":"from","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"condition","default_value":"nil","external_name":"condition","restriction":"::Clear::Expression::Node | ::Nil"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":"::Bool"},{"name":"type","default_value":":inner","external_name":"type","restriction":"Symbol"}],"args_string":"(from : Clear::SQL::SelectBuilder | String | Symbol, condition : Clear::Expression::Node | Nil = nil, lateral : Bool = false, type : Symbol = :inner)","args_html":"(from : Clear::SQL::SelectBuilder | String | Symbol, condition : Clear::Expression::Node | Nil = nil, lateral : Bool = false, type : Symbol = :inner)","location":{"filename":"src/clear/sql/fragment/join.cr","line_number":16,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L16"},"def":{"name":"new","args":[{"name":"from","external_name":"from","restriction":"::Clear::SQL::SelectBuilder | ::String | ::Symbol"},{"name":"condition","default_value":"nil","external_name":"condition","restriction":"::Clear::Expression::Node | ::Nil"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":"::Bool"},{"name":"type","default_value":":inner","external_name":"type","restriction":"Symbol"}],"visibility":"Public","body":"_ = allocate\n_.initialize(from, condition, lateral, type)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"condition:Clear::Expression::Node|Nil-instance-method","name":"condition","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L13"},"def":{"name":"condition","return_type":"Clear::Expression::Node | ::Nil","visibility":"Public","body":"@condition"}},{"html_id":"from:Selectable-instance-method","name":"from","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L12"},"def":{"name":"from","return_type":"Selectable","visibility":"Public","body":"@from"}},{"html_id":"lateral?:Bool-instance-method","name":"lateral?","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L14"},"def":{"name":"lateral?","return_type":"Bool","visibility":"Public","body":"@lateral"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":20,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L20"},"def":{"name":"to_sql","visibility":"Public","body":"from = @from\nfrom = case from\nwhen SQL::SelectBuilder\n \"(#{from.to_sql})\"\nelse\n from.to_s\nend\nif c = @condition\n [type, lateral? ? \"LATERAL\" : nil, from, \"ON\", c.resolve].compact.join(\" \")\nelse\n [type, lateral? ? \"LATERAL\" : nil, SQL.sel_str(from)].compact.join(\" \")\nend\n"}},{"html_id":"type:String-instance-method","name":"type","abstract":false,"location":{"filename":"src/clear/sql/fragment/join.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/fragment/join.cr#L11"},"def":{"name":"type","return_type":"String","visibility":"Public","body":"@type"}}]},{"html_id":"clear/Clear/SQL/JSONB","path":"Clear/SQL/JSONB.html","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":32,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L32"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}],"including_types":[{"html_id":"clear/Clear/Expression/Node/JSONB/Equality","kind":"class","full_name":"Clear::Expression::Node::JSONB::Equality","name":"Equality"},{"html_id":"clear/Clear/Expression/Node/JSONB/Field","kind":"class","full_name":"Clear::Expression::Node::JSONB::Field","name":"Field"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"instance_methods":[{"html_id":"jsonb_all_exists?(field,keys:Array(String))-instance-method","name":"jsonb_all_exists?","doc":"jsonb `?&` operator\nDo all of these array strings exist as top-level keys?","summary":"jsonb ?&
operator Do all of these array strings exist as top-level keys?
jsonb ?|
operator Do any of these array strings exist as top-level keys?
Test equality using the @>
operator
Does the string exist as a top-level key within the JSON value?
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"value","external_name":"value","restriction":""}],"args_string":"(field, value)","args_html":"(field, value)","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":50,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L50"},"def":{"name":"jsonb_exists?","args":[{"name":"field","external_name":"field","restriction":""},{"name":"value","external_name":"value","restriction":""}],"visibility":"Public","body":"{field, Clear::SQL.sanitize(value)}.join(\" ? \")"}},{"html_id":"jsonb_k2h(key:String,value:JSONBKey):JSONBHash-instance-method","name":"jsonb_k2h","doc":"Transform a key to a hash","summary":"Transform a key to a hash
","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"JSONBKey"}],"args_string":"(key : String, value : JSONBKey) : JSONBHash","args_html":"(key : String, value : JSONBKey) : JSONBHash","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L39"},"def":{"name":"jsonb_k2h","args":[{"name":"key","external_name":"key","restriction":"String"},{"name":"value","external_name":"value","restriction":"JSONBKey"}],"return_type":"JSONBHash","visibility":"Public","body":"jsonb_arr2h(jsonb_k2a(key), value)"}},{"html_id":"jsonb_resolve(field,arr:Array(String),cast=nil):String-instance-method","name":"jsonb_resolve","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"arr","external_name":"arr","restriction":"Array(String)"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"args_string":"(field, arr : Array(String), cast = nil) : String","args_html":"(field, arr : Array(String), cast = nil) : String","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":122,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L122"},"def":{"name":"jsonb_resolve","args":[{"name":"field","external_name":"field","restriction":""},{"name":"arr","external_name":"arr","restriction":"Array(String)"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"return_type":"String","visibility":"Public","body":"if arr.empty?\n return field\nend\no = ([field] + Clear::Expression[arr]).join(\"->\")\nif cast\n o = \"(#{o})::#{cast}\"\nend\no\n"}},{"html_id":"jsonb_resolve(field,key:String,cast=nil)-instance-method","name":"jsonb_resolve","doc":"Return text selector for the field/key :\n\n```\njsonb_text(\"data\", \"sub.key\").like(\"user%\")\n# => \"data->'sub'->>'key' LIKE 'user%'\"\n```","summary":"Return text selector for the field/key :
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"key","external_name":"key","restriction":"String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"args_string":"(field, key : String, cast = nil)","args_html":"(field, key : String, cast = nil)","location":{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":138,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L138"},"def":{"name":"jsonb_resolve","args":[{"name":"field","external_name":"field","restriction":""},{"name":"key","external_name":"key","restriction":"String"},{"name":"cast","default_value":"nil","external_name":"cast","restriction":""}],"visibility":"Public","body":"arr = jsonb_k2a(key)\njsonb_resolve(field, arr, cast)\n"}}],"types":[{"html_id":"clear/Clear/SQL/JSONB/JSONBHash","path":"Clear/SQL/JSONB/JSONBHash.html","kind":"alias","full_name":"Clear::SQL::JSONB::JSONBHash","name":"JSONBHash","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L36"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Hash(String, Clear::SQL::JSONB::JSONBKey)","aliased_html":"Hash(String, Clear::SQL::JSONB::JSONBKey)","const":false,"namespace":{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}},{"html_id":"clear/Clear/SQL/JSONB/JSONBKey","path":"Clear/SQL/JSONB/JSONBKey.html","kind":"alias","full_name":"Clear::SQL::JSONB::JSONBKey","name":"JSONBKey","abstract":false,"locations":[{"filename":"src/clear/extensions/jsonb/jsonb.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/jsonb/jsonb.cr#L35"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Bool | Clear::Expression::Literal | Float32 | Float64 | Hash(String, Clear::SQL::JSONB::JSONBKey) | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)","aliased_html":"Bool | Clear::Expression::Literal | Float32 | Float64 | Hash(String, Clear::SQL::JSONB::JSONBKey) | Int16 | Int32 | Int64 | Int8 | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL/JSONB","kind":"module","full_name":"Clear::SQL::JSONB","name":"JSONB"}}]},{"html_id":"clear/Clear/SQL/Logger","path":"Clear/SQL/Logger.html","kind":"module","full_name":"Clear::SQL::Logger","name":"Logger","abstract":false,"locations":[{"filename":"src/clear/sql/logger.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L4"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"class_methods":[{"html_id":"colorize=(colorize:Bool)-class-method","name":"colorize=","abstract":false,"args":[{"name":"colorize","external_name":"colorize","restriction":"Bool"}],"args_string":"(colorize : Bool)","args_html":"(colorize : Bool)","location":{"filename":"src/clear/sql/logger.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L5"},"def":{"name":"colorize=","args":[{"name":"colorize","external_name":"colorize","restriction":"Bool"}],"visibility":"Public","body":"@@colorize = colorize"}},{"html_id":"colorize?:Bool-class-method","name":"colorize?","abstract":false,"location":{"filename":"src/clear/sql/logger.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L5"},"def":{"name":"colorize?","return_type":"Bool","visibility":"Public","body":"@@colorize"}},{"html_id":"colorize_query(qry:String)-class-method","name":"colorize_query","abstract":false,"args":[{"name":"qry","external_name":"qry","restriction":"String"}],"args_string":"(qry : String)","args_html":"(qry : String)","location":{"filename":"src/clear/sql/logger.cr","line_number":21,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L21"},"def":{"name":"colorize_query","args":[{"name":"qry","external_name":"qry","restriction":"String"}],"visibility":"Public","body":"if @@colorize\nelse\n return qry\nend\no = (qry.to_s.split(/([a-zA-Z0-9_]+)/)).join(\"\") do |word|\n if SQL_KEYWORDS.includes?(word.upcase)\n word.colorize.bold.blue.to_s\n else\n if word =~ (/\\d+/)\n word.colorize.red\n else\n word.colorize.white\n end\n end\nend\no.gsub(/(--.*)$/) do |__arg0|\n __arg0.colorize.dark_gray\nend\n"}},{"html_id":"display_mn_sec(x):String-class-method","name":"display_mn_sec","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : String","args_html":"(x) : String","location":{"filename":"src/clear/sql/logger.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L37"},"def":{"name":"display_mn_sec","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"String","visibility":"Public","body":"mn = x.to_i / 60\nsc = x.to_i % 60\n({mn > 9 ? mn : \"0#{mn}\", sc > 9 ? sc : \"0#{sc}\"}.join(\"mn\")) + \"s\"\n"}},{"html_id":"display_time(x):String-class-method","name":"display_time","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : String","args_html":"(x) : String","location":{"filename":"src/clear/sql/logger.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L44"},"def":{"name":"display_time","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"String","visibility":"Public","body":"if x > 60\n display_mn_sec(x)\nelse\n if x > 1\n (\"%.2f\" % x) + \"s\"\n else\n if x > 0.001\n (1000 * x).to_i.to_s + \"ms\"\n else\n (1000000 * x).to_i.to_s + \"µs\"\n end\n end\nend"}}],"instance_methods":[{"html_id":"log_query(sql,&)-instance-method","name":"log_query","abstract":false,"args":[{"name":"sql","external_name":"sql","restriction":""}],"args_string":"(sql, &)","args_html":"(sql, &)","location":{"filename":"src/clear/sql/logger.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/logger.cr#L56"},"def":{"name":"log_query","args":[{"name":"sql","external_name":"sql","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"begin\n start_time = Time.monotonic\n o = yield\n elapsed_time = Time.monotonic - start_time\n Log.debug do\n (\"[\" + (Clear::SQL::Logger.display_time(elapsed_time.to_f)).colorize.bold.white.to_s) + \"] #{SQL::Logger.colorize_query(sql)}\"\n end\n o\nrescue e\n raise(Clear::SQL::Error.new(message: [e.message, \"Error caught, last query was:\", Clear::SQL::Logger.colorize_query(sql)].compact.join(\"\\n\"), cause: e))\nend"}}]},{"html_id":"clear/Clear/SQL/OperationNotPermittedError","path":"Clear/SQL/OperationNotPermittedError.html","kind":"class","full_name":"Clear::SQL::OperationNotPermittedError","name":"OperationNotPermittedError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/Query","path":"Clear/SQL/Query.html","kind":"module","full_name":"Clear::SQL::Query","name":"Query","abstract":false,"locations":[{"filename":"src/clear/sql/query/aggregate.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"types":[{"html_id":"clear/Clear/SQL/Query/Aggregate","path":"Clear/SQL/Query/Aggregate.html","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate","abstract":false,"locations":[{"filename":"src/clear/sql/query/aggregate.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"agg(field,x:X.class)forallX-instance-method","name":"agg","doc":"Call an custom aggregation function, like MEDIAN or other:\n\n```\nquery.agg(\"MEDIAN(age)\", Int64)\n```\n\nNote than COUNT, MIN, MAX, SUM and AVG are already conveniently mapped.\n\nThis return only one row, and should not be used with `group_by` (prefer pluck or fetch)","summary":"Call an custom aggregation function, like MEDIAN or other:
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L38"},"def":{"name":"agg","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"(clear_select.select(field)).scalar(X)"}},{"html_id":"avg(field,x:X.class)forallX-instance-method","name":"avg","doc":"SQL aggregation function \"AVG\":\n\n```\nquery.avg(\"field\", Int64)\n```","summary":"SQL aggregation function "AVG":
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L48"},"def":{"name":"avg","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"agg(\"AVG(#{field})\", X)"}},{"html_id":"count(type:X.class=Int64)forallX-instance-method","name":"count","doc":"Use SQL `COUNT` over your query, and return this number as a Int64\n\nas count return always a scalar, the usage of `COUNT(*) OVER GROUP BY` can be done by\nusing `pluck` or `select`","summary":"Use SQL COUNT
over your query, and return this number as a Int64
SQL aggregation function "MAX":
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L48"},"def":{"name":"max","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"agg(\"MAX(#{field})\", X)"}},{"html_id":"min(field,x:X.class)forallX-instance-method","name":"min","doc":"SQL aggregation function \"MIN\":\n\n```\nquery.min(\"field\", Int64)\n```","summary":"SQL aggregation function "MIN":
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"args_string":"(field, x : X.class) forall X","args_html":"(field, x : X.class) forall X","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L48"},"def":{"name":"min","args":[{"name":"field","external_name":"field","restriction":""},{"name":"x","external_name":"x","restriction":"X.class"}],"visibility":"Public","body":"agg(\"MIN(#{field})\", X)"}},{"html_id":"sum(field):Float64-instance-method","name":"sum","doc":"SUM through a field and return a Float64\nNote: This function is not safe injection-wise, so beware !.","summary":"SUM through a field and return a Float64 Note: This function is not safe injection-wise, so beware !.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""}],"args_string":"(field) : Float64","args_html":"(field) : Float64","location":{"filename":"src/clear/sql/query/aggregate.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/aggregate.cr#L44"},"def":{"name":"sum","args":[{"name":"field","external_name":"field","restriction":""}],"return_type":"Float64","visibility":"Public","body":"(agg(\"SUM(#{field})\", Union(Int64 | PG::Numeric | Nil))).try(&.to_f) || 0.0"}}]},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","path":"Clear/SQL/Query/BeforeQuery.html","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery","abstract":false,"locations":[{"filename":"src/clear/sql/query/before_query.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/before_query.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"}},{"html_id":"clear/Clear/SQL/Query/Change","path":"Clear/SQL/Query/Change.html","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change","abstract":false,"locations":[{"filename":"src/clear/sql/query/change.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/change.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/DeleteQuery","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery"},{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"change!:self-instance-method","name":"change!","doc":"This method is called everytime the request has been changed\nBy default, this do nothing and return `self`. However, it can be\nreimplemented to change some behavior when the query is changed\n\n(eg. it is by `Clear::Model::Collection`, to discard cache over collection)","summary":"This method is called everytime the request has been changed By default, this do nothing and return self
.
Connection used by the query.
","abstract":false,"location":{"filename":"src/clear/sql/query/connection.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/connection.cr#L5"},"def":{"name":"connection_name","return_type":"String","visibility":"Public","body":"@connection_name"}},{"html_id":"use_connection(connection_name:String)-instance-method","name":"use_connection","doc":"Change the connection used by the query on execution","summary":"Change the connection used by the query on execution
","abstract":false,"args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"}],"args_string":"(connection_name : String)","args_html":"(connection_name : String)","location":{"filename":"src/clear/sql/query/connection.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/connection.cr#L8"},"def":{"name":"use_connection","args":[{"name":"connection_name","external_name":"connection_name","restriction":"String"}],"visibility":"Public","body":"@connection_name = connection_name\nself\n"}}]},{"html_id":"clear/Clear/SQL/Query/CTE","path":"Clear/SQL/Query/CTE.html","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE","abstract":false,"locations":[{"filename":"src/clear/sql/query/cte.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"doc":"Allow usage of Common Table Expressions (CTE) in the query building","summary":"Allow usage of Common Table Expressions (CTE) in the query building
","instance_methods":[{"html_id":"cte:Hash(String,CTEAuthorized)-instance-method","name":"cte","doc":"List the current CTE of the query. The key is the name of the CTE,\nwhile the value is the fragment (string or Sub-select)","summary":"List the current CTE of the query.
","abstract":false,"location":{"filename":"src/clear/sql/query/cte.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L8"},"def":{"name":"cte","return_type":"Hash(String, CTEAuthorized)","visibility":"Public","body":"@cte"}},{"html_id":"with_cte(name,request:CTEAuthorized)-instance-method","name":"with_cte","doc":"Add a CTE to the query.\n\n```\nClear::SQL.select.with_cte(\"full_year\",\n \"SELECT DATE(date)\"\n \"FROM generate_series(NOW() - INTERVAL '1 year', NOW(), '1 day'::interval) date\")\n .select(\"*\").from(\"full_year\")\n# WITH full_year AS ( SELECT DATE(date) ... ) SELECT * FROM full_year;\n```","summary":"Add a CTE to the query.
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":""},{"name":"request","external_name":"request","restriction":"CTEAuthorized"}],"args_string":"(name, request : CTEAuthorized)","args_html":"(name, request : CTEAuthorized)","location":{"filename":"src/clear/sql/query/cte.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L19"},"def":{"name":"with_cte","args":[{"name":"name","external_name":"name","restriction":""},{"name":"request","external_name":"request","restriction":"CTEAuthorized"}],"visibility":"Public","body":"cte[name] = request\nchange!\n"}},{"html_id":"with_cte(tuple:NamedTuple)-instance-method","name":"with_cte","doc":"Add a CTE to the query. Use NamedTuple convention:\n\n```\nClear::SQL.select.with_cte(cte: \"xxx\")\n# WITH cte AS xxx SELECT...\n```","summary":"Add a CTE to the query.
","abstract":false,"args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"args_string":"(tuple : NamedTuple)","args_html":"(tuple : NamedTuple)","location":{"filename":"src/clear/sql/query/cte.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/cte.cr#L30"},"def":{"name":"with_cte","args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"visibility":"Public","body":"tuple.each do |k, v|\n cte[k.to_s] = v\nend\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/Execute","path":"Clear/SQL/Query/Execute.html","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute","abstract":false,"locations":[{"filename":"src/clear/sql/query/execute.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/execute.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/DeleteQuery","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"execute(connection_name:String|Nil=nil)-instance-method","name":"execute","doc":"\nExecute an SQL statement which does not return anything.\n\nIf an optional `connection_name` parameter is given, this will\n override the connection used by the query.\n\n```\n%(default secondary).each do |cnx|\n Clear::SQL.select(\"pg_shards('xxx')\").execute(cnx)\nend\n```","summary":"Execute an SQL statement which does not return anything.
","abstract":false,"args":[{"name":"connection_name","default_value":"nil","external_name":"connection_name","restriction":"String | ::Nil"}],"args_string":"(connection_name : String | Nil = nil)","args_html":"(connection_name : String | Nil = nil)","location":{"filename":"src/clear/sql/query/execute.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/execute.cr#L15"},"def":{"name":"execute","args":[{"name":"connection_name","default_value":"nil","external_name":"connection_name","restriction":"String | ::Nil"}],"visibility":"Public","body":"Clear::SQL.execute(connection_name || self.connection_name, to_sql)"}}]},{"html_id":"clear/Clear/SQL/Query/Fetch","path":"Clear/SQL/Query/Fetch.html","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch","abstract":false,"locations":[{"filename":"src/clear/sql/query/fetch.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"fetch(fetch_all=false,&:Hash(String,Clear::SQL::Any)->Nil)-instance-method","name":"fetch","doc":"Fetch the result set row per row\n`fetch_all` optional parameter is helpful in transactional environment, so it stores\nthe result and close the resultset before starting to call yield over the data\npreventing creation of a new connection if you need to call SQL into the\nyielded block.\n\n```\n# This is wrong: The connection is still busy retrieving the users:\nClear::SQL.select.from(\"users\").fetch do |u|\n Clear::SQL.select.from(\"posts\").where { u[\"id\"] == posts.id }\nend\n\n# Instead, use `fetch_all`\n# Clear will store the value of the result set in memory\n# before calling the block, and the connection is now ready to handle\n# another query.\nClear::SQL.select.from(\"users\").fetch(fetch_all: true) do |u|\n Clear::SQL.select.from(\"posts\").where { u[\"id\"] == posts.id }\nend\n```","summary":"Fetch the result set row per row fetch_all
optional parameter is helpful in transactional environment, so it stores the result and close the resultset before starting to call yield over the data preventing creation of a new connection if you need to call SQL into the yielded block.
Alias for #first
because first is redefined in Collection::Base object to return a model instead.
Fetch the data using CURSOR.
","abstract":false,"args":[{"name":"count","default_value":"1000","external_name":"count","restriction":""}],"args_string":"(count = 1000, & : Hash(String, Clear::SQL::Any) -> Nil)","args_html":"(count = 1000, & : Hash(String, Clear::SQL::Any) -> Nil)","location":{"filename":"src/clear/sql/query/fetch.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L24"},"def":{"name":"fetch_with_cursor","args":[{"name":"count","default_value":"1000","external_name":"count","restriction":""}],"yields":1,"block_arity":1,"block_arg":{"name":"","external_name":"","restriction":"(Hash(String, ::Clear::SQL::Any) -> Nil)"},"visibility":"Public","body":"trigger_before_query\nClear::SQL.transaction do |cnx|\n cursor_name = \"__cursor_#{Time.local.to_unix ^ (rand * 268435455).to_i}__\"\n cursor_declaration = \"DECLARE #{cursor_name} CURSOR FOR #{to_sql}\"\n Clear::SQL.log_query(cursor_declaration) do\n cnx.exec(cursor_declaration)\n end\n h = {} of String => ::Clear::SQL::Any\n we_loop = true\n while we_loop\n fetch_query = \"FETCH #{count} FROM #{cursor_name}\"\n rs = Clear::SQL.log_query(fetch_query) do\n cnx.query(fetch_query)\n end\n o = Array(Hash(String, ::Clear::SQL::Any)).new(initial_capacity: count)\n we_loop = fetch_result_set(h, rs) do |x|\n o << x.dup\n end\n o.each do |hash|\n yield(hash)\n end\n end\nend\n"}},{"html_id":"first-instance-method","name":"first","doc":"Return the first line of the query as Hash(String, ::Clear::SQL::Any), or nil\nif not found","summary":"Return the first line of the query as Hash(String, ::Clear::SQL::Any), or nil if not found
","abstract":false,"location":{"filename":"src/clear/sql/query/fetch.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L65"},"def":{"name":"first","visibility":"Public","body":"fetch_first"}},{"html_id":"first!-instance-method","name":"first!","abstract":false,"location":{"filename":"src/clear/sql/query/fetch.cr","line_number":69,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L69"},"def":{"name":"first!","visibility":"Public","body":"fetch_first!"}},{"html_id":"scalar(type:T.class)forallT-instance-method","name":"scalar","doc":"Helpers to fetch a SELECT with only one row and one column return.","summary":"Helpers to fetch a SELECT with only one row and one column return.
","abstract":false,"args":[{"name":"type","external_name":"type","restriction":"T.class"}],"args_string":"(type : T.class) forall T","args_html":"(type : T.class) forall T","location":{"filename":"src/clear/sql/query/fetch.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L53"},"def":{"name":"scalar","args":[{"name":"type","external_name":"type","restriction":"T.class"}],"visibility":"Public","body":"trigger_before_query\nsql = to_sql\nClear::SQL.log_query(sql) do\n (Clear::SQL::ConnectionPool.with_connection(connection_name, &.scalar(sql))).as(T)\nend\n"}},{"html_id":"to_a:Array(Hash(String,Clear::SQL::Any))-instance-method","name":"to_a","doc":"Return an array with all the rows fetched.","summary":"Return an array with all the rows fetched.
","abstract":false,"location":{"filename":"src/clear/sql/query/fetch.cr","line_number":90,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/fetch.cr#L90"},"def":{"name":"to_a","return_type":"Array(Hash(String, ::Clear::SQL::Any))","visibility":"Public","body":"trigger_before_query\nh = {} of String => ::Clear::SQL::Any\nsql = to_sql\nrs = Clear::SQL.log_query(sql) do\n Clear::SQL::ConnectionPool.with_connection(connection_name, &.query(sql))\nend\no = [] of Hash(String, ::Clear::SQL::Any)\nfetch_result_set(h, rs) do |x|\n o << x.dup\nend\no\n"}}]},{"html_id":"clear/Clear/SQL/Query/From","path":"Clear/SQL/Query/From.html","kind":"module","full_name":"Clear::SQL::Query::From","name":"From","abstract":false,"locations":[{"filename":"src/clear/sql/query/from.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_from-instance-method","name":"clear_from","doc":"Clear the FROM clause and return `self`","summary":"Clear the FROM clause and return self
FROM fragment of the SQL query
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/query/from.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L10"},"def":{"name":"from","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"args.each do |arg|\n case arg\n when NamedTuple\n arg.each do |k, v|\n @froms << (Clear::SQL::From.new(v, k.to_s))\n end\n else\n @froms << (Clear::SQL::From.new(arg))\n end\nend\nchange!\n"}},{"html_id":"from(**tuple)-instance-method","name":"from","abstract":false,"location":{"filename":"src/clear/sql/query/from.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L23"},"def":{"name":"from","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"tuple.each do |k, v|\n @froms << (Clear::SQL::From.new(v, k.to_s))\nend\nchange!\n"}},{"html_id":"froms:Array(SQL::From)-instance-method","name":"froms","abstract":false,"location":{"filename":"src/clear/sql/query/from.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/from.cr#L3"},"def":{"name":"froms","return_type":"Array(SQL::From)","visibility":"Public","body":"@froms"}}]},{"html_id":"clear/Clear/SQL/Query/GroupBy","path":"Clear/SQL/Query/GroupBy.html","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy","abstract":false,"locations":[{"filename":"src/clear/sql/query/group_by.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_group_bys-instance-method","name":"clear_group_bys","abstract":false,"location":{"filename":"src/clear/sql/query/group_by.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L4"},"def":{"name":"clear_group_bys","visibility":"Public","body":"@group_bys.clear\nchange!\n"}},{"html_id":"group_by(column:Symbolic)-instance-method","name":"group_by","abstract":false,"args":[{"name":"column","external_name":"column","restriction":"Symbolic"}],"args_string":"(column : Symbolic)","args_html":"(column : Symbolic)","location":{"filename":"src/clear/sql/query/group_by.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L9"},"def":{"name":"group_by","args":[{"name":"column","external_name":"column","restriction":"Symbolic"}],"visibility":"Public","body":"@group_bys << column\nchange!\n"}},{"html_id":"group_bys:Array(Symbolic)-instance-method","name":"group_bys","abstract":false,"location":{"filename":"src/clear/sql/query/group_by.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/group_by.cr#L2"},"def":{"name":"group_bys","return_type":"Array(Symbolic)","visibility":"Public","body":"@group_bys"}}]},{"html_id":"clear/Clear/SQL/Query/Having","path":"Clear/SQL/Query/Having.html","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having","abstract":false,"locations":[{"filename":"src/clear/sql/query/having.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/having.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_havings-instance-method","name":"clear_havings","doc":"Clear all the having clauses and return `self`","summary":"Clear all the having clauses and return self
Build SQL #having
condition using a Clear::Expression::Node
Build SQL #having
condition using the Expression engine.
Build SQL #having
condition using a NamedTuple.
Build SQL #having
condition using a template string and interpolating ?
characters with parameters given in a tuple or array.
Build SQL #having
interpolating :keyword
with the NamedTuple passed in argument.
Build SQL #or_having
condition using a Clear::Expression::Node
Build SQL #having
condition using the Expression engine.
Add a "FULL_OUTER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"full_outer_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :full_outer, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"full_outer_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"full_outer_join","doc":"Add a \"FULL_OUTER\" JOIN directive to the query","summary":"Add a "FULL_OUTER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"full_outer_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :full_outer, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"inner_join(name:Selectable,lateral=false,&)-instance-method","name":"inner_join","doc":"Add a \"INNER\" JOIN directive to the query","summary":"Add a "INNER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"inner_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :inner, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"inner_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"inner_join","doc":"Add a \"INNER\" JOIN directive to the query","summary":"Add a "INNER" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"inner_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :inner, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"join(name:Selectable,type=:inner,lateral=false,&)-instance-method","name":"join","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, type = :inner, lateral = false, &)","args_html":"(name : Selectable, type = :inner, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":14,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L14"},"def":{"name":"join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, type, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"join(name:Selectable,type=:inner,condition:String=\"true\",lateral=false)-instance-method","name":"join","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, type = :inner, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, type = :inner, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":18,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L18"},"def":{"name":"join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, type, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"join(name:Selectable,type=:inner,lateral=false)-instance-method","name":"join","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, type = :inner, lateral = false)","args_html":"(name : Selectable, type = :inner, lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L22"},"def":{"name":"join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"type","default_value":":inner","external_name":"type","restriction":""},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, type, lateral, nil)"}},{"html_id":"left_join(name:Selectable,lateral=false,&)-instance-method","name":"left_join","doc":"Add a \"LEFT\" JOIN directive to the query","summary":"Add a "LEFT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"left_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :left, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"left_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"left_join","doc":"Add a \"LEFT\" JOIN directive to the query","summary":"Add a "LEFT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"left_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :left, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}},{"html_id":"right_join(name:Selectable,lateral=false,&)-instance-method","name":"right_join","doc":"Add a \"RIGHT\" JOIN directive to the query","summary":"Add a "RIGHT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, lateral = false, &)","args_html":"(name : Selectable, lateral = false, &)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"right_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"yields":0,"block_arity":0,"visibility":"Public","body":"join_impl(name, :right, lateral, Clear::Expression.ensure_node!(with Clear::Expression.new yield))"}},{"html_id":"right_join(name:Selectable,condition:String=\"true\",lateral=false)-instance-method","name":"right_join","doc":"Add a \"RIGHT\" JOIN directive to the query","summary":"Add a "RIGHT" JOIN directive to the query
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"args_string":"(name : Selectable, condition : String = \"true\", lateral = false)","args_html":"(name : Selectable, condition : String = "true", lateral = false)","location":{"filename":"src/clear/sql/query/join.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/join.cr#L30"},"def":{"name":"right_join","args":[{"name":"name","external_name":"name","restriction":"Selectable"},{"name":"condition","default_value":"\"true\"","external_name":"condition","restriction":"String"},{"name":"lateral","default_value":"false","external_name":"lateral","restriction":""}],"visibility":"Public","body":"join_impl(name, :right, lateral, Clear::Expression::Node::Raw.new((\"(\" + condition) + \")\"))"}}]},{"html_id":"clear/Clear/SQL/Query/Lock","path":"Clear/SQL/Query/Lock.html","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock","abstract":false,"locations":[{"filename":"src/clear/sql/query/lock.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/lock.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"with_lock(str:String=\"FORUPDATE\")-instance-method","name":"with_lock","abstract":false,"args":[{"name":"str","default_value":"\"FOR UPDATE\"","external_name":"str","restriction":"String"}],"args_string":"(str : String = \"FOR UPDATE\")","args_html":"(str : String = "FOR UPDATE")","location":{"filename":"src/clear/sql/query/lock.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/lock.cr#L11"},"def":{"name":"with_lock","args":[{"name":"str","default_value":"\"FOR UPDATE\"","external_name":"str","restriction":"String"}],"visibility":"Public","body":"@lock = str\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","path":"Clear/SQL/Query/OffsetLimit.html","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit","abstract":false,"locations":[{"filename":"src/clear/sql/query/offset_limit.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_limit-instance-method","name":"clear_limit","abstract":false,"location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L12"},"def":{"name":"clear_limit","visibility":"Public","body":"@limit = nil\nchange!\n"}},{"html_id":"clear_offset-instance-method","name":"clear_offset","abstract":false,"location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L17"},"def":{"name":"clear_offset","visibility":"Public","body":"@offset = nil\nchange!\n"}},{"html_id":"limit(x:Int|Nil)-instance-method","name":"limit","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"args_string":"(x : Int | Nil)","args_html":"(x : Int | Nil)","location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L7"},"def":{"name":"limit","args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"visibility":"Public","body":"@limit = Int64.new(x)\nchange!\n"}},{"html_id":"offset(x:Int|Nil)-instance-method","name":"offset","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"args_string":"(x : Int | Nil)","args_html":"(x : Int | Nil)","location":{"filename":"src/clear/sql/query/offset_limit.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/offset_limit.cr#L22"},"def":{"name":"offset","args":[{"name":"x","external_name":"x","restriction":"Int | ::Nil"}],"visibility":"Public","body":"@offset = Int64.new(x)\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/OnConflict","path":"Clear/SQL/Query/OnConflict.html","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict","abstract":false,"locations":[{"filename":"src/clear/sql/query/on_conflict.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/InsertQuery","kind":"class","full_name":"Clear::SQL::InsertQuery","name":"InsertQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_conflict-instance-method","name":"clear_conflict","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":58,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L58"},"def":{"name":"clear_conflict","visibility":"Public","body":"@on_conflict_condition = false"}},{"html_id":"conflict?-instance-method","name":"conflict?","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":54,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L54"},"def":{"name":"conflict?","visibility":"Public","body":"!!@on_conflict_condition"}},{"html_id":"do_conflict_action(str)-instance-method","name":"do_conflict_action","abstract":false,"args":[{"name":"str","external_name":"str","restriction":""}],"args_string":"(str)","args_html":"(str)","location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L23"},"def":{"name":"do_conflict_action","args":[{"name":"str","external_name":"str","restriction":""}],"visibility":"Public","body":"@on_conflict_action = \"#{str}\"\nchange!\n"}},{"html_id":"do_nothing-instance-method","name":"do_nothing","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":35,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L35"},"def":{"name":"do_nothing","visibility":"Public","body":"@on_conflict_action = \"NOTHING\"\nchange!\n"}},{"html_id":"do_update(&)-instance-method","name":"do_update","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L28"},"def":{"name":"do_update","yields":1,"block_arity":1,"visibility":"Public","body":"action = Clear::SQL::UpdateQuery.new(nil)\nyield(action)\n@on_conflict_action = action\nchange!\n"}},{"html_id":"on_conflict(constraint:String|Bool|OnConflictWhereClause=true)-instance-method","name":"on_conflict","abstract":false,"args":[{"name":"constraint","default_value":"true","external_name":"constraint","restriction":"String | Bool | OnConflictWhereClause"}],"args_string":"(constraint : String | Bool | OnConflictWhereClause = true)","args_html":"(constraint : String | Bool | OnConflictWhereClause = true)","location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L40"},"def":{"name":"on_conflict","args":[{"name":"constraint","default_value":"true","external_name":"constraint","restriction":"String | Bool | OnConflictWhereClause"}],"visibility":"Public","body":"@on_conflict_condition = constraint\nchange!\n"}},{"html_id":"on_conflict(&)-instance-method","name":"on_conflict","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":45,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L45"},"def":{"name":"on_conflict","yields":0,"block_arity":0,"visibility":"Public","body":"condition = OnConflictWhereClause.new\ncondition.where(Clear::Expression.ensure_node!(with Clear::Expression.new yield))\n@on_conflict_condition = condition\nchange!\n"}},{"html_id":"on_conflict_action:String|Clear::SQL::UpdateQuery-instance-method","name":"on_conflict_action","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L5"},"def":{"name":"on_conflict_action","return_type":"String | Clear::SQL::UpdateQuery","visibility":"Public","body":"@on_conflict_action"}},{"html_id":"on_conflict_condition:String|OnConflictWhereClause|Bool-instance-method","name":"on_conflict_condition","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L4"},"def":{"name":"on_conflict_condition","return_type":"String | OnConflictWhereClause | Bool","visibility":"Public","body":"@on_conflict_condition"}}],"types":[{"html_id":"clear/Clear/SQL/Query/OnConflict/OnConflictWhereClause","path":"Clear/SQL/Query/OnConflict/OnConflictWhereClause.html","kind":"class","full_name":"Clear::SQL::Query::OnConflict::OnConflictWhereClause","name":"OnConflictWhereClause","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/query/on_conflict.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"}],"namespace":{"html_id":"clear/Clear/SQL/Query/OnConflict","kind":"module","full_name":"Clear::SQL::Query::OnConflict","name":"OnConflict"},"doc":"Fragment used when ON CONFLICT WHERE ...","summary":"Fragment used when ON CONFLICT WHERE ...
","constructors":[{"html_id":"new-class-method","name":"new","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L11"},"def":{"name":"new","visibility":"Public","body":"_ = allocate\n_.initialize\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"change!-instance-method","name":"change!","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L19"},"def":{"name":"change!","visibility":"Public","body":""}},{"html_id":"to_s-instance-method","name":"to_s","doc":"Returns a nicely readable and concise string representation of this object,\ntypically intended for users.\n\nThis method should usually **not** be overridden. It delegates to\n`#to_s(IO)` which can be overridden for custom implementations.\n\nAlso see `#inspect`.","summary":"Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"location":{"filename":"src/clear/sql/query/on_conflict.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/on_conflict.cr#L15"},"def":{"name":"to_s","visibility":"Public","body":"print_wheres"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}]}]},{"html_id":"clear/Clear/SQL/Query/OrderBy","path":"Clear/SQL/Query/OrderBy.html","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy","abstract":false,"locations":[{"filename":"src/clear/sql/query/order_by.cr","line_number":11,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L11"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"doc":"Encode for:\n\n`ORDER BY expression [ASC | DESC | USING operator] [NULLS FIRST | NULLS LAST];`\n\nCurrent implementation:\n\n[x] Multiple Order by clauses\n[x] ASC/DESC\n[x] NULLS FIRST / NULLS LAST\n[ ] NOT IMPLEMENTED: USING OPERATOR","summary":"Encode for:
","instance_methods":[{"html_id":"clear_order_bys-instance-method","name":"clear_order_bys","doc":"Remove all order by clauses","summary":"Remove all order by clauses
","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L19"},"def":{"name":"clear_order_bys","visibility":"Public","body":"@order_bys.clear\nchange!\n"}},{"html_id":"order_by(tuple:NamedTuple)-instance-method","name":"order_by","doc":"Add multiple ORDER BY clause using a tuple:\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(id: :desc, name: {:asc, :nulls_last})\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC, \"name\" ASC NULLS LAST\n```\n","summary":"Add multiple ORDER BY clause using a tuple:
","abstract":false,"args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"args_string":"(tuple : NamedTuple)","args_html":"(tuple : NamedTuple)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":81,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L81"},"def":{"name":"order_by","args":[{"name":"tuple","external_name":"tuple","restriction":"NamedTuple"}],"visibility":"Public","body":"tuple.each do |k, v|\n case v\n when Symbol, String\n order_by(k, v, nil)\n when Tuple\n order_by(k, v[0], v[1])\n else\n raise(\"order_by with namedtuple must be called with value of the tuple as Symbol, String or Tuple describing direction and nulls directive\")\n end\nend\nself\n"}},{"html_id":"order_by(expression:Symbol,direction:Symbol=:asc,nulls:Symbol|Nil=nil)-instance-method","name":"order_by","doc":"Add one ORDER BY clause\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(:id, :desc, nulls_last)\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC NULLS LAST\n```","summary":"Add one ORDER BY clause
","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"Symbol"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"args_string":"(expression : Symbol, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","args_html":"(expression : Symbol, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":102,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L102"},"def":{"name":"order_by","args":[{"name":"expression","external_name":"expression","restriction":"Symbol"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"visibility":"Public","body":"@order_bys << (Record.new(SQL.escape(expression.to_s), sanitize_direction(direction), sanitize_nulls(nulls)))\nchange!\n"}},{"html_id":"order_by(expression:String,direction:Symbol=:asc,nulls:Symbol|Nil=nil)-instance-method","name":"order_by","doc":"Add one ORDER BY clause\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(:id, :desc, nulls_last)\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC NULLS LAST\n```","summary":"Add one ORDER BY clause
","abstract":false,"args":[{"name":"expression","external_name":"expression","restriction":"String"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"args_string":"(expression : String, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","args_html":"(expression : String, direction : Symbol = :asc, nulls : Symbol | Nil = nil)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L108"},"def":{"name":"order_by","args":[{"name":"expression","external_name":"expression","restriction":"String"},{"name":"direction","default_value":":asc","external_name":"direction","restriction":"Symbol"},{"name":"nulls","default_value":"nil","external_name":"nulls","restriction":"Symbol | ::Nil"}],"visibility":"Public","body":"@order_bys << (Record.new(expression, sanitize_direction(direction), sanitize_nulls(nulls)))\nchange!\n"}},{"html_id":"order_by(**tuple)-instance-method","name":"order_by","doc":"Add multiple ORDER BY clause using a tuple:\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(id: :desc, name: {:asc, :nulls_last})\nquery.to_sql # > SELECT * FROM users ORDER BY \"id\" DESC, \"name\" ASC NULLS LAST\n```\n","summary":"Add multiple ORDER BY clause using a tuple:
","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":76,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L76"},"def":{"name":"order_by","double_splat":{"name":"tuple","external_name":"tuple","restriction":""},"visibility":"Public","body":"order_by(tuple)"}},{"html_id":"reverse_order_by-instance-method","name":"reverse_order_by","doc":"Flip over all order bys by switching the ASC direction to DESC and the NULLS FIRST to NULLS LAST\n\n```\nquery = Clear::SQL.select.from(\"users\").order_by(id: :desc, name: :asc, company: {:asc, :nulls_last})\nquery.reverse_order_by\nquery.to_sql # SELECT * FROM users ORDER BY \"id\" ASC, \"name\" DESC, \"company\" DESC NULLS FIRST\n```\n\nreturn `self`","summary":"Flip over all order bys by switching the ASC direction to DESC and the NULLS FIRST to NULLS LAST
","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L53"},"def":{"name":"reverse_order_by","visibility":"Public","body":"@order_bys = @order_bys.map do |rec|\n Record.new(rec.op, rec.dir == (:desc) ? :asc : :desc, rec.nulls.try do |n|\n n == (:nulls_last) ? :nulls_first : :nulls_last\n end)\nend\nchange!\n"}}],"types":[{"html_id":"clear/Clear/SQL/Query/OrderBy/Record","path":"Clear/SQL/Query/OrderBy/Record.html","kind":"struct","full_name":"Clear::SQL::Query::OrderBy::Record","name":"Record","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},"constructors":[{"html_id":"new(op:String,dir:Symbol,nulls:Symbol|Nil)-class-method","name":"new","abstract":false,"args":[{"name":"op","external_name":"op","restriction":"String"},{"name":"dir","external_name":"dir","restriction":"Symbol"},{"name":"nulls","external_name":"nulls","restriction":"Symbol | ::Nil"}],"args_string":"(op : String, dir : Symbol, nulls : Symbol | Nil)","args_html":"(op : String, dir : Symbol, nulls : Symbol | Nil)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"},"def":{"name":"new","args":[{"name":"op","external_name":"op","restriction":"String"},{"name":"dir","external_name":"dir","restriction":"Symbol"},{"name":"nulls","external_name":"nulls","restriction":"Symbol | ::Nil"}],"visibility":"Public","body":"_ = allocate\n_.initialize(op, dir, nulls)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@op.clone, @dir.clone, @nulls.clone)"}},{"html_id":"copy_with(op_op=@op,dir_dir=@dir,nulls_nulls=@nulls)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_op","default_value":"@op","external_name":"op","restriction":""},{"name":"_dir","default_value":"@dir","external_name":"dir","restriction":""},{"name":"_nulls","default_value":"@nulls","external_name":"nulls","restriction":""}],"args_string":"(op _op = @op, dir _dir = @dir, nulls _nulls = @nulls)","args_html":"(op _op = @op, dir _dir = @dir, nulls _nulls = @nulls)","location":{"filename":"src/clear/sql/query/order_by.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/order_by.cr#L12"},"def":{"name":"copy_with","args":[{"name":"_op","default_value":"@op","external_name":"op","restriction":""},{"name":"_dir","default_value":"@dir","external_name":"dir","restriction":""},{"name":"_nulls","default_value":"@nulls","external_name":"nulls","restriction":""}],"visibility":"Public","body":"self.class.new(_op, _dir, _nulls)"}},{"html_id":"dir:Symbol-instance-method","name":"dir","abstract":false,"def":{"name":"dir","return_type":"Symbol","visibility":"Public","body":"@dir"}},{"html_id":"nulls:Symbol|Nil-instance-method","name":"nulls","abstract":false,"def":{"name":"nulls","return_type":"Symbol | ::Nil","visibility":"Public","body":"@nulls"}},{"html_id":"op:String-instance-method","name":"op","abstract":false,"def":{"name":"op","return_type":"String","visibility":"Public","body":"@op"}}]}]},{"html_id":"clear/Clear/SQL/Query/Pluck","path":"Clear/SQL/Query/Pluck.html","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck","abstract":false,"locations":[{"filename":"src/clear/sql/query/pluck.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"pluck(fields:Tuple(*T))forallT-instance-method","name":"pluck","doc":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected\narguments:\n\n```\nUser.query.pluck(\"first_name\", \"last_name\").each do |(first_name, last_name)|\n # ...\nend\n```","summary":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected arguments:
","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":"Tuple(*T)"}],"args_string":"(fields : Tuple(*T)) forall T","args_html":"(fields : Tuple(*T)) forall T","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":77,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L77"},"def":{"name":"pluck","args":[{"name":"fields","external_name":"fields","restriction":"Tuple(*T)"}],"visibility":"Public","body":"select_clause = fields.join(\", \") do |f|\n f.is_a?(Symbol) ? Clear::SQL.escape(f) : f.to_s\nend\nsql = (clear_select.select(select_clause)).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n {% if true %}\n o = [] of Tuple({% for t in T %}Clear::SQL::Any,{% end %})\n\n while rs.move_next\n o << { {% for t in T %} rs.read.as(Clear::SQL::Any), {% end %} }\n end\n o\n {% end %}\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"pluck(*fields)-instance-method","name":"pluck","doc":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected\narguments:\n\n```\nUser.query.pluck(\"first_name\", \"last_name\").each do |(first_name, last_name)|\n # ...\nend\n```","summary":"Select specifics columns and return an array of Tuple(*Clear::SQL::Any) containing the columns in the order of the selected arguments:
","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":""}],"args_string":"(*fields)","args_html":"(*fields)","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":72,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L72"},"def":{"name":"pluck","args":[{"name":"fields","external_name":"fields","restriction":""}],"splat_index":0,"visibility":"Public","body":"pluck(fields)"}},{"html_id":"pluck(**fields:**T)forallT-instance-method","name":"pluck","doc":"Select specifics columns and returns on array of tuple of type of the named tuple passed as parameter:\n\n```\nUser.query.pluck(id: Int64, \"UPPER(last_name)\": String).each do #...\n```","summary":"Select specifics columns and returns on array of tuple of type of the named tuple passed as parameter:
","abstract":false,"location":{"filename":"src/clear/sql/query/pluck.cr","line_number":102,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L102"},"def":{"name":"pluck","double_splat":{"name":"fields","external_name":"fields","restriction":"**T"},"visibility":"Public","body":"sql = (clear_select.select(fields.keys.join(\", \"))).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n {% if true %}\n o = [] of Tuple({% for k, v in T %}{{ v.instance }},{% end %})\n\n while rs.move_next\n o << { {% for k, v in T %} rs.read({{ v.instance }}), {% end %}}\n end\n o\n {% end %}\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"pluck_col(field:Clear::SQL::Symbolic,type:T.class)forallT-instance-method","name":"pluck_col","doc":"Select a specific column of your SQL query, execute the query\nand return an array containing this field.\n\n```\nUser.query.pluck_col(\"id\") # [1,2,3,4...]\n```\n\nNote: It returns an array of `Clear::SQL::Any`. Therefore, you may want to use `pluck_col(str, Type)` to return\n an array of `Type`:\n\n```\nUser.query.pluck_col(\"id\", Int64)\n```\n\nThe field argument is a SQL fragment; it's not escaped (beware SQL injection) and allow call to functions\nand aggregate methods:\n\n```\n# ...\nUser.query.pluck_col(\"CASE WHEN id % 2 = 0 THEN id ELSE NULL END AS id\").each do\n# ...\n```","summary":"Select a specific column of your SQL query, execute the query and return an array containing this field.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"},{"name":"type","external_name":"type","restriction":"T.class"}],"args_string":"(field : Clear::SQL::Symbolic, type : T.class) forall T","args_html":"(field : Clear::SQL::Symbolic, type : T.class) forall T","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":44,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L44"},"def":{"name":"pluck_col","args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"},{"name":"type","external_name":"type","restriction":"T.class"}],"visibility":"Public","body":"if field.is_a?(Symbol)\n field = Clear::SQL.escape(field)\nend\nsql = (clear_select.select(field)).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n o = [] of T\n while rs.move_next\n o << (rs.read(T))\n end\n o\n ensure\n rs.try(&.close)\n end\nend\n"}},{"html_id":"pluck_col(field:Clear::SQL::Symbolic)-instance-method","name":"pluck_col","doc":"Select a specific column of your SQL query, execute the query\nand return an array containing this field.\n\n```\nUser.query.pluck_col(\"id\") # [1,2,3,4...]\n```\n\nNote: It returns an array of `Clear::SQL::Any`. Therefore, you may want to use `pluck_col(str, Type)` to return\n an array of `Type`:\n\n```\nUser.query.pluck_col(\"id\", Int64)\n```\n\nThe field argument is a SQL fragment; it's not escaped (beware SQL injection) and allow call to functions\nand aggregate methods:\n\n```\n# ...\nUser.query.pluck_col(\"CASE WHEN id % 2 = 0 THEN id ELSE NULL END AS id\").each do\n# ...\n```","summary":"Select a specific column of your SQL query, execute the query and return an array containing this field.
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"}],"args_string":"(field : Clear::SQL::Symbolic)","args_html":"(field : Clear::SQL::Symbolic)","location":{"filename":"src/clear/sql/query/pluck.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/pluck.cr#L24"},"def":{"name":"pluck_col","args":[{"name":"field","external_name":"field","restriction":"Clear::SQL::Symbolic"}],"visibility":"Public","body":"if field.is_a?(Symbol)\n field = Clear::SQL.escape(field)\nend\nsql = (clear_select.select(field)).to_sql\nClear::SQL::ConnectionPool.with_connection(connection_name) do |cnx|\n begin\n rs = Clear::SQL.log_query(sql) do\n cnx.query(sql)\n end\n o = [] of Clear::SQL::Any\n while rs.move_next\n o << (rs.read.as(Clear::SQL::Any))\n end\n o\n ensure\n rs.try(&.close)\n end\nend\n"}}]},{"html_id":"clear/Clear/SQL/Query/Select","path":"Clear/SQL/Query/Select.html","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select","abstract":false,"locations":[{"filename":"src/clear/sql/query/select.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"clear_distinct-instance-method","name":"clear_distinct","doc":"Remove distinct","summary":"Remove distinct
","abstract":false,"location":{"filename":"src/clear/sql/query/select.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L43"},"def":{"name":"clear_distinct","visibility":"Public","body":"distinct(nil)"}},{"html_id":"clear_select-instance-method","name":"clear_select","abstract":false,"location":{"filename":"src/clear/sql/query/select.cr","line_number":66,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L66"},"def":{"name":"clear_select","visibility":"Public","body":"@columns.clear\nchange!\n"}},{"html_id":"default_wildcard_table=(table:String|Nil=nil)-instance-method","name":"default_wildcard_table=","doc":"In some case you want you query to return `table.*` instead of `*`\n if no select parameters has been set. This occurs in the case of joins\n between models.","summary":"In some case you want you query to return table.*
instead of *
if no select parameters has been set.
Add DISTINCT to the SELECT part of the query
","abstract":false,"args":[{"name":"on","default_value":"\"\"","external_name":"on","restriction":"String | ::Nil"}],"args_string":"(on : String | Nil = \"\")","args_html":"(on : String | Nil = "")","location":{"filename":"src/clear/sql/query/select.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L37"},"def":{"name":"distinct","args":[{"name":"on","default_value":"\"\"","external_name":"on","restriction":"String | ::Nil"}],"visibility":"Public","body":"@distinct_value = on\nchange!\n"}},{"html_id":"distinct_value:String|Nil-instance-method","name":"distinct_value","abstract":false,"location":{"filename":"src/clear/sql/query/select.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L12"},"def":{"name":"distinct_value","return_type":"String | ::Nil","visibility":"Public","body":"@distinct_value"}},{"html_id":"select(c:Column)-instance-method","name":"select","doc":"def select(name : Symbolic, var = nil)\n @columns << Column.new(name, var)\n self\nend","summary":"def select(name : Symbolic, var = nil) @columns << Column.new(name, var) self end
","abstract":false,"args":[{"name":"c","external_name":"c","restriction":"Column"}],"args_string":"(c : Column)","args_html":"(c : Column)","location":{"filename":"src/clear/sql/query/select.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L26"},"def":{"name":"select","args":[{"name":"c","external_name":"c","restriction":"Column"}],"visibility":"Public","body":"@columns << c\nchange!\n"}},{"html_id":"select(*args)-instance-method","name":"select","doc":"Add field(s) to selection from tuple\n\n```\nselect({user_id: \"uid\", updated_at: \"updated_at\"})\n# => Output \"SELECT user_id as uid, updated_at as updated_at\"\n```","summary":"Add field(s) to selection from tuple
","abstract":false,"args":[{"name":"args","external_name":"args","restriction":""}],"args_string":"(*args)","args_html":"(*args)","location":{"filename":"src/clear/sql/query/select.cr","line_number":53,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/select.cr#L53"},"def":{"name":"select","args":[{"name":"args","external_name":"args","restriction":""}],"splat_index":0,"visibility":"Public","body":"args.each do |arg|\n case arg\n when NamedTuple\n arg.each do |k, v|\n @columns << (Column.new(v, k.to_s))\n end\n else\n @columns << (Column.new(arg))\n end\nend\nchange!\n"}}]},{"html_id":"clear/Clear/SQL/Query/Where","path":"Clear/SQL/Query/Where.html","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where","abstract":false,"locations":[{"filename":"src/clear/sql/query/where.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/where.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL/DeleteQuery","kind":"class","full_name":"Clear::SQL::DeleteQuery","name":"DeleteQuery"},{"html_id":"clear/Clear/SQL/Query/OnConflict/OnConflictWhereClause","kind":"class","full_name":"Clear::SQL::Query::OnConflict::OnConflictWhereClause","name":"OnConflictWhereClause"},{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"doc":"Feature WHERE clause building.\neach call to where method stack where clause.\nTheses clauses are then combined together using the `AND` operator.\nTherefore, `query.where(\"a\").where(\"b\")` will return `a AND b`\n","summary":"Feature WHERE clause building.
","instance_methods":[{"html_id":"clear_wheres-instance-method","name":"clear_wheres","doc":"Clear all the where clauses and return `self`","summary":"Clear all the where clauses and return self
Build SQL #or_where
condition using a Clear::Expression::Node
Build SQL #where
condition using the Expression engine.
Build SQL #where
condition using a Clear::Expression::Node
Build SQL #where
condition using the Expression engine.
Build SQL #where
condition using a NamedTuple.
Build custom SQL #where
beware of SQL injections!
Build SQL #where
condition using a template string and interpolating ?
characters with parameters given in a tuple or array.
Build SQL #where
interpolating :keyword
with the NamedTuple passed in argument.
eq.
","abstract":false,"location":{"filename":"src/clear/sql/query/window.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/window.cr#L5"},"def":{"name":"windows","return_type":"Array(WindowDeclaration)","visibility":"Public","body":"@windows"}}],"types":[{"html_id":"clear/Clear/SQL/Query/Window/WindowDeclaration","path":"Clear/SQL/Query/Window/WindowDeclaration.html","kind":"alias","full_name":"Clear::SQL::Query::Window::WindowDeclaration","name":"WindowDeclaration","abstract":false,"locations":[{"filename":"src/clear/sql/query/window.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/window.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"Tuple(String, String)","aliased_html":"{String, String}","const":false,"namespace":{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"}}]},{"html_id":"clear/Clear/SQL/Query/WithPagination","path":"Clear/SQL/Query/WithPagination.html","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination","abstract":false,"locations":[{"filename":"src/clear/sql/query/with_pagination.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"DEFAULT_LIMIT","name":"DEFAULT_LIMIT","value":"50"},{"id":"DEFAULT_PAGE","name":"DEFAULT_PAGE","value":"1"}],"including_types":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"}],"namespace":{"html_id":"clear/Clear/SQL/Query","kind":"module","full_name":"Clear::SQL::Query","name":"Query"},"instance_methods":[{"html_id":"current_page-instance-method","name":"current_page","doc":"Return the current page","summary":"Return the current page
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L33"},"def":{"name":"current_page","visibility":"Public","body":"if offset.nil? || limit.nil?\n 1\nelse\n ((offset.as(Int64)) / (limit.as(Int64))) + 1\nend"}},{"html_id":"first_page?-instance-method","name":"first_page?","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":64,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L64"},"def":{"name":"first_page?","visibility":"Public","body":"current_page <= 1"}},{"html_id":"last_page?-instance-method","name":"last_page?","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":60,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L60"},"def":{"name":"last_page?","visibility":"Public","body":"next_page.nil?"}},{"html_id":"next_page-instance-method","name":"next_page","doc":"Return `current_page + 1` or `nil` if there is no next page","summary":"Return current_page + 1
or nil
if there is no next page
Helper method that is true when someone tries to fetch a page with a larger number than the last page.
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L71"},"def":{"name":"out_of_bounds?","visibility":"Public","body":"current_page > total_pages"}},{"html_id":"paginate(page:Int32=DEFAULT_PAGE,per_page:Int32=DEFAULT_LIMIT)-instance-method","name":"paginate","doc":"Enter pagination mode.\nThis is helpful to manage paginated table.\nPagination will handle the page progression automatically and update\n`offset` and `limit` parameters by his own.\n\n```\npage = query.paginate(2, 50)\n```","summary":"Enter pagination mode.
","abstract":false,"args":[{"name":"page","default_value":"DEFAULT_PAGE","external_name":"page","restriction":"Int32"},{"name":"per_page","default_value":"DEFAULT_LIMIT","external_name":"per_page","restriction":"Int32"}],"args_string":"(page : Int32 = DEFAULT_PAGE, per_page : Int32 = DEFAULT_LIMIT)","args_html":"(page : Int32 = DEFAULT_PAGE, per_page : Int32 = DEFAULT_LIMIT)","location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":17,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L17"},"def":{"name":"paginate","args":[{"name":"page","default_value":"DEFAULT_PAGE","external_name":"page","restriction":"Int32"},{"name":"per_page","default_value":"DEFAULT_LIMIT","external_name":"per_page","restriction":"Int32"}],"visibility":"Public","body":"clear_limit.clear_offset\n@total_entries = count\npage = {1, page}.max\n@limit = per_page.to_i64\n@offset = (per_page * (page - 1)).to_i64\nchange!\n"}},{"html_id":"per_page-instance-method","name":"per_page","doc":"Return the number of items maximum per page.","summary":"Return the number of items maximum per page.
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":28,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L28"},"def":{"name":"per_page","visibility":"Public","body":"limit"}},{"html_id":"previous_page-instance-method","name":"previous_page","doc":"Return `current_page - 1` or `nil` if there is no previous page","summary":"Return current_page - 1
or nil
if there is no previous page
Return the total number of pages.
","abstract":false,"location":{"filename":"src/clear/sql/query/with_pagination.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/query/with_pagination.cr#L42"},"def":{"name":"total_pages","visibility":"Public","body":"if limit.nil? || total_entries.nil?\n 1\nelse\n ((total_entries.as(Int64)) / (limit.as(Int64)).to_f).ceil.to_i\nend"}}]}]},{"html_id":"clear/Clear/SQL/QueryBuildingError","path":"Clear/SQL/QueryBuildingError.html","kind":"class","full_name":"Clear::SQL::QueryBuildingError","name":"QueryBuildingError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/RecordNotFoundError","path":"Clear/SQL/RecordNotFoundError.html","kind":"class","full_name":"Clear::SQL::RecordNotFoundError","name":"RecordNotFoundError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L10"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/RollbackError","path":"Clear/SQL/RollbackError.html","kind":"class","full_name":"Clear::SQL::RollbackError","name":"RollbackError","abstract":false,"superclass":{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},"ancestors":[{"html_id":"clear/Clear/SQL/Error","kind":"class","full_name":"Clear::SQL::Error","name":"Error"},{"html_id":"clear/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/errors.cr","line_number":13,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/errors.cr#L13"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"Rollback the transaction or the last savepoint.","summary":"Rollback the transaction or the last savepoint.
"},{"html_id":"clear/Clear/SQL/Selectable","path":"Clear/SQL/Selectable.html","kind":"alias","full_name":"Clear::SQL::Selectable","name":"Selectable","abstract":false,"locations":[{"filename":"src/clear/sql/sql.cr","line_number":68,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L68"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Clear::SQL::SelectBuilder | String | Symbol)","aliased_html":"Clear::SQL::SelectBuilder | String | Symbol","const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/SelectBuilder","path":"Clear/SQL/SelectBuilder.html","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder","abstract":false,"ancestors":[{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"}],"locations":[{"filename":"src/clear/sql/select_builder.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"}],"including_types":[{"html_id":"clear/Clear/Model/CollectionBase","kind":"class","full_name":"Clear::Model::CollectionBase(T)","name":"CollectionBase"},{"html_id":"clear/Clear/SQL/SelectQuery","kind":"class","full_name":"Clear::SQL::SelectQuery","name":"SelectQuery"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"constructors":[{"html_id":"new(distinct_value=nil,cte={}ofString=>Clear::SQL::SelectBuilder|String,columns=[]ofSQL::Column,froms=[]ofSQL::From,joins=[]ofSQL::Join,wheres=[]ofClear::Expression::Node,havings=[]ofClear::Expression::Node,windows=[]of::Tuple(String,String),group_bys=[]ofSymbolic,order_bys=[]ofClear::SQL::Query::OrderBy::Record,limit=nil,offset=nil,lock=nil,before_query_triggers=[]of(->Nil))-class-method","name":"new","abstract":false,"args":[{"name":"distinct_value","default_value":"nil","external_name":"distinct_value","restriction":""},{"name":"cte","default_value":"{} of String => Clear::SQL::SelectBuilder | String","external_name":"cte","restriction":""},{"name":"columns","default_value":"[] of SQL::Column","external_name":"columns","restriction":""},{"name":"froms","default_value":"[] of SQL::From","external_name":"froms","restriction":""},{"name":"joins","default_value":"[] of SQL::Join","external_name":"joins","restriction":""},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":""},{"name":"havings","default_value":"[] of Clear::Expression::Node","external_name":"havings","restriction":""},{"name":"windows","default_value":"[] of ::Tuple(String, String)","external_name":"windows","restriction":""},{"name":"group_bys","default_value":"[] of Symbolic","external_name":"group_bys","restriction":""},{"name":"order_bys","default_value":"[] of Clear::SQL::Query::OrderBy::Record","external_name":"order_bys","restriction":""},{"name":"limit","default_value":"nil","external_name":"limit","restriction":""},{"name":"offset","default_value":"nil","external_name":"offset","restriction":""},{"name":"lock","default_value":"nil","external_name":"lock","restriction":""},{"name":"before_query_triggers","default_value":"[] of (-> Nil)","external_name":"before_query_triggers","restriction":""}],"args_string":"(distinct_value = nil, cte = {} of String => Clear::SQL::SelectBuilder | String, columns = [] of SQL::Column, froms = [] of SQL::From, joins = [] of SQL::Join, wheres = [] of Clear::Expression::Node, havings = [] of Clear::Expression::Node, windows = [] of ::Tuple(String, String), group_bys = [] of Symbolic, order_bys = [] of Clear::SQL::Query::OrderBy::Record, limit = nil, offset = nil, lock = nil, before_query_triggers = [] of (-> Nil))","args_html":"(distinct_value = nil, cte = {} of String => Clear::SQL::SelectBuilder | String, columns = [] of SQL::Column, froms = [] of SQL::From, joins = [] of SQL::Join, wheres = [] of Clear::Expression::Node, havings = [] of Clear::Expression::Node, windows = [] of ::Tuple(String, String), group_bys = [] of Symbolic, order_bys = [] of Clear::SQL::Query::OrderBy::Record, limit = nil, offset = nil, lock = nil, before_query_triggers = [] of (-> Nil))","location":{"filename":"src/clear/sql/select_builder.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L29"},"def":{"name":"new","args":[{"name":"distinct_value","default_value":"nil","external_name":"distinct_value","restriction":""},{"name":"cte","default_value":"{} of String => Clear::SQL::SelectBuilder | String","external_name":"cte","restriction":""},{"name":"columns","default_value":"[] of SQL::Column","external_name":"columns","restriction":""},{"name":"froms","default_value":"[] of SQL::From","external_name":"froms","restriction":""},{"name":"joins","default_value":"[] of SQL::Join","external_name":"joins","restriction":""},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":""},{"name":"havings","default_value":"[] of Clear::Expression::Node","external_name":"havings","restriction":""},{"name":"windows","default_value":"[] of ::Tuple(String, String)","external_name":"windows","restriction":""},{"name":"group_bys","default_value":"[] of Symbolic","external_name":"group_bys","restriction":""},{"name":"order_bys","default_value":"[] of Clear::SQL::Query::OrderBy::Record","external_name":"order_bys","restriction":""},{"name":"limit","default_value":"nil","external_name":"limit","restriction":""},{"name":"offset","default_value":"nil","external_name":"offset","restriction":""},{"name":"lock","default_value":"nil","external_name":"lock","restriction":""},{"name":"before_query_triggers","default_value":"[] of (-> Nil)","external_name":"before_query_triggers","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(distinct_value, cte, columns, froms, joins, wheres, havings, windows, group_bys, order_bys, limit, offset, lock, before_query_triggers)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"before_query(&block:->Nil)-instance-method","name":"before_query","doc":"A hook to apply some operation just before the query is executed.\n\n```\ncall = 0\nreq = Clear::SQL.select(\"1\").before_query { call += 1 }\n10.times { req.execute }\npp call # 10\n```","summary":"A hook to apply some operation just before the query is executed.
","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":26,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L26"},"def":{"name":"before_query","yields":0,"block_arity":0,"block_arg":{"name":"block","external_name":"block","restriction":"(-> Nil)"},"visibility":"Public","body":"@before_query_triggers << block\nself\n"}},{"html_id":"columns:Array(SQL::Column)-instance-method","name":"columns","abstract":false,"def":{"name":"columns","return_type":"Array(SQL::Column)","visibility":"Public","body":"@columns"}},{"html_id":"default_wildcard_table-instance-method","name":"default_wildcard_table","abstract":false,"def":{"name":"default_wildcard_table","visibility":"Public","body":"@default_wildcard_table"}},{"html_id":"dup:self-instance-method","name":"dup","doc":"Duplicate the query","summary":"Duplicate the query
","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":46,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L46"},"def":{"name":"dup","return_type":"self","visibility":"Public","body":"self.class.new(distinct_value: @distinct_value, cte: @cte.dup, columns: @columns.dup, froms: @froms.dup, joins: @joins.dup, wheres: @wheres.dup, havings: @havings.dup, windows: @windows.dup, group_bys: @group_bys.dup, order_bys: @order_bys.dup, limit: @limit, offset: @offset, lock: @lock, before_query_triggers: @before_query_triggers).use_connection(connection_name)"}},{"html_id":"havings:Array(Clear::Expression::Node)-instance-method","name":"havings","abstract":false,"def":{"name":"havings","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@havings"}},{"html_id":"is_distinct?-instance-method","name":"is_distinct?","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":4,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L4"},"def":{"name":"is_distinct?","visibility":"Public","body":"!!@distinct_value"}},{"html_id":"joins:Array(SQL::Join)-instance-method","name":"joins","abstract":false,"def":{"name":"joins","return_type":"Array(SQL::Join)","visibility":"Public","body":"@joins"}},{"html_id":"limit:Int64|Nil-instance-method","name":"limit","abstract":false,"def":{"name":"limit","return_type":"Int64 | ::Nil","visibility":"Public","body":"@limit"}},{"html_id":"lock:String|Nil-instance-method","name":"lock","abstract":false,"def":{"name":"lock","return_type":"String | ::Nil","visibility":"Public","body":"@lock"}},{"html_id":"offset:Int64|Nil-instance-method","name":"offset","abstract":false,"def":{"name":"offset","return_type":"Int64 | ::Nil","visibility":"Public","body":"@offset"}},{"html_id":"order_bys:Array(Clear::SQL::Query::OrderBy::Record)-instance-method","name":"order_bys","abstract":false,"def":{"name":"order_bys","return_type":"Array(Clear::SQL::Query::OrderBy::Record)","visibility":"Public","body":"@order_bys"}},{"html_id":"to_delete-instance-method","name":"to_delete","doc":"Construct a delete query from this select query.\nIt uses only the `from` and the `where` clause fo the current select request.\nCan be useful in some case, but\n use at your own risk !","summary":"Construct a delete query from this select query.
","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":83,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L83"},"def":{"name":"to_delete","visibility":"Public","body":"if @froms.size == 1\nelse\n raise(QueryBuildingError.new(\"Cannot build a delete query \" + \"from a select with multiple or none `from` clauses\"))\nend\nv = @froms[0].value\nif v.is_a?(SelectBuilder)\n raise(QueryBuildingError.new(\"Cannot delete from a select with sub-select as `from` clause\"))\nend\nDeleteQuery.new(v.dup, @wheres.dup)\n"}},{"html_id":"to_sql:String-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":65,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L65"},"def":{"name":"to_sql","return_type":"String","visibility":"Public","body":"[print_ctes, print_select, print_froms, print_joins, print_wheres, print_windows, print_group_bys, print_havings, print_order_bys, print_limit_offsets, print_lock].compact.reject(&.empty?).join(\" \")"}},{"html_id":"to_update-instance-method","name":"to_update","abstract":false,"location":{"filename":"src/clear/sql/select_builder.cr","line_number":94,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_builder.cr#L94"},"def":{"name":"to_update","visibility":"Public","body":"if @froms.size == 1\nelse\n raise(QueryBuildingError.new(\"Cannot build a update query \" + \"from a select with multiple or none `from` clauses\"))\nend\nv = @froms[0].value\nif v.is_a?(SelectBuilder)\n raise(QueryBuildingError.new(\"Cannot delete from a select with sub-select as `from` clause\"))\nend\nUpdateQuery.new(table: v.dup, wheres: @wheres.dup)\n"}},{"html_id":"total_entries:Int64|Nil-instance-method","name":"total_entries","abstract":false,"def":{"name":"total_entries","return_type":"Int64 | ::Nil","visibility":"Public","body":"@total_entries"}},{"html_id":"total_entries=(total_entries:Int64|Nil)-instance-method","name":"total_entries=","abstract":false,"args":[{"name":"total_entries","external_name":"total_entries","restriction":"Int64 | ::Nil"}],"args_string":"(total_entries : Int64 | Nil)","args_html":"(total_entries : Int64 | Nil)","def":{"name":"total_entries=","args":[{"name":"total_entries","external_name":"total_entries","restriction":"Int64 | ::Nil"}],"visibility":"Public","body":"@total_entries = total_entries"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}]},{"html_id":"clear/Clear/SQL/SelectQuery","path":"Clear/SQL/SelectQuery.html","kind":"class","full_name":"Clear::SQL::SelectQuery","name":"SelectQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Clear/SQL/Query/WithPagination","kind":"module","full_name":"Clear::SQL::Query::WithPagination","name":"WithPagination"},{"html_id":"clear/Clear/SQL/Query/BeforeQuery","kind":"module","full_name":"Clear::SQL::Query::BeforeQuery","name":"BeforeQuery"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/Pluck","kind":"module","full_name":"Clear::SQL::Query::Pluck","name":"Pluck"},{"html_id":"clear/Clear/SQL/Query/Fetch","kind":"module","full_name":"Clear::SQL::Query::Fetch","name":"Fetch"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Lock","kind":"module","full_name":"Clear::SQL::Query::Lock","name":"Lock"},{"html_id":"clear/Clear/SQL/Query/Window","kind":"module","full_name":"Clear::SQL::Query::Window","name":"Window"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Aggregate","kind":"module","full_name":"Clear::SQL::Query::Aggregate","name":"Aggregate"},{"html_id":"clear/Clear/SQL/Query/OffsetLimit","kind":"module","full_name":"Clear::SQL::Query::OffsetLimit","name":"OffsetLimit"},{"html_id":"clear/Clear/SQL/Query/GroupBy","kind":"module","full_name":"Clear::SQL::Query::GroupBy","name":"GroupBy"},{"html_id":"clear/Clear/SQL/Query/OrderBy","kind":"module","full_name":"Clear::SQL::Query::OrderBy","name":"OrderBy"},{"html_id":"clear/Clear/SQL/Query/Having","kind":"module","full_name":"Clear::SQL::Query::Having","name":"Having"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Join","kind":"module","full_name":"Clear::SQL::Query::Join","name":"Join"},{"html_id":"clear/Clear/SQL/Query/From","kind":"module","full_name":"Clear::SQL::Query::From","name":"From"},{"html_id":"clear/Clear/SQL/Query/Select","kind":"module","full_name":"Clear::SQL::Query::Select","name":"Select"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/select_query.cr","line_number":25,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_query.cr#L25"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/SelectBuilder","kind":"module","full_name":"Clear::SQL::SelectBuilder","name":"SelectBuilder"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"A Select Query builder\n\nPostgres documentation:\n\n```\n[ WITH [ RECURSIVE ] with_query [, ...] ]\nSELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]\n [ * | expression [ [ AS ] output_name ] [, ...] ]\n [ FROM from_item [, ...] ]\n [ WHERE condition ]\n [ GROUP BY grouping_element [, ...] ]\n [ HAVING condition [, ...] ]\n [ WINDOW window_name AS ( window_definition ) [, ...] ]\n [ { UNION | INTERSECT | EXCEPT } [ ALL | DISTINCT ] select ]\n [ ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] ]\n [ LIMIT { count | ALL } ]\n [ OFFSET start [ ROW | ROWS ] ]\n [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]\n [ FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT | SKIP LOCKED ] [...] ]\n```","summary":"A Select Query builder
","instance_methods":[{"html_id":"each(&):Nil-instance-method","name":"each","doc":"Must yield this collection's elements to the block.","summary":"Must yield this collection's elements to the block.
","abstract":false,"location":{"filename":"src/clear/sql/select_query.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/select_query.cr#L29"},"def":{"name":"each","yields":1,"block_arity":1,"return_type":"Nil","visibility":"Public","body":"fetch do |h|\n yield(h)\nend"}}]},{"html_id":"clear/Clear/SQL/Symbolic","path":"Clear/SQL/Symbolic.html","kind":"alias","full_name":"Clear::SQL::Symbolic","name":"Symbolic","abstract":false,"locations":[{"filename":"src/clear/sql/sql.cr","line_number":67,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/sql.cr#L67"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(String | Symbol)","aliased_html":"String | Symbol","const":false,"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}},{"html_id":"clear/Clear/SQL/Transaction","path":"Clear/SQL/Transaction.html","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction","abstract":false,"locations":[{"filename":"src/clear/sql/transaction.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"instance_methods":[{"html_id":"after_commit(connection:String=\"default\",&block:DB::Connection->Nil)-instance-method","name":"after_commit","doc":"Register a callback function which will be fired once when SQL `COMMIT`\noperation is called\n\nThis can be used for example to send email, or perform others tasks\nwhen you want to be sure the data is secured in the database.\n\n```\ntransaction do\n @user = User.find(1)\n @user.subscribe!\n Clear::SQL.after_commit { Email.deliver(ConfirmationMail.new(@user)) }\nend\n```\n\nIn case the transaction fail and eventually rollback, the code won't be called.\n","summary":"Register a callback function which will be fired once when SQL COMMIT
operation is called
Check whether the current pair of fiber/connection is in transaction block or not.
","abstract":false,"args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"}],"args_string":"(connection : String = \"default\")","args_html":"(connection : String = "default")","location":{"filename":"src/clear/sql/transaction.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L29"},"def":{"name":"in_transaction?","args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"Clear::SQL::ConnectionPool.with_connection(connection, &._clear_in_transaction?)"}},{"html_id":"rollback(to=nil)-instance-method","name":"rollback","doc":"Rollback a transaction or return to the previous savepoint in case of a\nwith_savepoint block.\nThe params `to` offer","summary":"Rollback a transaction or return to the previous savepoint in case of a with_savepoint block.
","abstract":false,"args":[{"name":"to","default_value":"nil","external_name":"to","restriction":""}],"args_string":"(to = nil)","args_html":"(to = nil)","location":{"filename":"src/clear/sql/transaction.cr","line_number":138,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L138"},"def":{"name":"rollback","args":[{"name":"to","default_value":"nil","external_name":"to","restriction":""}],"visibility":"Public","body":"raise(RollbackError.new(to))"}},{"html_id":"rollback_transaction-instance-method","name":"rollback_transaction","doc":"Rollback the transaction. In case the call is made inside a savepoint block\nrollback everything.","summary":"Rollback the transaction.
","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":144,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L144"},"def":{"name":"rollback_transaction","visibility":"Public","body":"raise(CancelTransactionError.new)"}},{"html_id":"transaction(connection:String=\"default\",level:Level=Level::Serializable,&)-instance-method","name":"transaction","doc":"Enter new transaction block for the current connection/fiber pair.\n\nExample:\n\n```\nClear::SQL.transaction do\n # do something\n Clear::SQL.transaction do # Technically, this block do nothing, since we already are in transaction\n rollback # < Rollback the up-most `transaction` block.\n end\nend\n```\n\nsee #with_savepoint to use a stackable version using savepoints.\n","summary":"Enter new transaction block for the current connection/fiber pair.
","abstract":false,"args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"},{"name":"level","default_value":"Level::Serializable","external_name":"level","restriction":"Level"}],"args_string":"(connection : String = \"default\", level : Level = Level::Serializable, &)","args_html":"(connection : String = "default", level : Level = Level::Serializable, &)","location":{"filename":"src/clear/sql/transaction.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L48"},"def":{"name":"transaction","args":[{"name":"connection","default_value":"\"default\"","external_name":"connection","restriction":"String"},{"name":"level","default_value":"Level::Serializable","external_name":"level","restriction":"Level"}],"yields":1,"block_arity":1,"visibility":"Public","body":"Clear::SQL::ConnectionPool.with_connection(connection) do |cnx|\n has_rollback = false\n if cnx._clear_in_transaction?\n return yield(cnx)\n else\n cnx._clear_in_transaction = true\n execute(level.to_begin_operation)\n begin\n return yield(cnx)\n rescue e\n has_rollback = true\n is_rollback_error = e.is_a?(RollbackError) || e.is_a?(CancelTransactionError)\n begin\n execute(\"ROLLBACK --\" + (is_rollback_error ? \"normal\" : \"program error\"))\n rescue\n nil\n end\n if is_rollback_error\n else\n raise(e)\n end\n ensure\n cnx._clear_in_transaction = false\n callbacks = @@commit_callbacks.delete(cnx)\n if has_rollback\n else\n execute(\"COMMIT\")\n callbacks.try(&.each(&.call(cnx)))\n end\n end\n end\nend"}},{"html_id":"with_savepoint(sp_name:Symbolic|Nil=nil,connection_name:String=\"default\",&)-instance-method","name":"with_savepoint","doc":"Create a transaction, but this one is stackable\nusing savepoints.\n\nExample:\n\n```\nClear::SQL.with_savepoint do\n # do something\n Clear::SQL.with_savepoint do\n rollback # < Rollback only the last `with_savepoint` block\n end\nend\n```","summary":"Create a transaction, but this one is stackable using savepoints.
","abstract":false,"args":[{"name":"sp_name","default_value":"nil","external_name":"sp_name","restriction":"Symbolic | ::Nil"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"args_string":"(sp_name : Symbolic | Nil = nil, connection_name : String = \"default\", &)","args_html":"(sp_name : Symbolic | Nil = nil, connection_name : String = "default", &)","location":{"filename":"src/clear/sql/transaction.cr","line_number":121,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L121"},"def":{"name":"with_savepoint","args":[{"name":"sp_name","default_value":"nil","external_name":"sp_name","restriction":"Symbolic | ::Nil"},{"name":"connection_name","default_value":"\"default\"","external_name":"connection_name","restriction":"String"}],"yields":0,"block_arity":0,"visibility":"Public","body":"transaction do |cnx|\n begin\n sp_name || (sp_name = \"sp_#{@@savepoint_uid = @@savepoint_uid + 1}\")\n execute(connection_name, \"SAVEPOINT #{sp_name}\")\n yield\n if cnx._clear_in_transaction?\n execute(connection_name, \"RELEASE SAVEPOINT #{sp_name}\")\n end\n rescue e : RollbackError\n if cnx._clear_in_transaction?\n execute(connection_name, \"ROLLBACK TO SAVEPOINT #{sp_name}\")\n if e.savepoint_id.try(&.!=(sp_name))\n raise(e)\n end\n end\n end\nend"}}],"types":[{"html_id":"clear/Clear/SQL/Transaction/Level","path":"Clear/SQL/Transaction/Level.html","kind":"enum","full_name":"Clear::SQL::Transaction::Level","name":"Level","abstract":false,"ancestors":[{"html_id":"clear/Enum","kind":"struct","full_name":"Enum","name":"Enum"},{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/transaction.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L6"}],"repository_name":"clear","program":false,"enum":true,"alias":false,"const":false,"constants":[{"id":"ReadCommitted","name":"ReadCommitted","value":"0"},{"id":"RepeatableRead","name":"RepeatableRead","value":"1"},{"id":"Serializable","name":"Serializable","value":"2"}],"namespace":{"html_id":"clear/Clear/SQL/Transaction","kind":"module","full_name":"Clear::SQL::Transaction","name":"Transaction"},"doc":"Represents the differents levels of transactions\n as described in https://www.postgresql.org/docs/9.5/transaction-iso.html\n\n ReadUncommited is voluntarly ommited as it fallback to ReadCommited in PostgreSQL","summary":"Represents the differents levels of transactions as described in https://www.postgresql.org/docs/9.5/transaction-iso.html
","instance_methods":[{"html_id":"read_committed?-instance-method","name":"read_committed?","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L7"},"def":{"name":"read_committed?","visibility":"Public","body":"self == ReadCommitted"}},{"html_id":"repeatable_read?-instance-method","name":"repeatable_read?","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L8"},"def":{"name":"repeatable_read?","visibility":"Public","body":"self == RepeatableRead"}},{"html_id":"serializable?-instance-method","name":"serializable?","abstract":false,"location":{"filename":"src/clear/sql/transaction.cr","line_number":9,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/transaction.cr#L9"},"def":{"name":"serializable?","visibility":"Public","body":"self == Serializable"}}]}]},{"html_id":"clear/Clear/SQL/UpdateQuery","path":"Clear/SQL/UpdateQuery.html","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"},{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/sql/update_query.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L6"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Clear/SQL/Query/Change","kind":"module","full_name":"Clear::SQL::Query::Change","name":"Change"},{"html_id":"clear/Clear/SQL/Query/Connection","kind":"module","full_name":"Clear::SQL::Query::Connection","name":"Connection"},{"html_id":"clear/Clear/SQL/Query/CTE","kind":"module","full_name":"Clear::SQL::Query::CTE","name":"CTE"},{"html_id":"clear/Clear/SQL/Query/Execute","kind":"module","full_name":"Clear::SQL::Query::Execute","name":"Execute"},{"html_id":"clear/Clear/SQL/Query/Where","kind":"module","full_name":"Clear::SQL::Query::Where","name":"Where"}],"namespace":{"html_id":"clear/Clear/SQL","kind":"module","full_name":"Clear::SQL","name":"SQL"},"doc":"TODO: Documentation","summary":"TODO Documentation
","constructors":[{"html_id":"new(table:String|Symbol|Nil,wheres:Array(Clear::Expression::Node)=[]ofClear::Expression::Node)-class-method","name":"new","abstract":false,"args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"args_string":"(table : String | Symbol | Nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","args_html":"(table : String | Symbol | Nil, wheres : Array(Clear::Expression::Node) = [] of Clear::Expression::Node)","location":{"filename":"src/clear/sql/update_query.cr","line_number":19,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L19"},"def":{"name":"new","args":[{"name":"table","external_name":"table","restriction":"::String | ::Symbol | ::Nil"},{"name":"wheres","default_value":"[] of Clear::Expression::Node","external_name":"wheres","restriction":"::Array(::Clear::Expression::Node)"}],"visibility":"Public","body":"_ = allocate\n_.initialize(table, wheres)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"set(row:NamedTuple)-instance-method","name":"set","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"args_string":"(row : NamedTuple)","args_html":"(row : NamedTuple)","location":{"filename":"src/clear/sql/update_query.cr","line_number":22,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L22"},"def":{"name":"set","args":[{"name":"row","external_name":"row","restriction":"NamedTuple"}],"visibility":"Public","body":"h = {} of String => Updatable\nrow.each do |k, v|\n h[k.to_s] = v\nend\nset(h)\nchange!\n"}},{"html_id":"set(row:String)-instance-method","name":"set","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"String"}],"args_string":"(row : String)","args_html":"(row : String)","location":{"filename":"src/clear/sql/update_query.cr","line_number":33,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L33"},"def":{"name":"set","args":[{"name":"row","external_name":"row","restriction":"String"}],"visibility":"Public","body":"@values << row\nchange!\n"}},{"html_id":"set(row:Hash(String,Updatable))-instance-method","name":"set","abstract":false,"args":[{"name":"row","external_name":"row","restriction":"Hash(String, Updatable)"}],"args_string":"(row : Hash(String, Updatable))","args_html":"(row : Hash(String, Updatable))","location":{"filename":"src/clear/sql/update_query.cr","line_number":38,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L38"},"def":{"name":"set","args":[{"name":"row","external_name":"row","restriction":"Hash(String, Updatable)"}],"visibility":"Public","body":"@values << (Hash(String, Updatable).new.merge(row))\nchange!\n"}},{"html_id":"set(**row)-instance-method","name":"set","abstract":false,"location":{"filename":"src/clear/sql/update_query.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L29"},"def":{"name":"set","double_splat":{"name":"row","external_name":"row","restriction":""},"visibility":"Public","body":"set(row)"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/sql/update_query.cr","line_number":62,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L62"},"def":{"name":"to_sql","visibility":"Public","body":"table = @table.is_a?(Symbol) ? SQL.escape(@table.to_s) : @table\n[print_ctes, \"UPDATE\", table, \"SET\", print_values, print_wheres].compact.join(\" \")\n"}},{"html_id":"wheres:Array(Clear::Expression::Node)-instance-method","name":"wheres","doc":"Return the list of where clause; each where clause are transformed into\nClear::Expression::Node","summary":"Return the list of where clause; each where clause are transformed into Clear::Expression::Node
","abstract":false,"def":{"name":"wheres","return_type":"Array(Clear::Expression::Node)","visibility":"Public","body":"@wheres"}}],"types":[{"html_id":"clear/Clear/SQL/UpdateQuery/Updatable","path":"Clear/SQL/UpdateQuery/Updatable.html","kind":"alias","full_name":"Clear::SQL::UpdateQuery::Updatable","name":"Updatable","abstract":false,"locations":[{"filename":"src/clear/sql/update_query.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L7"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil)","aliased_html":"Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil","const":false,"namespace":{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}},{"html_id":"clear/Clear/SQL/UpdateQuery/UpdateInstruction","path":"Clear/SQL/UpdateQuery/UpdateInstruction.html","kind":"alias","full_name":"Clear::SQL::UpdateQuery::UpdateInstruction","name":"UpdateInstruction","abstract":false,"locations":[{"filename":"src/clear/sql/update_query.cr","line_number":8,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/sql/update_query.cr#L8"}],"repository_name":"clear","program":false,"enum":false,"alias":true,"aliased":"(Hash(String, Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil) | String)","aliased_html":"Hash(String, Array(PG::BoolArray) | Array(PG::CharArray) | Array(PG::Float32Array) | Array(PG::Float64Array) | Array(PG::Int16Array) | Array(PG::Int32Array) | Array(PG::Int64Array) | Array(PG::NumericArray) | Array(PG::StringArray) | Array(PG::TimeArray) | Array(PG::UUIDArray) | BigDecimal | BigFloat | BigInt | Bool | Char | Clear::Expression::Literal | Crypto::Bcrypt::Password | Float32 | Float64 | Int16 | Int32 | Int64 | Int8 | JSON::Any | JSON::PullParser | PG::Geo::Box | PG::Geo::Circle | PG::Geo::Line | PG::Geo::LineSegment | PG::Geo::Path | PG::Geo::Point | PG::Geo::Polygon | PG::Interval | PG::Numeric | Slice(UInt8) | String | Time | UInt16 | UInt32 | UInt64 | UInt8 | UUID | Nil) | String","const":false,"namespace":{"html_id":"clear/Clear/SQL/UpdateQuery","kind":"class","full_name":"Clear::SQL::UpdateQuery","name":"UpdateQuery"}}]}]},{"html_id":"clear/Clear/TimeInDay","path":"Clear/TimeInDay.html","kind":"struct","full_name":"Clear::TimeInDay","name":"TimeInDay","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":29,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L29"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"`Clear::TimeInDay` represents the \"time\" object of PostgreSQL\n\nIt can be converted automatically from/to a `time` column.\nIt offers helpers which makes it usable also as a stand alone.\n\n## Usage example\n\n```\ntime = Clear::TimeInDay.parse(\"12:33\")\nputs time.hour # 12\nputs time.minutes # 0\n\nTime.local.at(time) # Today at 12:33:00\ntime.to_s # 12:33:00\ntime.to_s(false) # don't show seconds => 12:33\n\ntime = time + 2.minutes # 12:35\n```\n\nAs with Interval, you might wanna use it as a column (use underlying `time` type in PostgreSQL):\n\n```\nclass MyModel\n include Clear::Model\n\n column time_in_day : Clear::TimeInDay\nend\n```","summary":"Clear::TimeInDay
represents the "time" object of PostgreSQL
Parse a string, of format HH:MM or HH:MM:SS
","abstract":false,"args":[{"name":"str","external_name":"str","restriction":"String"}],"args_string":"(str : String)","args_html":"(str : String)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":113,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L113"},"def":{"name":"parse","args":[{"name":"str","external_name":"str","restriction":"String"}],"visibility":"Public","body":"if str =~ (/^[0-9]+:[0-9]{2}(:[0-9]{2})?$/)\nelse\n raise(\"Wrong format\")\nend\narr = (str.split(/\\:/)).map(&.try(&.to_i))\nhours = arr[0]\nminutes = arr[1]\nseconds = arr[2]?\nif seconds\n return Clear::TimeInDay.new(hours, minutes, seconds)\nend\nClear::TimeInDay.new(hours, minutes)\n"}}],"constructors":[{"html_id":"new(hours,minutes,seconds=0)-class-method","name":"new","abstract":false,"args":[{"name":"hours","external_name":"hours","restriction":""},{"name":"minutes","external_name":"minutes","restriction":""},{"name":"seconds","default_value":"0","external_name":"seconds","restriction":""}],"args_string":"(hours, minutes, seconds = 0)","args_html":"(hours, minutes, seconds = 0)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":36,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L36"},"def":{"name":"new","args":[{"name":"hours","external_name":"hours","restriction":""},{"name":"minutes","external_name":"minutes","restriction":""},{"name":"seconds","default_value":"0","external_name":"seconds","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(hours, minutes, seconds)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}},{"html_id":"new(microseconds:UInt64=0)-class-method","name":"new","abstract":false,"args":[{"name":"microseconds","default_value":"0","external_name":"microseconds","restriction":"UInt64"}],"args_string":"(microseconds : UInt64 = 0)","args_html":"(microseconds : UInt64 = 0)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":40,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L40"},"def":{"name":"new","args":[{"name":"microseconds","default_value":"0","external_name":"microseconds","restriction":"UInt64"}],"visibility":"Public","body":"_ = allocate\n_.initialize(microseconds)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"+(t:Time::Span)-instance-method","name":"+","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"args_string":"(t : Time::Span)","args_html":"(t : Time::Span)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L43"},"def":{"name":"+","args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"visibility":"Public","body":"Clear::TimeInDay.new(microseconds: @microseconds + (t.total_nanoseconds.to_i64 // 1000))"}},{"html_id":"+(x:self)-instance-method","name":"+","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"self"}],"args_string":"(x : self)","args_html":"(x : self)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":51,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L51"},"def":{"name":"+","args":[{"name":"x","external_name":"x","restriction":"self"}],"visibility":"Public","body":"TimeInDay.new(@microseconds + x.ms)"}},{"html_id":"-(t:Time::Span)-instance-method","name":"-","abstract":false,"args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"args_string":"(t : Time::Span)","args_html":"(t : Time::Span)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L47"},"def":{"name":"-","args":[{"name":"t","external_name":"t","restriction":"Time::Span"}],"visibility":"Public","body":"Clear::TimeInDay.new(microseconds: @microseconds - (t.total_nanoseconds.to_i64 // 1000))"}},{"html_id":"hour-instance-method","name":"hour","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":55,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L55"},"def":{"name":"hour","visibility":"Public","body":"(@microseconds // HOUR)"}},{"html_id":"inspect-instance-method","name":"inspect","doc":"Returns an unambiguous and information-rich string representation of this\nobject, typically intended for developers.\n\nThis method should usually **not** be overridden. It delegates to\n`#inspect(IO)` which can be overridden for custom implementations.\n\nAlso see `#to_s`.","summary":"Returns an unambiguous and information-rich string representation of this object, typically intended for developers.
","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":79,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L79"},"def":{"name":"inspect","visibility":"Public","body":"\"#{self.class.name}(#{self})\""}},{"html_id":"microseconds:UInt64-instance-method","name":"microseconds","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":30,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L30"},"def":{"name":"microseconds","return_type":"UInt64","visibility":"Public","body":"@microseconds"}},{"html_id":"minutes-instance-method","name":"minutes","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":59,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L59"},"def":{"name":"minutes","visibility":"Public","body":"(@microseconds % HOUR) // MINUTE"}},{"html_id":"seconds-instance-method","name":"seconds","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":63,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L63"},"def":{"name":"seconds","visibility":"Public","body":"(@microseconds % MINUTE) // SECOND"}},{"html_id":"to_json(json:JSON::Builder):Nil-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"args_string":"(json : JSON::Builder) : Nil","args_html":"(json : JSON::Builder) : Nil","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L108"},"def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"return_type":"Nil","visibility":"Public","body":"json.string(to_s)"}},{"html_id":"to_s(show_seconds:Bool=true)-instance-method","name":"to_s","doc":"Returns a nicely readable and concise string representation of this object,\ntypically intended for users.\n\nThis method should usually **not** be overridden. It delegates to\n`#to_s(IO)` which can be overridden for custom implementations.\n\nAlso see `#inspect`.","summary":"Returns a nicely readable and concise string representation of this object, typically intended for users.
","abstract":false,"args":[{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"args_string":"(show_seconds : Bool = true)","args_html":"(show_seconds : Bool = true)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":83,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L83"},"def":{"name":"to_s","args":[{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"visibility":"Public","body":"io = IO::Memory.new\nto_s(io, show_seconds)\nio.rewind\nio.to_s\n"}},{"html_id":"to_s(io,show_seconds:Bool=true)-instance-method","name":"to_s","doc":"Return a string","summary":"Return a string
","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""},{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"args_string":"(io, show_seconds : Bool = true)","args_html":"(io, show_seconds : Bool = true)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":91,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L91"},"def":{"name":"to_s","args":[{"name":"io","external_name":"io","restriction":""},{"name":"show_seconds","default_value":"true","external_name":"show_seconds","restriction":"Bool"}],"visibility":"Public","body":"hours, minutes, seconds = to_tuple\nif show_seconds\n io << ({hours.to_s.rjust(2, '0'), minutes.to_s.rjust(2, '0'), seconds.to_s.rjust(2, '0')}.join(':'))\nelse\n io << ({hours.to_s.rjust(2, '0'), minutes.to_s.rjust(2, '0')}.join(':'))\nend\n"}},{"html_id":"to_tuple-instance-method","name":"to_tuple","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":71,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L71"},"def":{"name":"to_tuple","visibility":"Public","body":"hours, left = @microseconds.divmod(HOUR)\nminutes, left = left.divmod(MINUTE)\nseconds = left // SECOND\n{hours, minutes, seconds}\n"}},{"html_id":"total_seconds-instance-method","name":"total_seconds","abstract":false,"location":{"filename":"src/clear/extensions/time_in_days/time_in_day.cr","line_number":67,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day.cr#L67"},"def":{"name":"total_seconds","visibility":"Public","body":"@microseconds // SECOND"}}],"types":[{"html_id":"clear/Clear/TimeInDay/Converter","path":"Clear/TimeInDay/Converter.html","kind":"module","full_name":"Clear::TimeInDay::Converter","name":"Converter","abstract":false,"locations":[{"filename":"src/clear/extensions/time_in_days/time_in_day_converter.cr","line_number":23,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day_converter.cr#L23"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/TimeInDay","kind":"struct","full_name":"Clear::TimeInDay","name":"TimeInDay"},"class_methods":[{"html_id":"to_column(x):TimeInDay|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : TimeInDay | Nil","args_html":"(x) : TimeInDay | Nil","location":{"filename":"src/clear/extensions/time_in_days/time_in_day_converter.cr","line_number":24,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day_converter.cr#L24"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"TimeInDay | ::Nil","visibility":"Public","body":"case x\nwhen TimeInDay\n x\nwhen UInt64\n TimeInDay.new(x)\nwhen Slice\n mem = IO::Memory.new(x, writeable: false)\n TimeInDay.new(mem.read_bytes(UInt64, IO::ByteFormat::BigEndian))\nwhen String\n TimeInDay.parse(x)\nwhen Nil\n nil\nelse\n raise(\"Cannot convert to TimeInDay from #{x.class}\")\nend"}},{"html_id":"to_db(x:TimeInDay|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"TimeInDay | ::Nil"}],"args_string":"(x : TimeInDay | Nil)","args_html":"(x : TimeInDay | Nil)","location":{"filename":"src/clear/extensions/time_in_days/time_in_day_converter.cr","line_number":42,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/time_in_days/time_in_day_converter.cr#L42"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"TimeInDay | ::Nil"}],"visibility":"Public","body":"x ? x.to_s : nil"}}]}]},{"html_id":"clear/Clear/TSVector","path":"Clear/TSVector.html","kind":"class","full_name":"Clear::TSVector","name":"TSVector","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"class_methods":[{"html_id":"decode(x:Slice(UInt8))-class-method","name":"decode","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"Slice(UInt8)"}],"args_string":"(x : Slice(UInt8))","args_html":"(x : Slice(UInt8))","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":70,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L70"},"def":{"name":"decode","args":[{"name":"x","external_name":"x","restriction":"Slice(UInt8)"}],"visibility":"Public","body":"io = IO::Memory.new(x, writeable: false)\nClear::TSVector.new(io)\n"}}],"constructors":[{"html_id":"new(io)-class-method","name":"new","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L56"},"def":{"name":"new","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(io)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"[](key:String)-instance-method","name":"[]","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":39,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L39"},"def":{"name":"[]","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"lexems[key]"}},{"html_id":"[]?(key:String)-instance-method","name":"[]?","abstract":false,"args":[{"name":"key","external_name":"key","restriction":"String"}],"args_string":"(key : String)","args_html":"(key : String)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":43,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L43"},"def":{"name":"[]?","args":[{"name":"key","external_name":"key","restriction":"String"}],"visibility":"Public","body":"lexems[key]?"}},{"html_id":"lexems:Hash(String,Lexem)-instance-method","name":"lexems","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":37,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L37"},"def":{"name":"lexems","return_type":"Hash(String, Lexem)","visibility":"Public","body":"@lexems"}},{"html_id":"to_sql-instance-method","name":"to_sql","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":47,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L47"},"def":{"name":"to_sql","visibility":"Public","body":"@lexems.values.join(\" \") do |v|\n {Clear::Expression[v.value], v.positions.join(\",\") do |p|\n {p.position, p.weight}.join\n end}.join(\":\")\nend"}}],"types":[{"html_id":"clear/Clear/TSVector/Converter","path":"Clear/TSVector/Converter.html","kind":"module","full_name":"Clear::TSVector::Converter","name":"Converter","abstract":false,"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":75,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L75"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/TSVector","kind":"class","full_name":"Clear::TSVector","name":"TSVector"},"class_methods":[{"html_id":"to_column(x):Clear::TSVector|Nil-class-method","name":"to_column","abstract":false,"args":[{"name":"x","external_name":"x","restriction":""}],"args_string":"(x) : Clear::TSVector | Nil","args_html":"(x) : Clear::TSVector | Nil","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":76,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L76"},"def":{"name":"to_column","args":[{"name":"x","external_name":"x","restriction":""}],"return_type":"Clear::TSVector | ::Nil","visibility":"Public","body":"case x\nwhen Slice\n Clear::TSVector.decode(x.as(Slice(UInt8)))\nwhen Clear::TSVector\n x\nwhen Nil\n nil\nelse\n raise(Clear::ErrorMessages.converter_error(x.class, \"TSVector\"))\nend"}},{"html_id":"to_db(x:TSVector|Nil)-class-method","name":"to_db","abstract":false,"args":[{"name":"x","external_name":"x","restriction":"TSVector | ::Nil"}],"args_string":"(x : TSVector | Nil)","args_html":"(x : TSVector | Nil)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":89,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L89"},"def":{"name":"to_db","args":[{"name":"x","external_name":"x","restriction":"TSVector | ::Nil"}],"visibility":"Public","body":"x.try(&.to_sql)"}}]},{"html_id":"clear/Clear/TSVector/Lexem","path":"Clear/TSVector/Lexem.html","kind":"struct","full_name":"Clear::TSVector::Lexem","name":"Lexem","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"WEIGHTS","name":"WEIGHTS","value":"['A', 'B', 'C', 'D']"}],"namespace":{"html_id":"clear/Clear/TSVector","kind":"class","full_name":"Clear::TSVector","name":"TSVector"},"constructors":[{"html_id":"new(io)-class-method","name":"new","abstract":false,"args":[{"name":"io","external_name":"io","restriction":""}],"args_string":"(io)","args_html":"(io)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":10,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L10"},"def":{"name":"new","args":[{"name":"io","external_name":"io","restriction":""}],"visibility":"Public","body":"_ = allocate\n_.initialize(io)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"positions:Array(Position)-instance-method","name":"positions","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":6,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L6"},"def":{"name":"positions","return_type":"Array(Position)","visibility":"Public","body":"@positions"}},{"html_id":"value:String-instance-method","name":"value","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":5,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L5"},"def":{"name":"value","return_type":"String","visibility":"Public","body":"@value"}}],"types":[{"html_id":"clear/Clear/TSVector/Lexem/Position","path":"Clear/TSVector/Lexem/Position.html","kind":"struct","full_name":"Clear::TSVector::Lexem::Position","name":"Position","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear/TSVector/Lexem","kind":"struct","full_name":"Clear::TSVector::Lexem","name":"Lexem"},"constructors":[{"html_id":"new(weight:Char,position:UInt16)-class-method","name":"new","abstract":false,"args":[{"name":"weight","external_name":"weight","restriction":"Char"},{"name":"position","external_name":"position","restriction":"UInt16"}],"args_string":"(weight : Char, position : UInt16)","args_html":"(weight : Char, position : UInt16)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"},"def":{"name":"new","args":[{"name":"weight","external_name":"weight","restriction":"Char"},{"name":"position","external_name":"position","restriction":"UInt16"}],"visibility":"Public","body":"_ = allocate\n_.initialize(weight, position)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"html_id":"clone-instance-method","name":"clone","abstract":false,"location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"},"def":{"name":"clone","visibility":"Public","body":"self.class.new(@weight.clone, @position.clone)"}},{"html_id":"copy_with(weight_weight=@weight,position_position=@position)-instance-method","name":"copy_with","abstract":false,"args":[{"name":"_weight","default_value":"@weight","external_name":"weight","restriction":""},{"name":"_position","default_value":"@position","external_name":"position","restriction":""}],"args_string":"(weight _weight = @weight, position _position = @position)","args_html":"(weight _weight = @weight, position _position = @position)","location":{"filename":"src/clear/extensions/full_text_searchable/tsvector.cr","line_number":3,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/full_text_searchable/tsvector.cr#L3"},"def":{"name":"copy_with","args":[{"name":"_weight","default_value":"@weight","external_name":"weight","restriction":""},{"name":"_position","default_value":"@position","external_name":"position","restriction":""}],"visibility":"Public","body":"self.class.new(_weight, _position)"}},{"html_id":"position:UInt16-instance-method","name":"position","abstract":false,"def":{"name":"position","return_type":"UInt16","visibility":"Public","body":"@position"}},{"html_id":"weight:Char-instance-method","name":"weight","abstract":false,"def":{"name":"weight","return_type":"Char","visibility":"Public","body":"@weight"}}]}]}]},{"html_id":"clear/Clear/Util","path":"Clear/Util.html","kind":"module","full_name":"Clear::Util","name":"Util","abstract":false,"locations":[{"filename":"src/clear/util.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/util.cr#L2"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"extended_modules":[{"html_id":"clear/Clear/Util","kind":"module","full_name":"Clear::Util","name":"Util"}],"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"A set of method(s) useful for building Clear ORM.","summary":"A set of method(s) useful for building Clear ORM.
","instance_methods":[{"html_id":"hash_union(h1:Hash(A,B),h2:Hash(C,D))forallA,B,C,D-instance-method","name":"hash_union","doc":"Return a new hash which is union of two hash (some kind of deep merge)","summary":"Return a new hash which is union of two hash (some kind of deep merge)
","abstract":false,"args":[{"name":"h1","external_name":"h1","restriction":"Hash(A, B)"},{"name":"h2","external_name":"h2","restriction":"Hash(C, D)"}],"args_string":"(h1 : Hash(A, B), h2 : Hash(C, D)) forall A, B, C, D","args_html":"(h1 : Hash(A, B), h2 : Hash(C, D)) forall A, B, C, D","location":{"filename":"src/clear/util.cr","line_number":12,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/util.cr#L12"},"def":{"name":"hash_union","args":[{"name":"h1","external_name":"h1","restriction":"Hash(A, B)"},{"name":"h2","external_name":"h2","restriction":"Hash(C, D)"}],"visibility":"Public","body":"o = Hash(A | C, B | D).new\nh1.each do |k, v|\n o[k] = v\nend\nh2.each do |k, v|\n case v\n when Hash\n if (v1 = o[k]).is_a?(Hash)\n o[k] = hash_union(v1, v)\n else\n o[k] = v\n end\n else\n o[k] = v\n end\nend\no\n"}},{"html_id":"lambda(u:U.class,v:V.class,&block:U->V)forallU,V-instance-method","name":"lambda","doc":"Equivalent to ruby's lambda with one parameter.\nThis method is useful combined with the macro system of Crystal.","summary":"Equivalent to ruby's lambda with one parameter.
","abstract":false,"args":[{"name":"u","external_name":"u","restriction":"U.class"},{"name":"v","external_name":"v","restriction":"V.class"}],"args_string":"(u : U.class, v : V.class, &block : U -> V) forall U, V","args_html":"(u : U.class, v : V.class, &block : U -> V) forall U, V","location":{"filename":"src/clear/util.cr","line_number":7,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/util.cr#L7"},"def":{"name":"lambda","args":[{"name":"u","external_name":"u","restriction":"U.class"},{"name":"v","external_name":"v","restriction":"V.class"}],"yields":1,"block_arity":1,"block_arg":{"name":"block","external_name":"block","restriction":"(U -> V)"},"visibility":"Public","body":"block"}}]},{"html_id":"clear/Clear/Validation","path":"Clear/Validation.html","kind":"module","full_name":"Clear::Validation","name":"Validation","abstract":false,"locations":[{"filename":"src/clear/model/validation/helper.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"types":[{"html_id":"clear/Clear/Validation/Helper","path":"Clear/Validation/Helper.html","kind":"module","full_name":"Clear::Validation::Helper","name":"Helper","abstract":false,"locations":[{"filename":"src/clear/model/validation/helper.cr","line_number":1,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L1"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"including_types":[{"html_id":"clear/Clear/Model/HasValidation","kind":"module","full_name":"Clear::Model::HasValidation","name":"HasValidation"}],"namespace":{"html_id":"clear/Clear/Validation","kind":"module","full_name":"Clear::Validation","name":"Validation"},"macros":[{"html_id":"ensure_than(field,message,&block)-macro","name":"ensure_than","doc":"Usage example:\n\n```\nensure_than email, \"must be an email\" do |v|\n EmailRegexp.valid?(v)\nend\n```","summary":"Usage example:
","abstract":false,"args":[{"name":"field","external_name":"field","restriction":""},{"name":"message","external_name":"message","restriction":""}],"args_string":"(field, message, &block)","args_html":"(field, message, &block)","location":{"filename":"src/clear/model/validation/helper.cr","line_number":15,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L15"},"def":{"name":"ensure_than","args":[{"name":"field","external_name":"field","restriction":""},{"name":"message","external_name":"message","restriction":""}],"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" if \n{{ field.id }}\n_column.defined?\n o = \n{{ field.id }}\n\n\n fn = Clear::Util.lambda(typeof(o), Object) \n{{ block }}\n\n\n unless fn.call(o)\n add_error(\n{{ field.stringify }}\n, \n{{ message }}\n)\n \nend\n \nend\n\n \n"}},{"html_id":"on_presence(*fields,&block)-macro","name":"on_presence","abstract":false,"args":[{"name":"fields","external_name":"fields","restriction":""}],"args_string":"(*fields, &block)","args_html":"(*fields, &block)","location":{"filename":"src/clear/model/validation/helper.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/model/validation/helper.cr#L2"},"def":{"name":"on_presence","args":[{"name":"fields","external_name":"fields","restriction":""}],"splat_index":0,"block_arg":{"name":"block","external_name":"block","restriction":""},"visibility":"Public","body":" if \n{{ (fields.map do |x|\n \"self.#{x.id}_column.defined?\"\nend.join(\" && \")).id }}\n\n \n{{ yield }}\n\n \nend\n \n"}}]}]},{"html_id":"clear/Clear/View","path":"Clear/View.html","kind":"class","full_name":"Clear::View","name":"View","abstract":false,"superclass":{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"clear/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/view/base.cr","line_number":48,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L48"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"namespace":{"html_id":"clear/Clear","kind":"module","full_name":"Clear","name":"Clear"},"doc":"Create and maintain your database views directly in the code.\n\nYou could use the migration system to create and drop your views. However this\nis proven to be difficult, even more if you want to update a view which depends on\nanother subviews.\n\n## How it works ?\n\nWhen you migrate using the migration system, all the views registered\nare going to be destroyed and recreated again.\nOrder of creation depends of the requirement for each views\n\n## Example\n\n```\nClear::View.register :room_per_days do |view|\n view.require(:rooms, :year_days)\n\n view.query <<-SQL\n SELECT room_id, day\n FROM year_days\n CROSS JOIN rooms\n SQL\nend\n\nClear::View.register :rooms do |view|\n view.query <<-SQL\n SELECT room.id as room_id\n FROM generate_series(1, 4) AS room(id)\n SQL\nend\n\nClear::View.register :year_days do |view|\n view.query <<-SQL\n SELECT date.day::date as day\n FROM generate_series(\n date_trunc('day', NOW()),\n date_trunc('day', NOW() + INTERVAL '364 days'),\n INTERVAL '1 day'\n ) AS date(day)\n SQL\nend\n```\n\nIn the example above, room_per_days will be first dropped before a migration\nstart and last created after the migration finished, to prevent issue where some\nviews are linked to others","summary":"Create and maintain your database views directly in the code.
","class_methods":[{"html_id":"apply(direction:Symbol,view_name:String,apply_cache:Set(String))-class-method","name":"apply","doc":"install the view into postgresql using CREATE VIEW","summary":"install the view into postgresql using CREATE VIEW
","abstract":false,"args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"view_name","external_name":"view_name","restriction":"String"},{"name":"apply_cache","external_name":"apply_cache","restriction":"Set(String)"}],"args_string":"(direction : Symbol, view_name : String, apply_cache : Set(String))","args_html":"(direction : Symbol, view_name : String, apply_cache : Set(String))","location":{"filename":"src/clear/view/base.cr","line_number":76,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L76"},"def":{"name":"apply","args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"view_name","external_name":"view_name","restriction":"String"},{"name":"apply_cache","external_name":"apply_cache","restriction":"Set(String)"}],"visibility":"Public","body":"if apply_cache.includes?(view_name)\n return\nend\nview = @@views[view_name]\nview.requirement.each do |dep_view|\n apply(direction, dep_view, apply_cache)\nend\nClear::SQL.execute(view.connection, direction == (:drop) ? view.to_drop_sql : view.to_create_sql)\napply_cache << view_name\n"}},{"html_id":"apply(direction:Symbol,apply_cache=Set(String).new)-class-method","name":"apply","doc":"install the view into postgresql using CREATE VIEW","summary":"install the view into postgresql using CREATE VIEW
","abstract":false,"args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"apply_cache","default_value":"Set(String).new","external_name":"apply_cache","restriction":""}],"args_string":"(direction : Symbol, apply_cache = Set(String).new)","args_html":"(direction : Symbol, apply_cache = Set(String).new)","location":{"filename":"src/clear/view/base.cr","line_number":68,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L68"},"def":{"name":"apply","args":[{"name":"direction","external_name":"direction","restriction":"Symbol"},{"name":"apply_cache","default_value":"Set(String).new","external_name":"apply_cache","restriction":""}],"visibility":"Public","body":"@@views.values.each do |view|\n if apply_cache.includes?(view.name)\n next\n end\n apply(direction, view.name, apply_cache)\nend"}},{"html_id":"register(name:Clear::SQL::Symbolic,&)-class-method","name":"register","doc":"Call the DSL to register a new view\n\n```\nClear::View.register(:name) do |view|\n # describe the view here.\nend\n```","summary":"Call the DSL to register a new view
","abstract":false,"args":[{"name":"name","external_name":"name","restriction":"Clear::SQL::Symbolic"}],"args_string":"(name : Clear::SQL::Symbolic, &)","args_html":"(name : Clear::SQL::Symbolic, &)","location":{"filename":"src/clear/view/base.cr","line_number":56,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L56"},"def":{"name":"register","args":[{"name":"name","external_name":"name","restriction":"Clear::SQL::Symbolic"}],"yields":1,"block_arity":1,"visibility":"Public","body":"view = Clear::View.new\nview.name(name)\nyield view\nif view.name == \"\"\n raise(\"Your view need to have a name\")\nend\nif view.query == \"\"\n raise(\"View `#{view.name}` need to have a query body\")\nend\n@@views[view.name] = view\n"}}],"instance_methods":[{"html_id":"connection(connection:String)-instance-method","name":"connection","doc":"database connection where is installed the view","summary":"database connection where is installed the view
","abstract":false,"args":[{"name":"connection","external_name":"connection","restriction":"String"}],"args_string":"(connection : String)","args_html":"(connection : String)","location":{"filename":"src/clear/view/base.cr","line_number":118,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L118"},"def":{"name":"connection","args":[{"name":"connection","external_name":"connection","restriction":"String"}],"visibility":"Public","body":"@connection = connection"}},{"html_id":"connection:String-instance-method","name":"connection","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":99,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L99"},"def":{"name":"connection","return_type":"String","visibility":"Public","body":"@connection"}},{"html_id":"full_name-instance-method","name":"full_name","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":137,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L137"},"def":{"name":"full_name","visibility":"Public","body":"{@schema, @name}.join(\".\") do |x|\n Clear::SQL.escape(x)\nend"}},{"html_id":"materialized(mat:Bool)-instance-method","name":"materialized","doc":"whether the view is materialized or not. I would recommend to use\nmigration execute create/drop whenever the view is a materialized view","summary":"whether the view is materialized or not.
","abstract":false,"args":[{"name":"mat","external_name":"mat","restriction":"Bool"}],"args_string":"(mat : Bool)","args_html":"(mat : Bool)","location":{"filename":"src/clear/view/base.cr","line_number":124,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L124"},"def":{"name":"materialized","args":[{"name":"mat","external_name":"mat","restriction":"Bool"}],"visibility":"Public","body":"@materialized = mat"}},{"html_id":"materialized?:Bool-instance-method","name":"materialized?","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":100,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L100"},"def":{"name":"materialized?","return_type":"Bool","visibility":"Public","body":"@materialized"}},{"html_id":"name(value:String|Symbol)-instance-method","name":"name","doc":"name of the view","summary":"name of the view
","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"args_string":"(value : String | Symbol)","args_html":"(value : String | Symbol)","location":{"filename":"src/clear/view/base.cr","line_number":103,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L103"},"def":{"name":"name","args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"visibility":"Public","body":"@name = value.to_s"}},{"html_id":"name:String-instance-method","name":"name","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":95,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L95"},"def":{"name":"name","return_type":"String","visibility":"Public","body":"@name"}},{"html_id":"query(query:String)-instance-method","name":"query","doc":"query body related to the view. Must be a SELECT clause","summary":"query body related to the view.
","abstract":false,"args":[{"name":"query","external_name":"query","restriction":"String"}],"args_string":"(query : String)","args_html":"(query : String)","location":{"filename":"src/clear/view/base.cr","line_number":113,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L113"},"def":{"name":"query","args":[{"name":"query","external_name":"query","restriction":"String"}],"visibility":"Public","body":"@query = query"}},{"html_id":"query:String-instance-method","name":"query","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":97,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L97"},"def":{"name":"query","return_type":"String","visibility":"Public","body":"@query"}},{"html_id":"require(*req)-instance-method","name":"require","doc":"list of dependencies from the other view related to this view","summary":"list of dependencies from the other view related to this view
","abstract":false,"args":[{"name":"req","external_name":"req","restriction":""}],"args_string":"(*req)","args_html":"(*req)","location":{"filename":"src/clear/view/base.cr","line_number":129,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L129"},"def":{"name":"require","args":[{"name":"req","external_name":"req","restriction":""}],"splat_index":0,"visibility":"Public","body":"req.map(&.to_s).each do |s|\n @requirement.add(s)\nend"}},{"html_id":"requirement:Set(String)-instance-method","name":"requirement","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":98,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L98"},"def":{"name":"requirement","visibility":"Public","body":"@requirement"}},{"html_id":"schema(value:String|Symbol)-instance-method","name":"schema","doc":"schema to store the view (default public)","summary":"schema to store the view (default public)
","abstract":false,"args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"args_string":"(value : String | Symbol)","args_html":"(value : String | Symbol)","location":{"filename":"src/clear/view/base.cr","line_number":108,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L108"},"def":{"name":"schema","args":[{"name":"value","external_name":"value","restriction":"String | Symbol"}],"visibility":"Public","body":"@schema = value.to_s"}},{"html_id":"schema:String-instance-method","name":"schema","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":96,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L96"},"def":{"name":"schema","return_type":"String","visibility":"Public","body":"@schema"}},{"html_id":"to_create_sql-instance-method","name":"to_create_sql","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":141,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L141"},"def":{"name":"to_create_sql","visibility":"Public","body":"{\"CREATE OR REPLACE\", (materialized? ? \"MATERIALIZED VIEW\" : \"VIEW\"), full_name, \"AS (\", @query, \")\"}.join(' ')"}},{"html_id":"to_drop_sql-instance-method","name":"to_drop_sql","abstract":false,"location":{"filename":"src/clear/view/base.cr","line_number":133,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/view/base.cr#L133"},"def":{"name":"to_drop_sql","visibility":"Public","body":"\"DROP VIEW IF EXISTS #{@name}\""}}]}]},{"html_id":"clear/Slice","path":"Slice.html","kind":"struct","full_name":"Slice(T)","name":"Slice","abstract":false,"superclass":{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Indexable/Mutable","kind":"module","full_name":"Indexable::Mutable","name":"Mutable"},{"html_id":"clear/Indexable","kind":"module","full_name":"Indexable","name":"Indexable"},{"html_id":"clear/Enumerable","kind":"module","full_name":"Enumerable","name":"Enumerable"},{"html_id":"clear/Iterable","kind":"module","full_name":"Iterable","name":"Iterable"},{"html_id":"clear/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"clear/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"clear/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"src/clear/extensions/core_ext.cr","line_number":109,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/core_ext.cr#L109"}],"repository_name":"clear","program":false,"enum":false,"alias":false,"const":false,"included_modules":[{"html_id":"clear/Comparable","kind":"module","full_name":"Comparable","name":"Comparable"},{"html_id":"clear/Indexable/Mutable","kind":"module","full_name":"Indexable::Mutable","name":"Mutable"}],"doc":"A `Slice` is a `Pointer` with an associated size.\n\nWhile a pointer is unsafe because no bound checks are performed when reading from and writing to it,\nreading from and writing to a slice involve bound checks.\nIn this way, a slice is a safe alternative to `Pointer`.\n\nA Slice can be created as read-only: trying to write to it\nwill raise. For example the slice of bytes returned by\n`String#to_slice` is read-only.","summary":"A Slice
is a Pointer
with an associated size.
Time
represents a date-time instant in incremental time observed in a specific time zone.
Represents a UUID (Universally Unique IDentifier).
","instance_methods":[{"html_id":"to_json(json:JSON::Builder)-instance-method","name":"to_json","abstract":false,"args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"args_string":"(json : JSON::Builder)","args_html":"(json : JSON::Builder)","location":{"filename":"src/clear/extensions/uuid/uuid.cr","line_number":2,"url":"https://github.com/crystal-garage/clear/blob/dd57cd6262e58b196e10686d759980d464ca7a77/src/clear/extensions/uuid/uuid.cr#L2"},"def":{"name":"to_json","args":[{"name":"json","external_name":"json","restriction":"JSON::Builder"}],"visibility":"Public","body":"json.string(to_s)"}}]}]}}) \ No newline at end of file diff --git a/toplevel.html b/toplevel.html new file mode 100644 index 000000000..2ee4aa0bc --- /dev/null +++ b/toplevel.html @@ -0,0 +1,1651 @@ + + + + + + + + + + + + + + + + +{"Bool" => "boolean[]", "String" => "text[]", "Float32" => "real[]", "Float64" => "double precision[]", "Int32" => "int[]", "Int64" => "bigint[]"}
+ {bool: Bool, s: String, f32: Float32, f: Float64, i: Int32, i64: Int64}
+ Used internally to deserialise json
Used internally to deserialise json
+