class Clear::SQL::InsertQuery

Overview

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 ] [, ...] ]

Included Modules

Defined in:

clear/sql/insert_query.cr

Constructors

Instance Method Summary

Instance methods inherited from module Clear::SQL::Query::OnConflict

clear_conflict clear_conflict, conflict? conflict?, do_conflict_action(str) do_conflict_action, do_nothing do_nothing, do_update(&) do_update, on_conflict(constraint : String | Bool | OnConflictWhereClause = true)
on_conflict(&)
on_conflict
, on_conflict_action : String | Clear::SQL::UpdateQuery on_conflict_action, on_conflict_condition : String | OnConflictWhereClause | Bool on_conflict_condition

Instance methods inherited from module Clear::SQL::Query::Connection

connection_name : String connection_name, use_connection(connection_name : String) use_connection

Instance methods inherited from module Clear::SQL::Query::Change

change! : self change!

Instance methods inherited from module Clear::SQL::Query::CTE

cte : Hash(String, Clear::SQL::Query::CTE::Record) cte, with_cte(name, request : CTEAuthorized, recursive = false)
with_cte(tuple : NamedTuple)
with_cte
, with_recursive_cte(tuple : NamedTuple) with_recursive_cte

Constructor Detail

def self.new(table : Symbol | String, values) #

[View source]
def self.new(table : Symbol | String) #

[View source]

Instance Method Detail

def clear_values #

[View source]
def columns(*args) #

Used with values


[View source]
def execute(connection_name : String = "default") : Hash(String, Clear::SQL::Any) #

[View source]
def fetch(connection_name : String = "default", &block : Hash(String, Clear::SQL::Any) -> Nil) #

[View source]
def into(table : Symbol | String) #

[View source]
def keys : Array(Symbolic) #

[View source]
def returning : String? #

[View source]
def returning(str : String) #

[View source]
def size : Int32 #

Number of rows of this insertion request


[View source]
def table : Symbol | String #

[View source]
def table? : Symbol | String? #

[View source]
def to_sql #

[View source]
def values(*args) #

[View source]
def values : SelectBuilder | Array(Array(Inserable)) #

[View source]
def values(select_query : SelectBuilder) #

Insert into ... (...) SELECT


[View source]
def values(rows : Array(NamedTuple)) #

[View source]
def values(row : NamedTuple) #

Fast insert system

insert({field: "value"}).into(:table)


[View source]
def values(rows : Array(Hash(Symbolic, Inserable))) #

[View source]
def values(row : Hash(Symbolic, Inserable)) #

[View source]